Package org.apache.flex.abc.semantics

Examples of org.apache.flex.abc.semantics.Name


        {
            // Get the Name for the mx.core.DeferredInstanceFromClass
            // or mx.core.DeferredInstanceFromFunction class.
            ICompilerProject project = getProject();
            ClassDefinition classReference = (ClassDefinition)deferredInstanceNode.getClassReference(project);
            Name deferredInstanceClassName = classReference.getMName(project);
           
            // Push this class.
            context.addInstruction(OP_finddef, deferredInstanceClassName);
           
            // Push the class or function to be used as the generator,
View Full Code Here


                       
                        // 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
                {
                    IMXMLInstanceNode instanceNode = propertyNode.getInstanceNode();
                    if (instanceNode instanceof IMXMLSingleDataBindingNode)
                        processMXMLDataBinding((IMXMLSingleDataBindingNode)instanceNode, context);
                    else if (instanceNode instanceof IMXMLConcatenatedDataBindingNode)
                        processMXMLConcatenatedDataBinding((IMXMLConcatenatedDataBindingNode)instanceNode, context);
                }
            }
            return;
        }
       
        boolean isDb = isDataboundProp(propertyNode);

        if (generateDescriptorCode(propertyNode, context))
        {
            if (!isDb)
            {
                context.startUsing(IL.DESCRIPTOR_PROPERTIES);
               
                context.addInstruction(OP_pushstring, propertyName);
               
                traverse(propertyNode, context);
               
                context.stopUsing(IL.DESCRIPTOR_PROPERTIES, 1);
            }
            else
            {
                IMXMLInstanceNode instanceNode = propertyNode.getInstanceNode();
                if (instanceNode instanceof IMXMLSingleDataBindingNode)
                    processMXMLDataBinding((IMXMLSingleDataBindingNode)instanceNode, context);
                else if (instanceNode instanceof IMXMLConcatenatedDataBindingNode)
                    processMXMLConcatenatedDataBinding((IMXMLConcatenatedDataBindingNode)instanceNode, context);
            }
        }
       
        if (generateNonDescriptorCode(propertyNode, context))
        {
            context.startUsing(IL.PROPERTIES);
           
            if (propertyNode.getParent().getNodeID() == ASTNodeID.MXMLObjectID)
            {
                // TODO This case presuambly also needs
                // some logic involving isDb.
               
                // Push the property name.
                context.addInstruction(OP_pushstring, propertyName);
               
                // Push the property value.
                // Do this by codegen'ing sole child, which is an IMXMLInstanceNode.
                traverse(propertyNode, context);
            }
            else
            {
                // Push the object on which the property is to be set.
                if (!isDb)
                    context.pushTarget();
               
                // Push the property value.
                // Do this by codegen'ing sole child, which is an IMXMLInstanceNode.
                traverse(propertyNode, context);
               
                // Set the property.
                // unless it's a databinding, then the property is set indiretly
               if (!isDb)
               {
                   IDefinition def = propertyNode.getDefinition();
                   Name n = ((DefinitionBase)def).getMName(getProject());
                   context.addInstruction(OP_setproperty, n);
               }
            }
           
            context.stopUsing(IL.PROPERTIES, 1);
View Full Code Here

        // Push the second argument: the value of the style.
        // Do this by codegen'ing sole child, which is an IMXMLInstanceNode.
        traverse(styleNode, context);
       
        // Set the style key/value on 'this', leaving nothing on the stack.
        context.addInstruction(OP_setproperty, new Name(styleName));
    }
View Full Code Here

    void processMXMLEventSpecifier(IMXMLEventSpecifierNode eventNode, Context context)
    { 
        // Event nodes (including state-dependent ones)
        // generate a new event handler method.
        // Create a MethodInfo and a method trait for the handler.
        Name name = getEventHandlerName(eventNode);
        MethodInfo methodInfo = createEventHandlerMethodInfo(
            getProject(), eventNode, name.getBaseName());
        addMethodTrait(name, methodInfo, false);
       
        // Use ABCGenerator to codegen the handler body from the
        // ActionScript nodes that are the children of the event node.
        classScope.getGenerator().generateMethodBodyForFunction(
            methodInfo, eventNode, classScope, null);

        // Otherwise, state-dependent nodes are handled by processMXMLState().
        if (isStateDependent(eventNode))
            return;
       
        String eventName = eventNode.getName();
        Name eventHandler = getEventHandlerName(eventNode);

        if (generateDescriptorCode(eventNode, context))
        {
            if (getProject().getTargetSettings().getMxmlChildrenAsData())
            {
                context.startUsing(IL.EVENTS);

                // Push the first argument: the name of the event (e.g., "click").
                context.addInstruction(OP_pushstring, eventName);
               
                // Push the second argument: the handler reference (e.g., >0).
                context.addInstruction(OP_getlocal0);
                context.addInstruction(OP_getproperty, eventHandler);               

                context.stopUsing(IL.EVENTS, 1);
            }
            else
            {
                context.startUsing(IL.DESCRIPTOR_EVENTS);
               
                context.addInstruction(OP_pushstring, eventName);
               
                context.addInstruction(OP_pushstring, eventHandler.getBaseName());
               
                context.stopUsing(IL.DESCRIPTOR_EVENTS, 1);
            }
        }
       
View Full Code Here

        else
        {
            methodName = "getObject";
        }
       
        Name resourceManagerName = project.getResourceManagerClassName();
       
        // Call the method to get the value, such as
        //   ResourceManager.getInstance().getString("bundle", "key")
        // for String type.
        context.addInstruction(ABCConstants.OP_getlex, resourceManagerName);
        context.addInstruction(ABCConstants.OP_callproperty, GET_INSTANCE_CALL_OPERANDS);
        context.addInstruction(ABCConstants.OP_pushstring, node.getBundleName());
        context.addInstruction(ABCConstants.OP_pushstring, node.getKey());
        context.addInstruction(ABCConstants.OP_callproperty, new Object[] { new Name(methodName), 2 });
    }
