flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject [1/8] git commit: [flex-falcon] [refs/heads/feature/amf] - generate class alias info [Forced Update!]
Date Wed, 06 Sep 2017 22:17:14 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/feature/amf f422c99c4 -> 2af5714e4 (forced update)


generate class alias info


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/fc13fbc5
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/fc13fbc5
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/fc13fbc5

Branch: refs/heads/feature/amf
Commit: fc13fbc54208b1bccaa62ebc0829f08f149b6fb0
Parents: 1b3b89a
Author: Alex Harui <aharui@apache.org>
Authored: Tue Aug 22 18:11:15 2017 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Aug 22 18:11:22 2017 -0700

----------------------------------------------------------------------
 .../internal/targets/FlexAppSWFTarget.java      | 143 ++++++++++---------
 .../internal/targets/FlexLibrarySWFTarget.java  |   2 +-
 .../compiler/internal/targets/FlexTarget.java   |  19 ++-
 3 files changed, 91 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/fc13fbc5/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
index d0f7f8f..b97daea 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
@@ -1370,7 +1370,74 @@ public class FlexAppSWFTarget extends AppSWFTarget
                 return false;
             ClassDefinition objectClassDef = (ClassDefinition)objectDef;
             
-            
+            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);
+                    }
+                }
+            }
+
             // Generate code for the constructor:
             // public function ClassName()
             // {
@@ -1458,7 +1525,8 @@ public class FlexAppSWFTarget extends AppSWFTarget
                         rslInfo,
                         problems,
                         isAppFlexInfo,
-                        isFlexSDKInfo);
+                        isFlexSDKInfo,
+                        remoteClassAliasMap);
                 
             }
             else
@@ -1491,74 +1559,6 @@ public class FlexAppSWFTarget extends AppSWFTarget
                 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())
                 {
@@ -1833,7 +1833,8 @@ public class FlexAppSWFTarget extends AppSWFTarget
                     rslInfo,
                     problemCollection,
                     false,
-                    isFlexSDKInfo);
+                    isFlexSDKInfo,
+                    null);
             
             classGen.finishScript();
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/fc13fbc5/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexLibrarySWFTarget.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexLibrarySWFTarget.java
b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexLibrarySWFTarget.java
index 823e54d..d24435b 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexLibrarySWFTarget.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexLibrarySWFTarget.java
@@ -462,7 +462,7 @@ public final class FlexLibrarySWFTarget extends LibrarySWFTarget
                     null, // rsls
                     null, // rslinof
                     problemCollection,
-                    false, false);
+                    false, false, null);
             
         }
         

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/fc13fbc5/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java
b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java
index 0e3351b..9263e79 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java
@@ -46,6 +46,7 @@ import org.apache.flex.compiler.definitions.references.ReferenceFactory;
 import org.apache.flex.compiler.internal.abc.ClassGeneratorHelper;
 import org.apache.flex.compiler.internal.as.codegen.LexicalScope;
 import org.apache.flex.compiler.internal.config.FrameInfo;
+import org.apache.flex.compiler.internal.definitions.ClassDefinition;
 import org.apache.flex.compiler.internal.definitions.NamespaceDefinition;
 import org.apache.flex.compiler.internal.projects.FlexProject;
 import org.apache.flex.compiler.internal.targets.Target.DirectDependencies;
@@ -256,6 +257,7 @@ public abstract class FlexTarget
      * @param rsls legacy RSLs. May be null for library swfs.
      * @param problemCollection problems found when generating the info method
      * are added to the collection.
+     * @param remoteClassAliasMap 
      * @throws InterruptedException 
      */
     
@@ -276,7 +278,8 @@ public abstract class FlexTarget
             FlexRSLInfo rslInfo,
             Collection<ICompilerProblem> problemCollection,
             boolean isAppFlexInfo,
-            boolean isFlexSDKInfo) 
+            boolean isFlexSDKInfo, 
+            Map<ClassDefinition, String> remoteClassAliasMap) 
             throws InterruptedException
     {
         IResolvedQualifiersReference applicationDomainRef = ReferenceFactory.packageQualifiedReference(flexProject.getWorkspace(),
@@ -422,6 +425,20 @@ public abstract class FlexTarget
             infoEntries++;            
         }
 
+        if (remoteClassAliasMap != null && !remoteClassAliasMap.isEmpty())
+        {
+            info.addInstruction(ABCConstants.OP_pushstring, "remoteClassAliases");
+            for (Map.Entry<ClassDefinition, String> classAliasEntry : remoteClassAliasMap.entrySet())
+            {
+                info.addInstruction(ABCConstants.OP_pushstring, classAliasEntry.getKey().getQualifiedName());
+                info.addInstruction(ABCConstants.OP_convert_s);
+                String value = classAliasEntry.getValue();
+                info.addInstruction(ABCConstants.OP_pushstring, value);
+            }
+            info.addInstruction(ABCConstants.OP_newobject, remoteClassAliasMap.size());
+            infoEntries++;
+        }
+        
         // fonts:
         if (!frame1Info.embeddedFonts.isEmpty())
         {


Mime
View raw message