Examples of IDefinition


Examples of org.apache.flex.compiler.definitions.IDefinition

        InstructionList result = createInstructionList(iNode);

        if ( unary.isLocal() ) {
            ICompilerProject project = currentScope.getProject();

            IDefinition inType = SemanticUtils.resolveUnaryExprType(iNode, project);

            IDefinition intType = project.getBuiltinType(BuiltinType.INT);
            IDefinition numberType = project.getBuiltinType(BuiltinType.NUMBER);
            if( inType == intType)
            {
                // Decrementing a local, typed as int
                // we can use declocal_i since we know the result will be stored in an int
                result.addInstruction(unary.declocal_i());
View Full Code Here

Examples of org.apache.flex.compiler.definitions.IDefinition

        InstructionList result = createInstructionList(iNode);

        if ( unary.isLocal() ) {
            ICompilerProject project = currentScope.getProject();

            IDefinition inType = SemanticUtils.resolveUnaryExprType(iNode, project);

            IDefinition intType = project.getBuiltinType(BuiltinType.INT);
            IDefinition numberType = project.getBuiltinType(BuiltinType.NUMBER);
            if( inType == intType)
            {
                // Incrementing a local, typed as int
                // we can use inclocal_i since we know the result will be stored in an int
                result.addInstruction(unary.inclocal_i());
View Full Code Here

Examples of org.apache.flex.compiler.definitions.IDefinition

     * @return LookupSwitchInfo if a lookup switch can be used, otherwise null
     */
    private LookupSwitchInfo getLookupSwitchInfo(IExpressionNode conditional, Vector<ConditionalFragment> cases)
    {
        // only generate a lookup switch if the conditional type is of type int or uint
        IDefinition conditionalType = conditional.resolveType(currentScope.getProject());
        if (!SemanticUtils.isBuiltin(conditionalType, BuiltinType.INT, currentScope.getProject()) &&
            !SemanticUtils.isBuiltin(conditionalType, BuiltinType.UINT, currentScope.getProject()))
            return null;

        LookupSwitchInfo lookupSwitchInfo = new LookupSwitchInfo();
View Full Code Here

Examples of org.apache.flex.compiler.definitions.IDefinition

        if (isBracketAssign)
            destinationType = binaryNode.getLeftOperandNode().resolveType(currentScope.getProject());
        TernaryOperatorNode ternaryNode = (TernaryOperatorNode)iNode;
       
        IExpressionNode valueNode;       
        IDefinition type_def; //= valueNode.resolveType(currentScope.getProject()); //SemanticUtils.getDefinitionOfUnderlyingType(,
                           // true, currentScope.getProject());
        boolean need_coerce = false;
       
        InstructionList result = createInstructionList(iNode, test.size() + when_true.size() + when_false.size() + 2);
        Label tail = new Label();

        result.addAll(test);
        result.addInstruction(OP_iffalse, when_false.getLabel());
        result.addAll(when_true);
        valueNode = ternaryNode.getLeftOperandNode();
        type_def = valueNode.resolveType(currentScope.getProject());
        need_coerce = type_def != null && !type_def.equals(destinationType);
        if (need_coerce && isBracketAssign)
            coerce(result, destinationType);
        result.addInstruction(OP_jump, tail);
        result.addAll(when_false);
        valueNode = ternaryNode.getRightOperandNode();
        type_def = valueNode.resolveType(currentScope.getProject());
        need_coerce = type_def != null && !type_def.equals(destinationType);
        if (need_coerce && isBracketAssign)
            coerce(result, destinationType);
        result.labelNext(tail);

        return result;
View Full Code Here

Examples of org.apache.flex.compiler.definitions.IDefinition

            //  Add initializer code to the init instructions.
            InstructionList init_insns = currentScope.getHoistedInitInstructions();

            ICompilerProject project = currentScope.getProject();

            IDefinition type_def = var_type.getDefinition();

            if  (
                    type_def == project.getBuiltinType(BuiltinType.INT) ||
                    type_def == project.getBuiltinType(BuiltinType.UINT)
                )
View Full Code Here

Examples of org.apache.flex.compiler.definitions.IDefinition

        ICompilerProject project = currentScope.getProject();

        // Determine if iNode represents super[...] (either as an l-value or an r-value).
        // If so, the namespace set will be slightly different; it will have
        // ProtectedNs(thisClass) instead of ProtectedNs(superClass>.
        IDefinition superDef = null;
        if (iNode instanceof IDynamicAccessNode)
        {
            IExpressionNode arrayNode = ((IDynamicAccessNode)iNode).getLeftOperandNode();
            if (arrayNode instanceof ILanguageIdentifierNode &&
                ((ILanguageIdentifierNode)arrayNode).getKind() == LanguageIdentifierKind.SUPER)
View Full Code Here

Examples of org.apache.flex.compiler.definitions.IDefinition

            info.addChildNode(modelNode);
        }
        else
        {
            FlexProject project = builder.getProject();
            IDefinition definition = builder.getFileScope().resolveTagToDefinition(childTag);
            if (definition instanceof ClassDefinition)
            {
                MXMLInstanceNode instanceNode = MXMLInstanceNode.createInstanceNode(
                        builder, definition.getQualifiedName(), this);
                instanceNode.setClassReference(project, (IClassDefinition)definition); // TODO Move this logic to initializeFromTag().
                instanceNode.initializeFromTag(builder, childTag);
                info.addChildNode(instanceNode);
            }
            else
View Full Code Here

Examples of org.apache.flex.compiler.definitions.IDefinition

            emitter.visit(ABCConstants.VERSION_ABC_MAJOR_FP10, ABCConstants.VERSION_ABC_MINOR_FP10);
            ICSSCodeGenResult cssCodeGenResult = cssCompilationSession.emitStyleDataClass(flexProject, emitter);

            Name stylesClassName = new Name(getStylesClassName());

            IDefinition objectDef = objectReference.resolve(flexProject);
            if ((objectDef == null) || (!(objectDef instanceof ClassDefinition)))
                return false;

            ClassDefinition objectClassDef = (ClassDefinition)objectDef;
View Full Code Here

Examples of org.apache.flex.compiler.definitions.IDefinition

                    IMXMLEmbedNode embedNode = (IMXMLEmbedNode)node;
                    IASNode parent = embedNode.getParent();
                    if (parent instanceof IMXMLPropertySpecifierNode)
                    {
                        IMXMLPropertySpecifierNode propertyNode = (IMXMLPropertySpecifierNode)parent;
                        IDefinition propertyDefinition = propertyNode.getDefinition();
                        if (propertyDefinition instanceof ISetterDefinition)
                        {
                            ISetterDefinition setter = (ISetterDefinition)propertyDefinition;
                            if (attributeName.equals(setter.getBaseName()))
                            {
View Full Code Here

Examples of org.apache.flex.compiler.definitions.IDefinition

           
            Name flexInitClassName = new Name(flexInitClassNameString);
           
            Name stylesClassName = new Name(getStylesClassName());

            IDefinition objectDef = objectReference.resolve(flexProject);
            if ((objectDef == null) || (!(objectDef instanceof ClassDefinition)))
                return false;
            ClassDefinition objectClassDef = (ClassDefinition)objectDef;
           
           
            // Generate code for the constructor:
            // public function ClassName()
            // {
            //    super();
            // }
            InstructionList classITraitsInit = new InstructionList();
            classITraitsInit.addInstruction(ABCConstants.OP_getlocal0);
            classITraitsInit.addInstruction(ABCConstants.OP_constructsuper, 0);
            classITraitsInit.addInstruction(ABCConstants.OP_returnvoid);
            ClassGeneratorHelper classGen = new ClassGeneratorHelper(flexProject, emitter, flexInitClassName,
                    objectClassDef, Collections.<Name>emptyList(), classITraitsInit);
           
            // Generate code for the static init method:
            // public static function init(mf : IFlexModuleFactory) : void
            // {
            //    new ChildManager(mf);
            //    var local2 : * = new StyleManagerImpl(mf);
            //
            //    // For each effect declared in the application:
            //    EffectManager.mx_internal::registerEffectTrigger(<effectName>, <eventName>);
            //
            //    // For each remote class alias declared in the application
            //    try
            //    {
            //        if (flash.net.getClassByAlias(<remote class alias>) != <class>)
            //        {
            //            flash.net.registerClassAlias(<remote class alias>, <class>);
            //        }
            //    }
            //    catch (e:Error)
            //    {
            //        flash.net.registerClassAlias(<remote class alias>, <class>);
            //    }
            //
            //    var local3 : * = [<names of all inheriting styles declared in the application>];
            //
            //    for each (var local0 : * in local3)
            //    {
            //        local2.registerInheritingStyle(local0);  // local2 is the style manager.
            //    }
            // }
            if (isAppFlexInfo)
            {
                MethodInfo initMethodInfo = new MethodInfo();
                initMethodInfo.setMethodName("FlexInit init method");
                initMethodInfo.setParamTypes(new Vector<Name>(Collections.singleton(new Name("Object"))));
                initMethodInfo.setReturnType(new Name(IASLanguageConstants.void_));
                IMethodVisitor initMethodVisitor = emitter.visitMethod(initMethodInfo);
                initMethodVisitor.visit();
                MethodBodyInfo initMethodBodyInfo = new MethodBodyInfo();
                initMethodBodyInfo.setMethodInfo(initMethodInfo);
                IMethodBodyVisitor initMethodBodyVisitor = initMethodVisitor.visitBody(initMethodBodyInfo);
                initMethodBodyVisitor.visit();
               
                // local0 = temp
                // local1 = module factory argument
                // local2 = style manager
                // local3 = inherited styles array
                InstructionList initMethod = new InstructionList();
                initMethod.addInstruction(ABCConstants.OP_returnvoid);
               
                initMethodBodyVisitor.visitInstructionList(initMethod);
                initMethodBodyVisitor.visitEnd();
                initMethodVisitor.visitEnd();
               
                ITraitVisitor initMethodTraitVisitor =
                    classGen.getCTraitsVisitor().visitMethodTrait(ABCConstants.TRAIT_Method, new Name("init"), 0, initMethodInfo);
                initMethodTraitVisitor.visitStart();
                initMethodTraitVisitor.visitEnd();

                codegenInfoMethod(classGen,
                        flexProject.getCompatibilityVersion(),
                        getMainClassQName(),
                        getPreloaderClassReference(),
                        getRuntimeDPIProviderClassReference(),
                        splashScreenImage,
                        getRootNode(),
                        getTargetAttributes(),
                        flexProject.getLocales(),
                        frame1Info,
                        accessibleClassNames,
                        getFlexInitClassName(),
                        getStylesClassName(),
                        targetSettings.getRuntimeSharedLibraries(),
                        rslInfo,
                        problems,
                        isAppFlexInfo);
               
            }
            else
            {
                MethodInfo initMethodInfo = new MethodInfo();
                initMethodInfo.setMethodName("FlexInit init method");
                initMethodInfo.setParamTypes(new Vector<Name>(Collections.singleton(iModuleFactoryReference.getMName())));
                initMethodInfo.setReturnType(new Name(IASLanguageConstants.void_));
                IMethodVisitor initMethodVisitor = emitter.visitMethod(initMethodInfo);
                initMethodVisitor.visit();
                MethodBodyInfo initMethodBodyInfo = new MethodBodyInfo();
                initMethodBodyInfo.setMethodInfo(initMethodInfo);
                IMethodBodyVisitor initMethodBodyVisitor = initMethodVisitor.visitBody(initMethodBodyInfo);
                initMethodBodyVisitor.visit();
               
                // local0 = temp
                // local1 = module factory argument
                // local2 = style manager
                // local3 = inherited styles array
                InstructionList initMethod = new InstructionList();
               
                // Since we don't need "this", we can kill local0, we'll use it later for something else.
                initMethod.addInstruction(ABCConstants.OP_kill, 0);
                initMethod.addInstruction(ABCConstants.OP_finddef, childManagerReference.getMName());
                initMethod.addInstruction(ABCConstants.OP_getlocal1);
                initMethod.addInstruction(ABCConstants.OP_constructprop, new Object[] { childManagerReference.getMName(), 1 });
                initMethod.addInstruction(ABCConstants.OP_pop);
                initMethod.addInstruction(ABCConstants.OP_finddef, styleManagerImplReference.getMName());
                initMethod.addInstruction(ABCConstants.OP_getlocal1);
                initMethod.addInstruction(ABCConstants.OP_constructprop, new Object[] { styleManagerImplReference.getMName(), 1 });
                initMethod.addInstruction(ABCConstants.OP_setlocal2);
               
                Map<String, String> effectNameToTriggerMap = new TreeMap<String, String>();
                Map<String, Boolean> inheritingStyleMap = new TreeMap<String, Boolean>();
                Map<ClassDefinition, String> remoteClassAliasMap =
                    new TreeMap<ClassDefinition, String>(new Comparator<ClassDefinition>()
                    {
                        @Override
                        public int compare(ClassDefinition o1, ClassDefinition o2)
                        {
                            return o1.getQualifiedName().compareTo(o2.getQualifiedName());
                        }
                    })
                    {
                        private static final long serialVersionUID = 1L;
   
                        /**
                         *  Override so warning messages can be logged.
                         */
                        @Override
                        public String put(ClassDefinition key, String value)
                        {
                            // check for duplicate values and log a warning if any remote
                            // classes try to use the same alias.
                            if (containsValue(value))
                            {
                               for (Map.Entry<ClassDefinition,String> entry  : entrySet())
                               {
                                   if (value != null && value.equals(entry.getValue()))
                                   {
                                       problems.add(new ClassesMappedToSameRemoteAliasProblem(key.getQualifiedName(),
                                               entry.getKey().getQualifiedName(), value));
                                       break;
                                   }
                               }
                            }
                            return super.put(key, value);
                        }
                    };
                   
                for (ICompilationUnit cu : emittedCompilationUnits)
                {
                    Collection<IDefinition> visibleDefs = cu.getFileScopeRequest().get().getExternallyVisibleDefinitions();
                    for (IDefinition visibleDef : visibleDefs)
                    {
                        if (visibleDef instanceof ClassDefinition)
                        {
                            ClassDefinition visibleClass = (ClassDefinition) visibleDef;
                            IEffectDefinition[] effectDefinitions = visibleClass.getEffectDefinitions(flexProject.getWorkspace());
                            for (IEffectDefinition effectDefinition : effectDefinitions)
                            {
                                // TODO create compiler problem if effect already has a trigger.
                                effectNameToTriggerMap.put(effectDefinition.getBaseName(), effectDefinition.getEvent());
                            }
                           
                            IStyleDefinition[] styleDefinitions = visibleClass.getStyleDefinitions(flexProject.getWorkspace());
                            for (IStyleDefinition styleDefinition : styleDefinitions)
                            {
                                boolean isInheriting = styleDefinition.isInheriting();
                                // TODO create compiler problem if style definitions conflict
                                inheritingStyleMap.put(styleDefinition.getBaseName(), isInheriting);
                            }
                           
                            String remoteClassAlias = visibleClass.getRemoteClassAlias();
                            if (remoteClassAlias != null)
                                remoteClassAliasMap.put(visibleClass, remoteClassAlias);
                        }
                    }
                }
               
                // register effects
                if (!effectNameToTriggerMap.isEmpty())
                {
                    IDefinition mxInternalDef = mxInternalReference.resolve(flexProject);
                    if (!(mxInternalDef instanceof NamespaceDefinition))
                        return false;
                   
                   
                    IResolvedQualifiersReference registerEffectTriggerRef =
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.