View Full Code Here

     * and <code>value</code> properties set.
     */
    void processPropertyOverride(IMXMLPropertySpecifierNode propertyNode, Context context)
    {
        FlexProject project = getProject();
        Name propertyOverride = project.getPropertyOverrideClassName();
        processPropertyOrStyleOverride(propertyOverride, propertyNode, context);
    }
View Full Code Here

     * and <code>value</code> properties set.
     */
    void processStyleOverride(IMXMLStyleSpecifierNode styleNode, Context context)
    {
        FlexProject project = getProject();
        Name styleOverride = project.getStyleOverrideClassName();
        processPropertyOrStyleOverride(styleOverride, styleNode, context);
    }
View Full Code Here

     * and <code>handlerFunction</code> properties set.
     */
    void processEventOverride(IMXMLEventSpecifierNode eventNode, Context context)
    {
        FlexProject project = getProject();
        Name eventOverride = project.getEventOverrideClassName();
       
        IASNode parentNode = eventNode.getParent();
        String id = parentNode instanceof IMXMLInstanceNode ?
                    ((IMXMLInstanceNode)parentNode).getEffectiveID() :
                    "";
       
        String name = eventNode.getName();
       
        Name eventHandler = getEventHandlerName(eventNode);

        // Construct the SetEventHandler object.
        context.addInstruction(OP_findpropstrict, eventOverride);
        context.addInstruction(OP_constructprop, new Object[] { eventOverride, 0 });
       
View Full Code Here

     */

    void processInstanceOverride(IMXMLInstanceNode instanceNode, Context context)
    {
        FlexProject project = getProject();
        Name instanceOverrideName = project.getInstanceOverrideClassName();
       
        assert nodeToIndexMap != null;
       
        if (getProject().getTargetSettings().getMxmlChildrenAsData())
        {
            context.addInstruction(OP_findpropstrict, instanceOverrideName);
            context.addInstruction(OP_getproperty, instanceOverrideName);
        }
        else
        {
            // create the AddItems object
            context.addInstruction(OP_findpropstrict, instanceOverrideName);
            context.addInstruction(OP_constructprop, new Object[] {instanceOverrideName, 0});
            // stack: AddItems
        }
       
        // Now set properties on it!
       
        //----------------------------------------------------------------------
        // First property: set itemsFactory to the deferredInstanceFunction we created earlier
        Integer index = nodeToIndexMap.get(instanceNode);
        assert index != null;
       
        InstructionList addItemsIL = new InstructionList();
        int addItemsCounter = 0;
        if (getProject().getTargetSettings().getMxmlChildrenAsData())
        {
           
            addItemsIL.addInstruction(OP_pushstring, "itemsDescriptor");
            addItemsIL.addInstruction(OP_pushtrue)// the value is an array of descriptor data that will be parsed later
            InstructionList il = nodeToInstanceDescriptorMap.get(instanceNode);
            InstructionList ilCopy = (InstructionList)il.clone();
            addItemsIL.addAll(ilCopy);
            addItemsCounter++;
        }
        else
        {
            context.addInstruction(OP_dup);         // stack: ..., addItems, addItems
            context.addInstruction(OP_getlocal3);   // stack: ..., addItems, addItems, instanceFuncs[]
            context.pushNumericConstant(index);     // stack: ..., addItems, addItems, instanceFuncs[], index
            context.addInstruction(OP_getproperty,  IMXMLTypeConstants.NAME_ARRAYINDEXPROP);
                                                    // stack: ..., addItems, addItems, instanceFunction
          
            context.addInstruction(OP_setproperty, new Name("itemsFactory"));
                                                    // stack: ..., addItems
        }
       
        //-----------------------------------------------------------------------------
        // Second property set: maybe set destination and propertyName
       
        // get the property specifier node for the property the instanceNode represents
        IMXMLPropertySpecifierNode propertySpecifier = (IMXMLPropertySpecifierNode)
            instanceNode.getAncestorOfType( IMXMLPropertySpecifierNode.class);
   
        if (propertySpecifier == null)
        {
           assert false;        // I think this indicates an invalid tree...
        }
        else
        {
            // Check the parent - if it's an instance then we want to use these
            // nodes to get our property values from. If not, then it's the root
            // and we don't need to specify destination
           
            IASNode parent = propertySpecifier.getParent();
            if (parent instanceof IMXMLInstanceNode)
            {
               IMXMLInstanceNode parentInstance = (IMXMLInstanceNode)parent;
               String parentId = parentInstance.getEffectiveID();
               assert parentId != null;
               String propName = propertySpecifier.getName();
              
              
               if (getProject().getTargetSettings().getMxmlChildrenAsData())
               {
                   addItemsIL.addInstruction(OP_pushstring, "destination");
                   addItemsIL.addInstruction(OP_pushtrue); // simple type
                   addItemsIL.addInstruction(OP_pushstring, parentId);
                   addItemsIL.addInstruction(OP_pushstring, "propertyName");
                   addItemsIL.addInstruction(OP_pushtrue); // simple type
                   addItemsIL.addInstruction(OP_pushstring, propName);
                   addItemsCounter += 2;
               }
               else
               {
                   context.addInstruction(OP_dup);         // stack: ..., addItems, addItems
                   context.addInstruction(OP_pushstring, parentId);
                   context.addInstruction(OP_setproperty, new Name("destination"));
                                                           // stack: ..., addItems
                   context.addInstruction(OP_dup);         // stack: ..., addItems, addItems
                   context.addInstruction(OP_pushstring, propName);
                   context.addInstruction(OP_setproperty, new Name("propertyName"));
                                                           // stack: ..., addItems
               }
            }
        } 
       
        //---------------------------------------------------------------
        // Third property set: position and relativeTo
        String positionPropertyValue = null;
        String relativeToPropertyValue = null;
      
        // look to see if we have any sibling nodes that are not state dependent
        // that come BEFORE us
        IASNode instanceParent = instanceNode.getParent();
        IASNode prevStatelessSibling=null;
        for (int i=0; i< instanceParent.getChildCount(); ++i)
        {
            IASNode sib = instanceParent.getChild(i);
            if (sib instanceof IMXMLInstanceNode)
            {
              
                // stop looking for previous nodes when we find ourself
                if (sib == instanceNode)
                    break;
   
                if (!isStateDependent(sib))
                {
                    prevStatelessSibling = sib;
                }
            }
        }
       
        if (prevStatelessSibling == null) {
            positionPropertyValue = "first";        // TODO: these should be named constants
        }
        else {
            positionPropertyValue = "after";
            relativeToPropertyValue = ((IMXMLInstanceNode)prevStatelessSibling).getEffectiveID();
        }
      
        if (getProject().getTargetSettings().getMxmlChildrenAsData())
        {
            // position
            addItemsIL.addInstruction(OP_pushstring, "position");
            addItemsIL.addInstruction(OP_pushtrue);
            addItemsIL.addInstruction(OP_pushstring, positionPropertyValue);
            addItemsCounter++;
        }
        else
        {
            // position
            context.addInstruction(OP_dup);       
            context.addInstruction(OP_pushstring, positionPropertyValue);
            context.addInstruction(OP_setproperty, new Name("position"));
           
        }
       
        // relativeTo
        if (relativeToPropertyValue != null)
        {
            if (getProject().getTargetSettings().getMxmlChildrenAsData())
            {
                // position
                addItemsIL.addInstruction(OP_pushstring, "relativeTo");
                addItemsIL.addInstruction(OP_pushtrue);
                addItemsIL.addInstruction(OP_pushstring, relativeToPropertyValue);
                addItemsCounter++;
            }
            else
            {
                context.addInstruction(OP_dup);       
                context.addInstruction(OP_pushstring, relativeToPropertyValue);
                context.addInstruction(OP_setproperty, new Name("relativeTo"));
            }
        }
        if (getProject().getTargetSettings().getMxmlChildrenAsData())
        {
            context.pushNumericConstant(addItemsCounter);
View Full Code Here

       
        // Leave a reference to the class on the stack.
        ClassDefinition classDefinition =
            (ClassDefinition)((IMXMLClassDefinitionNode)node).getClassDefinition();
        ICompilerProject project = getProject();
        Name className = classDefinition.getMName(project);
        context.addInstruction(OP_getlex, className);
    }
View Full Code Here

TOP

Related Classes of org.apache.flex.abc.semantics.Name

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.