зеркало из https://github.com/mozilla/gecko-dev.git
To mark special properties __proto__ and __parent__ in parse tree use integer ids instead of strings so it is easier to check tree consitency.
This commit is contained in:
Родитель
cbacb923d3
Коммит
a9bb9a44ac
|
@ -804,9 +804,20 @@ public class IRFactory {
|
|||
nodeType = Token.GETPROP;
|
||||
right.setType(Token.STRING);
|
||||
String id = right.getString();
|
||||
if (id.equals("__proto__") || id.equals("__parent__")) {
|
||||
int idlength = id.length();
|
||||
int special = 0;
|
||||
if (idlength == 9) {
|
||||
if (id.equals("__proto__")) {
|
||||
special = Node.SPECIAL_PROP_PROTO;
|
||||
}
|
||||
} else if (idlength == 10) {
|
||||
if (id.equals("__parent__")) {
|
||||
special = Node.SPECIAL_PROP_PARENT;
|
||||
}
|
||||
}
|
||||
if (special != 0) {
|
||||
Node result = new Node(nodeType, left);
|
||||
result.putProp(Node.SPECIAL_PROP_PROP, id);
|
||||
result.putIntProp(Node.SPECIAL_PROP_PROP, special);
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
|
@ -972,10 +983,10 @@ public class IRFactory {
|
|||
int type;
|
||||
if (nodeType == Token.GETPROP) {
|
||||
type = Token.SETPROP;
|
||||
String special = (String) left.getProp(Node.SPECIAL_PROP_PROP);
|
||||
if (special != null) {
|
||||
int special = left.getIntProp(Node.SPECIAL_PROP_PROP, 0);
|
||||
if (special != 0) {
|
||||
Node result = new Node(Token.SETPROP, obj, right);
|
||||
result.putProp(Node.SPECIAL_PROP_PROP, special);
|
||||
result.putIntProp(Node.SPECIAL_PROP_PROP, special);
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -557,11 +557,11 @@ public class Interpreter
|
|||
|
||||
case Token.GETPROP : {
|
||||
iCodeTop = generateICode(child, iCodeTop);
|
||||
String s = (String) node.getProp(Node.SPECIAL_PROP_PROP);
|
||||
if (s != null) {
|
||||
if (s.equals("__proto__")) {
|
||||
int special = node.getIntProp(Node.SPECIAL_PROP_PROP, 0);
|
||||
if (special != 0) {
|
||||
if (special == Node.SPECIAL_PROP_PROTO) {
|
||||
iCodeTop = addIcode(Icode_GETPROTO, iCodeTop);
|
||||
} else if (s.equals("__parent__")) {
|
||||
} else if (special == Node.SPECIAL_PROP_PARENT) {
|
||||
iCodeTop = addIcode(Icode_GETSCOPEPARENT, iCodeTop);
|
||||
} else {
|
||||
badTree(node);
|
||||
|
@ -624,11 +624,11 @@ public class Interpreter
|
|||
iCodeTop = generateICode(child, iCodeTop);
|
||||
child = child.getNext();
|
||||
iCodeTop = generateICode(child, iCodeTop);
|
||||
String s = (String) node.getProp(Node.SPECIAL_PROP_PROP);
|
||||
if (s != null) {
|
||||
if (s.equals("__proto__")) {
|
||||
int special = node.getIntProp(Node.SPECIAL_PROP_PROP, 0);
|
||||
if (special != 0) {
|
||||
if (special == Node.SPECIAL_PROP_PROTO) {
|
||||
iCodeTop = addIcode(Icode_SETPROTO, iCodeTop);
|
||||
} else if (s.equals("__parent__")) {
|
||||
} else if (special == Node.SPECIAL_PROP_PARENT) {
|
||||
iCodeTop = addIcode(Icode_SETPARENT, iCodeTop);
|
||||
} else {
|
||||
badTree(node);
|
||||
|
|
|
@ -396,6 +396,10 @@ public class Node implements Cloneable {
|
|||
|
||||
SPECIALCALL_PROP = 17;
|
||||
|
||||
public static final int // this value of the SPECIAL_PROP_PROP specifies
|
||||
SPECIAL_PROP_PROTO = 1,
|
||||
SPECIAL_PROP_PARENT = 2;
|
||||
|
||||
public static final int // this value of the ISNUMBER_PROP specifies
|
||||
BOTH = 0, // which of the children are Number types
|
||||
LEFT = 1,
|
||||
|
@ -633,25 +637,67 @@ public class Node implements Cloneable {
|
|||
sb.append(" [");
|
||||
sb.append(propToString(type));
|
||||
sb.append(": ");
|
||||
String value;
|
||||
switch (type) {
|
||||
case FIXUPS_PROP : // can't add this as it recurses
|
||||
sb.append("fixups property");
|
||||
case FIXUPS_PROP : // can't add this as it recurses
|
||||
value = "fixups property";
|
||||
break;
|
||||
case TARGETBLOCK_PROP : // can't add this as it recurses
|
||||
value = "target block property";
|
||||
break;
|
||||
case LASTUSE_PROP : // can't add this as it is dull
|
||||
value = "last use property";
|
||||
break;
|
||||
case SPECIAL_PROP_PROP:
|
||||
switch (x.intValue) {
|
||||
case SPECIAL_PROP_PROTO:
|
||||
value = "__proto__";
|
||||
break;
|
||||
case TARGETBLOCK_PROP : // can't add this as it recurses
|
||||
sb.append("target block property");
|
||||
case SPECIAL_PROP_PARENT:
|
||||
value = "__parent__";
|
||||
break;
|
||||
case LASTUSE_PROP : // can't add this as it is dull
|
||||
sb.append("last use property");
|
||||
default:
|
||||
throw Kit.codeBug();
|
||||
}
|
||||
break;
|
||||
case ISNUMBER_PROP:
|
||||
switch (x.intValue) {
|
||||
case BOTH:
|
||||
value = "both";
|
||||
break;
|
||||
default :
|
||||
Object obj = x.objectValue;
|
||||
if (obj != null) {
|
||||
sb.append(obj.toString());
|
||||
} else {
|
||||
sb.append(x.intValue);
|
||||
}
|
||||
case RIGHT:
|
||||
value = "right";
|
||||
break;
|
||||
case LEFT:
|
||||
value = "left";
|
||||
break;
|
||||
default:
|
||||
throw Kit.codeBug();
|
||||
}
|
||||
break;
|
||||
case SPECIALCALL_PROP:
|
||||
switch (x.intValue) {
|
||||
case SPECIALCALL_EVAL:
|
||||
value = "eval";
|
||||
break;
|
||||
case SPECIALCALL_WITH:
|
||||
value = "with";
|
||||
break;
|
||||
default:
|
||||
// NON_SPECIALCALL should not be stored
|
||||
throw Kit.codeBug();
|
||||
}
|
||||
break;
|
||||
default :
|
||||
Object obj = x.objectValue;
|
||||
if (obj != null) {
|
||||
value = obj.toString();
|
||||
} else {
|
||||
value = String.valueOf(x.intValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
sb.append(value);
|
||||
sb.append(']');
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
|
@ -3569,17 +3569,17 @@ class BodyCodegen
|
|||
|
||||
private void visitGetProp(Node node, Node child)
|
||||
{
|
||||
String s = (String) node.getProp(Node.SPECIAL_PROP_PROP);
|
||||
if (s != null) {
|
||||
int special = node.getIntProp(Node.SPECIAL_PROP_PROP, 0);
|
||||
if (special != 0) {
|
||||
while (child != null) {
|
||||
generateCodeFromNode(child, node);
|
||||
child = child.getNext();
|
||||
}
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
String runtimeMethod = null;
|
||||
if (s.equals("__proto__")) {
|
||||
if (special == Node.SPECIAL_PROP_PROTO) {
|
||||
runtimeMethod = "getProto";
|
||||
} else if (s.equals("__parent__")) {
|
||||
} else if (special == Node.SPECIAL_PROP_PARENT) {
|
||||
runtimeMethod = "getParent";
|
||||
} else {
|
||||
Codegen.badTree();
|
||||
|
@ -3635,17 +3635,17 @@ class BodyCodegen
|
|||
|
||||
private void visitSetProp(Node node, Node child)
|
||||
{
|
||||
String s = (String) node.getProp(Node.SPECIAL_PROP_PROP);
|
||||
if (s != null) {
|
||||
int special = node.getIntProp(Node.SPECIAL_PROP_PROP, 0);
|
||||
if (special != 0) {
|
||||
while (child != null) {
|
||||
generateCodeFromNode(child, node);
|
||||
child = child.getNext();
|
||||
}
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
String runtimeMethod = null;
|
||||
if (s.equals("__proto__")) {
|
||||
if (special == Node.SPECIAL_PROP_PROTO) {
|
||||
runtimeMethod = "setProto";
|
||||
} else if (s.equals("__parent__")) {
|
||||
} else if (special == Node.SPECIAL_PROP_PARENT) {
|
||||
runtimeMethod = "setParent";
|
||||
} else {
|
||||
Codegen.badTree();
|
||||
|
|
Загрузка…
Ссылка в новой задаче