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

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


    @Override
    protected void analyze(EnumSet<PostProcessStep> set, ASScope scope, Collection<ICompilerProblem> problems)
    {
        if (set.contains(PostProcessStep.POPULATE_SCOPE))
        {
            FunctionDefinition definition = buildDefinition();
            setDefinition(definition);

            // if the parent is an anonymous function, then don't add the function definition to the scope
            // we have already added the anonymous function to the scope and this function definition does not
            // belong to the scope
            if (this.getParent() instanceof FunctionObjectNode)
            {
                String funcName = definition.getBaseName()
                if (funcName.length() == 0)
                    scope.setAsContainingScopeOfAnonymousFunction(definition);
                else
                {
                    // If the parent is an "anonymous" function with a name, then
                    // the name will have to be visibly within the function body, so it can
                    // call itself recursively. So make a special closure scope
                    // Add a closure scope below the containing scope
                    ASScope closureScope = new ClosureScope(scope);
                    scope = closureScope;               // now build the function scope below this..
                    scope.addDefinition(definition);    // This sets the containing scope of the def
                }
            }
            else
                scope.addDefinition(definition);    // This sets the containing scope of the def

            ScopedBlockNode contents = contentsPart.getContents();
            if (contents != null)
            {
                ASScope localScope = new FunctionScope(scope, contents);
                definition.setContainedScope(localScope);
                scope = localScope;
            }
        }

        if (set.contains(PostProcessStep.RECONNECT_DEFINITIONS))
        {
            reconnectDef(scope);
            final FunctionDefinition functionDef = this.getDefinition();
            if (functionDef != null)
            {
                scope = functionDef.getContainedScope();
                ScopedBlockNode contents = contentsPart.getContents();
                // scope can be null for generated binding wrappers of
                // getters and setters
                if (contents != null && scope != null)
                {
View Full Code Here


        // these members should be initialized from the containing scope, as they'll be merged back
        // if the inline is successful
        this.containingClassBinding = storeClassBinding ? allocateTemp() : null;

        IScopedNode body = functionNode.getScopedNode();
        FunctionDefinition functionDefinition = (FunctionDefinition)functionNode.getDefinition();

        setInitialControlFlowRegionNode(body);
        setLocalASScope(functionDefinition.getContainedScope());
        resetDebugInfo();

        // Set the current file name - the function body will always start with an OP_debugfile
        // so we never need emit another one unless the method body spans multiple files
        setDebugFile(SemanticUtils.getFileName(functionNode));
View Full Code Here

        return new FunctionContentsPart();
    }

    private void tryAddDefaultArgument()
    {
        FunctionDefinition def = getDefinition();
        ASScope funcScope = def.getContainedScope();

        if (needsArguments && funcScope.getLocalDefinitionSetByName(IASLanguageConstants.arguments) == null)
        {
            // Add the arguments Array to the function scope
            // only do this if there is not already a local property, or parameter that is named arguments
View Full Code Here

    FunctionDefinition buildDefinition()
    {
        String definitionName = getName();
      //  System.out.println("buildDefinition: " + definitionName);
        FunctionDefinition definition = createFunctionDefinition(definitionName);
        definition.setNode(this);

        fillInNamespaceAndModifiers(definition);
        fillInMetadata(definition);

        // Set the return type. If a type annotation doesn't appear in the source,
        // the return type in the definition will be "".
        IReference returnType = typeNode != null ? typeNode.computeTypeReference() : null;
        definition.setReturnTypeReference(returnType);

        definition.setTypeReference(ReferenceFactory.builtinReference(IASLanguageConstants.BuiltinType.FUNCTION));
        setConstructorIfNeeded(definition);
        return definition;
    }
View Full Code Here

     *
     * @return A Definition object to represent this function
     */
    protected FunctionDefinition createFunctionDefinition(String name)
    {
        return new FunctionDefinition(name);
    }
View Full Code Here

            {
                IFunctionDefinition ctor = super_def.getConstructor();

                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

                ));
            }
        }
        else if ( def instanceof FunctionDefinition )
        {
            FunctionDefinition func = (FunctionDefinition)def;
            checkFormalsVsActuals(iNode, func, actuals);
        }
        else if ( def == project.getBuiltinType(BuiltinType.ARRAY) )
        {
            // Warn about calling Array as a function because developers
View Full Code Here

               addProblem(new ThisUsedInStaticFunctionProblem(iNode));
           }
        }
        else if ( SemanticUtils.isArgumentsReference(binding) )
        {
            FunctionDefinition functionDef = SemanticUtils.getFunctionDefinition(iNode);
            if (functionDef != null)
            {
                ParameterDefinition[] parameters = functionDef.getParameters();
                for (ParameterDefinition param : parameters)
                {
                    if (param.isRest())
                    {
                        addProblem(new RestParamAndArgumentsUsedTogetherProblem(iNode));
View Full Code Here

            {
                // pass
            }
            else if (def instanceof FunctionDefinition)
            {
                final FunctionDefinition func_def = (FunctionDefinition)def;
                switch (func_def.getFunctionClassification())
                {
                    case CLASS_MEMBER:
                    case INTERFACE_MEMBER:
                        addProblem(new MethodCannotBeConstructorProblem(call_node));
                        break;
View Full Code Here

            IFunctionDefinition ctor = class_def.getConstructor();

            if ( ctor instanceof FunctionDefinition )
            {
                FunctionDefinition func = (FunctionDefinition)ctor;
                checkFormalsVsActuals(iNode, func, args);
            }
        }
        else if ( def instanceof GetterDefinition )
        {
        }
        else if ( def instanceof FunctionDefinition )
        {
            FunctionDefinition func_def = (FunctionDefinition) def;

            IFunctionDefinition.FunctionClassification func_type = func_def.getFunctionClassification();

            if ( func_type.equals(IFunctionDefinition.FunctionClassification.CLASS_MEMBER) || func_type.equals(IFunctionDefinition.FunctionClassification.INTERFACE_MEMBER) )
            {
                addProblem(new MethodCannotBeConstructorProblem(
                    roundUpUsualSuspects(class_binding, iNode)
View Full Code Here

TOP

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

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.