Package org.apache.flex.abc.semantics

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


        }

        bodyInstructionList.addInstruction(ABCConstants.OP_newobject, entryCount);
        bodyInstructionList.addInstruction(ABCConstants.OP_returnvalue);

        Name getContentsMethodName = new Name(ABCConstants.CONSTANT_Qname,
                new Nsset(classGen.getProtectedNamespace()), "getContent");

        //Create getContents method
        classGen.addITraitsMethod(getContentsMethodName, Collections.<Name> emptyList(),
                new Name(IASLanguageConstants.Object), Collections.<Object> emptyList(),
                false, false, true, bodyInstructionList);

        classGen.finishScript();
    }
View Full Code Here


            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);

        Name returnType = method.getReturnType();
        methodDef.setReturnTypeReference(returnType == null ? TYPE_ANY : scopeBuilder.getReference(returnType));
       
        // The type of a getter or setter is its property type
        // (i.e., the getter's return type or the setter's parameter type).
        // The type of a method or function is "Function".
View Full Code Here

        {
            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)
                {
View Full Code Here

     */
    private void poolTraitsConstants(Traits ts)
    {
        for (Trait t : ts)
        {
            Name traitName = t.getNameAttr(Trait.TRAIT_NAME);
            visitPooledName(traitName);

            if (t.hasAttr(Trait.TRAIT_TYPE))
                visitPooledName(t.getNameAttr(Trait.TRAIT_TYPE));

View Full Code Here

        //  Push ancestor classes onto the scope stack in
        //  order by superclass relationship; the immediate
        //  superclass is handled specially just below.
       
        assert ancestorNames.size() > 0;
        Name superclassName = ancestorNames.removeLast();
        for (Name ancestorName : ancestorNames)
        {
            scriptInitInstructions.addInstruction(OP_findpropstrict, ancestorName);
            scriptInitInstructions.addInstruction(OP_getproperty, ancestorName);
            scriptInitInstructions.addInstruction(OP_pushscope);
View Full Code Here

     */
    public void makeVariable(Binding var, Name var_type, IMetaInfo[] meta_tags, Object initializer, VariableMutability mutability)
    {
        assert (initializer == null || SemanticUtils.isConstDefinition(var.getDefinition())) : "only consts can have an initializer";

        Name var_name = var.getName();
        if ( var_name == null || this.declaredVariables.contains(var_name) )
        {
            return;
        }

        declareVariableName(var_name);

        IDefinition var_def = var.getDefinition();
        if ( this.localsInRegisters() )
        {
            //  The Binding will already be in localBindings if it was referenced
            //  before it was set; if not, add it.
            if ( !this.localBindings.containsKey(var_name.getBaseName()) )
            {
                if ( var.getNode() instanceof BaseVariableNode )
                {
                    IExpressionNode name_node = ((BaseVariableNode)var.getNode()).getNameExpressionNode();
                    Binding var_binding = getBinding(name_node, var_name, var_def);
                    this.localBindings.put(var_name.getBaseName(), var_binding);
                    var_binding.setIsLocal(true);
                }
                else
                {
                    //  Error case, synthesize a Binding.
                    Binding error_binding = new Binding(var.getNode(), new Name("error in binding"), null);
                    this.localBindings.put(var_name.getBaseName(), error_binding);
                }
            }
        }
        else
        {
View Full Code Here

     * metadata - some callers of this method will not have an MetaTagsNode in
     * the AST, and want the metadata from the definition
     */
    public void makeBindableVariable(Binding var, Name var_type, IMetaInfo[] metaTags)
    {
        Name var_name = var.getName();
        if ( var_name == null || this.declaredVariables.contains(var_name) )
        {
            return;
        }

        declareVariableName(var_name);

        Name backingPropertyName = BindableHelper.getBackingPropertyName(var_name);

        assert(this.traitsVisitor != null): "No traits";

        this.traitsVisitor.visitSlotTrait(
            ABCConstants.TRAIT_Var,
View Full Code Here

     *    with the same base name and a more or less appropriate
     *    qualifier if it was not a QName.
     */
    private Name ensureQName(Name n)
    {
        Name result;

        if ( n != null )
        {
            if ( n.getKind() == ABCConstants.CONSTANT_Qname )
            {
                result = n;
            }
            else
            {
                result = new Name(ABCConstants.CONSTANT_Qname, new Nsset(new Namespace(ABCConstants.CONSTANT_PackageNs)), n.getBaseName());
            }
        }
        else
        {
            result = null;
View Full Code Here

     @param ns_binding - the namespace declaration's binding.
     *  @param ns_init - the namespace definition's initial AET Namespace.  May not be null.
     */
    public void makeNamespace(Binding ns_binding, Namespace ns_init)
    {
        Name ns_name = ns_binding.getName();

        //  TODO: Semantic analysis will issue a diagnostic.
        //  Repair locally by ignoring the second declaration.
        if ( this.declaredVariables.contains(ns_name))
            return;
        else
            declareVariableName(ns_name);


        assert ( ns_init != null );
        assert(this.traitsVisitor != null): "No traits";

        if ( this.localsInRegisters() )
        {
            this.localBindings.put(ns_name.getBaseName(), ns_binding);
            ns_binding.setIsLocal(true);
        }
        else
        {
            this.traitsVisitor.visitSlotTrait(ABCConstants.TRAIT_Const, ns_name, getSlotId(ns_binding), anyType, ns_init);
View Full Code Here

     @param def - the parameter's definition.
     *  @param param_type - the name of the parameter's type.
     */
    public void makeParameter(IDefinition def, Name param_type)
    {
        Name param_name = ((DefinitionBase)def).getMName(getProject());

        if (((IParameterDefinition)def).isRest())
            hasRestParam = true;
        else
            getParamTypes().add(param_type);
View Full Code Here

TOP

Related Classes of org.apache.flex.abc.semantics.Name

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.