flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/3] git commit: [flex-falcon] - Fix casts of getters, and newlines in string literals
Date Wed, 01 May 2013 19:03:47 GMT
Updated Branches:
  refs/heads/develop 444371793 -> d80c98572


Fix casts of getters, and newlines in string literals


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

Branch: refs/heads/develop
Commit: 14a3e9aaac6f7963bd2a7552c13c60b1f19906bd
Parents: 4443717
Author: Alex Harui <aharui@apache.org>
Authored: Tue Apr 30 15:29:49 2013 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Apr 30 15:29:49 2013 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/TestFlexJSExpressions.java   |    8 +++++
 .../codegen/js/flexjs/TestFlexJSStatements.java    |   10 ++++++
 .../flexjs/files/FlexJSTest_again_result.js        |    1 +
 .../flexjs/files/MyInitialView_result.js           |    5 ++-
 .../flexjs/files/wildcard_import_result.js         |    1 +
 .../codegen/js/flexjs/JSFlexJSEmitter.java         |   24 ++++++++++++++-
 6 files changed, 47 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/14a3e9aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index 33c5e99..bf89f94 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -558,6 +558,14 @@ public class TestFlexJSExpressions extends TestGoogExpressions
     }
 
     @Test
+    public void testClassCastOfGetter()
+    {
+        IFunctionNode node = getMethod("function foo(){var foo:Object = FalconTest_A(bar).bar
= '';}; public function get bar():Object { return this; };");
+        asBlockWalker.visitFunction(node);
+        assertOut("FalconTest_A.prototype.foo = function() {\n\tvar /** @type {Object} */
foo = this.get_bar()/** Cast to FalconTest_A */.set_bar('');\n}");
+    }
+
+    @Test
     public void testFunctionCall()
     {
         IFunctionNode node = getMethod("function foo(){bar(b).text = '';}");

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/14a3e9aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java
index c78fa77..b919436 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java
@@ -26,6 +26,7 @@ import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
 import org.apache.flex.compiler.tree.as.IFileNode;
 import org.apache.flex.compiler.tree.as.IForLoopNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
 import org.junit.Test;
 
 /**
@@ -40,6 +41,15 @@ public class TestFlexJSStatements extends TestGoogStatements
         super.setUp();
     }
     
+    @Test
+    public void testVarDeclaration_withTypeAssignedStringWithNewLine()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a:String = \"\\n\"",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = \"\\n\"");
+    }
+
     @Override
     @Test
     public void testVisitForEach_1()

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/14a3e9aa/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js b/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js
index f7e4e47..0e9dc85 100644
--- a/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js
+++ b/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js
@@ -9,6 +9,7 @@ goog.require('org.apache.flex.net.HTTPService');
 goog.require('org.apache.flex.net.dataConverters.LazyCollection');
 goog.require('org.apache.flex.net.JSONInputParser');
 goog.require('StockDataJSONItemConverter');
+goog.require('org.apache.flex.events.Event');
 
 /**
  * @constructor

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/14a3e9aa/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js b/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js
index 5bcf47d..3e91753 100644
--- a/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js
+++ b/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js
@@ -12,6 +12,9 @@ goog.require('org.apache.flex.html.staticControls.CheckBox');
 goog.require('org.apache.flex.html.staticControls.RadioButton');
 goog.require('org.apache.flex.html.staticControls.DropDownList');
 goog.require('org.apache.flex.html.staticControls.ComboBox');
+goog.require('org.apache.flex.events.CustomEvent');
+goog.require('org.apache.flex.events.Event');
+goog.require('org.apache.flex.utils.Timer');
 
 /**
  * @constructor
@@ -291,7 +294,7 @@ MyInitialView.prototype.$EH5 = function(event)
 /**
  * @this {MyInitialView}
  * @expose
- * @param {flash.events.Event} event
+ * @param {org.apache.flex.events.Event} event
  */
 MyInitialView.prototype.$EH6 = function(event)
 {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/14a3e9aa/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js b/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js
index eb17f8a..9c7c4c9 100644
--- a/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js
+++ b/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js
@@ -1,6 +1,7 @@
 goog.provide('wildcard_import');
 
 goog.require('org.apache.flex.core.Application');
+goog.require('org.apache.flex.html.staticControls.Button');
 
 /**
  * @constructor

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/14a3e9aa/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index a60643e..f223e91 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -68,6 +68,7 @@ import org.apache.flex.compiler.tree.as.IFunctionNode;
 import org.apache.flex.compiler.tree.as.IGetterNode;
 import org.apache.flex.compiler.tree.as.IIdentifierNode;
 import org.apache.flex.compiler.tree.as.ILanguageIdentifierNode;
+import org.apache.flex.compiler.tree.as.ILiteralNode;
 import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
 import org.apache.flex.compiler.tree.as.ISetterNode;
 import org.apache.flex.compiler.tree.as.ITypedExpressionNode;
@@ -488,7 +489,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
 
                     getWalker().walk(rightSide);
                 }
-                else
+                else if (parentNode instanceof IBinaryOperatorNode)
                 {
                     rightSide = ((IBinaryOperatorNode) parentNode)
                             .getRightOperandNode();
@@ -915,4 +916,25 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         write(JSGoogEmitterTokens.ARRAY);
     }
 
+    @Override
+    public void emitLiteral(ILiteralNode node)
+    {
+        String s = node.getValue();
+        s = s.replaceAll("\n", "__NEWLINE_PLACEHOLDER__");
+        s = s.replaceAll("\r", "__CR_PLACEHOLDER__");
+        s = s.replaceAll("\t", "__TAB_PLACEHOLDER__");
+        s = s.replaceAll("\f", "__FORMFEED_PLACEHOLDER__");
+        s = s.replaceAll("\b", "__BACKSPACE_PLACEHOLDER__");
+        s = s.replaceAll("\\\\\"", "__QUOTE_PLACEHOLDER__");
+        s = s.replaceAll("\\\\", "__ESCAPE_PLACEHOLDER__");
+        s = "\"" + s.replaceAll("\"", "\\\\\"") + "\"";
+        s = s.replaceAll("__ESCAPE_PLACEHOLDER__", "\\\\\\\\");
+        s = s.replaceAll("__QUOTE_PLACEHOLDER__", "\\\\\"");
+        s = s.replaceAll("__BACKSPACE_PLACEHOLDER__", "\\\\b");
+        s = s.replaceAll("__FORMFEED_PLACEHOLDER__", "\\\\f");
+        s = s.replaceAll("__TAB_PLACEHOLDER__", "\\\\t");
+        s = s.replaceAll("__CR_PLACEHOLDER__", "\\\\r");
+        s = s.replaceAll("__NEWLINE_PLACEHOLDER__", "\\\\n");
+        write(s);
+    }
 }


Mime
View raw message