Examples of ITraitVisitor


Examples of org.apache.flex.abc.visitors.ITraitVisitor

     * @param returnType {@link Name} of the return type of the method.
     * @param body An {@link InstructionList} for the body of the method.
     */
    public void addCTraitsGetter(Name getterName, Name returnType, InstructionList body)
    {
        ITraitVisitor traitVisitor = addMethodToTraits(ctraits, getterName, Collections.<Name>emptyList(), returnType, Collections.<Object>emptyList(), false, ABCConstants.TRAIT_Getter, body);
        traitVisitor.visitStart();
        traitVisitor.visitEnd();
    }
View Full Code Here

Examples of org.apache.flex.abc.visitors.ITraitVisitor

     *
     * @param variableName {@link Name} of the member variable to add.
     */
    public void addMemberVariable(Name variableName, Name type)
    {
        ITraitVisitor traitVisitor = itraits.visitSlotTrait(ABCConstants.TRAIT_Var, variableName, ITraitsVisitor.RUNTIME_SLOT, type, LexicalScope.noInitializer);
        traitVisitor.visitStart();
        traitVisitor.visitEnd();
    }
View Full Code Here

Examples of org.apache.flex.abc.visitors.ITraitVisitor

                trait_kind = ABCConstants.TRAIT_Const;
            else
                trait_kind = ABCConstants.TRAIT_Var;

            assert(this.traitsVisitor != null): "No traits";
            ITraitVisitor tv = this.traitsVisitor.visitSlotTrait(
                    trait_kind,
                    ensureQName(var_name),
                    getSlotId(var),
                    var_type,
                    initializer
            );
            tv.visitStart();
            processMetadata(tv, meta_tags);
            this.deferredVisitEnds.add(tv);
        }
    }
View Full Code Here

Examples of org.apache.flex.abc.visitors.ITraitVisitor

        generateBindableSetter(bindableVarDef, var_name, backingPropertyName, var_type, metaTags);
    }
   
    public void generateBindableGetter(IDefinition bindableVarDef, Name var_name, Name backingPropertyName, Name var_type, IMetaInfo[] metaTags)
    {
        ITraitVisitor getterTv = BindableHelper.generateBindableGetter(this, var_name, backingPropertyName, var_type);

        IMetaTag gotoDefinitionMetaTag = MetaTag.createGotoDefinitionHelp(bindableVarDef,
                bindableVarDef.getContainingFilePath(),
                Integer.toString(bindableVarDef.getNameStart()), false);
        metaTags = MetaTag.addMetaTag(metaTags, gotoDefinitionMetaTag);
       
        // If we have an IMetaTagsNode use that, otherwise get the metadata from the definition
            processMetadata(getterTv, metaTags);

            if (bindableVarDef.isOverride())
                getterTv.visitAttribute(Trait.TRAIT_OVERRIDE, Boolean.TRUE);

        // We don't codegen classes in parallel right now,
        // so we know that we are on the main code generation thread
        // because bindable variables are always members of a class.
        // Since we know are on the main code generation thread we can immediately
        // call visitEnd here and the vistEnd calls in generateBindableSetter
        // are ok too.
        getterTv.visitEnd();
    }
View Full Code Here

Examples of org.apache.flex.abc.visitors.ITraitVisitor

    }
   
    public void generateBindableSetter(IDefinition bindableVarDef, Name var_name, Name backingPropertyName, Name var_type, IMetaInfo[] metaTags)
    {

        ITraitVisitor setterTv = BindableHelper.generateBindableSetter(this, var_name, backingPropertyName, var_type, bindableVarDef);
       
        IMetaTag gotoDefinitionMetaTag = MetaTag.createGotoDefinitionHelp(bindableVarDef,
                bindableVarDef.getContainingFilePath(),
                Integer.toString(bindableVarDef.getNameStart()), false);
        metaTags = MetaTag.addMetaTag(metaTags, gotoDefinitionMetaTag);
       
        processMetadata(setterTv, metaTags);
       
        if (bindableVarDef.isOverride())
            setterTv.visitAttribute(Trait.TRAIT_OVERRIDE, Boolean.TRUE);

        setterTv.visitEnd();
    }
