Package org.apache.flex.compiler.internal.scopes

Examples of org.apache.flex.compiler.internal.scopes.ASScope


        String hostComponentClassName = getHostComponentClassName(metaTags[0]);
        if (hostComponentClassName == null)
            return null;

        ASScope containedScope = getContainedScope();
        VariableDefinition hostComponentDef = new VariableDefinition(HOST_COMPONENT);
        hostComponentDef.setPublic();
        hostComponentDef.setBindable();
        hostComponentDef.setImplicit();
        hostComponentDef.setContingent();

        IReference typeRef = ReferenceFactory.packageQualifiedReference(containedScope.getWorkspace(), hostComponentClassName);
        hostComponentDef.setTypeReference(typeRef);

        containedScope.addDefinition(hostComponentDef);

        return hostComponentDef;
    }
View Full Code Here


        return hostComponentDef;
    }

    public VariableDefinition buildOuterDocumentMember(IReference outerClass)
    {
        ASScope containedScope = getContainedScope();
        VariableDefinition outerDocumentDef = new VariableDefinition(IMXMLLanguageConstants.PROPERTY_OUTER_DOCUMENT);
        outerDocumentDef.setPublic();
        outerDocumentDef.setBindable();
        outerDocumentDef.setImplicit();
        outerDocumentDef.setTypeReference(outerClass);

        containedScope.addDefinition(outerDocumentDef);

        // the outer document isn't really a contingent definition, as the user
        // should never define it, and we should always create one, but making
        // use of the contingent variable is useful as we can create it here
        // and then resolve it during codegen and create a problem if
View Full Code Here

    public void setupThisAndSuper()
    {
        // Create an implicit VariableDefinition for "this".
        VariableDefinition thisDef = new VariableDefinition(IASKeywordConstants.THIS);

        ASScope containedScope = getContainedScope();
        IWorkspace workspace = containedScope.getWorkspace();

        // this is a lexical ref for codemodel backwards compat
        thisDef.setTypeReference(ReferenceFactory.lexicalReference(workspace, getBaseName()));
        thisDef.setImplicit();
        thisDef.setNamespaceReference(NamespaceDefinition.getCodeModelImplicitDefinitionNamespace());

        // Create an implicit VariableDefinition for "super".
        VariableDefinition superDef = new VariableDefinition(IASKeywordConstants.SUPER);
        IReference baseClassRef = getBaseClassReference();
        if (baseClassRef == null)
        {
            baseClassRef = ReferenceFactory.builtinReference(BuiltinType.OBJECT);
        }
        superDef.setTypeReference(baseClassRef);
        superDef.setImplicit();
        superDef.setNamespaceReference(NamespaceDefinition.getCodeModelImplicitDefinitionNamespace());

        // Add these definitions to the class scope.
        containedScope.addDefinition(thisDef);
        containedScope.addDefinition(superDef);
    }
View Full Code Here

                {
                    // 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;
            }
        }
View Full Code Here

    }

    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
            // and something in the function body references arguments - this should avoid creating the
            // definition when it's not needed.
            VariableDefinition argumentsDef = new VariableDefinition(IASLanguageConstants.arguments);
            argumentsDef.setNamespaceReference(NamespaceDefinition.getDefaultNamespaceDefinition(funcScope));
            argumentsDef.setTypeReference(ReferenceFactory.builtinReference(IASLanguageConstants.BuiltinType.ARRAY));

            argumentsDef.setImplicit();

            funcScope.addDefinition(argumentsDef);
        }
    }
View Full Code Here

                Collection<IDefinition> localDefs = functionScope.getAllLocalDefinitions();
                for (IDefinition def : localDefs)
                {
                    if (! (def instanceof IParameterDefinition))
                    {
                        ASScope asScope = (ASScope)functionScope;
                        asScope.removeDefinition(def);
                    }
                }
            }
            assert (contents.getScope() == null) || (!anyNonParametersInScope(contents));
        }
View Full Code Here

    {
        assert def != null;
        if (def instanceof AppliedVectorDefinition)
            return (AppliedVectorDefinition)def;

        ASScope containingScope = (ASScope)def.getContainingScope();
        if (containingScope == null)
            return null;
        IDefinition containingDefinition = containingScope.getDefinition();
        if (containingDefinition instanceof AppliedVectorDefinition)
            return (AppliedVectorDefinition)containingDefinition;
        IDefinition containingClassDefiniton = containingScope.getContainingClass();
        if (containingClassDefiniton instanceof AppliedVectorDefinition)
            return (AppliedVectorDefinition)containingClassDefiniton;
        return null;
    }
View Full Code Here

            needsSetActualSize = needsFunction(project, qualifier, definition, "setActualSize");
        }

        private static boolean needsGetter(ICompilerProject project, INamespaceDefinition qualifier, ClassDefinition classDefinition, String baseName)
        {
            final ASScope scope = classDefinition.getContainedScope();
            IDefinition def = scope.getQualifiedPropertyFromDef(project, classDefinition, baseName, qualifier, false);
            return (def instanceof IGetterDefinition) ? false : true;
        }
View Full Code Here

            return (def instanceof IGetterDefinition) ? false : true;
        }

        private static boolean needsFunction(ICompilerProject project, INamespaceDefinition qualifier, ClassDefinition classDefinition, String baseName)
        {
            final ASScope scope = classDefinition.getContainedScope();
            IDefinition def = scope.getQualifiedPropertyFromDef(project, classDefinition, baseName, qualifier, false);
            if (def instanceof IFunctionDefinition)
            {
                FunctionClassification classification = ((IFunctionDefinition)def).getFunctionClassification();
                return (classification == FunctionClassification.CLASS_MEMBER) ? false : true;
            }
View Full Code Here

    }
   
    @Override
    public ASScope getASScope()
    {
        ASScope scope = super.getASScope();

        if (scope instanceof WithScope)
        {
            // If this expression is part of the target expression of a with node
            // then we want the scope containing the with scope, not the with scope itself.
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.scopes.ASScope

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.