Package org.apache.flex.compiler.internal.definitions

Examples of org.apache.flex.compiler.internal.definitions.ParameterDefinition


       
        final INamespaceReference namespaceReference = getNamespaceReference(name);
        methodDef.setNamespaceReference(namespaceReference);

        int paramTypesSize = method.getParamTypes().size();
        final ParameterDefinition params[] = new ParameterDefinition[paramTypesSize + (method.needsRest() ? 1 : 0)];
        if (params.length > 0)
        {
            ASScope methodScope = new FunctionScope(scope);
            methodScope.setContainingDefinition(methodDef);
            methodDef.setContainedScope(methodScope);
            Vector<PooledValue> defaultValues = method.getDefaultValues();
            int firstOptionalParam = paramTypesSize - defaultValues.size();
            for (int i = 0; i < paramTypesSize; i++)
            {
                final Name paramType = method.getParamTypes().get(i);
                final String paramName = i < method.getParamNames().size() ? method.getParamNames().get(i) : MethodInfo.UNKNOWN_PARAM_NAME;
                params[i] = new ParameterDefinition(paramName);
                params[i].setTypeReference(paramType == null ? TYPE_ANY : scopeBuilder.getReference(paramType));
                if (i >= firstOptionalParam)
                {
                    Object defaultValue = defaultValues.get(i - firstOptionalParam).getValue();
                    params[i].setDefaultValue(defaultValue);
                }
                methodScope.addDefinition(params[i]);
            }
            if( method.needsRest() )
            {
                ParameterDefinition rest = new ParameterDefinition(MethodInfo.UNKNOWN_PARAM_NAME);
                rest.setRest();
                rest.setTypeReference(ReferenceFactory.builtinReference(IASLanguageConstants.BuiltinType.ARRAY));
                params[paramTypesSize] = rest;
            }
        }
        methodDef.setParameters(params);
View Full Code Here


        // NOTE: don't set a return type for constructors
        ctor.setReturnTypeReference(null);

        MethodInfo mInfo = iinfo.iInit;
        int paramTypesSize = mInfo.getParamTypes().size();
        final ParameterDefinition params[] = new ParameterDefinition[paramTypesSize + (mInfo.needsRest() ? 1 : 0)];
        if (params.length > 0)
        {
            Vector<PooledValue> defaultValues = mInfo.getDefaultValues();
            int firstOptionalParam = paramTypesSize - defaultValues.size();
            for (int i = 0; i < paramTypesSize; i++)
            {
                final Name paramType = mInfo.getParamTypes().get(i);
                final String paramName = i < mInfo.getParamNames().size() ? mInfo.getParamNames().get(i) : MethodInfo.UNKNOWN_PARAM_NAME;
                params[i] = new ParameterDefinition(paramName);
                params[i].setTypeReference(paramType == null ? TYPE_ANY : getReference(paramType));
                if (i >= firstOptionalParam)
                {
                    Object defaultValue = defaultValues.get(i - firstOptionalParam).getValue();
                    params[i].setDefaultValue(defaultValue);
                }
            }

            if (mInfo.needsRest())
            {
                ParameterDefinition rest = new ParameterDefinition(MethodInfo.UNKNOWN_PARAM_NAME);
                rest.setRest();
                rest.setTypeReference(ReferenceFactory.builtinReference(IASLanguageConstants.BuiltinType.ARRAY));
                params[paramTypesSize] = rest;
            }
        }

        ctor.setParameters(params);
View Full Code Here

    private final IMXMLEventSpecifierNode eventSpecifierNode;
   
    public void buildEventParameter(IReference typeRef)
    {
        assert eventParameter == null : "Event parameter should only be built once!";
        eventParameter = new ParameterDefinition(EVENT_HANDLER_PARAMETER_NAME);
        eventParameter.setTypeReference(typeRef);
        eventParameter.setPublic();
        eventParameter.setImplicit();
        addDefinition(eventParameter);
    }
View Full Code Here

                if (ctor instanceof FunctionDefinition)
                {
                    FunctionDefinition func = (FunctionDefinition)ctor;
                    if (func.getParameters() != null && func.getParameters().length != 0)
                    {
                        ParameterDefinition first_param = func.getParameters()[0];

                        if ( !first_param.hasDefaultValue() && ! first_param.isRest() )
                        {
                            addProblem(new NoDefaultConstructorInBaseClassProblem(iNode, super_def.getBaseName()));
                        }
                    }
                }
View Full Code Here

        if (isCatchParameter(scope))
        {
            if (set.contains(PostProcessStep.POPULATE_SCOPE) ||
                set.contains(PostProcessStep.RECONNECT_DEFINITIONS))
            {
                ParameterDefinition definition = buildDefinition();
                setDefinition(definition);
                // Don't hoist the catch scope's parameter definition
                ((CatchScope)scope).setParameterDefinition(definition);
            }
        }
View Full Code Here

     */
    @Override
    ParameterDefinition buildDefinition()
    {
        String definitionName = getName();
        ParameterDefinition definition = new ParameterDefinition(definitionName);
        definition.setNode(this);
        fillInNamespaceAndModifiers(definition);

        setDefinition(definition);

        // Set the type of the parameter. If a type annotation doesn't appear in the source,
        // the parameter type in the definition will be null.
        IReference typeRef = hasExplicitType() ? typeNode.computeTypeReference() : null;

        // If there is no type anno, and we're the rest parameter, we're typed as Array
        if (typeRef == null && this.isRest())
            typeRef = ReferenceFactory.builtinReference(IASLanguageConstants.BuiltinType.ARRAY);

        definition.setTypeReference(typeRef);

        // Tell the def we have a default value
        if (hasDefaultValue())
        {
            definition.setHasDefault();
            definition.setInitializer(this.getAssignedValueNode());
        }

        // Is it ... ?
        if (isRest())
            definition.setRest();

        return definition;
    }
View Full Code Here

        SetterDefinition setter = new SyntheticBindableSetterDefinition(definitionName);

        fillinDefinition(setter);

        // Set up the params for the setter
        ParameterDefinition param = new ParameterDefinition("");
        param.setTypeReference(typeRef);
        setter.setParameters(new ParameterDefinition[] {param});
        setter.setTypeReference(typeRef);
        ASScope setterContainedScope = new FunctionScope(containingScope);
        setter.setContainedScope(setterContainedScope);
        setterContainedScope.addDefinition(param);
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.definitions.ParameterDefinition

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.