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/05/01 21:03:48 UTC

[2/3] git commit: [flex-falcon] - don't try to escape regexp

don't try to escape regexp


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

Branch: refs/heads/develop
Commit: 7bf1bda8d2f9e9700457c882496758ac22ef8fd2
Parents: 14a3e9a
Author: Alex Harui <ah...@apache.org>
Authored: Wed May 1 12:02:49 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Wed May 1 12:02:49 2013 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java         |   36 ++++++++-------
 1 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7bf1bda8/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 f223e91..0325d44 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
@@ -54,6 +54,7 @@ import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
 import org.apache.flex.compiler.internal.tree.as.ParameterNode;
+import org.apache.flex.compiler.internal.tree.as.RegExpLiteralNode;
 import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.tree.ASTNodeID;
 import org.apache.flex.compiler.tree.as.IASNode;
@@ -919,22 +920,25 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     @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");
+        String s = node.getValue(true);
+        if (!(node instanceof RegExpLiteralNode))
+        {
+            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);
     }
 }