Author: erikdebruin
Date: Thu Feb 14 15:47:16 2013
New Revision: 1446246

URL: http://svn.apache.org/r1446246
Log:
Implemented 'final' is and as operator implementations.
Cleared a bunch of TODOs...
Added some new TODOs ;-)

Modified:
    
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogComments.java
    
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java
    
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java
    
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
    
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java
    
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
    
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
    
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java

Modified: 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogComments.java
URL: 
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogComments.java?rev=1446246&r1=1446245&r2=1446246&view=diff
==============================================================================
--- 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogComments.java
 (original)
+++ 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogComments.java
 Thu Feb 14 15:47:16 2013
@@ -28,8 +28,8 @@ import org.apache.flex.compiler.internal
  */
 public class TestGoogComments extends TestComments
 {
-       // TODO (erikdebruin) if comments aren't preserved in the base tests
-       //                    we can't test the 'goog' equivalents
+       // (erikdebruin) if comments aren't preserved in the base tests
+       //               we can't test the 'goog' equivalents
     
     @Override
     protected IBackend createBackend()

Modified: 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java
URL: 
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java?rev=1446246&r1=1446245&r2=1446246&view=diff
==============================================================================
--- 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java
 (original)
+++ 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java
 Thu Feb 14 15:47:16 2013
@@ -120,17 +120,15 @@ public class TestGoogExpressions extends
     @Test
     public void testVisitAs()
     {
-        // TODO (erikdebruin) the assert is a placeholder for the eventual 
workaround
         IBinaryOperatorNode node = getBinaryNode("a as b");
         visitor.visitBinaryOperator(node);
-        assertOut("as(a, b)");
+        assertOut("(is(a, b) ? a : null)");
     }
 
     @Override
     @Test
     public void testVisitBinaryOperator_Instancof()
     {
-        // TODO (erikdebruin) check if the AS and JS implementations match
         IBinaryOperatorNode node = getBinaryNode("a instanceof b");
         visitor.visitBinaryOperator(node);
         assertOut("a instanceof b");
@@ -140,7 +138,6 @@ public class TestGoogExpressions extends
     @Test
     public void testVisitBinaryOperator_Is()
     {
-        // TODO (erikdebruin) the assert is a placeholder for the eventual 
workaround
         IBinaryOperatorNode node = getBinaryNode("a is b");
         visitor.visitBinaryOperator(node);
         assertOut("is(a, b)");

Modified: 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java
URL: 
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java?rev=1446246&r1=1446245&r2=1446246&view=diff
==============================================================================
--- 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java
 (original)
+++ 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java
 Thu Feb 14 15:47:16 2013
@@ -208,7 +208,7 @@ public class TestGoogGlobalClasses exten
     @Test
     public void testRegExp()
     {
-        // TODO (erikdebruin) how to handle the escaping of backslashes in
+        // TODO (mschmalle) how to handle the escaping of backslashes in
         //                    strings in the tests?
         IVariableNode node = getVariable("var a:RegExp = new 
RegExp('test-\\d', 'i');");
         visitor.visitVariable(node);

Modified: 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
URL: 
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java?rev=1446246&r1=1446245&r2=1446246&view=diff
==============================================================================
--- 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
 (original)
+++ 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
 Thu Feb 14 15:47:16 2013
@@ -113,7 +113,6 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("mx_internal function foo(bar:String, 
baz:int = null):int{\treturn -1;}");
         visitor.visitFunction(node);
-        // TODO (erikdebruin) can we safely ignore custom namespaces?
         assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * 
@return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = 
this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 

Modified: 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java
URL: 
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java?rev=1446246&r1=1446245&r2=1446246&view=diff
==============================================================================
--- 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java
 (original)
+++ 
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java
 Thu Feb 14 15:47:16 2013
@@ -172,6 +172,8 @@ public class TestGoogStatements extends 
     @Test
     public void testVisitForEach_1()
     {
+        // TODO (erikdebruin) we need to insert a "goog.require('goog.array')"
+        //                    into the header
         IForLoopNode node = (IForLoopNode) getNode(
                 "for each(var i:int in obj) { break; }", IForLoopNode.class);
         visitor.visitForLoop(node);

Modified: 
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
URL: 
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java?rev=1446246&r1=1446245&r2=1446246&view=diff
==============================================================================
--- 
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java 
(original)
+++ 
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java 
Thu Feb 14 15:47:16 2013
@@ -140,9 +140,6 @@ public class MXMLJSC
     {
         long startTime = System.nanoTime();
 
-        // TODO (erikdebruin) we need a more elegant way to figure out which 
-        //                    backend to load, but this is all I could manage
-        //                    for now (looking for "-js-output-type=TYPE")
         IBackend backend = new ASBackend();
         for (String s : args)
         {

Modified: 
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
URL: 
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java?rev=1446246&r1=1446245&r2=1446246&view=diff
==============================================================================
--- 
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
 (original)
+++ 
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
 Thu Feb 14 15:47:16 2013
@@ -145,6 +145,7 @@ public class ASEmitter implements IASEmi
     public static final String PARENTHESES_CLOSE = ")";
     public static final String PARENTHESES_OPEN = "(";
     public static final String PERIOD = ".";
+    public static final String QUESTIONMARK = "?";
     public static final String SEMICOLON = ";";
     public static final String SINGLE_QUOTE = "'";
     public static final String SPACE = " ";

Modified: 
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
URL: 
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java?rev=1446246&r1=1446245&r2=1446246&view=diff
==============================================================================
--- 
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
 (original)
+++ 
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
 Thu Feb 14 15:47:16 2013
@@ -86,11 +86,6 @@ public class JSGoogEmitter extends JSEmi
 
     public static final String SELF = "self";
 
-    // TODO (erikdebruin) I needed some state to remember if an accessor is
-    //                    accompanied by it's counterpart, as 'goog' likes 
having
-    //                    a property with a type declaration to go with them. 
We
-    //                    only want one declaration per property, so we need to
-    //                    know if we visited the complementary instance 
already...
     private List<String> propertyNames = new ArrayList<String>();
 
     IJSGoogDocEmitter getDoc()
@@ -191,10 +186,6 @@ public class JSGoogEmitter extends JSEmi
         emitMethod((IFunctionNode) definition.getConstructor().getNode());
         write(SEMICOLON);
 
-        // TODO (erikdebruin) create a way to visit all members before actually
-        //                                       emitting the members 
themselves. This will allow 
-        //                    us to write stuff like a 'shared' property for 
-        //                    all combinations of accessors, for instance.
         IDefinitionNode[] dnodes = node.getAllMemberNodes();
         for (IDefinitionNode dnode : dnodes)
         {
@@ -1015,11 +1006,9 @@ public class JSGoogEmitter extends JSEmi
     {
         ASTNodeID id = node.getNodeID();
 
-        if (id == ASTNodeID.Op_AsID || id == ASTNodeID.Op_IsID)
+        if (id == ASTNodeID.Op_IsID)
         {
-            // TODO (erikdebruin) replace: this is a placeholder for the 
-            //                    eventual implementation
-            write((id == ASTNodeID.Op_AsID) ? "as" : "is");
+            write(ASTNodeID.Op_IsID.getParaphrase());
             write(PARENTHESES_OPEN);
             getWalker().walk(node.getLeftOperandNode());
             write(COMMA);
@@ -1027,6 +1016,27 @@ public class JSGoogEmitter extends JSEmi
             getWalker().walk(node.getRightOperandNode());
             write(PARENTHESES_CLOSE);
         }
+        else if (id == ASTNodeID.Op_AsID)
+        {
+            // (is(a, b) ? a : null)
+            write(PARENTHESES_OPEN);
+            write(ASTNodeID.Op_IsID.getParaphrase());
+            write(PARENTHESES_OPEN);
+            getWalker().walk(node.getLeftOperandNode());
+            write(COMMA);
+            write(SPACE);
+            getWalker().walk(node.getRightOperandNode());
+            write(PARENTHESES_CLOSE);
+            write(SPACE);
+            write(QUESTIONMARK);
+            write(SPACE);
+            getWalker().walk(node.getLeftOperandNode());
+            write(SPACE);
+            write(COLON);
+            write(SPACE);
+            write(IASLanguageConstants.NULL);
+            write(PARENTHESES_CLOSE);
+        }
         else
         {
             getWalker().walk(node.getLeftOperandNode());


Reply via email to