You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/05/25 22:31:17 UTC
[royale-compiler] branch develop updated: handle uninitialized
namespaces. Fixes apache/royale-asjs#251
This is an automated email from the ASF dual-hosted git repository.
aharui 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 8aa56c6 handle uninitialized namespaces. Fixes apache/royale-asjs#251
8aa56c6 is described below
commit 8aa56c63e0b22486b5fbbf6ac82c59a6be649fa9
Author: Alex Harui <ah...@apache.org>
AuthorDate: Fri May 25 15:30:46 2018 -0700
handle uninitialized namespaces. Fixes apache/royale-asjs#251
---
.../internal/codegen/js/royale/JSRoyaleEmitter.java | 10 +++++++++-
.../codegen/js/royale/TestRoyaleStatements.java | 19 +++++++++++++++++++
.../royale/compiler/internal/test/ASTestBase.java | 1 +
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
index 15d6415..92a12f7 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
@@ -476,7 +476,15 @@ public class JSRoyaleEmitter extends JSGoogEmitter implements IJSRoyaleEmitter
writeToken(ASEmitterTokens.NEW);
write(IASLanguageConstants.Namespace);
write(ASEmitterTokens.PAREN_OPEN);
- getWalker().walk(node.getNamespaceURINode());
+ IExpressionNode uriNode = node.getNamespaceURINode();
+ if (uriNode == null)
+ {
+ write(ASEmitterTokens.SINGLE_QUOTE);
+ write(node.getName());
+ write(ASEmitterTokens.SINGLE_QUOTE);
+ }
+ else
+ getWalker().walk(uriNode);
write(ASEmitterTokens.PAREN_CLOSE);
write(ASEmitterTokens.SEMICOLON);
}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
index 09e7e91..c00af2b 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
@@ -29,6 +29,7 @@ import org.apache.royale.compiler.tree.as.IForLoopNode;
import org.apache.royale.compiler.tree.as.IIfNode;
import org.apache.royale.compiler.tree.as.IImportNode;
import org.apache.royale.compiler.tree.as.ILiteralNode;
+import org.apache.royale.compiler.tree.as.INamespaceNode;
import org.apache.royale.compiler.tree.as.ISwitchNode;
import org.apache.royale.compiler.tree.as.ITryNode;
import org.apache.royale.compiler.tree.as.IVariableNode;
@@ -50,6 +51,24 @@ public class TestRoyaleStatements extends TestGoogStatements
}
@Test
+ public void testNamespaceStatement()
+ {
+ INamespaceNode node = (INamespaceNode) getNode("public namespace foo;",
+ INamespaceNode.class, WRAP_LEVEL_NONE);
+ asBlockWalker.visitNamespace(node);
+ assertOut("foo = new Namespace('foo');");
+ }
+
+ @Test
+ public void testNamespaceStatementWithURI()
+ {
+ INamespaceNode node = (INamespaceNode) getNode("public namespace foo = 'bar';",
+ INamespaceNode.class, WRAP_LEVEL_NONE);
+ asBlockWalker.visitNamespace(node);
+ assertOut("foo = new Namespace('bar');");
+ }
+
+ @Test
public void testObjectListeral_withPropertyNameMatchingConst()
{
ILiteralNode node = (ILiteralNode) getNode("static const myConst:int; function royaleTest_a():Object { return { myConst : myConst } }",
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/ASTestBase.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/ASTestBase.java
index a0daae8..fd484ba 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/ASTestBase.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/ASTestBase.java
@@ -87,6 +87,7 @@ public class ASTestBase extends TestBase
protected static final int WRAP_LEVEL_MEMBER = 3;
protected static final int WRAP_LEVEL_CLASS = 2;
protected static final int WRAP_LEVEL_PACKAGE = 1;
+ protected static final int WRAP_LEVEL_NONE = 0;
protected IASNode getNode(String code, Class<? extends IASNode> type)
{
--
To stop receiving notification emails like this one, please contact
aharui@apache.org.