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/10/10 19:33:49 UTC

[royale-compiler] 03/08: more tweaking of codegen for remoteobject

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 dee493d017bf187ed9632076bee54a967917deeb
Author: Alex Harui <ah...@apache.org>
AuthorDate: Tue Oct 9 09:47:38 2018 -0700

    more tweaking of codegen for remoteobject
---
 .../as/codegen/MXMLClassDirectiveProcessor.java    | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
index 9ad5f6d..b92da21 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
@@ -100,6 +100,7 @@ import static org.apache.royale.compiler.mxml.IMXMLTypeConstants.SET_DOCUMENT_DE
 import static org.apache.royale.compiler.mxml.IMXMLTypeConstants.SET_STYLE_CALL_OPERANDS;
 
 import java.util.ArrayDeque;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Deque;
 import java.util.EnumMap;
@@ -1881,6 +1882,9 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
         if (context.hasBeads)
             numProperties += 1;
         
+        int numOperations = context.getCounter(IL.WEB_SERVICE_OPERATIONS_OR_REMOTE_OBJECT_METHODS);
+        if (numOperations > 0)
+        	numProperties += 1;
         if (newCodeGen && addCounters)
             context.pushNumericConstant(numProperties);
         // Adds code such as
@@ -1890,6 +1894,20 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
         if (context.hasModel)
             context.transfer(IL.MXML_MODEL_PROPERTIES);
         context.transfer(IL.PROPERTIES);
+        if (numOperations > 0)
+        {
+            context.addInstruction(OP_pushstring, "operations");
+            context.addInstruction(OP_pushfalse);
+            context.addInstruction(OP_findpropstrict, IMXMLTypeConstants.NAME_OBJECT);
+            context.addInstruction(OP_getproperty, IMXMLTypeConstants.NAME_OBJECT);
+            context.pushNumericConstant(numOperations);
+        	context.transfer(IL.WEB_SERVICE_OPERATIONS_OR_REMOTE_OBJECT_METHODS);
+            context.pushNumericConstant(0);
+            context.pushNumericConstant(0);
+            context.pushNumericConstant(0);
+            context.addInstruction(OP_pushnull);
+            context.addInstruction(OP_newarray, numOperations * 3 + 6);      
+        }
         if (context.hasBeads)
             context.transfer(IL.MXML_BEAD_PROPERTIES);
         
@@ -2968,6 +2986,39 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
         // If 'name' is undefined, the WebService node will report problem.
         if (!Strings.isNullOrEmpty(name))
         {
+        	// build out the argument list if any
+        	int n = node.getChildCount();
+        	for (int i = 0; i < n; i++)
+        	{
+        		IASNode childNode = node.getChild(i);
+        		if (childNode.getNodeID() == ASTNodeID.MXMLPropertySpecifierID)
+        		{
+        			IMXMLPropertySpecifierNode propNode = (IMXMLPropertySpecifierNode)childNode;
+        			if (propNode.getName().equals("arguments"))
+        			{
+        				ArrayList<String> argList = new ArrayList<String>();
+        				childNode = propNode.getChild(0); // this is an MXMLObjectNode
+        				n = childNode.getChildCount();
+        				for (i = 0; i < n; i++)
+        				{
+        					IASNode argNode = childNode.getChild(i);
+        					propNode = (IMXMLPropertySpecifierNode)argNode;
+        					argList.add(propNode.getName());
+        				}
+        				if (argList.size() > 0)
+        				{
+        		            context.startUsing(IL.PROPERTIES);
+        		            context.addInstruction(OP_pushstring, "argumentNames");
+        		            context.addInstruction(OP_pushtrue);
+        		            for (String s : argList)
+            		            context.addInstruction(OP_pushstring, s);
+        	                context.addInstruction(OP_newarray, argList.size());      
+        		            context.stopUsing(IL.PROPERTIES, 1);        					
+        				}
+        				break;
+        			}
+        		}
+        	}
             context.startUsing(IL.WEB_SERVICE_OPERATIONS_OR_REMOTE_OBJECT_METHODS);
             context.addInstruction(OP_pushstring, name);
             processMXMLInstance(node, context);
@@ -3016,9 +3067,21 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
         traverse(objectNode, context);
         
         int numElements = context.getCounter(IL.PROPERTIES);
+        String id = objectNode.getEffectiveID();
+        if (id != null)
+        	numElements++;
         if (newCodeGen && !context.makingSimpleArray)
             context.pushNumericConstant(numElements);
         context.transfer(IL.PROPERTIES);
+        if (id != null)
+        {
+        	if (id.startsWith("#"))
+        		context.addInstruction(OP_pushstring, "_id");
+        	else
+        		context.addInstruction(OP_pushstring, "id");
+            context.addInstruction(OP_pushtrue);
+            context.addInstruction(OP_pushstring, id);
+        }
         
         if (!newCodeGen || context.makingSimpleArray)
         {