mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Parsing changes: for regular expression literals construct a tree node with regular expression number during parsing instead of generating a special subtree that is converted to such node during tree transformation.
This commit is contained in:
parent
406437f686
commit
a8e6f7c025
@ -665,13 +665,10 @@ public class IRFactory {
|
||||
/**
|
||||
* Regular expressions
|
||||
*/
|
||||
public Object createRegExp(String string, String flags) {
|
||||
return flags.length() == 0
|
||||
? new Node(TokenStream.REGEXP,
|
||||
Node.newString(string))
|
||||
: new Node(TokenStream.REGEXP,
|
||||
Node.newString(string),
|
||||
Node.newString(flags));
|
||||
public Object createRegExp(int regexpIndex) {
|
||||
Node n = new Node(TokenStream.REGEXP);
|
||||
n.putIntProp(Node.REGEXP_PROP, regexpIndex);
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,19 +340,6 @@ public class NodeTransformer {
|
||||
node.setType(inFunction ? TokenStream.POP : TokenStream.POPV);
|
||||
break;
|
||||
|
||||
case TokenStream.REGEXP:
|
||||
{
|
||||
Node left = node.getFirstChild();
|
||||
Node right = node.getLastChild();
|
||||
String string = left.getString();
|
||||
String flags = (left != right) ? right.getString() : null;
|
||||
int index = tree.addRegexp(string, flags);
|
||||
Node n = new Node(TokenStream.REGEXP);
|
||||
iter.replaceCurrent(n);
|
||||
n.putIntProp(Node.REGEXP_PROP, index);
|
||||
break;
|
||||
}
|
||||
|
||||
case TokenStream.VAR:
|
||||
{
|
||||
Node result = new Node(TokenStream.BLOCK);
|
||||
|
@ -1399,7 +1399,8 @@ class Parser {
|
||||
ts.regExpFlags = null;
|
||||
String re = ts.getString();
|
||||
sourceAddString(ts.REGEXP, '/' + re + '/' + flags);
|
||||
return nf.createRegExp(re, flags);
|
||||
int index = currentScriptOrFn.addRegexp(re, flags);
|
||||
return nf.createRegExp(index);
|
||||
}
|
||||
|
||||
case TokenStream.PRIMARY:
|
||||
|
Loading…
x
Reference in New Issue
Block a user