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/11/26 07:11:56 UTC

[royale-compiler] branch develop updated (94465cf -> a4f68b0)

This is an automated email from the ASF dual-hosted git repository.

aharui pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git.


    from 94465cf  fix function watcher JS output
     new e0c8091  fix databinding in fx:String
     new 9ec1156  check with project before renaming private vars
     new a4f68b0  handle empty conditionals

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../internal/codegen/js/jx/BindableEmitter.java    |  2 +-
 .../compiler/internal/codegen/js/jx/IfEmitter.java |  7 ++++
 .../codegen/mxml/royale/MXMLRoyaleEmitter.java     | 32 ++++++---------
 .../codegen/js/goog/TestGoogStatements.java        | 11 ++++++
 .../databinding/BindingDestinationMaker.java       | 45 ++++++++++++++++++++++
 5 files changed, 76 insertions(+), 21 deletions(-)


[royale-compiler] 02/03: check with project before renaming private vars

Posted by ah...@apache.org.
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

commit 9ec1156a306d114ffbb6805f644a4d5d7eea20b7
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sun Nov 25 23:11:16 2018 -0800

    check with project before renaming private vars
---
 .../apache/royale/compiler/internal/codegen/js/jx/BindableEmitter.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/BindableEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/BindableEmitter.java
index cbefd7e..1549a68 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/BindableEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/BindableEmitter.java
@@ -447,7 +447,7 @@ public class BindableEmitter extends JSSubEmitter implements
     {
         // TODO (mschmalle) will remove this cast as more things get abstracted
         JSRoyaleEmitter fjs = (JSRoyaleEmitter) getEmitter();
-    	String qname = info.namespace.equals("private") ? fjs.formatPrivateName(cdef.getQualifiedName(), name) : name;
+    	String qname = (info.namespace.equals("private") && getProject().getAllowPrivateNameConflicts()) ? fjs.formatPrivateName(cdef.getQualifiedName(), name) : name;
         if (info.namespace != "public") {
             writeNewline("/** @export");
             writeNewline("  * @private");


[royale-compiler] 01/03: fix databinding in fx:String

Posted by ah...@apache.org.
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

commit e0c80914b14270fb41734e5eb8e47bcaa02e15bf
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sun Nov 25 21:32:00 2018 -0800

    fix databinding in fx:String
---
 .../codegen/mxml/royale/MXMLRoyaleEmitter.java     | 32 ++++++---------
 .../databinding/BindingDestinationMaker.java       | 45 ++++++++++++++++++++++
 2 files changed, 57 insertions(+), 20 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
index d2fa869..56b39d1 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
@@ -1453,23 +1453,9 @@ public class MXMLRoyaleEmitter extends MXMLEmitter implements
 
 		StringBuilder sb = new StringBuilder();
 		sb.append("function (value) { ");
-		int lastGet = body.lastIndexOf("get_");
-		int lastDot = body.lastIndexOf(".");
-		if (lastDot == lastGet - 1)
-		{
-			String object = body.substring(0, lastDot);
-			String getter = body.substring(lastDot);
-			String setter = getter.replace("get_", "set_");
-			setter = setter.replace("()", "(value)");
-			body = object + setter;
-			sb.append(body);
-		}
-		else
-		{
-			sb.append(body);
-			sb.append(" = value;");
-		}
-		sb.append(";}");
+		sb.append(body);
+		sb.append(" = value;");
+		sb.append("}");
 		return sb.toString();
 	}
 
@@ -3129,9 +3115,15 @@ public class MXMLRoyaleEmitter extends MXMLEmitter implements
     	if (instanceNode instanceof IMXMLStringNode)
     	{
     		IMXMLStringNode stringNode = (IMXMLStringNode)instanceNode;
-            IMXMLLiteralNode valueNode = (IMXMLLiteralNode)(stringNode.getExpressionNode());
-            Object value = valueNode.getValue();
-            return objectToString(value);
+    		IASNode vNode = stringNode.getExpressionNode();
+    		if (vNode instanceof IMXMLLiteralNode)
+    		{
+	            IMXMLLiteralNode valueNode = (IMXMLLiteralNode)vNode;
+	            Object value = valueNode.getValue();
+	            return objectToString(value);
+    		}
+    		else
+    			return "''";
     	}
     	return "";
     }
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/codegen/databinding/BindingDestinationMaker.java b/compiler/src/main/java/org/apache/royale/compiler/internal/codegen/databinding/BindingDestinationMaker.java
index add3260..9550fb6 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/codegen/databinding/BindingDestinationMaker.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/codegen/databinding/BindingDestinationMaker.java
@@ -31,14 +31,23 @@ import org.apache.royale.compiler.internal.as.codegen.Binding;
 import org.apache.royale.compiler.internal.as.codegen.InstructionListNode;
 import org.apache.royale.compiler.internal.as.codegen.MXMLClassDirectiveProcessor;
 import org.apache.royale.compiler.internal.definitions.NamespaceDefinition;
+import org.apache.royale.compiler.internal.tree.as.DynamicAccessNode;
+import org.apache.royale.compiler.internal.tree.as.IdentifierNode;
+import org.apache.royale.compiler.internal.tree.as.MemberAccessExpressionNode;
+import org.apache.royale.compiler.internal.tree.as.NodeBase;
+import org.apache.royale.compiler.internal.tree.as.NumericLiteralNode;
 import org.apache.royale.compiler.tree.as.IASNode;
 import org.apache.royale.compiler.tree.as.IExpressionNode;
