Package flex2.compiler.mxml.reflect

Examples of flex2.compiler.mxml.reflect.Type


  /**
   * create Operation VO as child of <PRE><operations/></PRE> parent arg
   */
  public void addOperation(Model ops, MethodNode node)
    {
    Type type = typeTable.getType(node.getNamespace(), standardDefs.getConvertedTagName(node));

    //  push parent tag VO, child tag handler
    Model ro = component;
    ComponentChildNodeHandler roChildNodeHandler = childNodeHandler;

View Full Code Here


    }

        protected void vectorNode(Assignable property, VectorNode node)
        {
            String typeAttributeValue = (String) node.getAttribute(StandardDefs.PROP_TYPE).getValue();
            Type elementType = typeTable.getType(NameFormatter.toColon(typeAttributeValue));
            VectorBuilder builder = new VectorBuilder(unit, typeTable, mxmlConfiguration, document,
                                                      array, null, elementType, allowBinding);
            node.analyze(builder);
            builder.vector.setParentIndex(array.size());
            array.addEntry(builder.vector);
View Full Code Here

                        {
                            if (styleDef.isTypeSelector())
                            {
                                if (qualifiedTypeSelectors && mxmlConfiguration.showInvalidCssPropertyWarnings())
                                {
                                    Type type = typeTable.getType(NameFormatter.toColon(typeName));
   
                                    if (type != null)
                                    {
                                        validateTypeSelectorProperties(styleProperties, type, styleDef,
                                                                       typeName, themeNamesString);
                                    }
                                }
                            }
   
                            if (mxmlDocumentQName != null)
                            {
                                // Don't use getType(QName), because that
                                // tries to lookup the class name in the
                                // manifest.  Use getType(String) instead.
                                Type mxmlDocumentType = typeTable.getType(mxmlDocumentQName.toString());
                                assert mxmlDocumentType != null;
                                validatePropertyReferences(styleProperties, mxmlDocumentType);
                            }
                        }
                    }
