You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/01/11 21:20:59 UTC
svn commit: r1432261 [1/2] - in /flex/falcon/trunk/compiler.js:
src/org/apache/flex/compiler/clients/
src/org/apache/flex/compiler/internal/as/codegen/
src/org/apache/flex/compiler/internal/driver/
src/org/apache/flex/compiler/internal/legacy/ src/org/...
Author: aharui
Date: Fri Jan 11 20:20:58 2013
New Revision: 1432261
URL: http://svn.apache.org/viewvc?rev=1432261&view=rev
Log:
FalconJS can now handle enough MXML to compile the asjs demo. The output for both AS and MXML uses "goog".
MXML doesn't support binding syntax and probably lots of other things yet. It is only good enough for the demo.
The goog output seems to 'gjslint' ok. It will still complain about line-length, missing JSDoc comments, and strings with double-quotes.
The output is a series of js files. FalconJS already has code paths to call GoogleClosure, but they are disabled at this time.
Added:
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSMXMLClassDirectiveProcessor.java (with props)
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSMXMLEmitter.java (with props)
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/projects/
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java (with props)
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/problems/
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/problems/MXMLNotImplementedProblem.java (with props)
Modified:
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSClassDirectiveProcessor.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSEmitter.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGeneratingReducer.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGenerator.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGlobalDirectiveProcessor.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSSharedData.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/IBackend.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSBackend.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/legacy/ASDefinitionFilter.java
flex/falcon/trunk/compiler.js/tests/TestApp.as
Modified: flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java?rev=1432261&r1=1432260&r2=1432261&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java (original)
+++ flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java Fri Jan 11 20:20:58 2013
@@ -56,7 +56,9 @@ import org.apache.flex.compiler.exceptio
import org.apache.flex.compiler.exceptions.ConfigurationException.MustSpecifyTarget;
import org.apache.flex.compiler.exceptions.ConfigurationException.OnlyOneSource;
import org.apache.flex.compiler.filespecs.IFileSpecification;
+import org.apache.flex.compiler.internal.as.codegen.CodeGeneratorManager;
import org.apache.flex.compiler.internal.as.codegen.JSGeneratingReducer;
+import org.apache.flex.compiler.internal.as.codegen.JSGenerator;
import org.apache.flex.compiler.internal.as.codegen.JSSharedData;
import org.apache.flex.compiler.internal.as.codegen.JSWriter;
import org.apache.flex.compiler.internal.config.localization.LocalizationManager;
@@ -67,6 +69,7 @@ import org.apache.flex.compiler.internal
import org.apache.flex.compiler.internal.graph.GraphMLWriter;
import org.apache.flex.compiler.internal.projects.CompilerProject;
import org.apache.flex.compiler.internal.projects.DefinitionPriority;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
import org.apache.flex.compiler.internal.projects.FlexProject;
import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
import org.apache.flex.compiler.internal.projects.DefinitionPriority.BasePriority;
@@ -75,6 +78,7 @@ import org.apache.flex.compiler.internal
import org.apache.flex.compiler.internal.scopes.ASProjectScope.DefinitionPromise;
import org.apache.flex.compiler.internal.targets.LinkageChecker;
import org.apache.flex.compiler.internal.targets.Target;
+import org.apache.flex.compiler.internal.tree.mxml.MXMLClassDefinitionNode;
import org.apache.flex.compiler.internal.units.ABCCompilationUnit;
import org.apache.flex.compiler.internal.units.ResourceModuleCompilationUnit;
import org.apache.flex.compiler.internal.units.SWCCompilationUnit;
@@ -257,7 +261,8 @@ public class MXMLJSC
{
JSSharedData.backend = backend;
workspace = new Workspace();
- project = new FlexProject(workspace);
+ project = new FlexJSProject(workspace);
+ MXMLClassDefinitionNode.GENERATED_ID_BASE = "$ID";
problems = new ProblemQuery();
JSSharedData.OUTPUT_EXTENSION = backend.getOutputExtension();
JSSharedData.workspace = workspace;
@@ -334,6 +339,7 @@ public class MXMLJSC
protected boolean configure(final String[] args)
{
project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
+ CodeGeneratorManager.setFactory(JSGenerator.getABCGeneratorFactory());
projectConfigurator = createConfigurator();
try
@@ -484,7 +490,8 @@ public class MXMLJSC
List<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
for (final ICompilationUnit cu : reachableCompilationUnits)
{
- if (cu.getCompilationUnitType() == UnitType.AS_UNIT && cu != mainCU)
+ if ((cu.getCompilationUnitType() == UnitType.AS_UNIT ||
+ cu.getCompilationUnitType() == UnitType.MXML_UNIT) && cu != mainCU)
{
final File outputClassFile = new File(outputFolder.getAbsolutePath() + File.separator + cu.getShortNames().get(0) + ".js");
System.out.println(outputClassFile.getAbsolutePath());
@@ -878,6 +885,7 @@ public class MXMLJSC
if (getTargetSettings() == null)
return false;
+ project.setTargetSettings(getTargetSettings());
target = (JSTarget)JSSharedData.backend.createSWFTarget(project, getTargetSettings(), null);
return true;
Modified: flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSClassDirectiveProcessor.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSClassDirectiveProcessor.java?rev=1432261&r1=1432260&r2=1432261&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSClassDirectiveProcessor.java (original)
+++ flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSClassDirectiveProcessor.java Fri Jan 11 20:20:58 2013
@@ -27,9 +27,11 @@ import org.apache.flex.abc.visitors.ITra
import org.apache.flex.abc.visitors.ITraitsVisitor;
import org.apache.flex.abc.semantics.MethodInfo;
import org.apache.flex.abc.semantics.Name;
+import org.apache.flex.abc.semantics.Namespace;
import org.apache.flex.abc.semantics.Trait;
import org.apache.flex.abc.instructionlist.InstructionList;
import org.apache.flex.compiler.common.ASModifier;
+import org.apache.flex.compiler.internal.as.codegen.ICodeGenerator.IConstantValue;
import org.apache.flex.compiler.internal.definitions.ClassDefinition;
import org.apache.flex.compiler.internal.definitions.DefinitionBase;
import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
@@ -203,10 +205,18 @@ public class JSClassDirectiveProcessor e
boolean is_static = var.hasModifier(ASModifier.STATIC);
boolean is_const = SemanticUtils.isConst(var, classScope.getProject());
-
+ // simple initializers for public/protected vars go right on prototype.
+ // the rest (all private vars), all "complex" initializers (like array) get
+ // initialized in the constructor
+ boolean needs_constructor_init = true;
+
// generateConstantValue() returns null if no constant value
// can be generated, and null is the correct value for "no value."
- Object initializer = m_generator.generateConstantValue(var.getAssignedValueNode(), this.classScope.getProject());
+ IConstantValue constantValue = m_generator.generateConstantValue(var.getAssignedValueNode(), this.classScope.getProject());
+
+ // initializer is null if no constant value
+ // can be generated, and null is the correct value for "no value."
+ Object initializer = constantValue != null ? constantValue.getValue() : null;
ITraitVisitor tv = declareVariable(var, varDef, is_static, is_const, initializer);
@@ -249,10 +259,16 @@ public class JSClassDirectiveProcessor e
final byte kind = t.getKind();
if (kind == TRAIT_Const || kind == TRAIT_Var)
{
+ boolean is_private = false;
final Name name = t.getNameAttr(Trait.TRAIT_NAME);
+ Namespace ns = name.getSingleQualifier();
+ if (ns.getKind() == CONSTANT_PrivateNs)
+ is_private = true;
if (name.getBaseName().equals(varName))
{
t.setAttr(Trait.SLOT_VALUE, varInit);
+ if (!is_private)
+ needs_constructor_init = false;
break;
}
}
@@ -272,7 +288,7 @@ public class JSClassDirectiveProcessor e
cinitInsns.addAll(init_expression);
}
- else
+ else if (needs_constructor_init)
iinitInsns.addAll(init_expression);
}
}
Modified: flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSEmitter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSEmitter.java?rev=1432261&r1=1432260&r2=1432261&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSEmitter.java (original)
+++ flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSEmitter.java Fri Jan 11 20:20:58 2013
@@ -24,6 +24,7 @@ import static org.apache.flex.abc.ABCCon
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -73,6 +74,8 @@ import org.apache.flex.compiler.internal
import org.apache.flex.compiler.internal.legacy.ASDefinitionFilter.SearchScopeValue;
import org.apache.flex.compiler.internal.legacy.ASScopeUtils;
import org.apache.flex.compiler.internal.legacy.MemberedDefinitionUtils;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
import org.apache.flex.compiler.projects.ICompilerProject;
import org.apache.flex.compiler.scopes.IASScope;
import org.apache.flex.compiler.tree.as.IImportNode.ImportKind;
@@ -94,7 +97,7 @@ public class JSEmitter implements IABCVi
protected Set<String> m_importNames = new TreeSet<String>();
protected Set<String> m_useNames = new TreeSet<String>();
- private Vector<EmitterClassVisitor> definedClasses = new Vector<EmitterClassVisitor>();
+ protected Vector<EmitterClassVisitor> definedClasses = new Vector<EmitterClassVisitor>();
private Vector<MethodInfo> methodInfos = new Vector<MethodInfo>();
private Vector<MethodBodyInfo> methodBodies = new Vector<MethodBodyInfo>();
private Vector<ScriptInfo> scriptInfos = new Vector<ScriptInfo>();
@@ -108,6 +111,7 @@ public class JSEmitter implements IABCVi
// private ICompilationUnit.Operation m_buildPhase;
private IABCVisitor m_visitor = null;
protected ICompilerProject m_project = null;
+ private JSGenerator m_generator = null;
private IASScope m_currentScope = null;
protected Map<MethodInfo, FunctionDefinition> m_methodInfoToDefinition = new HashMap<MethodInfo, FunctionDefinition>();
protected Map<FunctionDefinition, MethodInfo> m_definitionToMethodInfo = new HashMap<FunctionDefinition, MethodInfo>();
@@ -115,13 +119,15 @@ public class JSEmitter implements IABCVi
public JSEmitter(JSSharedData sharedData,
ICompilationUnit.Operation buildPhase,
- ICompilerProject project)
+ ICompilerProject project,
+ JSGenerator generator)
{
this.w = new JSOutputStream();
m_sharedData = sharedData;
m_currentClassVisitor = null;
// m_buildPhase = buildPhase;
m_project = project;
+ m_generator = generator;
}
protected void writeString(String str)
@@ -243,7 +249,7 @@ public class JSEmitter implements IABCVi
}
}
else
- emitTraits(traits, true, isExtern, isInterface, isPackageFunction, ctor, packageName, className, superClass, "", ":", ",", isExtern ? EXTERN_PREFIX : "\t");
+ emitTraits(traits, true, isExtern, isInterface, isPackageFunction, ctor, packageName, className, superClass, "this.", "", ",", isExtern ? EXTERN_PREFIX : " ");
}
protected Boolean isExtern(Name name)
@@ -327,94 +333,6 @@ public class JSEmitter implements IABCVi
if (superClass.isEmpty())
superClass = "Object";
- // add _PACKAGE member to class
- if (packageName.isEmpty())
- {
- // add _PACKAGE member to class
- writeString("/**\n");
- writeString(" * Member: " + fullClassName + "_PACKAGE\n");
- writeString(" * @const\n");
- writeString(" * @type {" + fullClassNameWithoutDot + "}\n");
- writeString(" */\n");
- writeString(fullClassName + "_PACKAGE = adobe.globals;\n");
- writeString("\n");
- }
- else
- {
- // add _PACKAGE member to class
- writeString("/**\n");
- writeString(" * Member: " + fullClassName + "_PACKAGE\n");
- writeString(" * @const\n");
- writeString(" * @type {" + packageName + "}\n");
- writeString(" */\n");
- writeString(fullClassName + "_PACKAGE = " + packageName + ";\n");
- writeString("\n");
- }
-
- // add _NAME member to class
- writeString("\n");
- writeString("/**\n");
- writeString(" * Member: " + fullClassName + "_NAME\n");
- writeString(" * @const\n");
- writeString(" * @type {string}\n");
- writeString(" */\n");
- writeString(fullClassName + "_NAME = \"" + className + "\";\n");
-
- // add _FULLNAME member to class
- writeString("\n");
- writeString("/**\n");
- writeString(" * Member: " + fullClassName + "_FULLNAME\n");
- writeString(" * @const\n");
- writeString(" * @type {string}\n");
- writeString(" */\n");
- writeString(fullClassName + "_FULLNAME = \"" + fullClassNameWithoutDot + "\";\n");
-
- // add _SUPER member to class
- writeString("\n");
- writeString("/**\n");
- writeString(" * Member: " + fullClassName + "_SUPER\n");
- writeString(" * @const\n");
- writeString(" * @type {" + superClass + "}\n");
- writeString(" */\n");
- writeString(fullClassName + "_SUPER = " + superClass + ";\n");
-
- // add _DYNAMIC member to class
- if (isDynamic)
- {
- writeString("\n");
- writeString("/**\n");
- writeString(" * Member: " + fullClassName + "_DYNAMIC\n");
- writeString(" * @const\n");
- writeString(" * @type {boolean}\n");
- writeString(" */\n");
- writeString(fullClassName + "_DYNAMIC = true;\n");
- }
-
- // add _FINAL member to class
- if (isFinal)
- {
- writeString("\n");
- writeString("/**\n");
- writeString(" * Member: " + fullClassName + "_FINAL\n");
- writeString(" * @const\n");
- writeString(" * @type {boolean}\n");
- writeString(" */\n");
- writeString(fullClassName + "_FINAL = true;\n");
- }
-
- // Symbol support
- if (isSymbolClass(className))
- {
- // add instance member to class
- writeString("\n");
- writeString("/**\n");
- writeString(" * Member: " + fullClassName + JSSharedData.SYMBOL_INSTANCE + "\n");
- writeString(" * @const\n");
- writeString(" * @type {" + className + "}\n");
- writeString(" */\n");
- writeString(fullClassName + JSSharedData.SYMBOL_INSTANCE + " = null;\n");
- }
-
// Namespace support
final IDefinition def = JSSharedData.instance.getDefinition(fullClassNameWithoutDot);
if (def != null)
@@ -588,7 +506,7 @@ public class JSEmitter implements IABCVi
comma = true;
for (Namespace ns : nsset)
{
- names += "\t\"" + mangleName(name.getBaseName(), ns) + "\" : true";
+ names += " \"" + mangleName(name.getBaseName(), ns) + "\" : true";
}
}
}
@@ -622,7 +540,7 @@ public class JSEmitter implements IABCVi
names += ",\n";
else
comma = true;
- names += ("\t\"" + ns.getURI().replaceAll(":", ".") + "\" : \"" + uses + "\"");
+ names += (" \"" + ns.getURI().replaceAll(":", ".") + "\" : \"" + uses + "\"");
}
}
@@ -688,11 +606,11 @@ public class JSEmitter implements IABCVi
writeString(fullName + "._CLASSINFO =\n");
writeString("{\n");
- final String indent = "\t";
- final String indent2 = "\t\t";
- final String indent3 = "\t\t\t";
- final String indent4 = "\t\t\t\t";
- final String indent5 = "\t\t\t\t\t";
+ final String indent = " ";
+ final String indent2 = " ";
+ final String indent3 = " ";
+ final String indent4 = " ";
+ final String indent5 = " ";
// add name, bases, isDynamic, isFinal, isStatic
final InstanceInfo iinfo = clz.instanceInfo;
@@ -895,23 +813,23 @@ public class JSEmitter implements IABCVi
s += indent + "{\n";
for (Metadata md : metaData)
{
- s += indent + "\t" + md.getName() + ":\n";
- s += indent + "\t{\n";
- s += indent + "\t\t" + "name : \"" + md.getName() + "\",\n";
+ s += indent + " " + md.getName() + ":\n";
+ s += indent + " {\n";
+ s += indent + " " + "name : \"" + md.getName() + "\",\n";
final String[] keys = md.getKeys();
if (keys.length > 0)
{
final String[] values = md.getValues();
- s += indent + "\t\t" + "value:\n";
- s += indent + "\t\t" + "{\n";
+ s += indent + " " + "value:\n";
+ s += indent + " " + "{\n";
for (int i = 0; i < keys.length; ++i)
{
- s += indent + "\t\t\t" + keys[i] + ": {key: \"" + keys[i] + "\", value: \"" + values[i] + "\"},\n";
+ s += indent + " " + keys[i] + ": {key: \"" + keys[i] + "\", value: \"" + values[i] + "\"},\n";
}
- s += indent + "\t\t" + "}\n";
+ s += indent + " " + "}\n";
}
- s += indent + "\t},\n";
+ s += indent + " },\n";
}
s += indent + "}\n";
}
@@ -1018,25 +936,10 @@ public class JSEmitter implements IABCVi
if (!body.isEmpty() || JSSharedData.instance.hasClassInit(fullName))
{
- writeString("\n" + indent + "// Constructor\n");
+ // writeString("\n" + indent + "// Constructor\n");
m_methodPrologue = "";
- // cleaning up static inits.
- if (JSSharedData.instance.hasClassInit(fullName))
- m_methodPrologue += "\t" + fullName + "." + JSSharedData.STATIC_INIT + "();\n";
-
- // derived class without ctor don't call super()
- // AJH remove for now
- // if (!body.contains("goog.base(") && !JSGeneratingReducer.isDataType(superClassName))
- // m_methodPrologue += "\tgoog.base(this);\n";
-
- if (!JSSharedData.m_useSelfParameter && !body.contains("var self "))
- m_methodPrologue += "\tvar self = this;\n";
-
- if (!body.contains("return " + JSSharedData.THIS + ";"))
- m_methodPostlogue += "\treturn " + JSSharedData.THIS + ";\n";
-
final Boolean isPackageFunction = false;
if (JSSharedData.m_useClosureLib)
{
@@ -1044,9 +947,10 @@ public class JSEmitter implements IABCVi
emitMethod(null, ctor, isFramework, isExtern, isInterface, isPackageFunction, fullName, className, "", pkg, assignmentOp, separator, indent);
}
else
- emitMethod(null, ctor, isFramework, isExtern, isInterface, isPackageFunction, fullName, JSSharedData.CTOR_NAME, "", methodPrefix, assignmentOp, separator, indent);
-
- writeString("\n");
+ {
+ MethodBodyInfo mbi = findMethodBodyInfo(ctor);
+ emitMethodBody(mbi);
+ }
}
else
{
@@ -1057,7 +961,6 @@ public class JSEmitter implements IABCVi
// inherits
if (JSSharedData.m_useClosureLib && (!JSGeneratingReducer.isDataType(superClassName) || superClassName.equals("Error")))
{
- writeString("\n\n");
writeString("goog.inherits("
+ fullName + ", "
+ superClassName + ");\n");
@@ -1158,7 +1061,7 @@ public class JSEmitter implements IABCVi
protected Boolean emitVariable(Trait t, String baseName,
String packageName, String className, String superClassName,
- String methodPrefix, String assignmentOp, String separator, String indent) throws Exception
+ String methodPrefix, String assignment, String separator, String indent) throws Exception
{
Boolean needsSkinPartProcessing = false;
final Name name = t.getNameAttr("name");
@@ -1166,7 +1069,7 @@ public class JSEmitter implements IABCVi
// JSDoc
List<String> jsdoc = new ArrayList<String>();
- jsdoc.add("Member: " + createFullName(packageName, className + "." + baseName));
+ // jsdoc.add("Member: " + createFullName(packageName, className + "." + baseName));
if (name != null)
{
@@ -1175,6 +1078,8 @@ public class JSEmitter implements IABCVi
jsdoc.add("@private");
else if (ns.getKind() == CONSTANT_ProtectedNs)
jsdoc.add("@protected");
+ else
+ jsdoc.add("@expose");
}
if (t.getKind() == TRAIT_Const)
jsdoc.add("@const");
@@ -1201,18 +1106,7 @@ public class JSEmitter implements IABCVi
}
}
- writeString(indent + methodPrefix + baseName + " ");
-
- if (type != null)
- writeString("/* : " + JSGeneratingReducer.getBasenameFromName(type) + " */ ");
-
- writeString(assignmentOp + " ");
-
- writeString(emitSlotValue(t));
-
- // for ";"
- if (!separator.equals(","))
- writeString(separator + "\n");
+ writeString(indent + methodPrefix + baseName + assignment + ";\n\n");
// Examine var/const metadata
final Vector<Metadata> metaData = t.getMetadata();
@@ -1228,7 +1122,7 @@ public class JSEmitter implements IABCVi
return needsSkinPartProcessing;
}
- private void emitTraits(Traits traits,
+ protected void emitTraits(Traits traits,
Boolean isInstanceTraits, Boolean isExtern, Boolean isInterface, Boolean isPackageFunction,
MethodInfo ctor, String packageName, String className, String superClassName,
String methodPrefix, String assignmentOp, String separator, String indent) throws Exception
@@ -1254,7 +1148,6 @@ public class JSEmitter implements IABCVi
{
emitCtor(ctor, isExtern, isInterface, packageName, className, superClassName,
methodPrefix, assignmentOp, separator, indent);
- emitComma = true;
}
// Avoid emitting duplicate Traits, which starts happening after adding
@@ -1274,6 +1167,9 @@ public class JSEmitter implements IABCVi
case TRAIT_Const:
final Name name = t.getNameAttr("name");
+ Namespace ns = name.getSingleQualifier();
+ if (ns.getKind() != CONSTANT_PrivateNs)
+ break;
final String baseName = JSGeneratingReducer.getBasenameFromName(name);
if (!visitedTraits.contains(baseName))
@@ -1302,17 +1198,13 @@ public class JSEmitter implements IABCVi
if (emitVar)
{
- if (emitComma)
- writeString(separator + "\n");
- else
- emitComma = separator.equals(",");
+ writeString("\n");
- boolean methodNeedsSkinPartProcessing = emitVariable(t, baseName,
- packageName, className, superClassName,
- methodPrefix, assignmentOp, separator, indent);
-
- needsSkinPartProcessing = needsSkinPartProcessing || methodNeedsSkinPartProcessing;
+ boolean methodNeedsSkinPartProcessing = emitVariable(t, baseName,
+ packageName, className, superClassName,
+ methodPrefix, assignmentOp, separator, indent);
+ needsSkinPartProcessing = needsSkinPartProcessing || methodNeedsSkinPartProcessing;
// print warning in cases where FJS-24 is being hit
String fullName = createFullName(packageName, className);
if (!fullName.isEmpty())
@@ -1333,14 +1225,103 @@ public class JSEmitter implements IABCVi
break;
case TRAIT_Class:
// TODO: non-zero slot id
- // writeString( "\n\t// ClassInfo: " + ((ClassInfo)t.getAttr(Trait.TRAIT_CLASS)).toString() + "\n" );
+ // writeString( "\n // ClassInfo: " + ((ClassInfo)t.getAttr(Trait.TRAIT_CLASS)).toString() + "\n" );
break;
default:
throw new IllegalArgumentException("Unknown trait kind " + t.getKind());
}
}
+ if (isInstanceTraits && ctor != null)
+ {
+ writeString("};\n"); // end of constructor
+ final String cName = createFullName(packageName, className);
+ writeString("goog.inherits(" + cName + ", " + superClassName + ");\n");
+ }
+
+ // 3. emit public vars
+ for (Trait t : traits)
+ {
+ // Get the kind byte with its flags set in the high nibble.
+ switch (t.getKind())
+ {
+ case TRAIT_Var:
+ case TRAIT_Const:
+
+ final Name name = t.getNameAttr("name");
+ Namespace ns = name.getSingleQualifier();
+ if (ns.getKind() == CONSTANT_PrivateNs)
+ break;
+ final String baseName = JSGeneratingReducer.getBasenameFromName(name);
+
+ if (!visitedTraits.contains(baseName))
+ {
+ visitedTraits.add(baseName);
+
+ // see JSGlobalDirectiveProcessor::declareFunction.
+ // Functions at the global scope create a var of type '*'
+ Boolean emitVar = true;
+ if (isPackageFunction)
+ {
+ final Name type = t.getNameAttr("type");
+ if (type == null || type.equals("Function"))
+ {
+ for (MethodInfo mi : methodInfos)
+ {
+ if (mi.getMethodName() != null && mi.getMethodName().equals(baseName))
+ {
+ emitMethod(t, mi, isFramework, isExtern, isInterface, isPackageFunction, baseName, baseName, "", "var ", assignmentOp, separator, indent);
+ emitVar = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (emitVar)
+ {
+ String slotValue = (String)t.getAttr(Trait.SLOT_VALUE);
+ if (slotValue == null)
+ slotValue = "";
+ else
+ {
+ slotValue = " = " + slotValue;
+ }
+ writeString("\n");
+
+ boolean methodNeedsSkinPartProcessing = emitVariable(t, baseName,
+ packageName, className, superClassName,
+ (packageName == "") ? className + ".prototype." :
+ packageName + "." + className + ".prototype.", slotValue, "", "");
+
+ needsSkinPartProcessing = needsSkinPartProcessing || methodNeedsSkinPartProcessing;
+ // print warning in cases where FJS-24 is being hit
+ String fullName = createFullName(packageName, className);
+ if (!fullName.isEmpty())
+ fullName += ".";
+ fullName += baseName;
- // 3. emit all other methods (ctor already emitted)
+ warnIfPrivateNameCollision(baseClass, filter, baseName, fullName, "Field");
+ }
+ }
+ break;
+ case TRAIT_Method:
+ case TRAIT_Function:
+ case TRAIT_Getter:
+ case TRAIT_Setter:
+ {
+ // methods will be processed below.
+ }
+ break;
+ case TRAIT_Class:
+ // TODO: non-zero slot id
+ // writeString( "\n // ClassInfo: " + ((ClassInfo)t.getAttr(Trait.TRAIT_CLASS)).toString() + "\n" );
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown trait kind " + t.getKind());
+ }
+ }
+
+ // 4. emit all other methods (ctor already emitted)
for (Trait t : traits)
{
// Get the kind byte with its flags set in the high nibble.
@@ -1354,10 +1335,6 @@ public class JSEmitter implements IABCVi
// we can't emit getter and setter for extern declarations.
if (!isExtern || t.getKind() != TRAIT_Setter)
{
- if (emitComma)
- writeString(separator + "\n");
- else
- emitComma = separator.equals(",");
// write out full function name with package.
Name name = t.getNameAttr("name");
@@ -1371,7 +1348,7 @@ public class JSEmitter implements IABCVi
// cleaning up static inits.
// Static initializer is generated but not called for classes without explicit constructor
if ((!isInstanceTraits || ctor == null) && JSSharedData.instance.hasClassInit(fullName))
- m_methodPrologue += "\t\t" + fullName + "." + JSSharedData.STATIC_INIT + "();\n";
+ m_methodPrologue += " " + fullName + "." + JSSharedData.STATIC_INIT + "();\n";
if (!isExtern)
{
@@ -1390,7 +1367,9 @@ public class JSEmitter implements IABCVi
isExtern = isExtern(name);
// actually emit the JS code
- emitMethod(t, mi, isFramework, isExtern, isInterface, isPackageFunction, fullName, baseName, xetter, methodPrefix, assignmentOp, separator, indent);
+ emitMethod(t, mi, isFramework, isExtern, isInterface, isPackageFunction, fullName, baseName, xetter,
+ (packageName == "") ? className + ".prototype." :
+ packageName + "." + className + ".prototype." , "=", "", "");
// print warning in cases where FJS-24 is being hit
warnIfPrivateNameCollision(baseClass, filter, baseName, fullName, "Method");
@@ -1400,7 +1379,7 @@ public class JSEmitter implements IABCVi
}
}
- // 4. custom methods generated from metadata
+ // 5. custom methods generated from metadata
if (needsSkinPartProcessing)
{
if (emitComma)
@@ -1425,7 +1404,7 @@ public class JSEmitter implements IABCVi
final String fullName = createFullName(packageName, className);
- // writeString( "\n\t// Static inits:\n" );
+ // writeString( "\n // Static inits:\n" );
emitMethod(null, ctor, isFramework, isExtern, isInterface, isPackageFunction, fullName, null, "", methodPrefix, assignmentOp, separator, indent);
}
}
@@ -1461,7 +1440,7 @@ public class JSEmitter implements IABCVi
writeString("function() /* : Object */\n");
writeString("{\n");
- indent = "\t\t";
+ indent = " ";
writeString(indent + "return " + jsonResult + ";\n");
writeString("}");
@@ -1558,6 +1537,7 @@ public class JSEmitter implements IABCVi
writeString(indent + "\n\n");
writeString(indent + "/**\n");
+ /*
if (isCtor)
{
writeString(indent + " * Constructor: " + fullName + "()\n");
@@ -1571,7 +1551,7 @@ public class JSEmitter implements IABCVi
{
writeString(indent + " * Method: " + fullName + "()\n");
}
-
+ */
if (!isInterface)
{
if (fullName.contains("."))
@@ -1592,6 +1572,8 @@ public class JSEmitter implements IABCVi
writeString(indent + " * @private\n");
else if (ns.getKind() == CONSTANT_ProtectedNs)
writeString(indent + " * @protected\n");
+ else
+ writeString(indent + " * @expose\n");
}
if (t.isOverride() ||
(t.hasAttr("override") && (Boolean)(t.getAttr("override")) == true))
@@ -1601,6 +1583,21 @@ public class JSEmitter implements IABCVi
}
}
+ emitJSDocForParams(mi, indent);
+
+ if (mi.getReturnType() != null && !JSGeneratingReducer.getBasenameFromName(mi.getReturnType()).equals("void"))
+ {
+ final StringBuilder sb = new StringBuilder();
+ JSGeneratingReducer.nameToJSDocType(m_project, mi.getReturnType(), sb);
+
+ writeString(indent + " * @return {" + sb.toString() + "}\n");
+ }
+
+ writeString(indent + " */\n");
+ }
+
+ private void emitJSDocForParams(MethodInfo mi, String indent)
+ {
Vector<PooledValue> defaultValues = mi.getDefaultValues();
Vector<Name> paramTypes = mi.getParamTypes();
List<String> paramNames = mi.getParamNames();
@@ -1631,7 +1628,7 @@ public class JSEmitter implements IABCVi
else
{
// param with default value
- writeString(indent + " * @param {" + argType + "=} " + argName);
+ writeString(indent + " * @param {" + argType + "} " + JSSharedData.DEFAULT_PARAM_PREFIX + argName);
String defaultVal = "undefined";
PooledValue val = defaultValues.elementAt(nthParam - defaultsStartAt);
@@ -1672,23 +1669,14 @@ public class JSEmitter implements IABCVi
break;
}
}
- writeString(" Defaults to " + defaultVal + "\n");
+ writeString(" Defaults to " + defaultVal + ".\n");
}
}
nthParam++;
}
- if (mi.getReturnType() != null && !JSGeneratingReducer.getBasenameFromName(mi.getReturnType()).equals("void"))
- {
- final StringBuilder sb = new StringBuilder();
- JSGeneratingReducer.nameToJSDocType(m_project, mi.getReturnType(), sb);
-
- writeString(indent + " * @return {" + sb.toString() + "}\n");
- }
-
- writeString(indent + " */\n");
}
-
+
protected Boolean isPackageFunction(MethodInfo mi)
{
final FunctionDefinition fdef = m_methodInfoToDefinition.get(mi);
@@ -1779,8 +1767,8 @@ public class JSEmitter implements IABCVi
writeString(")");
// return type
- if (mi.getReturnType() != null)
- writeString(" /* : " + JSGeneratingReducer.getBasenameFromName(mi.getReturnType()) + " */");
+ // if (mi.getReturnType() != null)
+ // writeString(" /* : " + JSGeneratingReducer.getBasenameFromName(mi.getReturnType()) + " */");
if (isInterface)
{
@@ -1796,7 +1784,7 @@ public class JSEmitter implements IABCVi
writeString(a_priori_insns);
}
emitMethodBody(mbi);
- writeString(indent + "}");
+ writeString(indent + "};");
}
}
@@ -1816,7 +1804,7 @@ public class JSEmitter implements IABCVi
writeString(indent + staticInitName + " = ");
writeString("function() /* : void */\n");
writeString(indent + "{\n");
- writeString(indent + "\t" + staticInitName + " = " + JSSharedData.JS_EMPTY_FUNCTION + ";\n");
+ writeString(indent + " " + staticInitName + " = " + JSSharedData.JS_EMPTY_FUNCTION + ";\n");
// static init
emitMethodBody(mbi);
@@ -1828,7 +1816,7 @@ public class JSEmitter implements IABCVi
private void emitScriptInfo(ScriptInfo info) throws Exception
{
// w.writeU30(getScriptId(info.getInitId()));
- // emitTraits(info.getTraits(), "", "\t" );
+ // emitTraits(info.getTraits(), "", " " );
final Object init_id = info.getInit();
;
@@ -1845,7 +1833,7 @@ public class JSEmitter implements IABCVi
scriptInfos.append("// ScriptInfo \n");
scriptInfos.append("{\n");
- scriptInfos.append("\tvar " + JSSharedData.THIS + " = ");
+ scriptInfos.append(" var " + JSSharedData.THIS + " = ");
if (m_packageName != null && !m_packageName.isEmpty())
{
scriptInfos.append(m_packageName + ";\n");
@@ -1935,7 +1923,7 @@ public class JSEmitter implements IABCVi
* private String indentBlock( String block, int indentBy ) { Boolean
* firstPart = true; String s = ""; String[] parts = block.split( "\n" );
* for( String part : parts ) { if( firstPart ) firstPart = false; else s +=
- * "\n"; for( int i = 0; i < indentBy; ++i ) s += "\t"; s += part; } return
+ * "\n"; for( int i = 0; i < indentBy; ++i ) s += " "; s += part; } return
* s; } private void emitNamespace(Namespace ns) { w.write(ns.getKind());
* w.writeU30(stringPool.id(ns.getName())); }
*/
@@ -3214,21 +3202,58 @@ public class JSEmitter implements IABCVi
// TODO: Special case: className.equals( "Package" )
- // JSDoc
- writeString("/**\n");
- writeString(" * " + JSGeneratingReducer.getTimeStampString());
- writeString(" *\n");
- if (className.isEmpty())
- writeString(" * Function: \n");
+ if (className.isEmpty());
else if (classDef != null)
- writeString(" * Class: " + classDef.getQualifiedName() + "\n");
+ {
+ String classQName = classDef.getQualifiedName();
+ writeString("goog.provide('" + classQName + "');\n\n");
+ FlexJSProject project = (FlexJSProject)m_project;
+ ArrayList<String> deps = project.getRequires(m_generator.m_compilationUnit);
+ Collections.sort(deps);
+ String lastOne = "";
+ for (String imp : deps)
+ {
+ if (imp.indexOf("__AS3__") != -1)
+ continue;
+ if (imp.equals(classQName))
+ continue;
+ if (imp.equals("Array"))
+ continue;
+ if (imp.equals("Boolean"))
+ continue;
+ if (imp.equals("Error"))
+ continue;
+ if (imp.equals("Function"))
+ continue;
+ if (imp.equals("Number"))
+ continue;
+ if (imp.equals("int"))
+ continue;
+ if (imp.equals("Object"))
+ continue;
+ if (imp.equals("String"))
+ continue;
+ if (imp.equals("uint"))
+ continue;
+ if (imp != lastOne)
+ writeString("goog.require('" + imp + "');\n");
+ lastOne = imp;
+ }
+ writeString("\n");
+ }
else
- writeString(" * Class: " + className + "\n");
+ writeString("goog.provide('" + className + "');\n");
- if (!JSGeneratingReducer.isDataType(superClassName))
+ final MethodInfo ctor = clz.instanceInfo.name == null ? null : clz.instanceInfo.iInit;
+ // first check whether there is any code...
+ final String body = getCodeForConstructor(ctor);
+
+ writeString("/**\n");
+ if (!JSGeneratingReducer.isDataType(superClassName) || !body.isEmpty())
{
writeString(" * @constructor\n");
- writeString(" * @extends " + superClassName + "\n");
+ writeString(" * @extends {" + superClassName + "}\n");
+ emitJSDocForParams(ctor, "");
}
writeString(" */\n");
@@ -3242,7 +3267,6 @@ public class JSEmitter implements IABCVi
// every class extends another class or Object except for the framework class.
if (!className.equals(JSSharedData.JS_FRAMEWORK_NAME))
{
- final MethodInfo ctor = clz.instanceInfo.name == null ? null : clz.instanceInfo.iInit;
if (JSSharedData.m_useClosureLib)
{
/*
@@ -3264,22 +3288,15 @@ public class JSEmitter implements IABCVi
*/
final String fullName = createFullName(packageName, className);
- writeString(fullName + " = " + JSSharedData.JS_FRAMEWORK_NAME + ".extend( \"" + className + "\", " + superClassName + ", {\n");
- emitInstanceTraits(clz.instanceTraits, ctor, packageName, className, superClassName, isExtern, isInterface, isPackageFunction);
- writeString("\n});\n\n");
- // don't add _CLASS to DataClass instances.
- final IDefinition def = JSSharedData.instance.getDefinition(fullName);
- if (def == null || !isDataClassDefinition(def))
- {
- // add _CLASS member to instance
- writeString("\n");
- writeString("/**\n");
- writeString(" * Member: " + fullName + ".prototype._CLASS\n");
- writeString(" * @const\n");
- writeString(" * @type {" + fullName + "}\n");
- writeString(" */\n");
- writeString(fullName + ".prototype._CLASS = " + fullName + ";\n");
+ writeString(fullName + " = function(");
+ String a_priori_insns = emitParameters(ctor);
+ writeString(") {\n");
+ writeString(" " + superClassName + ".call(this);\n\n");
+ if (!a_priori_insns.isEmpty())
+ {
+ writeString(a_priori_insns);
}
+ emitInstanceTraits(clz.instanceTraits, ctor, packageName, className, superClassName, isExtern, isInterface, isPackageFunction);
}
}
@@ -3290,25 +3307,6 @@ public class JSEmitter implements IABCVi
isExtern, isPackageFunction, isDynamicClass, isFinalClass,
provideName != null);
- if (!isExtern && provideName != null && !provideName.isEmpty())
- {
- emitNamespaceInfo(clz, packageName, className, superClassName);
- emitJSONInfo(clz, packageName, className, superClassName);
-
- if (className.equals(JSSharedData.JS_FRAMEWORK_NAME))
- {
- emitFrameworkInit();
- }
-
- // export symbols
- final String fullName = createFullName(packageName, className);
- // AJH remove for now
- // writeString("\ngoog.exportSymbol(\"" + fullName + "\", " + fullName + ", " + JSSharedData.JS_SYMBOLS + ");\n");
-
- // register class
- writeString("\n" + JSSharedData.JS_CLASSES + "[\"" + fullName + "\"] = " + fullName + ";\n");
- }
-
// constructor, ii.iInit is a MethodInfo
// w.writeU30(getMethodId(ii.iInit));
Modified: flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGeneratingReducer.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGeneratingReducer.java?rev=1432261&r1=1432260&r2=1432261&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGeneratingReducer.java (original)
+++ flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGeneratingReducer.java Fri Jan 11 20:20:58 2013
@@ -64,6 +64,7 @@ import org.apache.flex.compiler.definiti
import org.apache.flex.compiler.definitions.ITypeDefinition;
import org.apache.flex.compiler.definitions.IVariableDefinition;
import org.apache.flex.compiler.definitions.metadata.IMetaTag;
+import org.apache.flex.compiler.definitions.references.INamespaceReference;
import org.apache.flex.compiler.definitions.references.IReference;
import org.apache.flex.compiler.exceptions.DuplicateLabelException;
import org.apache.flex.compiler.filespecs.IFileSpecification;
@@ -91,6 +92,7 @@ import org.apache.flex.compiler.internal
import org.apache.flex.compiler.internal.scopes.ASFileScope;
import org.apache.flex.compiler.internal.scopes.ASProjectScope;
import org.apache.flex.compiler.internal.scopes.ASScope;
+import org.apache.flex.compiler.internal.scopes.ASScopeBase;
import org.apache.flex.compiler.internal.scopes.CatchScope;
import org.apache.flex.compiler.internal.semantics.SemanticUtils;
import org.apache.flex.compiler.internal.tree.as.BaseDefinitionNode;
@@ -1247,6 +1249,7 @@ public class JSGeneratingReducer
if (return_type != null)
usedTypes.add(getBasenameFromName(return_type));
+ // AJH removed use of 'self'
/*
* !isAnonymousFunction is necessary. AS and JS are different in the way
* "this" is being treated in anonymous functions. i.e. public function
@@ -1259,17 +1262,17 @@ public class JSGeneratingReducer
* localFunction : Function = funciton():void { // NOT EMITTED: var self
* = this; self.callMe(); }; };
*/
- if (!JSSharedData.m_useSelfParameter && !isAnonymousFunction &&
- /* TODO: !needsSelfParameter(createFullClassName(false)) && */function_body.contains(JSSharedData.THIS))
- {
+ //if (!JSSharedData.m_useSelfParameter && !isAnonymousFunction &&
+ // /* TODO: !needsSelfParameter(createFullClassName(false)) && */function_body.contains(JSSharedData.THIS))
+ //{
// final Binding fullClassName = makeBinding(createFullClassName(false));
// this.registerLocalVariable(currentScope, makeBinding("self"), fullClassName, fullClassName);
- final Binding fullClassName = new Binding(iNode, makeName(createFullClassName(false)), null);
- this.registerLocalVariable(currentScope, new Binding(iNode, makeName("self"), null), fullClassName, fullClassName);
- result += indentBlock("/** @type {" + createFullClassName(true) + "} */" + endl(), 1);
- result += indentBlock("var " + JSSharedData.THIS + " = this;" + endl(), 1);
- }
+ // final Binding fullClassName = new Binding(iNode, makeName(createFullClassName(false)), null);
+ // this.registerLocalVariable(currentScope, new Binding(iNode, makeName("self"), null), fullClassName, fullClassName);
+ // result += indentBlock("/** @type {" + createFullClassName(true) + "} */" + endl(), 1);
+ // result += indentBlock("var " + JSSharedData.THIS + " = this;" + endl(), 1);
+ //}
// Constructor-specific processing: add the instance initializers,
// add a constructsuper call if none exists.
@@ -1291,65 +1294,8 @@ public class JSGeneratingReducer
*/
}
- // http://livedocs.adobe.com/flex/3/html/help.html?content=basic_as_2.html
- // "If you define the constructor, but omit the call to super(), Flex automatically
- // calls super() at the beginning of your constructor."
- if (isCtor)
- {
- if (function_body.indexOf(JSSharedData.m_superCalledMarker) >= 0)
- function_body = function_body.replaceAll(JSSharedData.m_superCalledMarker, "");
- else if (!function_body.contains("goog.base(this")) // we're only looking for super(), so ignore adobe.base() case
- {
- String derivedFrom = getCurrentSuperClassName();
- if (derivedFrom != null && !isDataType(derivedFrom) && !derivedFrom.equals("Globals"))
- {
- String superCall = indent();
- if (JSSharedData.m_useClosureLib)
- {
- // superCall += "goog.base(" + JSSharedData.ROOT_NAME + getCurrentFullClassName() + " /*generateFunctionBody*/";
- // superCall += ""goog.base(this"" + JSSharedData.THIS + " /*generateFunctionBody isCtor*/";
- superCall += "goog.base(this";
- }
- else
- {
- if (m_convertToStatic)
- {
- String fullClassName = createFullClassName(false);
- if (m_sharedData.hasClass(makeName(fullClassName)))
- {
- fullClassName = getCurrentSuperClassFullName();
- superCall += createFullName(fullClassName, true) + ".init(";
- }
- else
- superCall += createFullClassName(true) + "." + JSSharedData._SUPER + ".init(";
- }
- else
- superCall += JSSharedData.THIS + "." + JSSharedData._SUPER + "(";
- if (JSSharedData.m_useSelfParameter)
- superCall += JSSharedData.THIS;
- }
- superCall += "); /* Call to super() was missing in ctor! */" + endl();
- function_body = superCall + function_body;
-
- // workaround for Falcon bug.
- // The checker throws NoDefaultConstructorInBaseClassProblem if the ctor signatures
- // of base class and extended class don't match.
- // currentScope.getMethodBodySemanticChecker().checkDefaultSuperCall(iNode);
- }
- }
- }
-
- result += indentBlock(function_body, 1);
-
- if (isCtor)
- {
- if (!result.contains(JSSharedData.THIS))
- {
- result += indentBlock("/** @type {" + createFullClassName(true) + "} */" + endl(), 1);
- result += indentBlock("var " + JSSharedData.THIS + " = this;" + endl(), 1);
- }
- result += indentBlock("return " + JSSharedData.THIS + ";" + endl(), 1);
- }
+ if (!function_body.isEmpty())
+ result += indentBlock(function_body, 1);
// popIndent();
// result += indent() + "}";
@@ -3940,7 +3886,7 @@ public class JSGeneratingReducer
*/
// statement = Pattern ifElseIf
- result += indent() + "if(" + (test) + ")" + endl();
+ result += indent() + "if (" + (test) + ")" + endl();
result += indent() + "{" + endl();
result += indentBlock(then, 1);
result += indent() + "}" + endl();
@@ -3955,7 +3901,7 @@ public class JSGeneratingReducer
ConditionalFragment alternative = if_elseif.elementAt(i);
if (!alternative.isUnconditionalAlternative())
{
- result += " if(" + alternative.condition + ")";
+ result += " if (" + alternative.condition + ")";
}
result += endl();
result += indent() + "{" + endl();
@@ -4139,14 +4085,16 @@ public class JSGeneratingReducer
public String reduce_mxmlEventSpecifier(IASNode iNode, Vector<String> stmts)
{
// TODO: Investigate optimizing.
- // String body = createInstruction(iNode);
+ String body = createInstruction(iNode);
/*
* // An MXMLEventSpecifierNode can have N child nodes which are
* statements. // We need to codegen all of them as an effective method
- * body. for ( String stmt: stmts ) body += stmt; return
- * generateFunctionBody(iNode, body, LexicalScope.anyType);
+ * body.
*/
+ for ( String stmt: stmts )
+ body += stmt;
+ return generateFunctionBody(iNode, body, LexicalScope.anyType);
// function = Pattern mxmlEventSpecifier
// ArgumentID(Vector<String> stmts)
@@ -4171,7 +4119,7 @@ public class JSGeneratingReducer
* generateFunctionBody(body, null);
*/
- return null;
+ // return null;
}
public Binding reduce_namespaceAccess(IASNode iNode, IASNode qualifier, Binding qualified_name)
@@ -4533,7 +4481,7 @@ public class JSGeneratingReducer
final IDefinition valueDef = valueNode.resolve(currentScope.getProject());
result += id;
- result += " : " + injectCreateProxy(iNode, valueDef, value);
+ result += ": " + injectCreateProxy(iNode, valueDef, value);
// TODO: Push type analysis up through the CG,
// so that string constants don't go through
@@ -6554,8 +6502,8 @@ public class JSGeneratingReducer
result += indent() + getVarSnippet(iNode, varName);
}
- if (var_type != null && var_type.getName() != null)
- result += " /* : " + getBasenameFromBinding(var_type) + " */";
+// if (var_type != null && var_type.getName() != null)
+// result += " /* : " + getBasenameFromBinding(var_type) + " */";
if (var_initializer != null && !var_initializer.isEmpty())
result += " = " + var_initializer;
@@ -6669,8 +6617,8 @@ public class JSGeneratingReducer
// Don't emit dynamicCastAs() call when the typename on the RHS is one of our fake classes standing in for
// 'native' browser or JS APIs, or when we're inside the core adobe.* code.
- boolean suppress = getCurrentClassName().equals(JSSharedData.JS_FRAMEWORK_NAME) ||
- isExternalClass(currentScope.getProject(), getDefinitionForName(iNode, makeName(typename)));
+ boolean suppress = true; // AJH disabled getCurrentClassName().equals(JSSharedData.JS_FRAMEWORK_NAME) ||
+ // isExternalClass(currentScope.getProject(), getDefinitionForName(iNode, makeName(typename)));
/*
* // As with handleCastExpr(), we don't handle conversion to
@@ -7227,8 +7175,8 @@ public class JSGeneratingReducer
int nthParam = 0;
final int defaultsStartAt = paramTypes.size() - defaultValues.size();
final int restStartsAt = needsRest ? paramNames.size() - 1 : paramNames.size();
- final String varPrefix = "_default_";
- final String indent = "\t\t";
+ final String varPrefix = JSSharedData.DEFAULT_PARAM_PREFIX;
+ final String indent = " ";
for (String argName : paramNames)
{
if (nthParam == restStartsAt)
@@ -7249,7 +7197,7 @@ public class JSGeneratingReducer
a_priori_insns += indent + "var _args = [];\n";
a_priori_insns += indent + "for( var i = 0; i < (arguments.length - " + (argsLen - 1) + "); i++)\n";
a_priori_insns += indent + "{\n";
- a_priori_insns += indent + "\t_args.push(arguments[i+" + (argsLen - 1) + "]);\n";
+ a_priori_insns += indent + " _args.push(arguments[i+" + (argsLen - 1) + "]);\n";
a_priori_insns += indent + "}\n";
a_priori_insns += indent + "arguments = _args;\n";
}
@@ -7266,7 +7214,7 @@ public class JSGeneratingReducer
if (nthParam < defaultsStartAt)
{
// param without default value
- code += argName + " /* : " + argType + " */";
+ code += argName; // + " /* : " + argType + " */";
}
else
{
@@ -7317,12 +7265,12 @@ public class JSGeneratingReducer
}
}
- code += varPrefix + argName + " /* : " + argType + " = " + defaultVal + " */";
+ code += varPrefix + argName; // + " /* : " + argType + " = " + defaultVal + " */";
// feed a_priori_insns
- a_priori_insns += indent + "/** @typedef {" + argType + "} */\n";
- a_priori_insns += indent + "var " + argName + " /* " + argType + " */ = " + defaultVal + ";\n";
- a_priori_insns += indent + "if( typeof(" + varPrefix + argName + ") != \"undefined\" ) ";
+ a_priori_insns += indent + "/** @type {" + argType + "} */\n";
+ a_priori_insns += indent + "var " + argName + " = " + defaultVal + ";\n";
+ a_priori_insns += indent + "if (typeof(" + varPrefix + argName + ") != 'undefined') ";
a_priori_insns += "{ " + argName + " = " + varPrefix + argName + "; }\n";
}
}
@@ -7465,9 +7413,9 @@ public class JSGeneratingReducer
final StringBuilder sb = new StringBuilder();
sb.append("Warning: " + message + "\n");
if (iNode != null)
- sb.append("\t" + iNode.getSourcePath() + ": " + (iNode.getLine() + 1) + "\n");
+ sb.append(" " + iNode.getSourcePath() + ": " + (iNode.getLine() + 1) + "\n");
else
- sb.append("\t(unknown location in code)\n");
+ sb.append(" (unknown location in code)\n");
sb.append("\n");
JSSharedData.instance.stderr(sb.toString());
}
@@ -7589,6 +7537,10 @@ public class JSGeneratingReducer
{
return baseName;
}
+ else if (def instanceof ParameterDefinition)
+ {
+ return baseName;
+ }
else if (isGlobalName(def))
{
return baseName;
@@ -7599,7 +7551,7 @@ public class JSGeneratingReducer
if (isStatic)
return createFullNameFromDefinition(project, def);
- return JSSharedData.THIS + "." + baseName;
+ return "this" + "." + baseName;
}
}
return null;
@@ -9037,7 +8989,8 @@ public class JSGeneratingReducer
String getterName = "";
String result = "";
- if (def == null || !(def instanceof SetterDefinition))
+ // if (def == null || !(def instanceof SetterDefinition))
+ if (false) // AJH disable this clause for now
{
String self = JSSharedData.THIS;
final String currentFullClassName = getCurrentFullClassName();
@@ -10032,6 +9985,24 @@ public class JSGeneratingReducer
if (def == null)
def = AmbiguousDefinition.get();
}
+ else if (ns.getKind() == CONSTANT_PrivateNs)
+ {
+ final ASDefinitionFilter filterPrivate = new ASDefinitionFilter(ClassificationValue.VARIABLES_AND_FUNCTIONS, SearchScopeValue.CONTAINING_SCOPES, AccessValue.ALL, definitionContext);
+ defName += "." + name.getBaseName();
+ def = ASScopeUtils.findDefinitionByName(scope, project, defName, filterPrivate);
+ if (def == null && scope instanceof ASScopeBase)
+ {
+ final ASScope asScope = (ASScope)scope;
+ List<IDefinition> definitions = new ArrayList<IDefinition>(1);
+ Set<INamespaceDefinition> namespaceSet = null;
+ namespaceSet = new HashSet<INamespaceDefinition>(1);
+ INamespaceDefinition namespaceRef = NamespaceDefinition.createNamespaceDefinition(ns);
+ namespaceSet.add(namespaceRef);
+ asScope.getLocalProperty(project, definitions, name.getBaseName(), namespaceSet);
+ if (definitions.size() == 1)
+ def = definitions.get(0);
+ }
+ }
else
{
if (defName.isEmpty())
@@ -10364,7 +10335,7 @@ public class JSGeneratingReducer
{
String s = "";
for (int i = 0; i < m_indent; ++i)
- s += "\t";
+ s += " ";
return s;
}
@@ -10375,7 +10346,7 @@ public class JSGeneratingReducer
for (String part : parts)
{
for (int i = 0; i < indentBy; ++i)
- s += "\t";
+ s += " ";
s += part + "\n";
}
@@ -11173,7 +11144,7 @@ public class JSGeneratingReducer
private boolean haveAPrioriInstructions()
{
- return aPrioriInstructions != null;
+ return aPrioriInstructions != null && !aPrioriInstructions.isEmpty();
}
/*
Modified: flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGenerator.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGenerator.java?rev=1432261&r1=1432260&r2=1432261&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGenerator.java (original)
+++ flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGenerator.java Fri Jan 11 20:20:58 2013
@@ -22,13 +22,19 @@ package org.apache.flex.compiler.interna
import static org.apache.flex.abc.ABCConstants.OP_add;
import static org.apache.flex.abc.ABCConstants.OP_getlocal0;
import static org.apache.flex.abc.ABCConstants.OP_pushscope;
+import static org.apache.flex.abc.ABCConstants.OP_returnvalue;
import static org.apache.flex.abc.ABCConstants.OP_returnvoid;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Vector;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
import org.apache.flex.abc.ABCConstants;
import org.apache.flex.abc.instructionlist.InstructionList;
@@ -38,10 +44,12 @@ import org.apache.flex.abc.semantics.Nam
import org.apache.flex.abc.visitors.IMethodBodyVisitor;
import org.apache.flex.abc.visitors.IMethodVisitor;
import org.apache.flex.abc.visitors.IScriptVisitor;
+import org.apache.flex.abc.visitors.IVisitor;
import org.apache.flex.compiler.definitions.references.IReference;
import org.apache.flex.compiler.exceptions.BURMAbortException;
import org.apache.flex.compiler.exceptions.CodegenInterruptedException;
import org.apache.flex.compiler.exceptions.MissingBuiltinException;
+import org.apache.flex.compiler.internal.as.codegen.ICodeGenerator.IConstantValue;
import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
import org.apache.flex.compiler.internal.definitions.ParameterDefinition;
import org.apache.flex.compiler.internal.definitions.TypeDefinitionBase;
@@ -49,16 +57,20 @@ import org.apache.flex.compiler.internal
import org.apache.flex.compiler.internal.scopes.ASScope;
import org.apache.flex.compiler.internal.testing.NodesToXMLStringFormatter;
import org.apache.flex.compiler.internal.tree.as.FunctionNode;
+import org.apache.flex.compiler.internal.tree.mxml.MXMLFileNode;
import org.apache.flex.compiler.internal.units.requests.ABCBytesRequestResult;
import org.apache.flex.compiler.problems.CodegenInternalProblem;
import org.apache.flex.compiler.problems.ICompilerProblem;
import org.apache.flex.compiler.problems.MissingBuiltinProblem;
import org.apache.flex.compiler.projects.ICompilerProject;
import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
import org.apache.flex.compiler.units.ICompilationUnit;
import org.apache.flex.compiler.units.ICompilationUnit.Operation;
import org.apache.flex.compiler.units.requests.IABCBytesRequestResult;
+import com.google.common.util.concurrent.Futures;
+
/**
* ABCGenerator is the public interface to the code generator.
*/
@@ -73,7 +85,7 @@ import org.apache.flex.compiler.units.re
* implementation is part of FalconJS. For more details on FalconJS see
* org.apache.flex.compiler.JSDriver
*/
-public class JSGenerator
+public class JSGenerator implements ICodeGenerator
{
public ICompilationUnit m_compilationUnit = null;
private Boolean m_needsSecondPass = false;
@@ -126,8 +138,21 @@ public class JSGenerator
@SuppressWarnings("nls")
public ABCBytesRequestResult generate(String synthetic_name_prefix, IASNode root_node, ICompilerProject project) throws InterruptedException
{
+ return generate(null, false, synthetic_name_prefix, root_node, project, false, Collections.<String, String>emptyMap());
+ }
+
+ @Override
+ public ABCBytesRequestResult generate(ExecutorService executorService, boolean useParallelCodegen,
+ String synthetic_name_prefix, IASNode root_node,
+ ICompilerProject project, boolean inInvisibleCompilationUnit,
+ Map<String, String> encodedDebugFiles)
+ throws InterruptedException
+ {
m_needsSecondPass = false;
- m_emitter = JSSharedData.backend.createEmitter(m_buildPhase, project);
+ if (root_node instanceof MXMLFileNode)
+ m_emitter = new JSMXMLEmitter(JSSharedData.instance, m_buildPhase, project);
+ else
+ m_emitter = JSSharedData.backend.createEmitter(m_buildPhase, project, this);
m_emitter.visit(ABCConstants.VERSION_ABC_MAJOR_FP10, ABCConstants.VERSION_ABC_MINOR_FP10);
IScriptVisitor sv = m_emitter.visitScript();
@@ -143,7 +168,7 @@ public class JSGenerator
mbv.visit();
// Set up the global lexical scope.
- final LexicalScope global_scope = new GlobalLexicalScope(project, null, synthetic_name_prefix, m_emitter);
+ final LexicalScope global_scope = new GlobalLexicalScope(project, this, synthetic_name_prefix, m_emitter);
global_scope.traitsVisitor = sv.visitTraits();
global_scope.setMethodInfo(init_method);
global_scope.methodBodyVisitor = mbv;
@@ -306,12 +331,29 @@ public class JSGenerator
* JSSharedData.OP_JS, callInit ); } }
*/
m_burm.startFunction(func);
- mi = generateMethodBodyForFunction(mi, func, enclosing_scope, a_priori_insns);
+ generateMethodBodyForFunction(mi, func, enclosing_scope, a_priori_insns);
m_burm.endFunction(func);
}
return mi;
}
+
+ public GenerateFunctionInParallelResult generateFunctionInParallel (ExecutorService executorService, FunctionNode func, LexicalScope enclosing_scope)
+ {
+ /** AJH commented out for now
+ MethodInfo mi = createMethodInfo(enclosing_scope, func);
+ if (mi.isNative())
+ {
+ generateNativeMethod(func, mi, enclosing_scope);
+ return new GenerateFunctionInParallelResult(Futures.immediateFuture(null), mi, Collections.<IVisitor>emptyList());
+ }
+ GenerateFunctionRunnable runnable = new GenerateFunctionRunnable(mi, func, enclosing_scope);
+ Future<?> future = executorService.submit(runnable);
+ return new GenerateFunctionInParallelResult(future, mi, runnable.getDeferredVisitEndsList());
+ */
+ System.out.println("unhandled call to generateFunctionInParallel");
+ return null;
+ }
/**
* Helper method used by <code>generateFunction()</code>.
@@ -368,11 +410,11 @@ public class JSGenerator
* that should be included in the function (e.g., a constructor needs a
* priori instructions to initialize instance vars).
*/
- MethodInfo generateMethodBodyForFunction(MethodInfo mi, IASNode node,
+ public void generateMethodBodyForFunction(MethodInfo mi, IASNode node,
LexicalScope enclosing_scope,
InstructionList a_priori_insns)
{
- return generateMethodBody(mi, node, enclosing_scope, a_priori_insns, CmcEmitter.__function_NT, null);
+ generateMethodBody(mi, node, enclosing_scope, a_priori_insns, CmcEmitter.__function_NT, null);
}
/**
@@ -505,6 +547,116 @@ public class JSGenerator
}
/**
+ * Helper method used by mxml databinding codegen to emit an anonymous
+ * function used by an mxml data binding destination function. Example:
+ * <p>
+ * If the expression node is a.b.c, this method will generate a funtion
+ * whose source would look something like this:
+ *
+ * <pre>
+ * function (arg:*):void { a.b.c = arg; }
+ * </pre>
+ *
+ * @param mi - the MethodInfo describing the signature
+ * @param setterExpression {@link IExpressionNode} that is the destination
+ * expression of a mxml data binding.
+ * @param enclosing_scope {@link LexicalScope} for the class initializer
+ * that encloses the function being generated.
+ */
+ public void generateMXMLDataBindingSetterFunction (MethodInfo mi, IExpressionNode setterExpression, LexicalScope enclosing_scope)
+ {
+ System.out.println("unhandled call to generateMXMLDataBindingSetterFunction");
+ /* AJH commented out for now
+ IMethodVisitor methodVisitor = enclosing_scope.getEmitter().visitMethod(mi);
+ methodVisitor.visit();
+ MethodBodyInfo methodBodyInfo = new MethodBodyInfo();
+ methodBodyInfo.setMethodInfo(mi);
+ IMethodBodyVisitor methodBodyVisitor = methodVisitor.visitBody(methodBodyInfo);
+ methodBodyVisitor.visit();
+
+ // Set up a lexical scope for this function.
+ LexicalScope function_scope = enclosing_scope.pushFrame();
+
+ function_scope.methodBodyVisitor = methodBodyVisitor;
+ function_scope.traitsVisitor = methodBodyVisitor.visitTraits();
+ function_scope.setMethodInfo(mi);
+
+
+ InstructionList functionBody;
+ if (setterExpression instanceof InstructionListNode)
+ functionBody = ((InstructionListNode)setterExpression).getInstructions();
+ else
+ functionBody = generateInstructions(setterExpression, CmcEmitter.__mxml_data_binding_setter_expression_NT, function_scope, null);
+
+ functionBody.addInstruction(OP_returnvoid);
+
+ methodBodyVisitor.visitInstructionList(functionBody);
+ methodBodyVisitor.visitEnd();
+ methodVisitor.visitEnd();
+ */
+ }
+
+ /**
+ * Helper method used by databinding codegen to emit an anonymous function
+ * based on a list of {@link IExpressionNode}'s. This method emits a
+ * function that contains code that evaluates each expression in the list
+ * and adds the expressions together with {@link ABCConstants#OP_add}.
+ *
+ * @param mi - the MethodInfo describing the signature
+ * @param nodes - a {@link List} of {@link IExpressionNode}'s to be
+ * codegen'd.
+ * @param enclosing_scope {@link LexicalScope} for the class initializer
+ * that encloses the function being generated.
+ */
+ public void generateMXMLDataBindingGetterFunction (MethodInfo mi, List<IExpressionNode> nodes,
+ LexicalScope enclosing_scope)
+ {
+ System.out.println("unhandled call to generateMXMLDataBindingSetterFunction");
+ /* AJH commented out for now
+ IMethodVisitor methodVisitor = enclosing_scope.getEmitter().visitMethod(mi);
+ methodVisitor.visit();
+ MethodBodyInfo methodBodyInfo = new MethodBodyInfo();
+ methodBodyInfo.setMethodInfo(mi);
+ IMethodBodyVisitor methodBodyVisitor = methodVisitor.visitBody(methodBodyInfo);
+ methodBodyVisitor.visit();
+
+ // Set up a lexical scope for this function.
+ LexicalScope function_scope = enclosing_scope.pushFrame();
+
+ function_scope.methodBodyVisitor = methodBodyVisitor;
+ function_scope.traitsVisitor = methodBodyVisitor.visitTraits();
+ function_scope.setMethodInfo(mi);
+
+ InstructionList functionBody = null;
+ // for a list of nodes, generate all their instructions and add the results together.
+ // typically we are doing this to concatenate strings
+ for (IExpressionNode expressionNode : nodes)
+ {
+ InstructionList instructionsForExpression = generateInstructions(expressionNode, CmcEmitter.__expression_NT, function_scope, null);
+ if (functionBody == null)
+ {
+ // First one in the list makes a new IL and puts
+ // instructions into it
+ functionBody = instructionsForExpression;
+ }
+ else
+ {
+ // successive children generate into the same IL, then add the results
+ functionBody.addAll(instructionsForExpression);
+ functionBody.addInstruction(OP_add);
+ }
+ }
+
+ functionBody.addInstruction(OP_returnvalue);
+
+ methodBodyVisitor.visitInstructionList(functionBody);
+ function_scope.traitsVisitor.visitEnd();
+ methodBodyVisitor.visitEnd();
+ methodVisitor.visitEnd();
+ */
+ }
+
+ /**
* Creates a MethodInfo specifying the signature of a method declared by a
* FunctionNode.
*
@@ -567,6 +719,23 @@ public class JSGenerator
{
return JSGenerator.createMethodInfo(m_burm, m_emitter, scope, func);
}
+
+ /**
+ **
+ * Creates a MethodInfo specifying the signature of a method
+ * declared by a FunctionNode, and adds in the information for any
+ * default argument values.
+ *
+ * @param func - A FunctionNode representing a method declaration.
+ * @return The MethodInfo specifying the signature of the method.
+ *
+ * Will generate a compiler problem is the default value is bad
+ */
+ @Override
+ public MethodInfo createMethodInfoWithDefaultArgumentValues (LexicalScope scope, FunctionNode func)
+ {
+ return JSGenerator.createMethodInfo(m_burm, m_emitter, scope, func);
+ }
/**
* Helper method to expose the constant folding code to clients outside of
@@ -578,7 +747,7 @@ public class JSGenerator
* @return the constant value for the subtree, or null if a constant value
* can't be determined
*/
- public Object generateConstantValue(IASNode subtree, ICompilerProject project)
+ public IConstantValue generateConstantValue(IASNode subtree, ICompilerProject project)
{
Object result = null;
@@ -596,7 +765,7 @@ public class JSGenerator
}
}
- return result;
+ return new ConstantValue(result, null);
}
/**
@@ -703,4 +872,48 @@ public class JSGenerator
return m_burm;
}
+
+ /**
+ * Get an ICodeGeneratorFactory that will always return the same ABCGenerator instance
+ */
+ public static ICodeGeneratorFactory getABCGeneratorFactory()
+ {
+ return new ICodeGeneratorFactory()
+ {
+ public ICodeGenerator get ()
+ {
+ return new JSGenerator();
+ }
+ };
+ }
+
+ /**
+ * Represents the result of {@link #generateConstantValue}(}.
+ * <p>
+ * In addition to producing the constant value itself,
+ * the constant reduction process can also produce compiler problems.
+ */
+ public static final class ConstantValue implements IConstantValue
+ {
+ public ConstantValue(Object value, Collection<ICompilerProblem> problems)
+ {
+ this.value = value;
+ this.problems = problems;
+ }
+
+ private final Object value;
+ private final Collection<ICompilerProblem> problems;
+
+ @Override
+ public Object getValue()
+ {
+ return value;
+ }
+
+ @Override
+ public Collection<ICompilerProblem> getProblems()
+ {
+ return problems;
+ }
+ }
}
Modified: flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGlobalDirectiveProcessor.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGlobalDirectiveProcessor.java?rev=1432261&r1=1432260&r2=1432261&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGlobalDirectiveProcessor.java (original)
+++ flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGlobalDirectiveProcessor.java Fri Jan 11 20:20:58 2013
@@ -29,6 +29,7 @@ import org.apache.flex.abc.visitors.ITra
import org.apache.flex.abc.visitors.ITraitsVisitor;
import org.apache.flex.compiler.common.DependencyType;
import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.internal.definitions.ClassDefinition;
import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
import org.apache.flex.compiler.internal.scopes.ASScope;
import org.apache.flex.compiler.internal.tree.as.ClassNode;
@@ -42,6 +43,7 @@ import org.apache.flex.compiler.problems
import org.apache.flex.compiler.scopes.IASScope;
import org.apache.flex.compiler.tree.ASTNodeID;
import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
/**
* A GlobalDirectiveProcessor translates directives at global scope into ABC.
@@ -319,5 +321,25 @@ public class JSGlobalDirectiveProcessor
emitter.visitImport(importName, imp.getImportKind());
}
}
+
+ /**
+ * Declare an MXML document.
+ */
+ @Override
+ void declareMXMLDocument(IMXMLDocumentNode d)
+ {
+ verifySkinning((ClassDefinition)d.getDefinition());
+ try
+ {
+ MXMLClassDirectiveProcessor dp;
+ dp = new JSMXMLClassDirectiveProcessor(d, this.currentScope, this.emitter);
+ dp.processMainClassDefinitionNode(d);
+ dp.finishClassDefinition();
+ }
+ catch (Error e)
+ {
+ System.out.print(e);
+ }
+ }
}