Added Token.TYPEOFNAME to denote explicitly parser nodes for typeof(name) to make code more explicit about this case compared with typeof(expression) which is denote by Token.TYPEOF. Previously the ambiguity was resolved by using (Token.UNARY.OP, Token.TYPEOF) for parser tree nodes denoting the later and simple Token.TYPEOF for the former.

This commit is contained in:
igor%mir2.org 2003-08-15 09:00:42 +00:00
Родитель f82801fd15
Коммит 945c6bd1ec
4 изменённых файлов: 11 добавлений и 14 удалений

Просмотреть файл

@ -732,7 +732,7 @@ public class IRFactory {
if (nodeOp == Token.TYPEOF &&
childType == Token.NAME)
{
childNode.setType(Token.TYPEOF);
childNode.setType(Token.TYPEOFNAME);
return childNode;
}

Просмотреть файл

@ -665,7 +665,7 @@ public class Interpreter
itsStackDepth--;
break;
case Token.TYPEOF : {
case Token.TYPEOFNAME : {
String name = node.getString();
int index = -1;
// use typeofname if an activation frame exists

Просмотреть файл

@ -218,8 +218,9 @@ public class Token
NEWLOCAL = 119,
USELOCAL = 120,
SCRIPT = 121, // top-level node for entire script
TYPEOFNAME = 122, // for typeof(simple-name)
LAST_TOKEN = 121;
LAST_TOKEN = 122;
public static String name(int token)
{

Просмотреть файл

@ -1232,8 +1232,8 @@ public class Codegen extends Interpreter {
visitUnary(node, child);
break;
case Token.TYPEOF:
visitTypeof(node, child);
case Token.TYPEOFNAME:
visitTypeofname(node);
break;
case Token.INC:
@ -2318,7 +2318,10 @@ public class Codegen extends Interpreter {
switch (op) {
case Token.TYPEOF:
visitTypeof(node, child);
generateCodeFromNode(child, node);
addScriptRuntimeInvoke("typeof",
"(Ljava/lang/Object;"
+")Ljava/lang/String;");
break;
case Token.VOID:
@ -2332,15 +2335,8 @@ public class Codegen extends Interpreter {
}
}
private void visitTypeof(Node node, Node child)
private void visitTypeofname(Node node)
{
if (node.getType() == Token.UNARYOP) {
generateCodeFromNode(child, node);
addScriptRuntimeInvoke("typeof",
"(Ljava/lang/Object;"
+")Ljava/lang/String;");
return;
}
String name = node.getString();
if (hasVarsInRegs) {
OptLocalVariable lVar = fnCurrent.getVar(name);