View Full Code Here

Examples of org.apache.flex.abc.visitors.ITraitVisitor

        IMetaTag[] skinParts = classDefinition.findSkinParts(classScope.getProject(), null);
        if (skinParts.length > 0)
        {
            Name var_name = new Name(CONSTANT_Qname, new Nsset(skinPartPrivateNamespace), "skinParts");
            classStaticScope.declareVariableName(var_name);
            ITraitVisitor tv = classStaticScope.traitsVisitor.visitSlotTrait(TRAIT_Var, var_name,
                    ITraitsVisitor.RUNTIME_SLOT, NAME_OBJECT, LexicalScope.noInitializer);
            tv.visitEnd();

            cinitInsns.addInstruction(OP_findproperty, var_name);
           
            for (IMetaTag skinPart : skinParts)
            {
                cinitInsns.addInstruction(OP_pushstring, skinPart.getDecoratedDefinition().getBaseName());
                cinitInsns.addInstruction(OP_convert_s);
                IMetaTagAttribute attr = skinPart.getAttribute("required");
                if (attr == null || attr.getValue().equals("true"))
                    cinitInsns.addInstruction(OP_pushtrue);
                else
                    cinitInsns.addInstruction(OP_pushfalse);
            }
            cinitInsns.addInstruction(OP_newobject, skinParts.length);
            cinitInsns.addInstruction(OP_setproperty, var_name);
           
            // Equivalent AS:
            //
            //      protected function get skinParts():Object
            //      {
            //          return ClassName._skinParts;
            //      }
            //
            MethodInfo mi = new MethodInfo();
            mi.setMethodName("skinParts");

            mi.setReturnType(NAME_OBJECT);

            InstructionList insns = new InstructionList(3);
            insns.addInstruction(OP_getlocal0);
            insns.addInstruction(OP_findpropstrict, var_name);
            insns.addInstruction(OP_getproperty, var_name);
            insns.addInstruction(OP_returnvalue);

            FunctionGeneratorHelper.generateFunction(classScope.getEmitter(), mi, insns);

            NamespaceDefinition nd = (NamespaceDefinition)classDefinition.getProtectedNamespaceReference();
            Name func_name = new Name(nd.getAETNamespace(), "skinParts");
            tv = classScope.traitsVisitor.visitMethodTrait(TRAIT_Getter, func_name, 0, mi);
            tv.visitAttribute(Trait.TRAIT_OVERRIDE, Boolean.TRUE);
            tv.visitEnd();

        }
       
        // the generation of instructions for variable initialization is delayed
        // until now, so we can add that initialization to the front of
        // the cinit instruction list.
        if (!staticVariableInitializers.isEmpty())
        {
            InstructionList exisitingCinitInsns = null;
            if (!this.cinitInsns.isEmpty())
            {
                exisitingCinitInsns = new InstructionList();
                exisitingCinitInsns.addAll(this.cinitInsns);
                this.cinitInsns = new InstructionList();
            }

            for (VariableNode var : staticVariableInitializers)
                generateInstructions(var, true);

            if (exisitingCinitInsns != null)
                this.cinitInsns.addAll(exisitingCinitInsns);
        }

        // add "goto_definition_help" metadata to user defined metadata.
        ITraitVisitor tv = classScope.getGlobalScope().traitsVisitor.visitClassTrait(
                TRAIT_Class, className, 0, cinfo);
        IMetaInfo[] metaTags = getAllMetaTags(classDefinition);

        // Add "goto definition help" metadata for the constructor.
        if (this.ctorFunction != null)
        {
            FunctionDefinition ctorDef = this.ctorFunction.getDefinition();
            MetaTag metaTag = MetaTag.createGotoDefinitionHelp(classDefinition,
                    classDefinition.getContainingFilePath(),
                    Integer.toString(ctorDef.getNameStart()), true);
            if (metaTag != null)
                metaTags = MetaTag.addMetaTag(metaTags, metaTag);
        }       

        this.classScope.processMetadata(tv, metaTags);
        tv.visitEnd();
       
        // Need to do this before generating the CTOR as the generated code may result in insns that
        // need to be added to the ctor.
        generateBindableImpl();
