flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/3] git commit: [flex-falcon] [refs/heads/develop] - hack in emitting sub-components as inner classes. Implementation needs improvement someday
Date Tue, 01 Mar 2016 01:50:35 GMT
hack in emitting sub-components as inner classes.  Implementation needs improvement someday


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

Branch: refs/heads/develop
Commit: 47852ab48748b2a4fe865351f8aade16634395c5
Parents: eb41d25
Author: Alex Harui <aharui@apache.org>
Authored: Mon Feb 29 14:53:47 2016 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Feb 29 17:50:29 2016 -0800

----------------------------------------------------------------------
 .../compiler/internal/codegen/as/ASEmitter.java |  2 +-
 .../codegen/js/flexjs/JSFlexJSEmitter.java      |  5 ++++
 .../codegen/mxml/flexjs/MXMLFlexJSEmitter.java  | 25 ++++++++++++++++----
 .../codegen/mxml/jsc/MXMLJSCJSEmitter.java      |  2 +-
 4 files changed, 27 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/47852ab4/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
index 32e7130..107e809 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
@@ -115,7 +115,7 @@ public class ASEmitter implements IASEmitter, IEmitter
         return bufferWrite;
     }
 
-    protected void setBufferWrite(boolean value)
+    public void setBufferWrite(boolean value)
     {
         bufferWrite = value;
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/47852ab4/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index f3fd8b6..72a59f1 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -52,6 +52,7 @@ import org.apache.flex.compiler.internal.codegen.js.jx.PackageHeaderEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.SelfReferenceEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.SuperCallEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.VarDeclarationEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSEmitter;
 import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.internal.projects.FlexProject;
 import org.apache.flex.compiler.internal.tree.as.BinaryOperatorAsNode;
@@ -327,8 +328,12 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         return formatQualifiedName(name, false);
     }
 
+    public MXMLFlexJSEmitter mxmlEmitter = null;
+    
     public String formatQualifiedName(String name, boolean isDoc)
     {
+    	if (mxmlEmitter != null)
+    		name = mxmlEmitter.formatQualifiedName(name);
         /*
         if (name.contains("goog.") || name.startsWith("Vector."))
             return name;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/47852ab4/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
index d8d99ea..dd89f6b 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
@@ -116,6 +116,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     private ArrayList<MXMLScriptSpecifier> scripts;
     //private ArrayList<MXMLStyleSpecifier> styles;
     private IClassDefinition classDefinition;
+    private IClassDefinition documentDefinition;
     private ArrayList<String> usedNames = new ArrayList<String>();
     private ArrayList<IMXMLMetadataNode> metadataNodes = new ArrayList<IMXMLMetadataNode>();
     
@@ -228,6 +229,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         // visit MXML
         IClassDefinition cdef = node.getClassDefinition();
         classDefinition = cdef;
+        documentDefinition = cdef;
         
         // TODO (mschmalle) will remove this cast as more things get abstracted
         JSFlexJSEmitter fjs = (JSFlexJSEmitter) ((IMXMLBlockWalker) getMXMLWalker())
@@ -246,9 +248,6 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
 
         emitHeader(node);
 
-        write(subDocuments.toString());
-        writeNewline();
-
         emitClassDeclStart(cname, node.getBaseClassName(), false);
 
         emitComplexInitializers(node);
@@ -259,6 +258,9 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
 
         emitMetaData(cdef);
 
+        write(subDocuments.toString());
+        writeNewline();
+
         emitScripts();
 
         fjs.getBindableEmitter().emit(cdef);
@@ -318,7 +320,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                 .getASEmitter();
         ((JSFlexJSEmitter) asEmitter).getModel().pushClass(cdef);
-
+        
         IASNode classNode = node.getContainedClassDefinitionNode();
         // visit tags
         final int len = classNode.getChildCount();
@@ -329,6 +331,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
 
         String cname = cdef.getQualifiedName();
         subDocumentNames.add(cname);
+        ((JSFlexJSEmitter) asEmitter).mxmlEmitter = this;
         String baseClassName = cdef.getBaseClassAsDisplayString();
 
         emitClassDeclStart(cname, baseClassName, false);
@@ -366,6 +369,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         inMXMLContent = oldInMXMLContent;
         classDefinition = oldClassDef;
         ((JSFlexJSEmitter) asEmitter).getModel().popClass();
+        ((JSFlexJSEmitter) asEmitter).mxmlEmitter = null;
 
     }
 
@@ -1929,6 +1933,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         MXMLDescriptorSpecifier ps = getCurrentDescriptor("ps");
         ps.value = "new " + formatQualifiedName("org.apache.flex.core.ClassFactory") + "(";
 
+        ps.value += formatQualifiedName(documentDefinition.getQualifiedName()) + ".";
         ps.value += formatQualifiedName(node.getName());
         ps.value += ")";
         
@@ -1939,6 +1944,14 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         setBufferWrite(false);
     }
 
+    @Override
+    protected void setBufferWrite(boolean value)
+    {
+    	super.setBufferWrite(value);
+        IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker()).getASEmitter();
+        ((JSFlexJSEmitter)asEmitter).setBufferWrite(value);
+    }
+    
     //--------------------------------------------------------------------------
     //    JS output
     //--------------------------------------------------------------------------
@@ -2146,7 +2159,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         }
     }
 
-    protected String formatQualifiedName(String name)
+    public String formatQualifiedName(String name)
     {
     	return formatQualifiedName(name, true);
     }
@@ -2158,6 +2171,8 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     		return name;
     	name = name.replaceAll("\\.", "_");
     	*/
+    	if (subDocumentNames.contains(name))
+    		return documentDefinition.getQualifiedName() + "." + name;
 		if (useName && !usedNames.contains(name))
 			usedNames.add(name);
     	return name;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/47852ab4/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/jsc/MXMLJSCJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/jsc/MXMLJSCJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/jsc/MXMLJSCJSEmitter.java
index 184158b..088ee62 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/jsc/MXMLJSCJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/jsc/MXMLJSCJSEmitter.java
@@ -38,7 +38,7 @@ public class MXMLJSCJSEmitter extends MXMLFlexJSEmitter implements
 	}
 
 	@Override
-	protected String formatQualifiedName(String name)
+	public String formatQualifiedName(String name)
     {
     	return name;
     }


Mime
View raw message