mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 17:29:33 +02:00
fcl-js: added TJSUnaryBracketsExpression, needed for (function(){})
git-svn-id: trunk@41358 -
This commit is contained in:
parent
0a228b9115
commit
34515b09cf
@ -439,6 +439,13 @@ Type
|
|||||||
Class function PostFixOperatorToken : tjsToken; override;
|
Class function PostFixOperatorToken : tjsToken; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TJSUnaryBracketsExpression - e.g. '(A)' }
|
||||||
|
|
||||||
|
TJSUnaryBracketsExpression = Class(TJSUnaryExpression)
|
||||||
|
Public
|
||||||
|
Class function PrefixOperatorToken : tjsToken; override;
|
||||||
|
Class function PostFixOperatorToken : tjsToken; override;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TJSBinary - base class }
|
{ TJSBinary - base class }
|
||||||
|
|
||||||
@ -1432,6 +1439,18 @@ begin
|
|||||||
Result:=tjsThrow;
|
Result:=tjsThrow;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TJSUnaryBracketsExpression }
|
||||||
|
|
||||||
|
class function TJSUnaryBracketsExpression.PrefixOperatorToken: tjsToken;
|
||||||
|
begin
|
||||||
|
Result:=tjsBraceOpen;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TJSUnaryBracketsExpression.PostFixOperatorToken: tjsToken;
|
||||||
|
begin
|
||||||
|
Result:=tjsBraceClose;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TJSUnaryPostMinusMinusExpression }
|
{ TJSUnaryPostMinusMinusExpression }
|
||||||
|
|
||||||
Class function TJSUnaryPostMinusMinusExpression.PostFixOperatorToken : tjsToken;
|
Class function TJSUnaryPostMinusMinusExpression.PostFixOperatorToken : tjsToken;
|
||||||
|
@ -240,7 +240,9 @@ Type
|
|||||||
Property Options : TWriteOptions Read FOptions Write SetOptions;
|
Property Options : TWriteOptions Read FOptions Write SetOptions;
|
||||||
Property IndentSize : Byte Read FIndentSize Write FIndentSize;
|
Property IndentSize : Byte Read FIndentSize Write FIndentSize;
|
||||||
Property UseUTF8 : Boolean Read GetUseUTF8;
|
Property UseUTF8 : Boolean Read GetUseUTF8;
|
||||||
property LastChar: WideChar read FLastChar;
|
Property LastChar: WideChar read FLastChar;
|
||||||
|
Property SkipCurlyBrackets : Boolean read FSkipCurlyBrackets write FSkipCurlyBrackets;
|
||||||
|
Property SkipRoundBrackets : Boolean read FSkipRoundBrackets write FSkipRoundBrackets;
|
||||||
end;
|
end;
|
||||||
EJSWriter = Class(Exception);
|
EJSWriter = Class(Exception);
|
||||||
|
|
||||||
@ -944,10 +946,14 @@ begin
|
|||||||
and (not (A is TJSSourceElements))
|
and (not (A is TJSSourceElements))
|
||||||
and (not (A is TJSEmptyBlockStatement))
|
and (not (A is TJSEmptyBlockStatement))
|
||||||
then
|
then
|
||||||
|
begin
|
||||||
|
if FLastChar<>';' then
|
||||||
|
Write(';');
|
||||||
if C then
|
if C then
|
||||||
Write('; ')
|
Write(' ')
|
||||||
else
|
else
|
||||||
Writeln(';');
|
Writeln('');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
Writer.CurElement:=LastEl;
|
Writer.CurElement:=LastEl;
|
||||||
if C then
|
if C then
|
||||||
@ -1197,17 +1203,15 @@ begin
|
|||||||
Write(S);
|
Write(S);
|
||||||
end;
|
end;
|
||||||
WriteJS(El.A);
|
WriteJS(El.A);
|
||||||
if (S='') then
|
S:=El.PostFixOperator;
|
||||||
|
if (S<>'') then
|
||||||
begin
|
begin
|
||||||
S:=El.PostFixOperator;
|
Writer.CurElement:=El;
|
||||||
if (S<>'') then
|
case S[1] of
|
||||||
begin
|
'+': if FLastChar='+' then Write(' ');
|
||||||
Writer.CurElement:=El;
|
'-': if FLastChar='-' then Write(' ');
|
||||||
if ((S='-') and (FLastChar='-'))
|
end;
|
||||||
or ((S='+') and (FLastChar='+')) then
|
Write(S);
|
||||||
Write(' ');
|
|
||||||
Write(S);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1240,10 +1244,12 @@ begin
|
|||||||
begin
|
begin
|
||||||
if not (LastEl is TJSStatementList) then
|
if not (LastEl is TJSStatementList) then
|
||||||
begin
|
begin
|
||||||
|
if FLastChar<>';' then
|
||||||
|
Write(';');
|
||||||
if C then
|
if C then
|
||||||
Write('; ')
|
Write(' ')
|
||||||
else
|
else
|
||||||
Writeln(';');
|
Writeln('');
|
||||||
end;
|
end;
|
||||||
FSkipCurlyBrackets:=True;
|
FSkipCurlyBrackets:=True;
|
||||||
WriteJS(El.B);
|
WriteJS(El.B);
|
||||||
@ -1252,11 +1258,14 @@ begin
|
|||||||
if (not C) and not (LastEl is TJSStatementList) then
|
if (not C) and not (LastEl is TJSStatementList) then
|
||||||
writeln(';');
|
writeln(';');
|
||||||
end
|
end
|
||||||
else if Assigned(El.B) then
|
else if Assigned(El.B) and not IsEmptyStatement(El.B) then
|
||||||
begin
|
begin
|
||||||
WriteJS(El.B);
|
WriteJS(El.B);
|
||||||
if (not C) and not (El.B is TJSStatementList) then
|
if (not C) and not (El.B is TJSStatementList) then
|
||||||
writeln(';');
|
if FLastChar=';' then
|
||||||
|
writeln('')
|
||||||
|
else
|
||||||
|
writeln(';');
|
||||||
end;
|
end;
|
||||||
if B then
|
if B then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user