You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/11/05 21:58:29 UTC

[1/3] git commit: [flex-falcon] [refs/heads/develop] - More binding fixes

Updated Branches:
  refs/heads/develop 7020dcfac -> 325cce668


More binding fixes


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

Branch: refs/heads/develop
Commit: d097b08a832ce6ca6be57f4f8a64f9ec08717b0e
Parents: 525c271
Author: Alex Harui <ah...@apache.org>
Authored: Mon Nov 4 23:32:24 2013 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Nov 5 06:32:22 2013 -0800

----------------------------------------------------------------------
 .../databinding/MXMLBindingDirectiveHelper.java | 30 ++++++++++++++------
 1 file changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d097b08a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
index 7d7d41d..b4ea1c3 100644
--- a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
+++ b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
@@ -163,6 +163,11 @@ public class MXMLBindingDirectiveHelper
             else
                 host.addVariableTrait(IMXMLTypeConstants.NAME_BINDINGS, NAME_ARRAYTYPE);
         }
+        else
+        {
+            makeSpecialMemberVariablesForBinding();
+            isFlexSDK = true;
+        }
         
         if (host.getProject().getTargetSettings().getMxmlChildrenAsData())
             return outputBindingInfoAsData(isFlexSDK);
@@ -211,6 +216,12 @@ public class MXMLBindingDirectiveHelper
             else
                 ret.addInstruction(OP_pushstring, s);
             
+            IExpressionNode destNode = bi.getExpressionNodeForDestination();
+            if (destNode != null)
+                BindingCodeGenUtils.generateSetter(ret, destNode, host.getInstanceScope());
+            else
+                ret.addInstruction(OP_pushnull);
+            
             s = bi.getDestinationString();
             if (s.contains("."))
             {
@@ -219,13 +230,9 @@ public class MXMLBindingDirectiveHelper
                     ret.addInstruction(OP_pushstring, part);
                 ret.addInstruction(OP_newarray, parts.length);
             }
-            else if (s == null || s.length() == 0)
-            {
-                BindingCodeGenUtils.generateSetter(ret, bi.getExpressionNodeForDestination(), host.getInstanceScope());
-            }
             else
                 ret.addInstruction(OP_pushstring, s);
-            propertyCount += 2;
+            propertyCount += 3;
         }
         Set<Entry<Object, WatcherInfoBase>> watcherChains = bindingDataBase.getWatcherChains();
         if (watcherChains != null)
@@ -242,13 +249,11 @@ public class MXMLBindingDirectiveHelper
         // stack : this, bindings
         ret.addInstruction(OP_swap);
         // stack : bindings, this
-        ret.addInstruction(OP_setproperty, IMXMLTypeConstants.NAME_BINDINGS);
         
         if (isFlexSDK)
-        {
-            ret.addInstruction(OP_getlocal0);
             ret.addInstruction(OP_callpropvoid, IMXMLTypeConstants.ARG_SETUPBINDINGS);
-        }
+        else
+            ret.addInstruction(OP_setproperty, IMXMLTypeConstants.NAME_BINDINGS);
 
         return ret;
     }
@@ -298,6 +303,13 @@ public class MXMLBindingDirectiveHelper
                 ret.addInstruction(OP_pushnull);            // null is valid
             else 
                 ret.addInstruction(OP_newfunction, propertyGetterFunction);
+            if (type == WatcherType.STATIC_PROPERTY)
+            {
+                StaticPropertyWatcherInfo pwinfo = (StaticPropertyWatcherInfo)watcherInfoBase;
+                Name classMName = pwinfo.getContainingClass(host.getProject());
+                ret.addInstruction(OP_getlex, classMName);
+                propertyCount++;
+            }
             propertyCount += 5;
         }
         else if (type == WatcherType.XML)


[2/3] git commit: [flex-falcon] [refs/heads/develop] - Add flag to info() structure so we can tell if a SWF was compiled by Falcon

Posted by ah...@apache.org.
Add flag to info() structure so we can tell if a SWF was compiled by Falcon


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

Branch: refs/heads/develop
Commit: 525c2717a9e4f5daf71cd6bb9b23b7d0f586321e
Parents: 7020dcf
Author: Alex Harui <ah...@apache.org>
Authored: Mon Nov 4 23:31:46 2013 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Nov 5 06:32:22 2013 -0800

----------------------------------------------------------------------
 .../org/apache/flex/compiler/internal/targets/FlexTarget.java   | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/525c2717/compiler/src/org/apache/flex/compiler/internal/targets/FlexTarget.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/targets/FlexTarget.java b/compiler/src/org/apache/flex/compiler/internal/targets/FlexTarget.java