+import org.apache.royale.compiler.tree.mxml.IMXMLArrayNode;
+import org.apache.royale.compiler.tree.mxml.IMXMLConcatenatedDataBindingNode;
 import org.apache.royale.compiler.tree.mxml.IMXMLDataBindingNode;
+import org.apache.royale.compiler.tree.mxml.IMXMLLiteralNode;
 import org.apache.royale.compiler.tree.mxml.IMXMLModelNode;
 import org.apache.royale.compiler.tree.mxml.IMXMLModelPropertyNode;
 import org.apache.royale.compiler.tree.mxml.IMXMLModelRootNode;
 import org.apache.royale.compiler.tree.mxml.IMXMLPropertySpecifierNode;
 import org.apache.royale.compiler.tree.mxml.IMXMLSingleDataBindingNode;
+import org.apache.royale.compiler.tree.mxml.IMXMLStringNode;
 
 /**
  * Utility class for analyze binding destinations and making
@@ -144,6 +153,42 @@ public class BindingDestinationMaker
                 }
             }
         }
+        else if (parent instanceof IMXMLStringNode && dbnode instanceof IMXMLConcatenatedDataBindingNode)
+        {
+        	// this is a binding in a literal like a string, such as 'this is {SOME_VAR} times';
+        	// we need to figure out how to set the evaluated value.
+        	// if this binding is not in an array, then other code will use the effectiveID of the string
+        	// and set the value.
+        	// if it is in an array, then figure out the index in the array to set
+        	if (parent.getParent() instanceof IMXMLArrayNode)
+        	{
+        		int index = -1;
+        		int n = parent.getParent().getChildCount();
+        		for (int i = 0; i < n; i++)
+        		{
+        			IASNode child = parent.getParent().getChild(i);
+        			if (child == parent)
+        			{
+        				index = i;
+        				break;
+        			}
+        		}
+        		IdentifierNode arrayNode = new IdentifierNode(((IMXMLArrayNode)parent.getParent()).getEffectiveID());
+        		arrayNode.setSourcePath(parent.getSourcePath());
+        		arrayNode.setColumn(parent.getColumn());
+        		arrayNode.setLine(parent.getLine());
+        		NumericLiteralNode indexNode = new NumericLiteralNode(new Integer(index).toString());
+        		indexNode.setSourcePath(parent.getSourcePath());
+        		indexNode.setColumn(parent.getColumn());
+        		indexNode.setLine(parent.getLine());
+        		DynamicAccessNode mae = new DynamicAccessNode(arrayNode);
+        		mae.setRightOperandNode(indexNode);
+        		mae.setParent((NodeBase) dbnode.getParent());
+        		arrayNode.setParent(mae);
+        		indexNode.setParent(mae);
+        		return mae;
+        	}
+        }
         return ret;   
     }
     


[royale-compiler] 03/03: handle empty conditionals

Posted by ah...@apache.org.
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

commit a4f68b07cfbc36f15643ca641a93416e86ad4d84
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sun Nov 25 23:11:37 2018 -0800

    handle empty conditionals
---
 .../royale/compiler/internal/codegen/js/jx/IfEmitter.java     |  7 +++++++
 .../compiler/internal/codegen/js/goog/TestGoogStatements.java | 11 +++++++++++
 2 files changed, 18 insertions(+)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IfEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IfEmitter.java
index 74ca31c..a5c987b 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IfEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IfEmitter.java
@@ -68,6 +68,13 @@ public class IfEmitter extends JSSubEmitter implements
         {
             emitElse(elseNode);
         }
+        // if no actual work is done in the if clause, and there are no else/elseif causes
+        // emit an empty block.  Closure doesn't like a plain semicolon.
+        if (nodes.length == 0 && elseNode == null && conditional.getChild(1).getChildCount() == 0)
+        {
+        	write(ASEmitterTokens.BLOCK_OPEN);
+        	writeNewline(ASEmitterTokens.BLOCK_CLOSE);
+        }
         
     }
 
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogStatements.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogStatements.java
index 4247a29..9df4078 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogStatements.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogStatements.java
@@ -25,6 +25,7 @@ import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
 import org.apache.royale.compiler.internal.tree.as.LabeledStatementNode;
 import org.apache.royale.compiler.tree.as.IFileNode;
 import org.apache.royale.compiler.tree.as.IForLoopNode;
+import org.apache.royale.compiler.tree.as.IIfNode;
 import org.apache.royale.compiler.tree.as.ISwitchNode;
 import org.apache.royale.compiler.tree.as.ITryNode;
 import org.apache.royale.compiler.tree.as.IVariableNode;
@@ -310,6 +311,16 @@ public class TestGoogStatements extends TestStatements
         assertOut("goog.provide('RoyaleTest_A');\n\n/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\nRoyaleTest_A.prototype.royaleTest_a = function() {\n\tvar self = this;\n\ttry {\n\t\ta;\n\t} catch (e) {\n\t\tif (a) {\n\t\t\tif (b) {\n\t\t\t\tif (c)\n\t\t\t\t\tb;\n\t\t\t\telse if (f)\n\t\t\t\t\ta;\n\t\t\t\telse\n\t\t\t\t\te;\n\t\t\t}\n\t\t}\n\t} finally {\n\t}\n\tif (d)\n\t\tfor (var /** @type {number} */ i = 0; i < len; i++)\n\t\t\tbreak;\n\tif (a) {\n\t\twith (ab) {\n\t\ [...]
     }
 
+    @Test
+    public void testVisitIf_NoClauses()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) ;", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (a)\n{}\n");
+    }
+
+
     @Override
     protected IBackend createBackend()
     {