View Full Code Here

            ((value.charAt(0) == '\'') || (value.charAt(0) == '\"')) &&
            ((value.charAt(value.length() - 1) == '\'') || (value.charAt(value.length() - 1) == '\"')))
        {
            String potentialProperty = value.substring(1, value.length() - 1);

            Type type = mxmlDocument.getRoot().getType();

            if (type != null && type.getProperty(potentialProperty) != null)
            {
                result = potentialProperty;
            }

            // deprecated - Flex 1.5 support only
View Full Code Here

  /**
   * note the exception for simple classdef-based deferrals
   */
  protected boolean isInstanceGeneratorOverDefinition()
  {
    Type ltype = getLValueType();
    return standardDefs.isIFactory(ltype) || (standardDefs.isIDeferredInstance(ltype) && !rvalueIsClassRef());
  }
View Full Code Here

  /**
   *
   */
  public String getValueExpr()
  {
    Type lvalueType = getLValueType();

    if (standardDefs.isIDeferredInstance(lvalueType))
    {
      if (rvalueIsClassRef())
      {
View Full Code Here

   */
  public Node generateValueExpr(NodeFactory nodeFactory, HashSet<String> configNamespaces,
                                  boolean generateDocComments)
  {
    Node result;
    Type lvalueType = getLValueType();

    if (standardDefs.isIDeferredInstance(lvalueType))
    {
      IdentifierNode typeIdentifier;
      ArgumentListNode args;
View Full Code Here

        assert value instanceof Model : "non-Model value has definition in getDefinitionBody()";

        final String varName = "temp";

        Model self = (Model)value;
        Type selfType = self.getType();
        String selfTypeName;

        if (value instanceof Vector)
        {
            Vector vector = (Vector) value;
            String elementTypeName = vector.getElementTypeName();
            selfTypeName = StandardDefs.CLASS_VECTOR + ".<" + elementTypeName + ">";
        }
        else
        {
            selfTypeName = NameFormatter.toDot(selfType.getName());
        }

        boolean isDeclared = self.isDeclared();
        String id = isDeclared ? self.getId() : varName;

        int line = getLineRef();

        CodeFragmentList list = new CodeFragmentList();

        //  function header
        list.add("private function ", getDefinitionName(), "() : ", selfTypeName, line);
        list.add("{", line);

        //  value creation
        StringBuilder stringBuilder = new StringBuilder("\tvar " + varName + " : " + selfTypeName + " = ");

        if (modelHasInlineRValue())
        {
            stringBuilder.append(getInlineRValue());
        }
        else if (value instanceof Vector)
        {
            Vector vector = (Vector) value;

            stringBuilder.append("new " + selfTypeName + "(" + vector.size());
           
            if (vector.isFixed())
            {
                stringBuilder.append(", true)");
            }
            else
            {
                stringBuilder.append(")");
            }
        }
        else
        {
            // TODO confirm the availability of a 0-arg ctor!! but do it upstream from here, like when Model is built
            stringBuilder.append("new " + selfTypeName + "()");
        }

        stringBuilder.append(";");
        list.add(stringBuilder.toString(), line);

        if (!modelHasInlineRValue())
        {
            if (value instanceof Vector)
            {
                Vector vector = (Vector) value;
                addAssignExprs(list, vector.getElementInitializerIterator(), varName);
            }
            else
            {
                // set properties
                addAssignExprs(list, self.getPropertyInitializerIterator(self.getType().hasDynamic()), varName);
            }
        }
       
        //  set styles
        addAssignExprs(list, self.getStyleInitializerIterator(), varName);

        //  set effects
        addAssignExprs(list, self.getEffectInitializerIterator(), varName);

        //  add event handlers
        addAssignExprs(list, self.getEventInitializerIterator(), varName);

        //  register effect names
        String effectEventNames = self.getEffectNames();
        if (effectEventNames.length() > 0)
        {
            list.add("\t", varName, ".registerEffects([ ", effectEventNames, " ]);", line);
        }

        //  post-init actions for values that are being assigned to properties (via id attribution)
        if (isDeclared && standardDefs.isIUIComponentWithIdProperty(selfType))
        {
            //  set id on IUIComponents that carry an id prop
            list.add("\t", varName, ".id = \"", id, "\";", line);
        }

        // Design layer related items
        if (self.layerParent != null)
        {
            if (self instanceof DesignLayer)
            {
                list.add("\t", self.layerParent.getId(), ".addLayer(", varName, ");", line);
            }
            else if (self.getType().isAssignableTo(standardDefs.INTERFACE_IVISUALELEMENT))
            {
                list.add("\t", varName, ".designLayer = ", self.layerParent.getId(), ";", line);
            }   
        }
       
        //  UIComponent-specific init steps
        if (standardDefs.isIUIComponent(selfType))
        {
            assert self instanceof MovieClip : "isIUIComponent(selfType) but !(self instanceof MovieClip)";
            MovieClip movieClip = (MovieClip) self;

            //  MXML implementations of IUIComponent initialize set their document property to themselves at
            //  construction time. Others need it set to the enclosing document (us).

            list.add("\tif (!", varName, ".document) ", varName, ".document = this;", line);

            //  add visual children
            if (!standardDefs.isRepeater(selfType))
            {
                if (standardDefs.isContainer(selfType))
                {
                    if (movieClip.hasChildren())
                    {
                        list.add("\t", varName, ".mx_internal::_documentDescriptor = ", line);
                        DescriptorGenerator.addDescriptorInitializerFragments(list, movieClip,
                                                                              Collections.<String>emptySet(),
                                                                              false, "\t\t");
                        list.add("\t;", line);
                        list.add("\t", varName, ".mx_internal::_documentDescriptor.document = this;", line);
                    }
                }
                else
                {
                    //  non-repeater - replicate DI child-creation sequence procedurally:
                    Iterator childIter = movieClip.getChildInitializerIterator();

                    while (childIter.hasNext())
                    {
                        VisualChildInitializer init = (VisualChildInitializer)childIter.next();

                        // Filter out state specific children.
                        if ( !((Model)init.getValue()).isStateSpecific())
                        {
                            list.add("\t", init.getAssignExpr(varName), ";", init.getLineRef());
                        }
                    }
                }
            }
            else
            {
                //  repeater-specific init sequence: don't add children directly, instead use existing DI setup
                //  initializing repeater's childDescriptors property, for now

                list.add("\tvar cd:Array = ", varName, ".childDescriptors = [", line);

                for (Iterator childIter = movieClip.children().iterator(); childIter.hasNext(); )
                {
                    VisualChildInitializer init = (VisualChildInitializer)childIter.next();
                    DescriptorGenerator.addDescriptorInitializerFragments(list, (MovieClip)init.getValue(), "\t\t");

                    if (childIter.hasNext())
                    {
                        list.add(",", 0);
                    }
                }

                list.add("\t];", line);
                list.add("\tfor (var i:int = 0; i < cd.length; i++) cd[i].document = this;", line);
            }
        }

        // TODO: Remove [IMXMLObject] metadata support once we have a
        // non-framework dependent swc to link in mx.core.IMXMLObject

        //  call IMXMLObject.initialized() on implementors
        if (self.getType().isAssignableTo(standardDefs.INTERFACE_IMXMLOBJECT)
                || self.getType().hasMetadata(StandardDefs.MD_IMXMLOBJECT, true))
        {
            String idParam = (isDeclared ? TextGen.quoteWord(id) : "null");
            list.add("\t", varName, ".initialized(this, ", idParam, ")", line);
        }

        // generate idAssigned dispatching logic for user declared instances.
        if (isDeclared)
        {
            if (self.getRepeaterLevel() == 0)
            {
                list.add("\t", id, " = ", varName, ";", line);
            }
            else
            {
                ThreadLocalToolkit.log(new DeclaredAndProceduralWithinRepeater(), self.getDocument().getSourcePath(), line);
            }

            //  evaluate all property bindings for this object - i.e. initialize properties of the object whose values
            //  are binding expressions. E.g. if we've just created <mx:Foo id="bar" x="100" y="{baz.z}"/>, then
            //  we need to evaluate (baz.z) and assign it to bar.y. This explicit evaluation pass is necessary because
            //  baz may already have been initialized, although the fact that we do it even when that's not the case is
            //  suboptimal.
            list.add("\t", NameFormatter.toDot(standardDefs.CLASS_BINDINGMANAGER),
                     ".executeBindings(this, ", TextGen.quoteWord(id), ", " + id + ");", line);
        }

        // If this is a stateful Halo Container, with itemCreationPolicy "immediate" we need to ensure
        // that the instance and all descendants are instantiated.
        if (standardDefs.isContainer(selfType) && self.isEarlyInit())
        {
            list.add("\t", varName,".initialize();", line);
        }
       
        //  return created value
        list.add("\treturn ", varName, ";", line);
        list.add("}", line);
       
        Type lvalueType = getLValueType();
        if (standardDefs.isITransientDeferredInstance(lvalueType) || self.getIsTransient())
          list = getDestructorBody(list, line);

        return list;
    }
View Full Code Here

        StatementListNode result = statementList;

        final String varName = TEMP;
       
        Model self = (Model) value;
        Type selfType = self.getType();
        String selfTypeName;

        if (value instanceof Vector)
        {
            Vector vector = (Vector) value;
            String elementTypeName = vector.getElementTypeName();
            selfTypeName = StandardDefs.CLASS_VECTOR + ".<" + elementTypeName + ">";
        }
        else
        {
            selfTypeName = NameFormatter.toDot(selfType.getName());
        }

        boolean isDeclared = self.isDeclared();
        String id = isDeclared ? self.getId() : varName;

        TypeExpressionNode returnType =
            AbstractSyntaxTreeUtil.generateTypeExpression(nodeFactory, selfTypeName, true);
        FunctionSignatureNode functionSignature = nodeFactory.functionSignature(null, returnType);       
        int position = AbstractSyntaxTreeUtil.lineNumberToPosition(nodeFactory, getLineRef());
        VariableDefinitionNode variableDefinition;

        //  value creation
        if (modelHasInlineRValue())
        {
            Node inlineRValue = generateInlineRValue(nodeFactory, configNamespaces, generateDocComments);
            variableDefinition = AbstractSyntaxTreeUtil.generateVariable(nodeFactory, varName,
                                                                         selfTypeName, true,
                                                                         inlineRValue, position);
        }
        else if (value instanceof Vector)
        {
            Vector vector = (Vector) value;
            LiteralNumberNode literalNumber = nodeFactory.literalNumber(vector.size());
            ArgumentListNode argumentList = nodeFactory.argumentList(null, literalNumber);

            if (vector.isFixed())
            {
                LiteralBooleanNode literalBoolean = nodeFactory.literalBoolean(vector.isFixed());
                argumentList = nodeFactory.argumentList(argumentList, literalBoolean);
            }
           
            variableDefinition = AbstractSyntaxTreeUtil.generateVariableNew(nodeFactory, varName,
                                                                            selfTypeName, argumentList,
                                                                            position);
        }
        else
        {
            //  TODO confirm the availability of a 0-arg ctor!! but do
            //  it upstream from here, like when Model is built
            variableDefinition = AbstractSyntaxTreeUtil.generateVariableNew(nodeFactory, varName,
                                                                            selfTypeName, position);
        }

        StatementListNode functionStatementList = nodeFactory.statementList(null, variableDefinition);

        if (!modelHasInlineRValue())
        {
            if (value instanceof Vector)
            {
                Vector vector = (Vector) value;
                addAssignExprs(nodeFactory, configNamespaces, generateDocComments, functionStatementList,
                               vector.getElementInitializerIterator(), varName);
            }
            else
            {
                // set properties
                addAssignExprs(nodeFactory, configNamespaces, generateDocComments, functionStatementList,
                               self.getPropertyInitializerIterator(self.getType().hasDynamic()),
                               varName);
            }
        }
       
        //  set styles
        addAssignExprs(nodeFactory, configNamespaces, generateDocComments, functionStatementList,
                       self.getStyleInitializerIterator(), varName);

        //  set effects
        addAssignExprs(nodeFactory, configNamespaces, generateDocComments, functionStatementList,
                       self.getEffectInitializerIterator(), varName);

        //  add event handlers
        addAssignExprs(nodeFactory, configNamespaces, generateDocComments, functionStatementList,
                       self.getEventInitializerIterator(), varName);

        //  register effect names
        Iterator<Initializer> iterator = self.getEffectInitializerIterator();

        if (iterator.hasNext())
        {
            //list.add("\t", varName, ".registerEffects([ ", effectEventNames, " ]);", line);
            MemberExpressionNode base = AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, varName, false);

            IdentifierNode identifier = nodeFactory.identifier(REGISTER_EFFECTS, false);
            ArgumentListNode effectEventNamesArgumentList = null;

            while (iterator.hasNext())
            {
                EffectInitializer effectInitializer = (EffectInitializer) iterator.next();
                String effectName = effectInitializer.getName();
                LiteralStringNode literalString = nodeFactory.literalString(effectName);
                effectEventNamesArgumentList = nodeFactory.argumentList(effectEventNamesArgumentList,
                                                                        literalString);
            }

            LiteralArrayNode literalArray = nodeFactory.literalArray(effectEventNamesArgumentList);
            ArgumentListNode argumentList = nodeFactory.argumentList(null, literalArray);
            CallExpressionNode selector = (CallExpressionNode) nodeFactory.callExpression(identifier,
                                                                                          argumentList);
            selector.setRValue(false);
            MemberExpressionNode memberExpression = nodeFactory.memberExpression(base, selector);
            ListNode list = nodeFactory.list(null, memberExpression);
            ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
            functionStatementList = nodeFactory.statementList(functionStatementList, expressionStatement);
        }

        //  post-init actions for values that are being assigned to properties (via id attribution)
        if (isDeclared && standardDefs.isIUIComponentWithIdProperty(selfType))
        {
            //  set id on IUIComponents that carry an id prop
            MemberExpressionNode base = AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, varName, false);
            IdentifierNode identifier = nodeFactory.identifier(ID, false);
            LiteralStringNode literalString = nodeFactory.literalString(id);
            ArgumentListNode argumentList = nodeFactory.argumentList(null, literalString);
            SetExpressionNode selector = nodeFactory.setExpression(identifier, argumentList, false);
            MemberExpressionNode memberExpression = nodeFactory.memberExpression(base, selector);
            ListNode list = nodeFactory.list(null, memberExpression);
            ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
            functionStatementList = nodeFactory.statementList(functionStatementList, expressionStatement);
        }

        // Design layer related items
        if (self.layerParent != null)
        {
            if (self instanceof DesignLayer)
            {
                //list.add("\t", self.layerParent.getId(), ".addLayer(", varName, ");", line);
             
                IdentifierNode method = nodeFactory.identifier(ADD_LAYER, false);
               
                IdentifierNode layerIdentifier = nodeFactory.identifier(self.layerParent.getId());
              GetExpressionNode getExpression = nodeFactory.getExpression(layerIdentifier);
              MemberExpressionNode layerMemberExpression = nodeFactory.memberExpression(null, getExpression);
             
              IdentifierNode varIdentifier = nodeFactory.identifier(varName);
              GetExpressionNode varGetExpression = nodeFactory.getExpression(varIdentifier);
              MemberExpressionNode varMemberExpression = nodeFactory.memberExpression(null, varGetExpression);
             
                ArgumentListNode argumentList = nodeFactory.argumentList(null, varMemberExpression);
               
                CallExpressionNode selector = (CallExpressionNode) nodeFactory.callExpression(method, argumentList);
                selector.setRValue(false);
               
                MemberExpressionNode memberExpression = nodeFactory.memberExpression(layerMemberExpression, selector);
                ListNode list = nodeFactory.list(null, memberExpression);
                ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
                functionStatementList = nodeFactory.statementList(functionStatementList, expressionStatement);
               
            }
            else if (self.getType().isAssignableTo(standardDefs.INTERFACE_IVISUALELEMENT))
            {  
              // list.add("\t", varName, ".layer = ", self.layerParent.getId(), ";", line);
              IdentifierNode varIdentifier = nodeFactory.identifier(varName);
              GetExpressionNode varGetExpression = nodeFactory.getExpression(varIdentifier);
              MemberExpressionNode base = nodeFactory.memberExpression(null, varGetExpression);
             

              IdentifierNode identifier = nodeFactory.identifier(DESIGN_LAYER, false);
             
              IdentifierNode layerIdentifier = nodeFactory.identifier(self.layerParent.getId());
              GetExpressionNode getExpression = nodeFactory.getExpression(layerIdentifier);
             
              MemberExpressionNode rvalueMemberExpression = nodeFactory.memberExpression(null, getExpression);
                ArgumentListNode argumentList = nodeFactory.argumentList(null, rvalueMemberExpression);
               
              SetExpressionNode selector = nodeFactory.setExpression(identifier, argumentList, false);
             
                MemberExpressionNode memberExpression = nodeFactory.memberExpression(base, selector);
                ListNode list = nodeFactory.list(null, memberExpression);
                ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
                functionStatementList = nodeFactory.statementList(functionStatementList, expressionStatement);
            }   
        }
       
        //  UIComponent-specific init steps
        if (standardDefs.isIUIComponent(selfType))
        {
            assert self instanceof MovieClip : "isIUIComponent(selfType) but !(self instanceof MovieClip)";
            MovieClip movieClip = (MovieClip) self;

            //  MXML implementations of IUIComponent initialize set their document property to themselves at
            //  construction time. Others need it set to the enclosing document (us).

            ListNode test;
            {
                MemberExpressionNode base =
                    AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, varName, false);
                IdentifierNode identifier = nodeFactory.identifier(DOCUMENT, false);
                GetExpressionNode selector = nodeFactory.getExpression(identifier);
                MemberExpressionNode memberExpression = nodeFactory.memberExpression(base, selector);
                Node unaryExpression = nodeFactory.unaryExpression(Tokens.NOT_TOKEN, memberExpression);
                test = nodeFactory.list(null, unaryExpression);
            }

            StatementListNode then;
            {
                MemberExpressionNode base =
                    AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, varName, false);
                IdentifierNode identifier = nodeFactory.identifier(DOCUMENT, false);
                ThisExpressionNode thisExpression = nodeFactory.thisExpression(-1);
                ArgumentListNode argumentList = nodeFactory.argumentList(null, thisExpression);
                SetExpressionNode selector = nodeFactory.setExpression(identifier, argumentList, false);
                MemberExpressionNode memberExpression = nodeFactory.memberExpression(base, selector);
                ListNode list = nodeFactory.list(null, memberExpression);
                ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
                then = nodeFactory.statementList(null, expressionStatement);
            }

            Node ifStatement = nodeFactory.ifStatement(test, then, null);
            functionStatementList = nodeFactory.statementList(functionStatementList, ifStatement);

            //  add visual children
            if (!standardDefs.isRepeater(selfType))
            {
                if (standardDefs.isContainer(selfType))
                {
                    if (movieClip.hasChildren())
                    {
                        functionStatementList = generateDocumentDescriptorAssignment(nodeFactory, configNamespaces, generateDocComments,
                                                                                     movieClip, varName, functionStatementList);
                        functionStatementList = generateDocumentDescriptorDocumentAssignment(nodeFactory, varName,
                                                                                             functionStatementList);
                    }
                }
                else
                {
                    //  non-repeater - replicate DI child-creation sequence procedurally:      
                    Iterator childIter = movieClip.getChildInitializerIterator();
                    while (childIter.hasNext())
                    {
                        VisualChildInitializer init = (VisualChildInitializer)childIter.next();
                   
                        // Filter out state specific children.
                        if ( !((Model)init.getValue()).isStateSpecific())
                        {
                            MemberExpressionNode memberExpression =
                                AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, varName, true);
                            functionStatementList =
                                init.generateAssignExpr(nodeFactory, configNamespaces, generateDocComments,
                                                        functionStatementList, memberExpression);
                        }
                    }
                }
            }
            else
            {
                //  repeater-specific init sequence: don't add children directly, instead use existing DI setup
                //  initializing repeater's childDescriptors property, for now
                VariableDefinitionNode childDescriptorVariableDefinition =
                    generateChildDescriptorVariable(nodeFactory, configNamespaces, generateDocComments,
                                                    varName, movieClip);
                functionStatementList = nodeFactory.statementList(functionStatementList,
                                                                  childDescriptorVariableDefinition);
                Node forStatement = generateRepeaterChildDescriptorLoop(nodeFactory);
                functionStatementList = nodeFactory.statementList(functionStatementList, forStatement);
            }
        }

        //  call IMXMLObject.initialized() on implementors
        if (self.getType().isAssignableTo(standardDefs.INTERFACE_IMXMLOBJECT)
                || self.getType().hasMetadata(StandardDefs.MD_IMXMLOBJECT, true))
        {
            MemberExpressionNode varNameMemberExpression =
                AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, varName, false);
            IdentifierNode identifier = nodeFactory.identifier(INITIALIZED, false);
            ThisExpressionNode thisExpression = nodeFactory.thisExpression(-1);
            ArgumentListNode argumentList = nodeFactory.argumentList(null, thisExpression);

            if (isDeclared)
            {
                LiteralStringNode literalString = nodeFactory.literalString(id);
                argumentList = nodeFactory.argumentList(argumentList, literalString);
            }
            else
            {
                LiteralNullNode literalNull = nodeFactory.literalNull(-1);
                argumentList = nodeFactory.argumentList(argumentList, literalNull);
            }

            CallExpressionNode callExpression =
                (CallExpressionNode) nodeFactory.callExpression(identifier, argumentList);
            callExpression.setRValue(false);
            MemberExpressionNode memberExpression = nodeFactory.memberExpression(varNameMemberExpression,
                                                                                 callExpression);
            ListNode list = nodeFactory.list(null, memberExpression);
            ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
            functionStatementList = nodeFactory.statementList(functionStatementList, expressionStatement);
        }

        // generate idAssigned dispatching logic for user declared instances.
        if (isDeclared)
        {
            if (self.getRepeaterLevel() == 0)
            {
                functionStatementList = generateValueCreation(nodeFactory, functionStatementList, id, varName);
            }
            else
            {
                ThreadLocalToolkit.log(new DeclaredAndProceduralWithinRepeater(),
                                       self.getDocument().getSourcePath(), getLineRef());
            }
       
            //  evaluate all property bindings for this object - i.e. initialize properties of the object whose values
            //  are binding expressions. E.g. if we've just created <mx:Foo id="bar" x="100" y="{baz.z}"/>, then
            //  we need to evaluate (baz.z) and assign it to bar.y. This explicit evaluation pass is necessary because
            //  baz may already have been initialized, although the fact that we do it even when that's not the case is
            //  suboptimal.
            MemberExpressionNode base =
                AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, standardDefs.getBindingPackage(), BINDING_MANAGER, false);
            IdentifierNode identifier = nodeFactory.identifier(EXECUTE_BINDINGS, false);
            ThisExpressionNode thisExpression = nodeFactory.thisExpression(-1);
            ArgumentListNode argumentList = nodeFactory.argumentList(null, thisExpression);
            LiteralStringNode literalString = nodeFactory.literalString(id);
            argumentList = nodeFactory.argumentList(argumentList, literalString);
            MemberExpressionNode idMemberExpression =
                AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, id, true);
            argumentList = nodeFactory.argumentList(argumentList, idMemberExpression);
            CallExpressionNode selector = (CallExpressionNode) nodeFactory.callExpression(identifier, argumentList);
            selector.setRValue(false);
            MemberExpressionNode memberExpression = nodeFactory.memberExpression(base, selector);
            ListNode list = nodeFactory.list(null, memberExpression);
            ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
            functionStatementList = nodeFactory.statementList(functionStatementList, expressionStatement);
        }

        // If this is a stateful Halo Container, with itemCreationPolicy "immediate" we need to ensure
        // that the instance and all descendants are instantiated.
        if (standardDefs.isContainer(selfType) && self.isEarlyInit())
        {
            MemberExpressionNode varNameMemberExpression =
                AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, varName, false);
            IdentifierNode identifier = nodeFactory.identifier(INITIALIZE, false);
           
            CallExpressionNode callExpression =
                (CallExpressionNode) nodeFactory.callExpression(identifier, null);
            callExpression.setRValue(false);
            MemberExpressionNode memberExpression = nodeFactory.memberExpression(varNameMemberExpression,
                                                                                 callExpression);
            ListNode list = nodeFactory.list(null, memberExpression);
            ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
            functionStatementList = nodeFactory.statementList(functionStatementList, expressionStatement);
        }
       
        //  return created value
        MemberExpressionNode memberExpression =
            AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, varName, false);
        ListNode list = nodeFactory.list(null, memberExpression);
        ReturnStatementNode returnStatement = nodeFactory.returnStatement(list);
        functionStatementList = nodeFactory.statementList(functionStatementList, returnStatement);

        IdentifierNode functionIdentifier = nodeFactory.identifier(getDefinitionName());
        FunctionCommonNode functionCommon = nodeFactory.functionCommon(context,
                                                                       functionIdentifier,
                                                                       functionSignature,
                                                                       functionStatementList);
        functionCommon.setUserDefinedBody(true);
        AttributeListNode attributeList = AbstractSyntaxTreeUtil.generatePrivateAttribute(nodeFactory);
        FunctionNameNode functionName = nodeFactory.functionName(Tokens.EMPTY_TOKEN, functionIdentifier);

        FunctionDefinitionNode functionDefinition = nodeFactory.functionDefinition(context, attributeList,
                                                                                   functionName, functionCommon);

        result = nodeFactory.statementList(result, functionDefinition);

        Type lvalueType = getLValueType();
        if (standardDefs.isITransientDeferredInstance(lvalueType) || self.getIsTransient())
          result = generateDestructorBody(context, result);
       
        return result;
    }
View Full Code Here

      boolean result = false;
     
      if ((destination != null) && (destinationProperty != null && destinationStyle == null) &&
            !isArrayAccess() && !((isDestinationXMLAttribute || isDestinationXMLNode)))
      {
        Type type = destination.getType();
        Property property = type.getProperty(destinationProperty);
       
        if (property != null && !property.hasPublic())
          result = true;
      }
     
View Full Code Here

TOP

Related Classes of flex2.compiler.mxml.reflect.Type

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.