Package org.apache.flex.abc.semantics

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


        // that started code generation here.
        classScope.callVisitEnds();
       
        {
            // Synthesize a constructor.
            iinfo.iInit = new MethodInfo();
            MethodBodyInfo iinit = new MethodBodyInfo();
            iinit.setMethodInfo(iinfo.iInit);
           
            IMethodVisitor mv = emitter.visitMethod(iinfo.iInit);
            mv.visit();
            IMethodBodyVisitor mbv = mv.visitBody(iinit);
           
            InstructionList ctor_insns = new InstructionList();
           
            // Don't even think of removing these instructions!
            // there is lots of code we are generating that assumes that the
            // scopes and such are set up like this!!
            // In particular the data binding code may create anonymous function objects
            // in the constructor that assume "this" is already on the scope stack.
            ctor_insns.addInstruction(OP_getlocal0);
            ctor_insns.addInstruction(OP_pushscope);
           
            // iinitInsns go before the constructsuper opcode.
            ctor_insns.addAll(iinitInsns);
   
            // Call the superclass' constructor after the instance
            // init instructions; this doesn't seem like an abstractly
            // correct sequence, but it's what ASC does.
            ctor_insns.addInstruction(OP_getlocal0);
            ctor_insns.addInstruction(OP_constructsuper, 0);

            // initialize currentState to first state
            // this has to go before other iinit because
            // otherwise setCurrentState will fire off transitions
            setCurrentState(ctor_insns);
           
            if (!getProject().getTargetSettings().getMxmlChildrenAsData())
            {
                // 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() && numElements > 0)
            {
                // generateMXMLAttributes(attributes);
                FunctionDefinition funcDef = (FunctionDefinition)SemanticUtils.findProperty(classDefinition.getContainedScope(),
                        "generateMXMLAttributes",
                        getProject(), false);
                if (funcDef != null)
                {
                    Name funcName = ((FunctionDefinition)funcDef).getMName(getProject());
                    ctor_insns.addInstruction(OP_getlocal0);          
                    ctor_insns.addAll(mxmlPropertiesInsns);
                    ctor_insns.addInstruction(OP_callpropvoid, new Object[] {funcName, 1 });
                }
            }

            ctor_insns.addInstruction(OP_returnvoid);
           
            mbv.visit();
            mbv.visitInstructionList(ctor_insns);
            mbv.visitEnd();
            mv.visitEnd();
        }
       
        // If the class has static variables with
        // initialization instructions, emit a class
        // init routine.
        if (!cinitInsns.isEmpty())
        {
            cinfo.cInit = new MethodInfo();
            MethodBodyInfo cinit_info = new MethodBodyInfo();
            cinit_info.setMethodInfo(cinfo.cInit);
           
            IMethodVisitor mv = emitter.visitMethod(cinfo.cInit);
            mv.visit();
View Full Code Here


            context.addInstruction(OP_newobject, counter);
            context.addInstruction(OP_returnvalue);
            context.stopUsing(IL.DESCRIPTOR_PROPERTIES, 0);

            // Create the anonymous function.
            MethodInfo methodInfo = createNoParameterAnonymousFunction(
                NAME_OBJECT, context.get(IL.DESCRIPTOR_PROPERTIES));
            context.remove(IL.DESCRIPTOR_PROPERTIES);

            // Set this function as the value of the argument Object's propertiesFactory.
            context.addInstruction(OP_pushstring, "propertiesFactory");
            context.addInstruction(OP_newfunction, methodInfo);
            n++;
        }
       
        // Append the effects styles onto the styles.
        counter = context.getCounter(IL.DESCRIPTOR_EFFECT_STYLES);
        if (counter > 0)
        {
            context.transfer(IL.DESCRIPTOR_EFFECT_STYLES, IL.DESCRIPTOR_STYLES);
            context.incrementCounter(IL.DESCRIPTOR_STYLES, counter);
        }
       
        // stylesFactory: function():void { this.fontFamily = "Arial"; this.fontSize = 20;
        //                                  this.showEffect = "Fade"; this.hideEffect = "Fade"; },
        counter = context.getCounter(IL.DESCRIPTOR_STYLES);
        if (counter > 0)
        {
            // A a returnvoid instruction to the body of the anonymous function
            // for the stylesFactory.
            context.startUsing(IL.DESCRIPTOR_STYLES);
            context.addInstruction(OP_returnvoid);
            context.stopUsing(IL.DESCRIPTOR_STYLES, 0);
           
            // Create the anonymous function.
            MethodInfo methodInfo = createNoParameterAnonymousFunction(
                NAME_VOID, context.get(IL.DESCRIPTOR_STYLES));
            context.remove(IL.DESCRIPTOR_STYLES);
           
            // Set this function as the value of the argument Object's stylesFactory.
            context.addInstruction(OP_pushstring, "stylesFactory");
View Full Code Here

     * Creates an anonymous function with signature function():T
     * whose body is the specified list of instructions.
     */
    private MethodInfo createNoParameterAnonymousFunction(Name returnType, InstructionList instructionList)
    {
        MethodInfo mi = new MethodInfo();       
        mi.setReturnType(returnType);
       
        MethodBodyInfo methodBodyInfo = new MethodBodyInfo();
        methodBodyInfo.setMethodInfo(mi);

        IMethodVisitor methodVisitor = emitter.visitMethod(mi);
View Full Code Here

     */
    // TODO Report a problem if there is already an initialize() override in this class.
    private void overrideInitializeMethod(IMXMLClassDefinitionNode node)
    {
        String name = "initialize";
        MethodInfo methodInfo = new MethodInfo();       
        methodInfo.setMethodName(name);
        methodInfo.setReturnType(NAME_VOID);
       
        InstructionList body = new InstructionList();
       
        body.addInstruction(OP_getlocal0);
        body.addInstruction(OP_pushscope);
View Full Code Here

     */
    // TODO gosmith Report a problem if there is already an initialize() override in this class.
    void overrideMXMLDescriptorGetter(IMXMLClassDefinitionNode node, Context context)
    {
        String name = "MXMLDescriptor";
        MethodInfo methodInfo = new MethodInfo();       
        methodInfo.setMethodName(name);
        methodInfo.setReturnType(NAME_ARRAY);
       
        InstructionList body = new InstructionList();
       
        body.addInstruction(OP_getlocal0);
        body.addInstruction(OP_pushscope);
View Full Code Here

            Name initializerName = null;
                      
            if (isInitializer)
            {
                initializerName = getInstanceInitializerName(instanceNode);
                MethodInfo methodInfo = createInstanceInitializerMethodInfo(
                    initializerName.getBaseName(), instanceClassName);
                addMethodTrait(initializerName, methodInfo, false);
   
                childContext.addInstruction(OP_returnvalue);
                generateMethodBody(methodInfo, classScope, childContext.currentInstructionList);
View Full Code Here

   
        // Event nodes (including state-dependent ones)
        // generate a new event handler method.
        // Create a MethodInfo and a method trait for the handler.
        Name name = getVectorGeneratorName(typeName);
        MethodInfo methodInfo = createVectorGeneratorMethodInfo(
            getProject(), vectorNode, name.getBaseName());
        addMethodTrait(name, methodInfo, false);
       
        ICompilerProject project = getProject();
        ASProjectScope projectScope = (ASProjectScope)project.getScope();
View Full Code Here

   
        // 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.
View Full Code Here

        final IResolvedQualifiersReference styleManagerReference = ReferenceFactory.packageQualifiedReference(
                this.getProject().getWorkspace(),
                "mx.styles.StyleManagerImpl");
        final Name styleManagerReferenceName = styleManagerReference.getMName();

        final MethodInfo methodInfo = new MethodInfo();
        methodInfo.setMethodName("moduleFactory");
        methodInfo.setReturnType(NAME_VOID);
        methodInfo.setParamNames(ImmutableList.<String> of("factory"));

        final Vector<Name> paramTypes = new Vector<Name>();
        final Name flexModuleFactoryTypeName = new Name(
                new Namespace(ABCConstants.CONSTANT_PackageNs, "mx.core"),
                "IFlexModuleFactory");
        paramTypes.add(flexModuleFactoryTypeName);
        methodInfo.setParamTypes(paramTypes);
       
        final InstructionList methodInstructions = new InstructionList();
       
        // super.moduleFactory = factory;
        methodInstructions.addInstruction(ABCConstants.OP_getlocal0);
        methodInstructions.addInstruction(ABCConstants.OP_getlocal1);
        methodInstructions.addInstruction(ABCConstants.OP_setsuper, moduleFactoryName);
       
        // if (mfi)
        //     return;
        Label label1 = new Label();
        methodInstructions.addInstruction(OP_getlocal0);
        methodInstructions.addInstruction(OP_getproperty, NAME_MODULE_FACTORY_INITIALIZED);
        methodInstructions.addInstruction(OP_iffalse, label1);
       
        methodInstructions.addInstruction(OP_returnvoid);
        methodInstructions.labelNext(label1);

        // mfi = true;
        methodInstructions.addInstruction(OP_getlocal0);
        methodInstructions.addInstruction(OP_pushtrue);
        methodInstructions.addInstruction(OP_setproperty, NAME_MODULE_FACTORY_INITIALIZED);
       
        if (hasStyleSpecifiers || hasEffectSpecifiers)
        {
            FlexProject project = this.getProject();
            Name cssStyleDeclarationName = project.getCSSStyleDeclarationClassName();
           
            // Create an anonymous function from the style and effect-style specifiers
            // for the class definition tag. It will be set as the value of
            // styleDeclaration.defaultFactory.
            MethodInfo styleDeclarationDefaultFactory = createStyleDeclarationDefaultFactory(context);
           
            // if (this.styleDeclaration == null)
            //     this.styleDeclaration = new CSSStyleDeclaration(null, this.styleManager);
            Label label2 = new Label();
            methodInstructions.addInstruction(OP_getlocal0);
View Full Code Here

    @Override
    void declareFunction(FunctionNode f)
    {
        verifyFunctionModifiers(f);

        final MethodInfo mi = startFunctionGeneration(f);
        if ( mi != null )
        {
            FunctionDefinition funcDef = f.getDefinition();
            Name funcName = funcDef.getMName(this.currentScope.getProject());
           
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.