You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/06/24 01:11:09 UTC
[royale-compiler] branch develop updated: Fix while loop without
body needs correct transpile: added trailing semicolon.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
The following commit(s) were added to refs/heads/develop by this push:
new e21fc8d Fix while loop without body needs correct transpile: added trailing semicolon.
e21fc8d is described below
commit e21fc8d7b394f00dec83f94e4f1c8705e5152e25
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed Jun 24 13:06:05 2020 +1200
Fix while loop without body needs correct transpile: added trailing semicolon.
---
.../internal/codegen/js/jx/WhileLoopEmitter.java | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/WhileLoopEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/WhileLoopEmitter.java
index 2bd7da3..8395fc1 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/WhileLoopEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/WhileLoopEmitter.java
@@ -39,7 +39,6 @@ public class WhileLoopEmitter extends JSSubEmitter implements
@Override
public void emit(IWhileLoopNode node)
{
- IContainerNode cnode = (IContainerNode) node.getChild(1);
startMapping(node);
writeToken(ASEmitterTokens.WHILE);
@@ -49,13 +48,20 @@ public class WhileLoopEmitter extends JSSubEmitter implements
IASNode conditionalExpression = node.getConditionalExpressionNode();
getWalker().walk(conditionalExpression);
- IASNode statementContentsNode = node.getStatementContentsNode();
+ IContainerNode statementContentsNode = (IContainerNode) node.getStatementContentsNode();
startMapping(node, conditionalExpression);
write(ASEmitterTokens.PAREN_CLOSE);
- if (!EmitterUtils.isImplicit(cnode))
+ if (!EmitterUtils.isImplicit(statementContentsNode))
write(ASEmitterTokens.SPACE);
endMapping(node);
-
- getWalker().walk(statementContentsNode);
+ //if we have a while loop that has no body, then emit it the same way as it would be expressed
+ //in the original as3 source, with a semicolon terminator.
+ //Otherwise the loop body will be considered to be the following statement
+ if (EmitterUtils.isImplicit(statementContentsNode)
+ && statementContentsNode.getChildCount() == 0) {
+ writeToken(ASEmitterTokens.SEMICOLON);
+ } else {
+ getWalker().walk(statementContentsNode);
+ }
}
}