flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [6/7] git commit: [flex-falcon] [refs/heads/develop] - handle states sharing instances
Date Sat, 22 Nov 2014 00:32:00 GMT
handle states sharing instances


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/e28cf157
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/e28cf157
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/e28cf157

Branch: refs/heads/develop
Commit: e28cf157d27b074bb156b05a3a4e5d2b88f17585
Parents: 1157e2e
Author: Alex Harui <aharui@apache.org>
Authored: Fri Nov 21 14:58:02 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Nov 21 14:58:16 2014 -0800

----------------------------------------------------------------------
 .../codegen/mxml/flexjs/MXMLFlexJSEmitter.java  | 48 +++++++++++++++-----
 1 file changed, 36 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e28cf157/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
index 5955432..5bfe515 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
@@ -22,7 +22,9 @@ package org.apache.flex.compiler.internal.codegen.mxml.flexjs;
 
 import java.io.FilterWriter;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
@@ -109,6 +111,18 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     private StringBuilder subDocuments = new StringBuilder();
     private ArrayList<String> subDocumentNames = new ArrayList<String>();
 
+    /**
+     * This keeps track of the entries in our temporary array of 
+     * DeferredInstanceFromFunction objects that we CG to help with
+     * State override CG.
+     * 
+     * Keys are Instance nodes,
+     * values are the array index where the deferred instance is:
+     * 
+     *  deferred instance = local3[ nodeToIndexMap.get(an instance) ]
+     */
+    protected Map<IMXMLNode, Integer> nodeToIndexMap;
+    
     public MXMLFlexJSEmitter(FilterWriter out)
     {
         super(out);
@@ -1207,18 +1221,28 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
 
         MXMLDescriptorSpecifier overrideInstances = getCurrentDescriptor("so");
         int index = overrideInstances.propertySpecifiers.size();
-        MXMLDescriptorSpecifier itemsDesc = new MXMLDescriptorSpecifier();
-        itemsDesc.isProperty = true;
-        itemsDesc.hasArray = true;
-        itemsDesc.name = "itemsDescriptorIndex";
-        itemsDesc.parent = overrideInstances;
-        overrideInstances.propertySpecifiers.add(itemsDesc);
-        boolean oldInMXMLContent = inMXMLContent;
-        moveDown(false, null, itemsDesc);
-        inMXMLContent = true;
-        getMXMLWalker().walk(instanceNode); // instance node
-        inMXMLContent = oldInMXMLContent;
-        moveUp(false, false);
+        if (nodeToIndexMap == null)
+        	nodeToIndexMap = new HashMap<IMXMLNode, Integer>();
+        if (nodeToIndexMap.containsKey(instanceNode))
+        {
+        	index = nodeToIndexMap.get(instanceNode);
+        }
+        else
+        {
+        	nodeToIndexMap.put(instanceNode, index);
+            MXMLDescriptorSpecifier itemsDesc = new MXMLDescriptorSpecifier();
+            itemsDesc.isProperty = true;
+            itemsDesc.hasArray = true;
+            itemsDesc.name = "itemsDescriptor";
+            itemsDesc.parent = overrideInstances;
+            overrideInstances.propertySpecifiers.add(itemsDesc);
+            boolean oldInMXMLContent = inMXMLContent;
+            moveDown(false, null, itemsDesc);
+            inMXMLContent = true;
+            getMXMLWalker().walk(instanceNode); // instance node
+            inMXMLContent = oldInMXMLContent;
+            moveUp(false, false);
+        }
 
         MXMLDescriptorSpecifier addItems = new MXMLDescriptorSpecifier();
         addItems.isProperty = false;


Mime
View raw message