mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 21:49:11 +02:00
* Debugger statement
This commit is contained in:
parent
652643499a
commit
6a9d2cae93
@ -26,6 +26,7 @@ Const
|
||||
SEmptyLabel = '';
|
||||
MinAsyncVersion = ecma2021;
|
||||
minLetVersion = ecma2021;
|
||||
MinDebuggerVersion = ecma2021;
|
||||
|
||||
Type
|
||||
TECMAVersion = jsScanner.TECMAVersion;
|
||||
@ -102,6 +103,7 @@ Type
|
||||
function ParseThrowStatement: TJSElement;
|
||||
function ParseTryStatement: TJSElement;
|
||||
function ParseUnaryExpression: TJSElement;
|
||||
function ParseDebuggerStatement: TJSElement;
|
||||
function ParseVariableDeclaration(aVarType : TJSVarType = vtVar): TJSElement;
|
||||
function ParseVariableDeclarationList(aVarType : TJSVarType = vtVar): TJSElement;
|
||||
function ParseVariableStatement(aVarType : TJSVarType = vtVar): TJSElement;
|
||||
@ -968,6 +970,17 @@ begin
|
||||
{$ifdef debugparser} Writeln('Exit ParseUnaryExpression');{$endif debugparser}
|
||||
end;
|
||||
|
||||
function TJSParser.ParseDebuggerStatement: TJSElement;
|
||||
|
||||
begin
|
||||
Result:=CreateElement(TJSDebuggerStatement);
|
||||
try
|
||||
Consume(tjsDebugger);
|
||||
except
|
||||
FreeAndNil(Result);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TJSParser.ParseMultiplicativeExpression: TJSElement;
|
||||
|
||||
Var
|
||||
@ -2014,6 +2027,8 @@ begin
|
||||
Result:=ParseReturnStatement;
|
||||
tjsWith:
|
||||
Result:=ParseWithStatement;
|
||||
tjsDebugger:
|
||||
Result:=ParseDebuggerStatement;
|
||||
tjsSwitch:
|
||||
Result:=ParseSwitchStatement;
|
||||
tjsThrow:
|
||||
@ -2043,7 +2058,7 @@ Const
|
||||
StatementTokens = [tjsNULL, tjsTRUE, tjsFALSE,
|
||||
tjsTHIS, tjsIdentifier,jstoken.tjsSTRING,tjsNUMBER,
|
||||
tjsBraceOpen,tjsCurlyBraceOpen,tjsSquaredBraceOpen,
|
||||
tjsLet, tjsConst,
|
||||
tjsLet, tjsConst, tjsDebugger,
|
||||
tjsNew,tjsDelete,tjsVoid,tjsTypeOf,
|
||||
tjsPlusPlus,tjsMinusMinus,
|
||||
tjsPlus,tjsMinus,tjsNot,tjsNE,tjsSNE,tjsSemicolon,
|
||||
|
@ -669,6 +669,8 @@ Type
|
||||
Property C : TJSElement Read FC Write FC;
|
||||
end;
|
||||
|
||||
TJSDebuggerStatement = Class(TJSElement);
|
||||
|
||||
{ TJSAssignStatement - e.g. LHS operator Expr }
|
||||
|
||||
TJSAssignStatement = Class(TJSElement)
|
||||
|
@ -195,6 +195,7 @@ Type
|
||||
Procedure WriteVariableStatement(El: TJSVariableStatement);
|
||||
Procedure WriteEmptyBlockStatement(El: TJSEmptyBlockStatement); virtual;
|
||||
Procedure WriteEmptyStatement(El: TJSEmptyStatement);virtual;
|
||||
Procedure WriteDebuggerStatement(E: TJSDebuggerStatement) ;virtual;
|
||||
Procedure WriteLiteral(El: TJSLiteral);virtual;
|
||||
Procedure WriteArrayLiteral(El: TJSArrayLiteral);virtual;
|
||||
Procedure WriteObjectLiteral(El: TJSObjectLiteral);virtual;
|
||||
@ -1004,6 +1005,11 @@ begin
|
||||
Write('/* Empty statement */')
|
||||
end;
|
||||
|
||||
procedure TJSWriter.WriteDebuggerStatement(E: TJSDebuggerStatement);
|
||||
begin
|
||||
Write('debugger');
|
||||
end;
|
||||
|
||||
procedure TJSWriter.WriteRegularExpressionLiteral(
|
||||
El: TJSRegularExpressionLiteral);
|
||||
|
||||
@ -1935,6 +1941,8 @@ begin
|
||||
WriteEmptyBlockStatement(TJSEmptyBlockStatement(El))
|
||||
else if (C=TJSEmptyStatement) then
|
||||
WriteEmptyStatement(TJSEmptyStatement(El))
|
||||
else if (C=TJSDebuggerStatement) then
|
||||
WriteDebuggerStatement(TJSDebuggerStatement(El))
|
||||
else if (C=TJSLiteral) then
|
||||
WriteLiteral(TJSLiteral(El))
|
||||
else if C.InheritsFrom(TJSPrimaryExpression) then
|
||||
|
@ -105,6 +105,7 @@ type
|
||||
procedure TestVarDeclarationSimpleInit;
|
||||
procedure TestConstDeclarationSimpleInit;
|
||||
procedure TestVarDeclarationDoubleInit;
|
||||
procedure TestDebuggerStatement;
|
||||
procedure TestBlockEmpty;
|
||||
procedure TestBlockEmptyStatement;
|
||||
procedure TestBlockSimpleStatement;
|
||||
@ -1680,6 +1681,19 @@ begin
|
||||
AssertEquals('Member name identifier correct', 'b', TJSPrimaryExpressionIdent(V.init).Name);
|
||||
end;
|
||||
|
||||
procedure TTestJSParser.TestDebuggerStatement;
|
||||
Var
|
||||
E : TJSSourceElements;
|
||||
X : TJSElement;
|
||||
|
||||
begin
|
||||
CreateParser('debugger',MinDebuggerVersion);
|
||||
E:=GetSourceElements;
|
||||
AssertEquals('1 statement in block',1,E.Statements.Count);
|
||||
X:=E.Statements.Nodes[0].Node;
|
||||
CheckClass(X,TJSDebuggerStatement);
|
||||
end;
|
||||
|
||||
procedure TTestJSParser.TestBlockEmpty;
|
||||
|
||||
Var
|
||||
|
@ -99,6 +99,7 @@ type
|
||||
Procedure TestVarDeclarationStatement;
|
||||
Procedure TestLetDeclarationStatement;
|
||||
Procedure TestConstDeclarationStatement;
|
||||
Procedure TestDebuggerStatement;
|
||||
Procedure TestVarListDeclarationStatement;
|
||||
Procedure TestVarListDeclarationStatement2Vars;
|
||||
Procedure TestVarListDeclarationStatement3Vars;
|
||||
@ -1005,6 +1006,15 @@ begin
|
||||
AssertWrite('simple const','const a = 1',S);
|
||||
end;
|
||||
|
||||
procedure TTestStatementWriter.TestDebuggerStatement;
|
||||
Var
|
||||
S : TJSDebuggerStatement;
|
||||
|
||||
begin
|
||||
S:=TJSDebuggerStatement.Create(0,0);
|
||||
AssertWrite('debugger statement','debugger',S);
|
||||
end;
|
||||
|
||||
procedure TTestStatementWriter.TestVarListDeclarationStatement;
|
||||
|
||||
Var
|
||||
|
Loading…
Reference in New Issue
Block a user