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

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


    public Name reduce_declName(IASNode iNode )
    {
        // We are the name of a declaration, get the containing DefinitionNode and grab the
        // name from there
        BaseDefinitionNode bdn = (BaseDefinitionNode)iNode.getAncestorOfType(BaseDefinitionNode.class);
        DefinitionBase db = bdn.getDefinition();
        Name n = db.getMName(currentScope.getProject());
        return n;
    }
View Full Code Here


                scope.addDefinition(bindingDefs[0]);
                scope.addDefinition(bindingDefs[1]);
            }
            else
            {
                DefinitionBase definition = buildDefinition();
                setDefinition(definition);
                scope.addDefinition(definition);
            }
        }
View Full Code Here

            addProblem(problem);
            return false;
        }

        configScope.addItemAfterNormalization(node);
        DefinitionBase constDef = node.getDefinition();
        configScope.getASScope().addDefinition(constDef);
        if (constDef instanceof ConstantDefinition)
        {
            ConstantDefinition def = (ConstantDefinition)constDef;
            Object value = def.resolveValue(backingProject);
            if (value == ConfigConstNode.UNKNOWN_VALUE)
            {
                // Get the real source node for the problem.
                // If there isn't one, then don't make a problem - assume
                // someone else already found the cause and logged it.
                IASNode problemLocationNode = node.getAssignedValueNode();
                if (problemLocationNode != null)
                {
                    ICompilerProblem problem = new NonConstantConfigInitProblem(
                            problemLocationNode);
                    addProblem(problem);
                }
            }
        }
        // Check for redeclaration
        // Config vars don't care about MultiDefinitionType.MANY vs. AMBIGUOUS
        // and it's not possible for them to shadow params, so we only have to check if
        // the multi type is not NONE
        if (SemanticUtils.getMultiDefinitionType(constDef, backingProject) != SemanticUtils.MultiDefinitionType.NONE)
        {
            addProblem(new ConflictingNameInNamespaceProblem(node, constDef.getBaseName(), node.getNamespace()));
            return false;
        }
        return true;
    }
View Full Code Here

        if (var.getMetaTags() != null && var.getMetaTags().hasTagByName(IMetaAttributeConstants.ATTRIBUTE_EMBED))
        {
            currentScope.addProblem(new EmbedOnlyOnClassesAndVarsProblem(var));
        }

        DefinitionBase varDef = var.getDefinition();
        SemanticUtils.checkScopedToDefaultNamespaceProblem(this.currentScope, var, varDef, null);
        if ( var.hasModifier(ASModifier.STATIC))
        {
           
            ICompilerProject project = this.currentScope.getProject();

            Name var_name = varDef.getMName(project);

            TypeDefinitionBase typeDef = (TypeDefinitionBase)varDef.resolveType(project);
            Name var_type = typeDef != null ? typeDef.getMName(project) : null;
           
            //  It's not necessary to check for duplicates
            //  in the traits because that is a semantic error
            //  in this context.
            ITraitVisitor tv = this.currentScope.traitsVisitor.visitSlotTrait(ABCConstants.TRAIT_Const, var_name, ITraitsVisitor.RUNTIME_SLOT, var_type, LexicalScope.noInitializer);
            this.currentScope.declareVariableName(var_name);
            this.currentScope.processMetadata(tv, varDef.getAllMetaTags());
            tv.visitEnd();
        }
        //  Run the BURM to process any initialization instructions.
        processDirective(var);
    }
View Full Code Here

    @Override
    public ITraitVisitor visitSlotTrait(int kind, Name name, int slot_id, Name slot_type, Object slot_value)
    {
        final String definitionName = getDefinitionName(name);

        final DefinitionBase def;       
        kind &= ABCConstants.TRAIT_KIND_MASK;
        switch (kind)
        {
            case ABCConstants.KIND_SLOT:
                def = new VariableDefinition(definitionName, slot_value);
                break;
            case ABCConstants.KIND_CONST:
                if (slot_value instanceof Namespace)
                    def = NamespaceDefinition.createNamespaceDefinition(definitionName, (Namespace)slot_value);
                else
                    def = new ConstantDefinition(definitionName, slot_value);
                break;
               
            default:
                throw new IllegalStateException("Invalid slot kind: " + kind);
        }
       
        final INamespaceReference namespaceReference = getNamespaceReference(name);
        def.setNamespaceReference(namespaceReference);

        if (isStatic)
            def.setStatic();

        def.setTypeReference(slot_type == null ? TYPE_ANY : scopeBuilder.getReference(slot_type));
       
        scope.addDefinition(def);

        return new CollectMetadataTraitVisitor(def);
    }
View Full Code Here

    private static void setNameLocation(IDefinition def, IMetaTag gotoDefTag)
    {
        String posString = gotoDefTag.getAttributeValue(IMetaAttributeConstants.NAME_GOTODEFINITIONHELP_POS);
        int nameStart = Integer.parseInt(posString);

        DefinitionBase constructorDef = (DefinitionBase)def;
        int nameEnd = nameStart + def.getBaseName().length();
        constructorDef.setNameLocation(nameStart, nameEnd);
    }
View Full Code Here

        {
            if (wasOverride)
                funcDef.setOverride();
            if (funcDef instanceof GetterDefinition)
            {
                DefinitionBase bindableGetter = func.buildBindableGetter(funcName.getBaseName());
                ASScope funcScope = (ASScope)funcDef.getContainingScope();
                bindableGetter.setContainingScope(funcScope);
                LexicalScope ls = funcDef.isStatic()? classStaticScope: classScope;
                ls.generateBindableGetter(bindableGetter, funcName, bindableName,
                                        funcDef.resolveType(project).getMName(project), getAllMetaTags(funcDef));
            }
            else
            {
                TypeDefinitionBase typeDef = funcDef.resolveType(project);
                ASScope funcScope = (ASScope)funcDef.getContainingScope();
                DefinitionBase bindableSetter = func.buildBindableSetter(funcName.getBaseName(),
                        funcScope,
                        funcDef.getTypeReference());
                bindableSetter.setContainingScope(funcScope);
                LexicalScope ls = funcDef.isStatic()? classStaticScope: classScope;
                ls.generateBindableSetter(bindableSetter, funcName, bindableName,
                        typeDef.getMName(project), getAllMetaTags(funcDef))
            }
        }
View Full Code Here

        if (problems != null)
            classScope.addProblems(problems);
       
        final MethodBodySemanticChecker checker = new MethodBodySemanticChecker(this.classScope);
       
        DefinitionBase varType = (DefinitionBase)varDef.resolveType(project);
       
        Object transformed_initializer = null;
       
        if ((initializer != null) && (varType != null))
        {
            transformed_initializer =
                checker.checkInitialValue(var, new Binding(null, varType.getMName(this.classScope.getProject()), varType), new PooledValue(initializer)).getValue();
        }
        else
        {
            transformed_initializer = initializer;
        }
View Full Code Here

    /**
     *  Extract a definition's name.
     */
    private Name getNameFromDefinition(IDefinition idef)
    {
        DefinitionBase def = (DefinitionBase)idef;
        return def.getMName(getProject());
    }
View Full Code Here

        return sourcePath;
    }

    private OffsetLookup getOffsetLookup()
    {
        DefinitionBase definition = (DefinitionBase)getDecoratedDefinition();
        if (definition == null)
            return null;

        final ASFileScope fileScope = definition.getFileScope();
        if (fileScope == null)
            return null;

        return fileScope.getOffsetLookup();
    }
View Full Code Here

TOP

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

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.