Package org.apache.flex.abc.semantics

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


        //                                        listener:Function,
        //                                        useCapture:Boolean = false):void
        //    {
        //        _bindingEventDispatcher.removeEventListener(type, listener, useCapture);
        //    }
        MethodInfo mi = new MethodInfo();
        mi.setMethodName(NAME_REMOVE_EVENT_LISTENER.getBaseName());
        Vector<Name> paramTypes = new Vector<Name>(5);

        paramTypes.add(NAME_STRING);
        paramTypes.add(NAME_FUNCTION);
        paramTypes.add(NAME_BOOLEAN);

        mi.setParamTypes(paramTypes);

        mi.setFlags(ABCConstants.HAS_OPTIONAL);

        mi.addDefaultValue(new PooledValue(false));

        mi.setReturnType(NAME_VOID);

        InstructionList insns = new InstructionList(10);
         insns.addInstruction(OP_getlocal0);
         insns.addInstruction(OP_getproperty, NAME_BINDING_EVENT_DISPATCHER);
         insns.addInstruction(OP_getlocal1);
View Full Code Here


        //    public function willTrigger(type:String):Boolean
        //    {
        //        return _bindingEventDispatcher.willTrigger(type);
        //    }

        MethodInfo mi = new MethodInfo();
        mi.setMethodName(NAME_WILL_TRIGGER.getBaseName());
        Vector<Name> paramTypes = new Vector<Name>(5);

        paramTypes.add(NAME_STRING);

        mi.setParamTypes(paramTypes);

        mi.setReturnType(NAME_BOOLEAN);

        InstructionList insns = new InstructionList(8);
        insns.addInstruction(OP_getlocal0);
        insns.addInstruction(OP_getproperty, NAME_BINDING_EVENT_DISPATCHER);
        insns.addInstruction(OP_getlocal1);