View Full Code Here

Examples of org.apache.flex.abc.visitors.ITraitVisitor

            MethodInfo mi = classScope.getGenerator().generateFunction(func, ls, null, bindableName);
           
            if ( mi != null )
            {
                ITraitVisitor tv = ls.traitsVisitor.visitMethodTrait(functionTraitKind(func, TRAIT_Method),
                        bindableName != null ? bindableName : funcName, 0, mi);
               
                if (funcName != null && bindableName == null)
                    classScope.getMethodBodySemanticChecker().checkFunctionForConflictingDefinitions(func, funcDef);

                if ( ! funcDef.isStatic() && bindableName == null)
                    if (funcDef.getNamespaceReference() instanceof NamespaceDefinition.IProtectedNamespaceDefinition)
                        this.iinfo.flags |= ABCConstants.CLASS_FLAG_protected;

                ls.processMetadata(tv, getAllMetaTags(funcDef));
               
                if ( func.hasModifier(ASModifier.FINAL))
                    tv.visitAttribute(Trait.TRAIT_FINAL, Boolean.TRUE);
                // don't set override if we've moved it to the bindable namespace
                if (!wasOverride && (func.hasModifier(ASModifier.OVERRIDE) || funcDef.isOverride()))
                    tv.visitAttribute(Trait.TRAIT_OVERRIDE, Boolean.TRUE);
                tv.visitEnd();
            }
        }
        if (isBindable)
        {
            if (wasOverride)
View Full Code Here

Examples of org.apache.flex.abc.visitors.ITraitVisitor

        else
        {
            transformed_initializer = initializer;
        }
       
        ITraitVisitor tv = declareVariable(var, varDef, is_static, is_const, transformed_initializer);
        if ( is_static )
            this.classStaticScope.processMetadata(tv, getAllMetaTags(varDef));
        else
            this.classScope.processMetadata(tv, getAllMetaTags(varDef));
        tv.visitEnd();
       
        //  Generate variable initializers and append them to the
        //  proper initialization list.
        if ( transformed_initializer == null && var.getAssignedValueNode() != null )
        {
View Full Code Here

Examples of org.apache.flex.abc.visitors.ITraitVisitor

        LexicalScope ls = is_static? this.classStaticScope: this.classScope;

        ls.declareVariableName(var_name);

        ITraitVisitor tv = ls.traitsVisitor.visitSlotTrait(trait_kind, var_name, ITraitsVisitor.RUNTIME_SLOT, var_type, initializer);

        if ( ! is_static )
            if (varDef.getNamespaceReference() instanceof NamespaceDefinition.IProtectedNamespaceDefinition)
                this.iinfo.flags |= ABCConstants.CLASS_FLAG_protected;
       
View Full Code Here

Examples of org.apache.flex.abc.visitors.ITraitVisitor

        setup_insns.addInstruction(OP_pushnull);

        setup_insns.addInstruction(OP_newclass, cinfo);
        setup_insns.addInstruction(OP_initproperty, interfaceName);
       
        ITraitVisitor tv = this.interfaceScope.getGlobalScope().traitsVisitor.visitClassTrait(TRAIT_Class, interfaceName, 0, cinfo);
        this.interfaceScope.processMetadata(tv, interfDef.getAllMetaTags());
        tv.visitEnd();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.