flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ftho...@apache.org
Subject [03/35] git commit: [flex-falcon] [refs/heads/IDEA-FLEX_JS_COMPILER] - - Refactored Class emitting into shared jx package for future use. - Refactored Bindable class level emittion; - Refactored GetSet class level emition - Created a shared model for eac
Date Tue, 02 Jun 2015 12:42:10 GMT
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
new file mode 100644
index 0000000..1800afa
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
@@ -0,0 +1,156 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.asdoc.flexjs.ASDocComment;
+import org.apache.flex.compiler.clients.MXMLJSC;
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.definitions.IFunctionDefinition;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.utils.DocEmitterUtils;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IAccessorNode;
+import org.apache.flex.compiler.tree.as.IClassNode;
+import org.apache.flex.compiler.tree.as.IDefinitionNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+
+public class ClassEmitter extends JSSubEmitter implements
+        ISubEmitter<IClassNode>
+{
+    private BindableEmitter bindableEmitter;
+    private GetSetEmitter getSetEmitter;
+    
+    public BindableEmitter getBindableEmitter()
+    {
+        return bindableEmitter;
+    }
+    
+    public GetSetEmitter getGetSetEmitter()
+    {
+        return getSetEmitter;
+    }
+    
+    public ClassEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+        
+        bindableEmitter = new BindableEmitter(emitter);
+        getSetEmitter = new GetSetEmitter(emitter);
+    }
+
+    @Override
+    public void emit(IClassNode node)
+    {
+        getModel().setCurrentClass(node.getDefinition());
+
+        // TODO (mschmalle) will remove this cast as more things get abstracted
+        JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
+
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        if (asDoc != null && MXMLJSC.keepASDoc)
+            DocEmitterUtils.loadImportIgnores(fjs, asDoc.commentNoEnd());
+
+        IClassDefinition definition = node.getDefinition();
+
+        IFunctionDefinition ctorDefinition = definition.getConstructor();
+
+        // Static-only (Singleton) classes may not have a constructor
+        if (ctorDefinition != null)
+        {
+            IFunctionNode ctorNode = (IFunctionNode) ctorDefinition.getNode();
+            if (ctorNode != null)
+            {
+                // constructor
+                getEmitter().emitMethod(ctorNode);
+                write(ASEmitterTokens.SEMICOLON);
+            }
+            else
+            {
+                String qname = definition.getQualifiedName();
+                if (qname != null && !qname.equals(""))
+                {
+                    write(fjs.formatQualifiedName(qname));
+                    write(ASEmitterTokens.SPACE);
+                    writeToken(ASEmitterTokens.EQUAL);
+                    write(ASEmitterTokens.FUNCTION);
+                    write(ASEmitterTokens.PAREN_OPEN);
+                    write(ASEmitterTokens.PAREN_CLOSE);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.BLOCK_OPEN);
+                    writeNewline();
+                    write(ASEmitterTokens.BLOCK_CLOSE);
+                    write(ASEmitterTokens.SEMICOLON);
+                }
+            }
+        }
+
+        IDefinitionNode[] dnodes = node.getAllMemberNodes();
+        for (IDefinitionNode dnode : dnodes)
+        {
+            if (dnode.getNodeID() == ASTNodeID.VariableID)
+            {
+                writeNewline();
+                writeNewline();
+                writeNewline();
+                getEmitter().emitField((IVariableNode) dnode);
+                write(ASEmitterTokens.SEMICOLON);
+            }
+            else if (dnode.getNodeID() == ASTNodeID.FunctionID)
+            {
+                if (!((IFunctionNode) dnode).isConstructor())
+                {
+                    writeNewline();
+                    writeNewline();
+                    writeNewline();
+                    getEmitter().emitMethod((IFunctionNode) dnode);
+                    write(ASEmitterTokens.SEMICOLON);
+                }
+            }
+            else if (dnode.getNodeID() == ASTNodeID.GetterID
+                    || dnode.getNodeID() == ASTNodeID.SetterID)
+            {
+                //writeNewline();
+                //writeNewline();
+                //writeNewline();
+                fjs.emitAccessors((IAccessorNode) dnode);
+                //this shouldn't write anything, just set up
+                //a data structure for emitASGettersAndSetters
+                //write(ASEmitterTokens.SEMICOLON);
+            }
+            else if (dnode.getNodeID() == ASTNodeID.BindableVariableID)
+            {
+                writeNewline();
+                writeNewline();
+                writeNewline();
+                getEmitter().emitField((IVariableNode) dnode);
+                write(ASEmitterTokens.SEMICOLON);
+            }
+        }
+
+        bindableEmitter.emit(definition);
+
+        getSetEmitter.emit(definition);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/GetSetEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/GetSetEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/GetSetEmitter.java
new file mode 100644
index 0000000..c4db6fa
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/GetSetEmitter.java
@@ -0,0 +1,195 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import java.util.Set;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSDocEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSessionModel.PropertyNodes;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+
+public class GetSetEmitter extends JSSubEmitter implements
+        ISubEmitter<IClassDefinition>
+{
+
+    public GetSetEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IClassDefinition definition)
+    {
+        // TODO (mschmalle) will remove this cast as more things get abstracted
+        JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
+
+        if (!getModel().getPropertyMap().isEmpty())
+        {
+            writeNewline();
+            writeNewline();
+            writeNewline();
+            write(JSGoogEmitterTokens.OBJECT);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSEmitterTokens.DEFINE_PROPERTIES);
+            write(ASEmitterTokens.PAREN_OPEN);
+            String qname = definition.getQualifiedName();
+            write(fjs.formatQualifiedName(qname));
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSEmitterTokens.PROTOTYPE);
+            write(ASEmitterTokens.COMMA);
+            write(ASEmitterTokens.SPACE);
+            write("/** @lends {" + fjs.formatQualifiedName(qname)
+                    + ".prototype} */ ");
+            writeNewline(ASEmitterTokens.BLOCK_OPEN);
+
+            Set<String> propertyNames = getModel().getPropertyMap().keySet();
+            boolean firstTime = true;
+            for (String propName : propertyNames)
+            {
+                if (firstTime)
+                    firstTime = false;
+                else
+                    writeNewline(ASEmitterTokens.COMMA);
+
+                PropertyNodes p = getModel().getPropertyMap().get(propName);
+                writeNewline("/** @expose */");
+                write(propName);
+                write(ASEmitterTokens.COLON);
+                write(ASEmitterTokens.SPACE);
+                writeNewline(ASEmitterTokens.BLOCK_OPEN);
+                if (p.getter != null)
+                {
+                    write(ASEmitterTokens.GET);
+                    write(ASEmitterTokens.COLON);
+                    write(ASEmitterTokens.SPACE);
+                    write(JSDocEmitterTokens.JSDOC_OPEN);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.ATSIGN);
+                    write(ASEmitterTokens.THIS);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.BLOCK_OPEN);
+                    write(fjs.formatQualifiedName(qname));
+                    write(ASEmitterTokens.BLOCK_CLOSE);
+                    write(ASEmitterTokens.SPACE);
+                    write(JSDocEmitterTokens.JSDOC_CLOSE);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.FUNCTION);
+                    fjs.emitParameters(p.getter.getParameterNodes());
+
+                    fjs.emitDefinePropertyFunction(p.getter);
+                }
+                if (p.setter != null)
+                {
+                    if (p.getter != null)
+                        writeNewline(ASEmitterTokens.COMMA);
+
+                    write(ASEmitterTokens.SET);
+                    write(ASEmitterTokens.COLON);
+                    write(ASEmitterTokens.SPACE);
+                    write(JSDocEmitterTokens.JSDOC_OPEN);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.ATSIGN);
+                    write(ASEmitterTokens.THIS);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.BLOCK_OPEN);
+                    write(fjs.formatQualifiedName(qname));
+                    write(ASEmitterTokens.BLOCK_CLOSE);
+                    write(ASEmitterTokens.SPACE);
+                    write(JSDocEmitterTokens.JSDOC_CLOSE);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.FUNCTION);
+                    fjs.emitParameters(p.setter.getParameterNodes());
+
+                    fjs.emitDefinePropertyFunction(p.setter);
+                }
+                write(ASEmitterTokens.BLOCK_CLOSE);
+            }
+            writeNewline(ASEmitterTokens.BLOCK_CLOSE);
+            write(ASEmitterTokens.PAREN_CLOSE);
+            write(ASEmitterTokens.SEMICOLON);
+        }
+        if (!getModel().getStaticPropertyMap().isEmpty())
+        {
+            write(JSGoogEmitterTokens.OBJECT);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSEmitterTokens.DEFINE_PROPERTIES);
+            write(ASEmitterTokens.PAREN_OPEN);
+            String qname = definition.getQualifiedName();
+            write(fjs.formatQualifiedName(qname));
+            write(ASEmitterTokens.COMMA);
+            write(ASEmitterTokens.SPACE);
+            write("/** @lends {" + fjs.formatQualifiedName(qname) + "} */ ");
+            writeNewline(ASEmitterTokens.BLOCK_OPEN);
+
+            Set<String> propertyNames = getModel().getStaticPropertyMap()
+                    .keySet();
+            boolean firstTime = true;
+            for (String propName : propertyNames)
+            {
+                if (firstTime)
+                    firstTime = false;
+                else
+                    writeNewline(ASEmitterTokens.COMMA);
+
+                PropertyNodes p = getModel().getStaticPropertyMap().get(
+                        propName);
+                writeNewline("/** @expose */");
+                write(propName);
+                write(ASEmitterTokens.COLON);
+                write(ASEmitterTokens.SPACE);
+                writeNewline(ASEmitterTokens.BLOCK_OPEN);
+                if (p.getter != null)
+                {
+                    write(ASEmitterTokens.GET);
+                    write(ASEmitterTokens.COLON);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.FUNCTION);
+                    fjs.emitParameters(p.getter.getParameterNodes());
+
+                    fjs.emitDefinePropertyFunction(p.getter);
+                }
+                if (p.setter != null)
+                {
+                    if (p.getter != null)
+                        writeNewline(ASEmitterTokens.COMMA);
+
+                    write(ASEmitterTokens.SET);
+                    write(ASEmitterTokens.COLON);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.FUNCTION);
+                    fjs.emitParameters(p.setter.getParameterNodes());
+
+                    fjs.emitDefinePropertyFunction(p.setter);
+                }
+                write(ASEmitterTokens.BLOCK_CLOSE);
+            }
+            writeNewline(ASEmitterTokens.BLOCK_CLOSE);
+            write(ASEmitterTokens.PAREN_CLOSE);
+            write(ASEmitterTokens.SEMICOLON);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/DocEmitterUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/DocEmitterUtils.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/DocEmitterUtils.java
new file mode 100644
index 0000000..7d7bf16
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/DocEmitterUtils.java
@@ -0,0 +1,49 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.utils;
+
+import java.util.ArrayList;
+
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
+
+public class DocEmitterUtils
+{
+    public static void loadImportIgnores(JSFlexJSEmitter emitter, String doc)
+    {
+        ArrayList<String> ignoreList = new ArrayList<String>();
+        String ignoreToken = JSFlexJSEmitterTokens.IGNORE_IMPORT.getToken();
+        int index = doc.indexOf(ignoreToken);
+        while (index != -1)
+        {
+            String ignorable = doc.substring(index + ignoreToken.length());
+            int endIndex = ignorable.indexOf("\n");
+            ignorable = ignorable.substring(0, endIndex);
+            ignorable = ignorable.trim();
+            ignoreList.add(ignorable);
+            System.out.println("Found ignorable: " + ignorable);
+            index = doc.indexOf(ignoreToken, index + endIndex);
+        }
+        
+        // TODO (mschmalle)
+        ((JSFlexJSDocEmitter)emitter.getDocEmitter()).setClassIgnoreList(ignoreList);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
new file mode 100644
index 0000000..94a2120
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
@@ -0,0 +1,121 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flex.compiler.constants.IASLanguageConstants;
+import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.definitions.ITypeDefinition;
+import org.apache.flex.compiler.internal.definitions.ClassDefinition;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IDefinitionNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IScopedNode;
+
+/**
+ * Various static methods used in shared emitter logic.
+ */
+public class EmitterUtils
+{
+    public static boolean isSameClass(IDefinition pdef, IDefinition thisClass,
+            ICompilerProject project)
+    {
+        if (pdef == thisClass)
+            return true;
+
+        IDefinition cdef = ((ClassDefinition) thisClass)
+                .resolveBaseClass(project);
+        while (cdef != null)
+        {
+            // needs to be a loop
+            if (cdef == pdef)
+                return true;
+            cdef = ((ClassDefinition) cdef).resolveBaseClass(project);
+        }
+        return false;
+    }
+
+    public static boolean hasSuperClass(ICompilerProject project,
+            IDefinitionNode node)
+    {
+        IClassDefinition superClassDefinition = getSuperClassDefinition(node,
+                project);
+        // XXX (mschmalle) this is nulling for MXML super class, figure out why
+        if (superClassDefinition == null)
+            return false;
+        String qname = superClassDefinition.getQualifiedName();
+        return superClassDefinition != null
+                && !qname.equals(IASLanguageConstants.Object);
+    }
+
+    public static boolean hasSuperCall(IScopedNode node)
+    {
+        for (int i = node.getChildCount() - 1; i > -1; i--)
+        {
+            IASNode cnode = node.getChild(i);
+            if (cnode.getNodeID() == ASTNodeID.FunctionCallID
+                    && cnode.getChild(0).getNodeID() == ASTNodeID.SuperID)
+                return true;
+        }
+
+        return false;
+    }
+
+    public static boolean hasBody(IFunctionNode node)
+    {
+        IScopedNode scope = node.getScopedNode();
+        return scope.getChildCount() > 0;
+    }
+
+    public static IClassDefinition getSuperClassDefinition(
+            IDefinitionNode node, ICompilerProject project)
+    {
+        IClassDefinition parent = (IClassDefinition) node.getDefinition()
+                .getParent();
+        IClassDefinition superClass = parent.resolveBaseClass(project);
+        return superClass;
+    }
+
+    public static List<String> resolveImports(ITypeDefinition type)
+    {
+        ArrayList<String> list = new ArrayList<String>();
+        IScopedNode scopeNode = type.getContainedScope().getScopeNode();
+        if (scopeNode != null)
+        {
+            scopeNode.getAllImports(list);
+        }
+        else
+        {
+            // MXML
+            ClassDefinition cdefinition = (ClassDefinition) type;
+            String[] implicitImports = cdefinition.getImplicitImports();
+            for (String imp : implicitImports)
+            {
+                list.add(imp);
+            }
+        }
+        return list;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
index 9a9a2c5..ea68760 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
@@ -111,8 +111,6 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
         super(out);
     }
 
-    public IDefinition thisClass;
-
     @Override
     protected String getIndent(int numIndent)
     {
@@ -131,12 +129,11 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
     @Override
     public void emitClass(IClassNode node)
     {
-        thisClass = node.getDefinition();
+        IClassDefinition definition = node.getDefinition();
+        getModel().setCurrentClass(definition);
 
         project = getWalker().getProject();
 
-        IClassDefinition definition = node.getDefinition();
-
         IFunctionDefinition ctorDefinition = definition.getConstructor();
 
         // Static-only (Singleton) classes may not have a constructor
@@ -291,7 +288,7 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
         // (erikdebruin): If the initial value of a variable is set using
         //                a method, JS needs this initialization to be done
         //                in the constructor
-    	IClassNode cdnode = (IClassNode) thisClass.getNode();
+    	IClassNode cdnode = (IClassNode) getModel().getCurrentClass().getNode();
         IDefinitionNode[] dnodes = cdnode.getAllMemberNodes();
         for (IDefinitionNode dnode : dnodes)
         {
@@ -697,6 +694,7 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
         ASTNodeID parentNodeId = parentNode.getNodeID();
 
         IASNode firstChild = parentNode.getChild(0);
+        IClassDefinition thisClass = getModel().getCurrentClass();
 
         boolean identifierIsMemberAccess = parentNodeId == ASTNodeID.MemberAccessExpressionID;
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/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 f7d9c55..4efa7a6 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
@@ -114,7 +114,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     
     private StringBuilder subDocuments = new StringBuilder();
     private ArrayList<String> subDocumentNames = new ArrayList<String>();
-
+    
     /**
      * This keeps track of the entries in our temporary array of 
      * DeferredInstanceFromFunction objects that we CG to help with
@@ -184,7 +184,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         classDefinition = cdef;
         IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                 .getASEmitter();
-        ((JSFlexJSEmitter) asEmitter).thisClass = cdef;
+        ((JSFlexJSEmitter) asEmitter).getModel().setCurrentClass(cdef);
 
         // visit tags
         final int len = node.getChildCount();
@@ -210,8 +210,8 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
 
         emitScripts();
 
-        ((JSFlexJSEmitter)asEmitter).emitBindableVariables(cdef);
-        ((JSFlexJSEmitter)asEmitter).emitASGettersAndSetters(cdef);
+        ((JSFlexJSEmitter)asEmitter).getClassEmiter().getBindableEmitter().emit(cdef);
+        ((JSFlexJSEmitter)asEmitter).getClassEmiter().getGetSetEmitter().emit(cdef);
         
         emitEvents(cname);
 
@@ -267,8 +267,8 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         classDefinition = cdef;
         IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                 .getASEmitter();
-        IDefinition oldThisClass = ((JSFlexJSEmitter) asEmitter).thisClass;
-        ((JSFlexJSEmitter) asEmitter).thisClass = cdef;
+        IClassDefinition oldThisClass = ((JSFlexJSEmitter) asEmitter).getModel().getCurrentClass();
+        ((JSFlexJSEmitter) asEmitter).getModel().setCurrentClass(cdef);
 
         IASNode classNode = node.getContainedClassDefinitionNode();
         // visit tags
@@ -312,7 +312,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         idCounter = oldIdCounter;
         inMXMLContent = oldInMXMLContent;
         classDefinition = oldClassDef;
-        ((JSFlexJSEmitter) asEmitter).thisClass = oldThisClass;
+        ((JSFlexJSEmitter) asEmitter).getModel().setCurrentClass(oldThisClass);
 
     }
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
index 60702a8..5c2aae0 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
@@ -144,7 +144,7 @@ public class MXMLVF2JSEmitter extends MXMLEmitter implements
         IClassDefinition cdef = node.getClassDefinition();
         IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                 .getASEmitter();
-        ((JSVF2JSEmitter) asEmitter).thisClass = cdef;
+        ((JSVF2JSEmitter) asEmitter).getModel().setCurrentClass(cdef);
 
         // visit tags
         final int len = node.getChildCount();
@@ -218,7 +218,7 @@ public class MXMLVF2JSEmitter extends MXMLEmitter implements
         IClassDefinition cdef = node.getContainedClassDefinition();
         IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                 .getASEmitter();
-        ((JSVF2JSEmitter) asEmitter).thisClass = cdef;
+        ((JSVF2JSEmitter) asEmitter).getModel().setCurrentClass(cdef);
 
         IASNode classNode = node.getContainedClassDefinitionNode();
         // visit tags


Mime
View raw message