View Full Code Here

            //        local2.registerInheritingStyle(local0);  // local2 is the style manager.
            //    }
            // }
            if (isAppFlexInfo)
            {
                MethodInfo initMethodInfo = new MethodInfo();
                initMethodInfo.setMethodName("FlexInit init method");
                initMethodInfo.setParamTypes(new Vector<Name>(Collections.singleton(new Name("Object"))));
                initMethodInfo.setReturnType(new Name(IASLanguageConstants.void_));
                IMethodVisitor initMethodVisitor = emitter.visitMethod(initMethodInfo);
                initMethodVisitor.visit();
                MethodBodyInfo initMethodBodyInfo = new MethodBodyInfo();
                initMethodBodyInfo.setMethodInfo(initMethodInfo);
                IMethodBodyVisitor initMethodBodyVisitor = initMethodVisitor.visitBody(initMethodBodyInfo);
                initMethodBodyVisitor.visit();
               
                // local0 = temp
                // local1 = module factory argument
                // local2 = style manager
                // local3 = inherited styles array
                InstructionList initMethod = new InstructionList();
                initMethod.addInstruction(ABCConstants.OP_returnvoid);
               
                initMethodBodyVisitor.visitInstructionList(initMethod);
                initMethodBodyVisitor.visitEnd();
                initMethodVisitor.visitEnd();
               
                ITraitVisitor initMethodTraitVisitor =
                    classGen.getCTraitsVisitor().visitMethodTrait(ABCConstants.TRAIT_Method, new Name("init"), 0, initMethodInfo);
                initMethodTraitVisitor.visitStart();
                initMethodTraitVisitor.visitEnd();

                codegenInfoMethod(classGen,
                        flexProject.getCompatibilityVersion(),
                        getMainClassQName(),
                        getPreloaderClassReference(),
                        getRuntimeDPIProviderClassReference(),
                        splashScreenImage,
                        getRootNode(),
                        getTargetAttributes(),
                        flexProject.getLocales(),
                        frame1Info,
                        accessibleClassNames,
                        getFlexInitClassName(),
                        getStylesClassName(),
                        targetSettings.getRuntimeSharedLibraries(),
                        rslInfo,
                        problems,
                        isAppFlexInfo);
               
            }
            else
            {
                MethodInfo initMethodInfo = new MethodInfo();
                initMethodInfo.setMethodName("FlexInit init method");
                initMethodInfo.setParamTypes(new Vector<Name>(Collections.singleton(iModuleFactoryReference.getMName())));
                initMethodInfo.setReturnType(new Name(IASLanguageConstants.void_));
                IMethodVisitor initMethodVisitor = emitter.visitMethod(initMethodInfo);
                initMethodVisitor.visit();
                MethodBodyInfo initMethodBodyInfo = new MethodBodyInfo();
                initMethodBodyInfo.setMethodInfo(initMethodInfo);
                IMethodBodyVisitor initMethodBodyVisitor = initMethodVisitor.visitBody(initMethodBodyInfo);
View Full Code Here

        // CG targets the latest version - these ABCs can be postprocessed to downgrade to previous versions
        emitter.visit(ABCConstants.VERSION_ABC_MAJOR_FP10, ABCConstants.VERSION_ABC_MINOR_FP10);

        IScriptVisitor sv = emitter.visitScript();
        sv.visit();
        MethodInfo init_method = new MethodInfo();
        sv.visitInit(init_method);
       
        MethodBodyInfo init_body = new MethodBodyInfo();
        init_body.setMethodInfo(init_method);
       
View Full Code Here

     * constructor.
     * @return {@link MethodInfo} created for the function.
     */
    public MethodInfo generateFunction (FunctionNode func, LexicalScope enclosing_scope, InstructionList instance_init_insns, Name alternate_name)
    {
        MethodInfo mi = createMethodInfo(enclosing_scope, func, alternate_name);
        if (mi.isNative())
        {
            generateNativeMethod(func, mi, enclosing_scope);
        }
        else
        {
View Full Code Here

     * completes ( you don't have to wait for code generation of the specified
     * function complete ).
     */
    public GenerateFunctionInParallelResult generateFunctionInParallel (ExecutorService executorService, FunctionNode func, LexicalScope enclosing_scope)
    {
        MethodInfo mi = createMethodInfo(enclosing_scope, func, null);
        if (mi.isNative())
        {
            generateNativeMethod(func, mi, enclosing_scope);
            return new GenerateFunctionInParallelResult(Futures.immediateFuture(null), mi, Collections.<IVisitor>emptyList());
        }
        GenerateFunctionRunnable runnable = new GenerateFunctionRunnable(mi, func, enclosing_scope);
View Full Code Here

    }
   
    private static MethodInfo createMethodInfoWithOptionalDefaultArgumentValues(LexicalScope scope, FunctionNode func,
                                        boolean addDefalutValues, Name alternate_name)
    {
        MethodInfo mi = new MethodInfo();
        mi.setMethodName(alternate_name != null ? alternate_name.getBaseName() : func.getName());

        FunctionDefinition funcDef = func.getDefinition();
        //  Marshal the function's arguments.
        ParameterDefinition[] args = funcDef.getParameters();
        List<String> param_names = new ArrayList<String>();

        ICompilerProject project = scope.getProject();
        if ( args.length > 0 )
        {
          Vector<Name> method_args = new Vector<Name>();
          for ( ParameterDefinition arg: args)
          {
                TypeDefinitionBase arg_type = (TypeDefinitionBase)arg.resolveType(project);
                Name type_name = arg_type != null ? arg_type.getMName(project) : null;

            if ( arg.isRest() )
                {
                mi.setFlags( (byte)(mi.getFlags() | ABCConstants.NEED_REST) );
                }
            else
            {
                    method_args.add(type_name);
                    param_names.add(arg.getBaseName());
              }
         
            // If appropriate, tell the MethodInfo about the default parameter value
            if (addDefalutValues && arg.hasDefaultValue())
            {
                Object initValue = arg.resolveInitialValue(project);
               
                // init value might resolve to null, if the source code is bad
                if (initValue == null)
                {
                    IParameterNode paramNode = arg.getNode();
                    scope.addProblem(new NonConstantParamInitializerProblem(paramNode.getAssignedValueNode()));
                      // re-write non-constant expression to undefined, so resulting ABC will pass the verifier.
                      initValue = ABCConstants.UNDEFINED_VALUE;
                }
                mi.addDefaultValue(new PooledValue(initValue));
            }
            }
          mi.setParamTypes(method_args);
            mi.setParamNames(param_names);
        }

        // check for native modifier
        if ( func.getDefinition().isNative() )
        {
            mi.setFlags( (byte)(mi.getFlags() | ABCConstants.NATIVE) );
        }

        // The return type will be set by the BURM.
       
        return mi;
View Full Code Here

     */
    public static MethodInfo createEventHandlerMethodInfo(ICompilerProject project,
                                                          IMXMLEventSpecifierNode eventNode,
                                                          String handlerName)
    {      
        MethodInfo mi = new MethodInfo();
       
        mi.setMethodName(handlerName);
       
        // Event handlers all have one parameter, whose type is determined by
        // the [Event] metadata that declared the event.
        // This type was stored in the EventDefinition
        // that the MXMLEventSpecifierNode refers to.
        EventDefinition eventDefinition = (EventDefinition)eventNode.getDefinition();
        Name eventTypeName = eventDefinition.getTypeReference().getMName(
            project, (ASScope)eventDefinition.getContainingScope());
        Vector<Name> paramTypes = new Vector<Name>();
        paramTypes.add(eventTypeName);
        mi.setParamTypes(paramTypes);
       
        Vector<String> paramName = new Vector<String>();
        paramName.add("event");
        mi.setParamNames(paramName);
       
        //  TODO: Allow these MXML nodes to use registers.
        mi.setFlags(mi.getFlags() | ABCConstants.NEED_ACTIVATION);
       
        // Event handlers return void.
        mi.setReturnType(NAME_VOID);
       
        return mi;
    }
View Full Code Here

     */
    public static MethodInfo createVectorGeneratorMethodInfo(ICompilerProject project,
                                                          IMXMLVectorNode vectorNode,
                                                          String handlerName)
    {      
        MethodInfo mi = new MethodInfo();
       
        mi.setMethodName(handlerName);
       
        ITypeDefinition type = vectorNode.getType();
        Name typeName = ((TypeDefinitionBase)type).getMName(project);
       
        Vector<Name> paramTypes = new Vector<Name>();
        paramTypes.add(IMXMLTypeConstants.NAME_ARRAY);
        mi.setParamTypes(paramTypes);
       
        Vector<String> paramName = new Vector<String>();
        paramName.add("array");
        mi.setParamNames(paramName);
       
        //  TODO: Allow these MXML nodes to use registers.
        mi.setFlags(mi.getFlags() | ABCConstants.NEED_ACTIVATION);
       
        // Event handlers return void.
        mi.setReturnType(typeName);
       
        return mi;
    }
View Full Code Here

     * Instance initializers have no parameters, and their return type
     * is the type of the instance that they create.
     */
    private static MethodInfo createInstanceInitializerMethodInfo(String name, Name type)
    {
        MethodInfo mi = new MethodInfo();       
        mi.setMethodName(name);
        mi.setReturnType(type);
        return mi;
    }
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.