index c668941..f9a9e60 100644
--- a/compiler/src/org/apache/flex/compiler/internal/targets/FlexTarget.java
+++ b/compiler/src/org/apache/flex/compiler/internal/targets/FlexTarget.java
@@ -319,6 +319,11 @@ public abstract class FlexTarget
             infoEntries++;
         }
         
+        // mark this SWF as being built with Falcon
+        info.addInstruction(ABCConstants.OP_pushstring, "isMXMLC");
+        info.addInstruction(ABCConstants.OP_pushfalse);
+        infoEntries++;
+        
         // mainClassName:
         if (mainClassQName != null)
         {


[3/3] git commit: [flex-falcon] [refs/heads/develop] - Switch mxml properties to private var so each layer of inheritance will run it in the same order as MXMLC would do it. Also don't put protected/private vars in the descriptor stream. And handle fx:

Posted by ah...@apache.org.
Switch mxml properties to private var so each layer of inheritance will run it in the same order as MXMLC would do it.  Also don't put protected/private vars in the descriptor stream.  And handle fx:Components in fx:Declarations.  They need to be special cased into a simple value


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

Branch: refs/heads/develop
Commit: 325cce6682f162567f12455bc3f1f1a1218595b7
Parents: d097b08
Author: Alex Harui <ah...@apache.org>
Authored: Mon Nov 4 23:40:32 2013 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Nov 5 06:32:23 2013 -0800

----------------------------------------------------------------------
 .../as/codegen/MXMLClassDirectiveProcessor.java | 162 +++++++++++--------
 .../flex/compiler/mxml/IMXMLTypeConstants.java  |   2 +-
 2 files changed, 93 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/325cce66/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java b/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
index ac6cb24..a8d6593 100644
--- a/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
+++ b/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
@@ -333,7 +333,6 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
     private static Name NAME_MXML_DESCRIPTOR = createMXMLPrivateName("mxmldd");
     private static Name NAME_MXML_DESCRIPTOR_GETTER = new Name("MXMLDescriptor");
     private static Name NAME_MXML_PROPERTIES = createMXMLPrivateName("mxmldp");
-    private static Name NAME_MXML_PROPERTIES_GETTER = new Name("MXMLProperties");
     private static Name NAME_GENERATE_CSSSTYLEDECLARATIONS = new Name("generateCSSStyleDeclarations");
 
     /**
@@ -465,6 +464,11 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
     protected final LexicalScope globalScope;
     
     /**
+     * number of attributes on top tag that weren't bindable
+     */
+    private int numElements = 0;
+    
+    /**
      * An incrementing counter used to create the names of the
      * auto-generated instance initializer methods.
      */
@@ -499,6 +503,23 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
     private final InstructionList iinitAfterSuperInsns = new InstructionList();
         
     /**
+     * Instructions to place in the class' constructor
+     * after the constructsuper opcode.
+     * This is currently used only for initializing
+     * MXML properties, styles, and events for non-public
+     * properties when mxml.children-as-data is true.
+     */
+    private final InstructionList iinitForNonPublicProperties = new InstructionList();
+        
+    /**
+     * Instructions to place in the class' constructor
+     * that represent the MXML properties.
+     * This is currently used only for initializing
+     * MXML properties, styles, and events on the main tag.
+     */
+    private final InstructionList mxmlPropertiesInsns = new InstructionList();
+        
+    /**
      * A Map mapping an instance node to the Name of the instance
      * initializer method (i0, i1, etc.) that creates it.
      * <P>
@@ -632,12 +653,13 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
         
         // Generate code in the constructor to set properties,
         // then styles, then events, then effects.
-        int numElements = setSpecifiers(context, getProject().getTargetSettings().getMxmlChildrenAsData(), true);
+        numElements = setSpecifiers(context, getProject().getTargetSettings().getMxmlChildrenAsData(), true);
         
         if (getProject().getTargetSettings().getMxmlChildrenAsData())
         {
             overrideMXMLDescriptorGetter(node, context);
-            overrideMXMLPropertiesGetter(node, context, numElements);
+            if (numElements > 0)
+                overrideMXMLPropertiesGetter(node, context, numElements);
         }
 
         generateBindableImpl();
@@ -1181,12 +1203,17 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
                 // iinitAfterSuperInsns go after the constructsuper opcode.
                 ctor_insns.addAll(iinitAfterSuperInsns);
             }
+            else
+            {
+                if (!iinitForNonPublicProperties.isEmpty())
+                    ctor_insns.addAll(iinitForNonPublicProperties);
+            }
             
             // call the Binding helper to get all the data binding setup code
             addBindingCodeForCtor(ctor_insns);
 
             // add call to MXMLAttributes
-            if (getProject().getTargetSettings().getMxmlChildrenAsData())
+            if (getProject().getTargetSettings().getMxmlChildrenAsData() && numElements > 0)
             {
                 // generateMXMLAttributes(attributes);
                 FunctionDefinition funcDef = (FunctionDefinition)SemanticUtils.findProperty(classDefinition.getContainedScope(), 
@@ -1196,8 +1223,7 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
                 {
                     Name funcName = ((FunctionDefinition)funcDef).getMName(getProject());
                     ctor_insns.addInstruction(OP_getlocal0);           
-                    ctor_insns.addInstruction(OP_findpropstrict, NAME_MXML_PROPERTIES_GETTER);
-                    ctor_insns.addInstruction(OP_getproperty, NAME_MXML_PROPERTIES_GETTER);
+                    ctor_insns.addAll(mxmlPropertiesInsns);
                     ctor_insns.addInstruction(OP_callpropvoid, new Object[] {funcName, 1 });
                 }
             }
@@ -1644,60 +1670,7 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
     // TODO gosmith Report a problem if there is already an initialize() override in this class.
     void overrideMXMLPropertiesGetter(IMXMLClassDefinitionNode node, Context context, int numElements)
     {
-        String name = "MXMLProperties";
-        MethodInfo methodInfo = new MethodInfo();        
-        methodInfo.setMethodName(name);
-        methodInfo.setReturnType(NAME_ARRAY);
-        
-        InstructionList body = new InstructionList();
-        
-        body.addInstruction(OP_getlocal0);
-        body.addInstruction(OP_pushscope);
-                    
-        // if (_MXMLProperties)
-        Label label0 = new Label();
-        body.addInstruction(OP_getlocal0);
-        body.addInstruction(OP_getproperty, NAME_MXML_PROPERTIES);
-        body.addInstruction(OP_not);
-        body.addInstruction(OP_iffalse, label0);
-        
-        // arr = super.MXMLProperties;
-        body.addInstruction(OP_findpropstrict, NAME_MXML_PROPERTIES_GETTER);
-        body.addInstruction(OP_getsuper, NAME_MXML_PROPERTIES_GETTER);
-        body.addInstruction(OP_setlocal1);
-
-        // data = [...]
-        addPropertiesData(body, context, numElements);
-        body.addInstruction(OP_setlocal2);
-        
-        // if (arr)
-        Label label1 = new Label();
-        body.addInstruction(OP_getlocal1);
-        body.addInstruction(OP_iffalse, label1);
-        
-        // _MXMLProperties = arr.concat(data);
-        body.addInstruction(OP_getlocal0);
-        body.addInstruction(OP_getlocal1);
-        body.addInstruction(OP_getlocal2);
-        body.addInstruction(OP_callproperty, CONCAT_CALL_OPERANDS); 
-        body.addInstruction(OP_setproperty, NAME_MXML_PROPERTIES);
-        body.addInstruction(OP_jump, label0);
-        
-        // _MXMLProperties = data;
-        body.labelNext(label1);
-        body.addInstruction(OP_getlocal0);
-        body.addInstruction(OP_getlocal2);
-        body.addInstruction(OP_setproperty, NAME_MXML_PROPERTIES);
-        
-        // return _MXMLProperties;
-        body.labelNext(label0);
-        body.addInstruction(OP_getlocal0);
-        body.addInstruction(OP_getproperty, NAME_MXML_PROPERTIES);
-        body.addInstruction(OP_returnvalue);
-
-        generateMethodBody(methodInfo, classScope, body);
-        
-        addGetter(NAME_MXML_PROPERTIES_GETTER, methodInfo, true);
+        addPropertiesData(mxmlPropertiesInsns, context, numElements);
     }
     
     /**
@@ -2624,6 +2597,7 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
     boolean isChildrenAsDataCodeGen(IMXMLExpressionNode node, Context context)
     {
         if (context.parentContext.makingSimpleArray) return false;
+        if (context.parentContext.nonPublic) return false;
         
         return (getProject().getTargetSettings().getMxmlChildrenAsData() && 
                 (node.getParent().getNodeID() == ASTNodeID.MXMLPropertySpecifierID ||
@@ -3633,15 +3607,34 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
             {
                 if (!isDataboundProp(propertyNode))
                 {
-                    context.startUsing(IL.PROPERTIES);
-                    
-                    context.addInstruction(OP_pushstring, propertyName);
-                    
-                    context.isContentFactory = false;
-                    
-                    traverse(propertyNode, context);
-                    
-                    context.stopUsing(IL.PROPERTIES, 1);
+                    IDefinition propDef = propertyNode.getDefinition();
+                    if (propDef.isPublic())
+                    {
+                        context.startUsing(IL.PROPERTIES);
+                        
+                        context.addInstruction(OP_pushstring, propertyName);
+                        
+                        context.isContentFactory = false;
+                        
+                        traverse(propertyNode, context);
+                        
+                        context.stopUsing(IL.PROPERTIES, 1);
+                    }
+                    else
+                    {
+                        Context tempContext = new Context(classDefinitionNode, iinitForNonPublicProperties);
+                        tempContext.nonPublic = true;
+                        
+                        // Push the object on which the property is to be set.
+                        tempContext.pushTarget();
+                        
+                        // Push the property value.
+                        // Do this by codegen'ing sole child, which is an IMXMLInstanceNode.
+                        traverse(propertyNode, tempContext);
+                        
+                        Name n = ((DefinitionBase)propDef).getMName(getProject());
+                        tempContext.addInstruction(OP_setproperty, n);
+                    }
                 }
                 else
                 {
@@ -4351,6 +4344,14 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
                 context.parentContext.incrementCounter(IL.MXML_STATES_ARRAY, numElements);
             }
         }
+        else
+        {
+            if (getProject().getTargetSettings().getMxmlChildrenAsData())
+            {
+                numElements += setSpecifiers(context, true, false);
+                context.parentContext.incrementCounter(IL.MXML_STATES_ARRAY, numElements);
+            }
+        }
         if (getProject().getTargetSettings().getMxmlChildrenAsData())
         {
             context.isStateDescriptor = false;
@@ -4406,7 +4407,10 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
             // whose property or style this override will set.
             context.addInstruction(OP_pushstring, "target");
             context.addInstruction(OP_pushtrue);
-            context.addInstruction(OP_pushstring, id);
+            if (id.length() == 0)
+                context.addInstruction(OP_pushnull);
+            else
+                context.addInstruction(OP_pushstring, id);
 
             // Set its 'name' property to the name of the property or style.
             context.addInstruction(OP_pushstring, "name");
@@ -4718,6 +4722,15 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
 
     void processMXMLComponent(IMXMLComponentNode node, Context context)
     {
+        boolean inDecl = false;
+        if (getProject().getTargetSettings().getMxmlChildrenAsData() &&
+                node.getParent() instanceof IMXMLDeclarationsNode)
+        {
+            inDecl = true;
+            context = context.parentContext;    // up-level to parent context's properties list
+            context.startUsing(IL.PROPERTIES);
+            context.addInstruction(OP_pushstring, node.getID());
+        }
         // Resolve the outer document, and if it doesn't resolve to the contingent
         // definition, that means there is already an existing definition declared
         // which is an error.
@@ -4742,6 +4755,9 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
         context.addInstruction(OP_getlocal0);
         context.addInstruction(OP_newobject, 1);
         context.addInstruction(OP_setproperty, IMXMLTypeConstants.NAME_PROPERTIES);
+        
+        if (inDecl)
+            context.stopUsing(IL.PROPERTIES, 1);
     }
 
     void processMXMLLibrary(IMXMLLibraryNode node, Context context)
@@ -5202,6 +5218,12 @@ public class MXMLClassDirectiveProcessor extends ClassDirectiveProcessor
          */
         private InstructionList currentInstructionList;
         
+        /**
+         * A flag indicating whether the class reference node
+         * needs to codegen a for a non-public property
+         */
+        private boolean nonPublic = false;
+        
        /**
          * A flag indicating whether the class reference node
          * needs to codegen a UIComponentDescriptor.

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/325cce66/compiler/src/org/apache/flex/compiler/mxml/IMXMLTypeConstants.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTypeConstants.java b/compiler/src/org/apache/flex/compiler/mxml/IMXMLTypeConstants.java
index a93bf9b..c639dd7 100644
--- a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTypeConstants.java
+++ b/compiler/src/org/apache/flex/compiler/mxml/IMXMLTypeConstants.java
@@ -196,7 +196,7 @@ public interface IMXMLTypeConstants
             new Name("updateParent"), 1};
     public final Object[] ARG_ADDCHILD = new Object[] {new Name("addChild"), 1};
     public final Object[] ARG_EXECUTE = new Object[] {NAME_EXECUTE, 0};
-    public final Object[] ARG_SETUPBINDINGS = new Object[] {NAME_SETUPBINDINGS, 0};
+    public final Object[] ARG_SETUPBINDINGS = new Object[] {NAME_SETUPBINDINGS, 1};
 
     // this is a "Name" to use for the property "array index"
     public final Name NAME_ARRAYINDEXPROP = new Name(ABCConstants.CONSTANT_MultinameL, new Nsset(new Namespace(CONSTANT_PackageNs)), null);