Package org.apache.flex.abc.semantics

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


     */
    private void writeMethodTrait (String kindStr, Trait t, boolean isStatic)
    {
        String qual = nsQualifierForName(t.getName());
        String nameStr = nameToString(t.getName());
        MethodInfo methodInfo = (MethodInfo) t.getAttr(Trait.TRAIT_METHOD);
        printer.println("");
        writeMetaData(t);
        //printer.println("// name_id=" + t.name_index + " method_id=" + t.method_info + " disp_id=" + t.disp_id)
        writeMethodInfo(qual, nameStr, kindStr, methodInfo, isStatic, t.getBooleanAttr(Trait.TRAIT_OVERRIDE), t.getBooleanAttr(Trait.TRAIT_FINAL));
    }
View Full Code Here


            //      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();

        generateRequiredContingentDefinitions();
       
        addAnyEmbeddedAsset();

        // Make any vistEnd method calls
        // that were deferred.
        // callVisitEnds must be called on the same thread
        // that started code generation.  Since we don't generate
        // classes in parallel yet, we know that we are on the thread
        // that started code generation here.
        classScope.callVisitEnds();
        classStaticScope.callVisitEnds();
       
        //  Create the class' constructor function.
        if ( this.ctorFunction != null )
        {
            MethodInfo mi = classScope.getGenerator().generateFunction(this.ctorFunction, classScope, this.iinitInsns, null);

            if ( mi != null )
                this.iinfo.iInit = mi;
        }
        else if ( !this.iinitInsns.isEmpty() )
        {
            //  Synthesize a constructor.

            this.iinfo.iInit = new MethodInfo();
            MethodBodyInfo iinit = new MethodBodyInfo();
            iinit.setMethodInfo(this.iinfo.iInit);
           
            IMethodVisitor mv = emitter.visitMethod(this.iinfo.iInit);
            mv.visit();
View Full Code Here

        }
        else
        {
            LexicalScope ls = funcDef.isStatic()? classStaticScope: classScope;

            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);
View Full Code Here

        {
            //  Speculatively initialize the class' cinit
            //  (static class initializer routine)'s data
            //  structures; the code generator may need to
            //  store information in them.
            this.cinfo.cInit = new MethodInfo();
            MethodBodyInfo cinit_info = new MethodBodyInfo();
            cinit_info.setMethodInfo(this.cinfo.cInit);
       
            this.classStaticScope.setMethodInfo(this.cinfo.cInit);
            this.classStaticScope.methodVisitor = emitter.visitMethod(this.cinfo.cInit);
View Full Code Here

    private void generateNestedFunction(IASNode iNode, InstructionList controlFlowSensitiveDestination, Binding func_name, Name return_type, InstructionList function_body)
    {
        currentScope.setFunctionName(func_name.getName().getBaseName());
        currentScope.generateNestedFunction(generateFunctionBody(iNode, function_body, return_type));
        //  Pull the nested function's MethodInfo out of its scope before we pop it.
        MethodInfo nested_method_info = currentScope.getMethodInfo();

        currentScope = currentScope.popFrame();

        //  Initialize the nested function; add a variable
        //  to the containing function scope and add
View Full Code Here

        else
            return_type = null;

        currentScope.generateNestedFunction(generateFunctionBody(iNode, function_body, return_type));
        //  Pull the nested function's MethodInfo out of its scope before we pop it.
        MethodInfo nested_method_info = currentScope.getMethodInfo();
        currentScope = currentScope.popFrame();

        //  Create a wrapper routine that returns the named
        //  routine wrapped in a closure; it's an anonymous
        //  function with an activation record.
        currentScope = currentScope.pushFrame();
        currentScope.declareAnonymousFunction();
        currentScope.setInitialControlFlowRegionNode(((FunctionObjectNode)iNode).getFunctionNode().getScopedNode());
        currentScope.setNeedsActivation();

        currentScope.makeVariable(
                nestedFunctionName,
                SemanticUtils.getAETName(currentScope.getProject().getBuiltinType(BuiltinType.FUNCTION), currentScope.getProject()),
                null, // no meta tags
                null, // no initializer
                LexicalScope.VariableMutability.Constant
            );

        InstructionList wrapper_insns = createInstructionList(iNode);

        wrapper_insns.addInstruction(OP_newfunction, nested_method_info);
        wrapper_insns.addInstruction(OP_dup);
        wrapper_insns.addInstruction(OP_findproperty, nestedFunctionName.getName());
        wrapper_insns.addInstruction(OP_swap);
        wrapper_insns.addInstruction(OP_setslot, 1);
        wrapper_insns.addInstruction(OP_returnvalue);
        currentScope.generateNestedFunction(generateFunctionBody(iNode, wrapper_insns, LexicalScope.anyType));

        MethodInfo wrapper_method_info = currentScope.getMethodInfo();
        currentScope = currentScope.popFrame();

        result.addInstruction(OP_newfunction, wrapper_method_info);
        //  Doesn't matter much what we use as "this" --
        //  the store acts on the activation.
View Full Code Here

            PropertyWatcherInfo propertyWatcherInfo = (PropertyWatcherInfo)watcherInfoBase;
          
            boolean makeStaticWatcher = (watcherInfoBase.getType() == WatcherType.STATIC_PROPERTY);
           
            // round up the getter function for the watcher, or null if we don't need one
            MethodInfo propertyGetterFunction = null;
            if (watcherInfoBase.isRoot && !makeStaticWatcher)
            {
                propertyGetterFunction = this.propertyGetter;
            }
            else if (watcherInfoBase.isRoot && makeStaticWatcher)
View Full Code Here

            PropertyWatcherInfo propertyWatcherInfo = (PropertyWatcherInfo)watcherInfo;
          
            boolean makeStaticWatcher = (watcherInfo.getType() == WatcherType.STATIC_PROPERTY);
           
            // round up the getter function for the watcher, or null if we don't need one
            MethodInfo propertyGetterFunction = null;
            if (watcherInfo.isRoot && !makeStaticWatcher)
            {
                propertyGetterFunction = this.propertyGetter;
                assert propertyGetterFunction != null;
            }
View Full Code Here

            return;
        }

        // make the method info, including any default vaules of parameters. Will do semantic checks
        // on the default values, too.
        MethodInfo mi = interfaceScope.getGenerator().createMethodInfoWithDefaultArgumentValues(this.interfaceScope, func);

        ICompilerProject project = interfaceScope.getProject();

        ExpressionNodeBase return_type_expr = (ExpressionNodeBase)func.getReturnTypeNode();
        if ( return_type_expr != null )
        {
            Name return_type_name = return_type_expr.getMName(project);
            mi.setReturnType(return_type_name);
        }

        IMethodVisitor mv = this.emitter.visitMethod(mi);
        mv.visit();
        mv.visitEnd();
View Full Code Here

     *      exit: new function object for getter on TOS
     */
    public static  void generateGetter(IABCVisitor emitter, InstructionList ret, List<IExpressionNode> expressions, LexicalScope enclosing_scope)
    {
        // get a method info and a scope for the getter we will generate
        MethodInfo mi = createGetterMethodInfo();
       
        mi.setMethodName("bind_getter");
        log(ret, "making bind_getter");
        
        // generate the getter function
        CodeGeneratorManager.getCodeGenerator().generateMXMLDataBindingGetterFunction(mi, expressions, enclosing_scope);
       
View Full Code Here

TOP

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

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.