Package org.apache.flex.abc.semantics

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


                assert false: "Unhandled LanguageIdentifierKind " + kind;
            }
        }

        IDefinition def = id.resolve(project);
        Name name;
        if ( id.getName().length() == 0 )
            name = new Name(getGlobalScope().getSyntheticName("anonymous"));
        else
            name = id.getMName(project);

        if( SemanticUtils.isRefToClassBeingInited(id, def) && !insideInlineFunction())
        {
            // Return a slightly modified binding
            // this binding will have the name and node that created the binding,
            // but its local will be set to 0, so that getlocal0 will be used instead of a name lookup
            // this is because we are in code that may be run as part of the class cinit method, and the
            // class slot won't have been initialized yet, so a named lookup will fail.
            // class C
            // {
            //    static var a = C; //C must be codegen'ed as getlocal0 instead of findprop, getprop
            // }

            Binding b = getBinding(id, name, def);
            b.setIsLocal(true);
            b.setLocalRegister(0);
            return b;
        }
        else if ( name != null )
        {
            return getBinding(id, name, def);
        }
  else
  {
      //  Error case, return trivial name
      return new Binding(id, new Name(id.getName()), def);
  }
    }
View Full Code Here


                //  TODO: More fine-grained determination
                //  of which parameters need to live in the activation record.
                for ( int param_num = 0; param_num < this.allParams.size(); param_num++ )
                {
                    Name param_name = this.allParams.get(param_num);
                    result.addInstruction(ABCConstants.OP_findpropstrict, param_name);
                    //  Parameter numbering in the AVM is 1-based
                    //  since local 0 holds "this."
                    result.addInstruction(ABCConstants.OP_getlocal, param_num + 1);
                    result.addInstruction(ABCConstants.OP_setproperty, param_name);
                }

                temp_register_count = this.allParams.size() + 1;
            }
            else
            {
                // Find the bindings for the parameters
                // and give them their corresponding local number.
                // There is a complication, however. The same parameter name may occur more than
                // Once in the parameter list. In this case, ECMA says the last one wins.
                // So in the loop below will go from last parameter to first, and skip any
                // that we have already seen
               
                Set<String> uniqueParamNames = new HashSet<String>();
                for (int param_num = this.allParams.size()-1; param_num >= 0; param_num--)
                {
                    Name param_name = this.allParams.get(param_num);
                    String param_base_name = param_name.getBaseName();
                    Binding param_binding = this.localBindings.get(param_base_name);
                    if (param_binding!=null && !uniqueParamNames.contains(param_base_name))
                    {
                        param_binding.setLocalRegister(param_num+1);
                        uniqueParamNames.add(param_base_name);
View Full Code Here

    {
        assert this.needsActivation(): "no activation storage present";

        if ( this.activationStorage == null )
        {
            this.activationStorage = new Binding(null, new Name("activation"),null);
            this.activationStorage.setIsLocal(true);
            this.tempManager.addAllocatedTemp(this.activationStorage);
        }

        return this.activationStorage;
View Full Code Here

        {
            Binding result;

            if ( this.freeTemps.isEmpty() || !reuse_free )
            {
                result = new Binding(null, new Name("Temp #" + tempNum++), null);
                result.setIsLocal(true);
                addAllocatedTemp(result);
            }
            else
            {
View Full Code Here

            case CONSTANT_RTQnameA:
                return "<error> " + n.toString();
            case CONSTANT_MultinameL:
                return "<error> " + n.toString();
            case CONSTANT_TypeName:
                Name typeName = n.getTypeNameParameter();
                return nameToString(n.getTypeNameBase()) + ".<" + nameToString(typeName) + ">";
        }
        return "<error> " + n.toString();
    }
View Full Code Here

     * definition. Will return null if errors are encountered while constructing
     * the name (such as, the Namespace of the Definition is unresolved).
     */
    public Name getMName(ICompilerProject project)
    {
        Name name = null;

        Namespace qual = null;
        if (namespaceReference != null)
        {
            qual = namespaceReference.resolveAETNamespace(project);
        }
        else
        {
            assert false : "All definitions should have a namespaceReference qualifier.";
            ASScope scope = getContainingASScope();
            if (scope != null)
                qual = ((NamespaceDefinition)NamespaceDefinition.getDefaultNamespaceDefinition(scope)).getAETNamespace();
        }

        // if we can't figure out the namespaceReference, we can't generate a valid name
        if (qual != null)
            name = new Name(ABCConstants.CONSTANT_Qname, new Nsset(qual), getBaseName());
        return name;
    }
View Full Code Here

            // push "this" on the stack
            inst.addInstruction(ABCConstants.OP_getlocal0);
            // push value on the stack
            inst.addAll(valueInstructions);
            // set the property value
            inst.addInstruction(ABCConstants.OP_setproperty, new Name(name));
        }

        return new PairOfInstructionLists(new InstructionList(), inst);
    }
View Full Code Here

        try
        {
            // TODO: Generate class names from CSS file name after the CSS module runtime code is finalized.
            final String moduleName = "CSSModule2";

            final Name mainClassName = new Name(moduleName + "Main");
            CSSModuleGenerator.generateMainClass(emitter, project, mainClassName);

            final Name styleDataClassName = new Name(moduleName + "_StyleData");
            CSSModuleGenerator.generateStyleDataClass(
                    emitter,
                    project,
                    semanticResult.cssDocument,
                    semanticResult.cssCompilationSession,
View Full Code Here

        for (int i = 0; i < n_interfaces; i++)
        {
            InterfaceDefinition idef = (InterfaceDefinition)interfaces[i];
            if (idef != null)
            {
                Name interfaceName = ((InterfaceDefinition)interfaces[i]).getMName(project);
                interface_names.add(interfaceName);
            }
        }
        iinfo.interfaceNames = interface_names.toArray(new Name[interface_names.size()]);
       
        // Set the flags corresponding to 'final' and 'dynamic'.
        if (classDefinition.isFinal())
            iinfo.flags |= ABCConstants.CLASS_FLAG_final;
        if (!classDefinition.isDynamic())
            iinfo.flags |= ABCConstants.CLASS_FLAG_sealed;
       
        iinfo.protectedNs = ((NamespaceDefinition)classDefinition.getProtectedNamespaceReference()).getAETNamespace();
       
        this.cv = emitter.visitClass(iinfo, cinfo);
        cv.visit();
       
        this.itraits = cv.visitInstanceTraits();
        this.ctraits = cv.visitClassTraits();

        this.classScope.traitsVisitor = this.itraits;
        this.classStaticScope.traitsVisitor = this.ctraits;

        // Build an array of the names of all the ancestor classes.
        ArrayList<Name> ancestorClassNames = new ArrayList<Name>();
       
        // Walk the superclass chain, starting with this class
        // and (unless there are problems) ending with Object.
        // This will accomplish three things:
        // - find loops;
        // - build the array of names of ancestor classes;
        // - set the needsProtected flag if this class or any of its ancestor classes needs it.

        boolean needsProtected = false;

        //  Remember the most recently examined class in case there's a cycle in the superclass
        //  chain, in which case we'll need it to issue a diagnostic.
        ClassDefinition c = null;

        IClassDefinition.IClassIterator classIterator =
            classDefinition.classIterator(project, true);

        while (classIterator.hasNext())
        {
            c = (ClassDefinition)classIterator.next();
            needsProtected |= c.getOwnNeedsProtected();
            if (c != classDefinition)
                ancestorClassNames.add(c.getMName(project));
        }
       
        // Report a loop in the superclass chain, such as A extends B and B extends A.
        // Note: A extends A was found previously by SemanticUtils.resolveBaseClass().
        if (classIterator.foundLoop())
            classScope.addProblem(new CircularTypeReferenceProblem(c, c.getQualifiedName()));
       
        // In the case of class A extends A, ancestorClassNames will be empty at this point.
        // Change it to be Object to prevent "Warning: Stack underflow" in the script init code below.
        if (ancestorClassNames.isEmpty())
        {
            ClassDefinition objectDefinition = (ClassDefinition)project.getBuiltinType(
                IASLanguageConstants.BuiltinType.OBJECT);
            ancestorClassNames.add(objectDefinition.getMName(project));
        }
       
        // If this class or any of its ancestor classes needs the protected flag set, set it.
        if (needsProtected)
            iinfo.flags |= ABCConstants.CLASS_FLAG_protected;

        // Add the class initialization logic to the script init.
        // For class B extends A, where class A extends Object, this looks like
        // getscopeobject
        // findpropstrict Object
        // getproperty Object
        // pushscope
        // findpropstrict A
        // getproperty A
        // dup
        // pushscope
        // newclass
        // popscope
        // popscope
        // initproperty B
        InstructionList initInstructions = this.classScope.getInitInstructions();
        initInstructions.addInstruction(OP_getscopeobject, 0);

        // Push ancestor classes onto the scope stack.
        for (int i = ancestorClassNames.size() - 1; i >= 0; i--)
        {
            Name ancestorClassName = ancestorClassNames.get(i);
            initInstructions.addInstruction(OP_getlex, ancestorClassName);
            // The newclass instruction below also needs the superclass on the stack, so dup it
            if (i == 0)
                initInstructions.addInstruction(OP_dup);
            initInstructions.addInstruction(OP_pushscope);
View Full Code Here

        // already called getSkinsParts and collected problems.  This
        // call should get the cached array.
        IMetaTag[] skinParts = classDefinition.findSkinParts(classScope.getProject(), null);
        if (skinParts.length > 0)
        {
            Name var_name = new Name(CONSTANT_Qname, new Nsset(skinPartPrivateNamespace), "skinParts");
            classStaticScope.declareVariableName(var_name);
            ITraitVisitor tv = classStaticScope.traitsVisitor.visitSlotTrait(TRAIT_Var, var_name,
                    ITraitsVisitor.RUNTIME_SLOT, NAME_OBJECT, LexicalScope.noInitializer);
            tv.visitEnd();

            cinitInsns.addInstruction(OP_findproperty, var_name);
           
            for (IMetaTag skinPart : skinParts)
            {
                cinitInsns.addInstruction(OP_pushstring, skinPart.getDecoratedDefinition().getBaseName());
                cinitInsns.addInstruction(OP_convert_s);
                IMetaTagAttribute attr = skinPart.getAttribute("required");
                if (attr == null || attr.getValue().equals("true"))
                    cinitInsns.addInstruction(OP_pushtrue);
                else
                    cinitInsns.addInstruction(OP_pushfalse);
            }
            cinitInsns.addInstruction(OP_newobject, skinParts.length);
            cinitInsns.addInstruction(OP_setproperty, var_name);
           
            // Equivalent AS:
            //
            //      protected function get skinParts():Object
            //      {
            //          return ClassName._skinParts;
            //      }
            //
            MethodInfo mi = new MethodInfo();
            mi.setMethodName("skinParts");

            mi.setReturnType(NAME_OBJECT);

            InstructionList insns = new InstructionList(3);
            insns.addInstruction(OP_getlocal0);
            insns.addInstruction(OP_findpropstrict, var_name);
            insns.addInstruction(OP_getproperty, var_name);
            insns.addInstruction(OP_returnvalue);

            FunctionGeneratorHelper.generateFunction(classScope.getEmitter(), mi, insns);

            NamespaceDefinition nd = (NamespaceDefinition)classDefinition.getProtectedNamespaceReference();
            Name func_name = new Name(nd.getAETNamespace(), "skinParts");
            tv = classScope.traitsVisitor.visitMethodTrait(TRAIT_Getter, func_name, 0, mi);
            tv.visitAttribute(Trait.TRAIT_OVERRIDE, Boolean.TRUE);
            tv.visitEnd();

        }
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.