fcl-js: jswriter: accelerated WriteJS

git-svn-id: trunk@37288 -
This commit is contained in:
Mattias Gaertner 2017-09-21 10:59:40 +00:00
parent c25487ebdc
commit 88c515a6c4

View File

@ -1453,6 +1453,8 @@ begin
end; end;
procedure TJSWriter.WriteJS(El: TJSElement); procedure TJSWriter.WriteJS(El: TJSElement);
var
C: TClass;
begin begin
{$IFDEF DEBUGJSWRITER} {$IFDEF DEBUGJSWRITER}
if (El<>Nil) then if (El<>Nil) then
@ -1461,57 +1463,58 @@ begin
system.Writeln('WriteJS : El = Nil'); system.Writeln('WriteJS : El = Nil');
{$ENDIF} {$ENDIF}
Writer.CurElement:=El; Writer.CurElement:=El;
if (El is TJSEmptyBlockStatement ) then C:=El.ClassType;
if (C=TJSEmptyBlockStatement ) then
WriteEmptyBlockStatement(TJSEmptyBlockStatement(El)) WriteEmptyBlockStatement(TJSEmptyBlockStatement(El))
else if (El is TJSEmptyStatement) then else if (C=TJSEmptyStatement) then
WriteEmptyStatement(TJSEmptyStatement(El)) WriteEmptyStatement(TJSEmptyStatement(El))
else if (El is TJSLiteral) then else if (C=TJSLiteral) then
WriteLiteral(TJSLiteral(El)) WriteLiteral(TJSLiteral(El))
else if (El is TJSPrimaryExpression) then else if C.InheritsFrom(TJSPrimaryExpression) then
WritePrimaryExpression(TJSPrimaryExpression(El)) WritePrimaryExpression(TJSPrimaryExpression(El))
else if (El is TJSArrayLiteral) then else if C.InheritsFrom(TJSArrayLiteral) then
WriteArrayLiteral(TJSArrayLiteral(El)) WriteArrayLiteral(TJSArrayLiteral(El))
else if (El is TJSObjectLiteral) then else if (C=TJSObjectLiteral) then
WriteObjectLiteral(TJSObjectLiteral(El)) WriteObjectLiteral(TJSObjectLiteral(El))
else if (El is TJSMemberExpression) then else if C.InheritsFrom(TJSMemberExpression) then
WriteMemberExpression(TJSMemberExpression(El)) WriteMemberExpression(TJSMemberExpression(El))
else if (El is TJSRegularExpressionLiteral) then else if (C=TJSRegularExpressionLiteral) then
WriteRegularExpressionLiteral(TJSRegularExpressionLiteral(El)) WriteRegularExpressionLiteral(TJSRegularExpressionLiteral(El))
else if (El is TJSCallExpression) then else if (C=TJSCallExpression) then
WriteCallExpression(TJSCallExpression(El)) WriteCallExpression(TJSCallExpression(El))
else if (El is TJSLabeledStatement) then // Before unary else if (C=TJSLabeledStatement) then // Before unary
WriteLabeledStatement(TJSLabeledStatement(El)) WriteLabeledStatement(TJSLabeledStatement(El))
else if (El is TJSFunctionBody) then // Before unary else if (C=TJSFunctionBody) then // Before unary
WriteFunctionBody(TJSFunctionBody(El)) WriteFunctionBody(TJSFunctionBody(El))
else if (El is TJSVariableStatement) then // Before unary else if (C=TJSVariableStatement) then // Before unary
WriteVariableStatement(TJSVariableStatement(El)) WriteVariableStatement(TJSVariableStatement(El))
else if (El is TJSUNary) then else if C.InheritsFrom(TJSUnary) then
WriteUnary(TJSUnary(El)) WriteUnary(TJSUnary(El))
else if (El is TJSVariableDeclarationList) then else if (C=TJSVariableDeclarationList) then
WriteVarDeclarationList(TJSVariableDeclarationList(El)) // Must be before binary WriteVarDeclarationList(TJSVariableDeclarationList(El)) // Must be before binary
else if (El is TJSStatementList) then else if (C=TJSStatementList) then
WriteStatementList(TJSStatementList(El)) // Must be before binary WriteStatementList(TJSStatementList(El)) // Must be before binary
else if (El is TJSWithStatement) then else if (C=TJSWithStatement) then
WriteWithStatement(TJSWithStatement(El)) // Must be before binary WriteWithStatement(TJSWithStatement(El)) // Must be before binary
else if (El is TJSBinary) then else if C.InheritsFrom(TJSBinary) then
WriteBinary(TJSBinary(El)) WriteBinary(TJSBinary(El))
else if (El is TJSConditionalExpression) then else if (C=TJSConditionalExpression) then
WriteConditionalExpression(TJSConditionalExpression(El)) WriteConditionalExpression(TJSConditionalExpression(El))
else if (El is TJSAssignStatement) then else if C.InheritsFrom(TJSAssignStatement) then
WriteAssignStatement(TJSAssignStatement(El)) WriteAssignStatement(TJSAssignStatement(El))
else if (El is TJSVarDeclaration) then else if (C=TJSVarDeclaration) then
WriteVarDeclaration(TJSVarDeclaration(El)) WriteVarDeclaration(TJSVarDeclaration(El))
else if (El is TJSIfStatement) then else if (C=TJSIfStatement) then
WriteIfStatement(TJSIfStatement(El)) WriteIfStatement(TJSIfStatement(El))
else if (El is TJSTargetStatement) then else if C.InheritsFrom(TJSTargetStatement) then
WriteTargetStatement(TJSTargetStatement(El)) WriteTargetStatement(TJSTargetStatement(El))
else if (El is TJSReturnStatement) then else if (C=TJSReturnStatement) then
WriteReturnStatement(TJSReturnStatement(El)) WriteReturnStatement(TJSReturnStatement(El))
else if (El is TJSTryStatement) then else if C.InheritsFrom(TJSTryStatement) then
WriteTryStatement(TJSTryStatement(El)) WriteTryStatement(TJSTryStatement(El))
else if (El is TJSFunctionDeclarationStatement) then else if (C=TJSFunctionDeclarationStatement) then
WriteFunctionDeclarationStatement(TJSFunctionDeclarationStatement(El)) WriteFunctionDeclarationStatement(TJSFunctionDeclarationStatement(El))
else if (El is TJSSourceElements) then else if (C=TJSSourceElements) then
WriteSourceElements(TJSSourceElements(El)) WriteSourceElements(TJSSourceElements(El))
else if El=Nil then else if El=Nil then
Error(SErrNilNode) Error(SErrNilNode)