Merged in changes from FESI 1.1.5
This commit is contained in:
parent
19fd7b0f7d
commit
719959353e
5 changed files with 95 additions and 55 deletions
|
@ -185,11 +185,15 @@ public final class ESArguments extends ESObject {
|
||||||
ESValue[] argumentValues) {
|
ESValue[] argumentValues) {
|
||||||
ObjectPrototype op =
|
ObjectPrototype op =
|
||||||
(ObjectPrototype) evaluator.getObjectPrototype();
|
(ObjectPrototype) evaluator.getObjectPrototype();
|
||||||
|
// Get maximum number of arguments (formal or actual), as
|
||||||
|
// more than the number of formal arguments can be reached
|
||||||
|
// using the (old fashioned) arguments variable).
|
||||||
|
int maxArgs = Math.max(argumentValues.length, argumentNames.length);
|
||||||
ESArguments args = new ESArguments(op, evaluator, argumentNames,
|
ESArguments args = new ESArguments(op, evaluator, argumentNames,
|
||||||
Math.max(argumentValues.length, argumentNames.length),
|
maxArgs,
|
||||||
callee);
|
callee);
|
||||||
try {
|
try {
|
||||||
for (int i=0; i<argumentValues.length; i++) {
|
for (int i=0; i<maxArgs; i++) {
|
||||||
ESValue val = (i<argumentValues.length) ? argumentValues[i] :
|
ESValue val = (i<argumentValues.length) ? argumentValues[i] :
|
||||||
ESUndefined.theUndefined;
|
ESUndefined.theUndefined;
|
||||||
if (i<argumentNames.length) {
|
if (i<argumentNames.length) {
|
||||||
|
|
|
@ -311,8 +311,8 @@ public class EcmaScriptEvaluateVisitor
|
||||||
|
|
||||||
public Object visit(ASTStatementList node, Object data) {
|
public Object visit(ASTStatementList node, Object data) {
|
||||||
int n = node.jjtGetNumChildren();
|
int n = node.jjtGetNumChildren();
|
||||||
// Accepts empty statement lists (for example generated
|
// Return ESUndefined for empty statement lists (for
|
||||||
// by function(){}
|
// example generated by calling 'function(){}')
|
||||||
Object result = ESUndefined.theUndefined;
|
Object result = ESUndefined.theUndefined;
|
||||||
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
|
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
|
||||||
if (completionCode != C_NORMAL) return result;
|
if (completionCode != C_NORMAL) return result;
|
||||||
|
@ -344,11 +344,11 @@ public class EcmaScriptEvaluateVisitor
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object visit(ASTVariableDeclaration node, Object data) {
|
public Object visit(ASTVariableDeclaration node, Object data) {
|
||||||
|
Object result = null;
|
||||||
int nChildren = node.jjtGetNumChildren();
|
int nChildren = node.jjtGetNumChildren();
|
||||||
if (nChildren<1 || nChildren>2) {
|
if (nChildren<1 || nChildren>2) {
|
||||||
throw new ProgrammingError("Bad AST in variable declaration");
|
throw new ProgrammingError("Bad AST in variable declaration");
|
||||||
}
|
}
|
||||||
Object result = null;
|
|
||||||
if (nChildren == 2) {
|
if (nChildren == 2) {
|
||||||
try {
|
try {
|
||||||
Object lvo = node.jjtGetChild(0).jjtAccept(this,FOR_REFERENCE);
|
Object lvo = node.jjtGetChild(0).jjtAccept(this,FOR_REFERENCE);
|
||||||
|
@ -376,7 +376,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
throw new ProgrammingError("Bad AST in IF statement");
|
throw new ProgrammingError("Bad AST in IF statement");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ESValue testValue = (ESValue) node.jjtGetChild(0).jjtAccept(this, FOR_VALUE);
|
ESValue testValue = acceptNull(node.jjtGetChild(0).jjtAccept(this, FOR_VALUE));
|
||||||
boolean test = testValue.booleanValue();
|
boolean test = testValue.booleanValue();
|
||||||
if (test) {
|
if (test) {
|
||||||
result = node.jjtGetChild(1).jjtAccept(this,FOR_VALUE);
|
result = node.jjtGetChild(1).jjtAccept(this,FOR_VALUE);
|
||||||
|
@ -395,7 +395,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
Object result = null;
|
Object result = null;
|
||||||
node.assertTwoChildren();
|
node.assertTwoChildren();
|
||||||
try {
|
try {
|
||||||
ESValue testValue = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
|
ESValue testValue = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
|
||||||
while (testValue.booleanValue()) {
|
while (testValue.booleanValue()) {
|
||||||
|
|
||||||
// Thread.yield ();
|
// Thread.yield ();
|
||||||
|
@ -409,10 +409,10 @@ public class EcmaScriptEvaluateVisitor
|
||||||
completionCode = C_NORMAL;
|
completionCode = C_NORMAL;
|
||||||
return result;
|
return result;
|
||||||
} else if (completionCode == C_CONTINUE) {
|
} else if (completionCode == C_CONTINUE) {
|
||||||
testValue = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
|
testValue = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
|
||||||
completionCode = C_NORMAL;
|
completionCode = C_NORMAL;
|
||||||
} else {
|
} else {
|
||||||
testValue = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
|
testValue = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (EcmaScriptException e) {
|
} catch (EcmaScriptException e) {
|
||||||
|
@ -433,7 +433,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
if (testNode instanceof ASTEmptyExpression) {
|
if (testNode instanceof ASTEmptyExpression) {
|
||||||
testValue = ESBoolean.makeBoolean(true);
|
testValue = ESBoolean.makeBoolean(true);
|
||||||
} else {
|
} else {
|
||||||
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
|
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
|
||||||
}
|
}
|
||||||
while (testValue.booleanValue()) {
|
while (testValue.booleanValue()) {
|
||||||
// Thread.yield ();
|
// Thread.yield ();
|
||||||
|
@ -452,7 +452,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
if (testNode instanceof ASTEmptyExpression) {
|
if (testNode instanceof ASTEmptyExpression) {
|
||||||
testValue = ESBoolean.makeBoolean(true);
|
testValue = ESBoolean.makeBoolean(true);
|
||||||
} else {
|
} else {
|
||||||
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
|
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
|
||||||
}
|
}
|
||||||
completionCode = C_NORMAL;
|
completionCode = C_NORMAL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -460,7 +460,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
if (testNode instanceof ASTEmptyExpression) {
|
if (testNode instanceof ASTEmptyExpression) {
|
||||||
testValue = ESBoolean.makeBoolean(true);
|
testValue = ESBoolean.makeBoolean(true);
|
||||||
} else {
|
} else {
|
||||||
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
|
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
if (testNode instanceof ASTEmptyExpression) {
|
if (testNode instanceof ASTEmptyExpression) {
|
||||||
testValue = ESBoolean.makeBoolean(true);
|
testValue = ESBoolean.makeBoolean(true);
|
||||||
} else {
|
} else {
|
||||||
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
|
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
|
||||||
}
|
}
|
||||||
while (testValue.booleanValue()) {
|
while (testValue.booleanValue()) {
|
||||||
result = node.jjtGetChild(3).jjtAccept(this,FOR_VALUE);
|
result = node.jjtGetChild(3).jjtAccept(this,FOR_VALUE);
|
||||||
|
@ -498,7 +498,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
if (testNode instanceof ASTEmptyExpression) {
|
if (testNode instanceof ASTEmptyExpression) {
|
||||||
testValue = ESBoolean.makeBoolean(true);
|
testValue = ESBoolean.makeBoolean(true);
|
||||||
} else {
|
} else {
|
||||||
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
|
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
|
||||||
}
|
}
|
||||||
completionCode = C_NORMAL;
|
completionCode = C_NORMAL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -506,7 +506,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
if (testNode instanceof ASTEmptyExpression) {
|
if (testNode instanceof ASTEmptyExpression) {
|
||||||
testValue = ESBoolean.makeBoolean(true);
|
testValue = ESBoolean.makeBoolean(true);
|
||||||
} else {
|
} else {
|
||||||
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
|
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
Object result = null; // No value by default
|
Object result = null; // No value by default
|
||||||
node.assertThreeChildren();
|
node.assertThreeChildren();
|
||||||
try {
|
try {
|
||||||
ESValue ob = (ESValue) node.jjtGetChild(1).jjtAccept(this,FOR_VALUE);
|
ESValue ob = acceptNull(node.jjtGetChild(1).jjtAccept(this,FOR_VALUE));
|
||||||
ESObject obj = (ESObject) ob.toESObject(evaluator);
|
ESObject obj = (ESObject) ob.toESObject(evaluator);
|
||||||
boolean directEnumeration = obj.isDirectEnumerator();
|
boolean directEnumeration = obj.isDirectEnumerator();
|
||||||
for (Enumeration e = obj.getProperties() ; e.hasMoreElements() ;) {
|
for (Enumeration e = obj.getProperties() ; e.hasMoreElements() ;) {
|
||||||
|
@ -576,10 +576,10 @@ public class EcmaScriptEvaluateVisitor
|
||||||
// Should not happen as it should be an identifier
|
// Should not happen as it should be an identifier
|
||||||
throw new ProgrammingError("Value '"+lvo.toString()+"' is not a variable");
|
throw new ProgrammingError("Value '"+lvo.toString()+"' is not a variable");
|
||||||
}
|
}
|
||||||
ESValue init = (ESValue) node.jjtGetChild(1).jjtAccept(this, FOR_VALUE);
|
ESValue init = acceptNull(node.jjtGetChild(1).jjtAccept(this, FOR_VALUE));
|
||||||
evaluator.putValue(lv, init);
|
evaluator.putValue(lv, init);
|
||||||
|
|
||||||
ESValue ob = (ESValue) node.jjtGetChild(2).jjtAccept(this,FOR_VALUE);
|
ESValue ob = acceptNull(node.jjtGetChild(2).jjtAccept(this,FOR_VALUE));
|
||||||
ESObject obj = (ESObject) ob.toESObject(evaluator);
|
ESObject obj = (ESObject) ob.toESObject(evaluator);
|
||||||
boolean directEnumeration = obj.isDirectEnumerator();
|
boolean directEnumeration = obj.isDirectEnumerator();
|
||||||
for (Enumeration e = obj.getProperties() ; e.hasMoreElements() ;) {
|
for (Enumeration e = obj.getProperties() ; e.hasMoreElements() ;) {
|
||||||
|
@ -635,7 +635,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
ESValue result = null;
|
ESValue result = null;
|
||||||
try {
|
try {
|
||||||
EvaluationSource es = (EvaluationSource) node.getEvaluationSource();
|
EvaluationSource es = (EvaluationSource) node.getEvaluationSource();
|
||||||
ESValue scopeValue = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
|
ESValue scopeValue = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
|
||||||
ASTStatement statementNode = (ASTStatement) (node.jjtGetChild(1));
|
ASTStatement statementNode = (ASTStatement) (node.jjtGetChild(1));
|
||||||
ESObject scopeObject = (ESObject) scopeValue.toESObject(evaluator);
|
ESObject scopeObject = (ESObject) scopeValue.toESObject(evaluator);
|
||||||
result = evaluator.evaluateWith(statementNode, scopeObject, es);
|
result = evaluator.evaluateWith(statementNode, scopeObject, es);
|
||||||
|
@ -679,7 +679,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
String id = ((ASTIdentifier)baseNode).getName();
|
String id = ((ASTIdentifier)baseNode).getName();
|
||||||
currentProperty = new ESString(id);
|
currentProperty = new ESString(id);
|
||||||
} else {
|
} else {
|
||||||
lastResult = (ESValue) baseNode.jjtAccept(this,FOR_VALUE);
|
lastResult = acceptNull(baseNode.jjtAccept(this,FOR_VALUE));
|
||||||
currentProperty = null; // No reference so far
|
currentProperty = null; // No reference so far
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -811,6 +811,9 @@ public class EcmaScriptEvaluateVisitor
|
||||||
//System.out.println("--->Build value cp: " + currentProperty + " lr: " + lastResult + "<---"); // ********
|
//System.out.println("--->Build value cp: " + currentProperty + " lr: " + lastResult + "<---"); // ********
|
||||||
if (currentProperty != null) {
|
if (currentProperty != null) {
|
||||||
// Must dereference value
|
// Must dereference value
|
||||||
|
if (lastResult == null) {
|
||||||
|
throw new EcmaScriptException("'undefined' is not an object with properties");
|
||||||
|
}
|
||||||
ESObject currentBase = (ESObject) lastResult.toESObject(evaluator);
|
ESObject currentBase = (ESObject) lastResult.toESObject(evaluator);
|
||||||
String propertyName = currentProperty.toString();
|
String propertyName = currentProperty.toString();
|
||||||
//System.out.println("--->getProperty in cb: " + currentBase + " pn: " + propertyName + "<---"); // *******
|
//System.out.println("--->getProperty in cb: " + currentBase + " pn: " + propertyName + "<---"); // *******
|
||||||
|
@ -822,6 +825,9 @@ public class EcmaScriptEvaluateVisitor
|
||||||
} else {
|
} else {
|
||||||
// We want a reference - therefore it cannot be just a value, it
|
// We want a reference - therefore it cannot be just a value, it
|
||||||
// must be a delayed reference.
|
// must be a delayed reference.
|
||||||
|
if (lastResult == null) {
|
||||||
|
throw new EcmaScriptException("'undefined' is not an assignable value");
|
||||||
|
}
|
||||||
if (currentProperty == null) {
|
if (currentProperty == null) {
|
||||||
throw new EcmaScriptException("'"+lastResult.toString()+"' is not an assignable value");
|
throw new EcmaScriptException("'"+lastResult.toString()+"' is not an assignable value");
|
||||||
}
|
}
|
||||||
|
@ -850,7 +856,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
|
|
||||||
public Object visit(ASTPropertyValueReference node, Object data) {
|
public Object visit(ASTPropertyValueReference node, Object data) {
|
||||||
node.assertOneChild();
|
node.assertOneChild();
|
||||||
return node.jjtGetChild(0).jjtAccept(this, FOR_VALUE);
|
return acceptNull(node.jjtGetChild(0).jjtAccept(this, FOR_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object visit(ASTPropertyIdentifierReference node, Object data) {
|
public Object visit(ASTPropertyIdentifierReference node, Object data) {
|
||||||
|
@ -872,7 +878,8 @@ public class EcmaScriptEvaluateVisitor
|
||||||
try {
|
try {
|
||||||
int nChildren=node.jjtGetNumChildren();
|
int nChildren=node.jjtGetNumChildren();
|
||||||
Node baseNode = node.jjtGetChild(0);
|
Node baseNode = node.jjtGetChild(0);
|
||||||
ESValue constr = (ESValue) baseNode.jjtAccept(this, FOR_VALUE); // Can be any expression (in fact a a.b.c sequence)
|
// Can be any expression (in fact a a.b.c sequence) [code bizare here]
|
||||||
|
ESValue constr = acceptNull(baseNode.jjtAccept(this, FOR_VALUE));
|
||||||
Node compositor = node.jjtGetChild(1);
|
Node compositor = node.jjtGetChild(1);
|
||||||
if (compositor instanceof ASTFunctionCallParameters) {
|
if (compositor instanceof ASTFunctionCallParameters) {
|
||||||
ASTFunctionCallParameters fc = (ASTFunctionCallParameters) compositor;
|
ASTFunctionCallParameters fc = (ASTFunctionCallParameters) compositor;
|
||||||
|
@ -956,7 +963,8 @@ public class EcmaScriptEvaluateVisitor
|
||||||
if (n instanceof ASTIdentifier) {
|
if (n instanceof ASTIdentifier) {
|
||||||
// We need to get a reference, as an null based referenced is "undefined"
|
// We need to get a reference, as an null based referenced is "undefined"
|
||||||
ESReference ref = (ESReference) n.jjtAccept(this,FOR_REFERENCE);
|
ESReference ref = (ESReference) n.jjtAccept(this,FOR_REFERENCE);
|
||||||
if (ref.getBase()==null) {
|
// If reference to nothing, consider undefined
|
||||||
|
if (ref == null || ref.getBase()==null) {
|
||||||
r = new ESString("undefined");
|
r = new ESString("undefined");
|
||||||
} else {
|
} else {
|
||||||
ESValue v = ref.getValue();
|
ESValue v = ref.getValue();
|
||||||
|
@ -964,7 +972,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// It is a value, directly get its string
|
// It is a value, directly get its string
|
||||||
ESValue v = (ESValue) n.jjtAccept(this,FOR_VALUE);
|
ESValue v = acceptNull(n.jjtAccept(this,FOR_VALUE));
|
||||||
r = new ESString(v.getTypeofString());
|
r = new ESString(v.getTypeofString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1035,9 +1043,9 @@ public class EcmaScriptEvaluateVisitor
|
||||||
public Object visit(ASTBinaryExpressionSequence node, Object data) {
|
public Object visit(ASTBinaryExpressionSequence node, Object data) {
|
||||||
ESValue result = null;
|
ESValue result = null;
|
||||||
try {
|
try {
|
||||||
ESValue v1 = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
|
ESValue v1 = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
|
||||||
for (int i = 0; i < node.jjtGetNumChildren()-1; i+=2) {
|
for (int i = 0; i < node.jjtGetNumChildren()-1; i+=2) {
|
||||||
ESValue v2 = (ESValue) node.jjtGetChild(i+2).jjtAccept(this,FOR_VALUE);
|
ESValue v2 = acceptNull(node.jjtGetChild(i+2).jjtAccept(this,FOR_VALUE));
|
||||||
int operator = ((ASTOperator)(node.jjtGetChild(i+1))).getOperator();
|
int operator = ((ASTOperator)(node.jjtGetChild(i+1))).getOperator();
|
||||||
// System.out.println("V1 = " + v1 + " v2 = " + v2);
|
// System.out.println("V1 = " + v1 + " v2 = " + v2);
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
|
@ -1168,10 +1176,10 @@ public class EcmaScriptEvaluateVisitor
|
||||||
ESValue result = null;
|
ESValue result = null;
|
||||||
int nChildren = node.jjtGetNumChildren();
|
int nChildren = node.jjtGetNumChildren();
|
||||||
try {
|
try {
|
||||||
result = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
|
result = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (result.booleanValue() && (i<nChildren)) {
|
while (result.booleanValue() && (i<nChildren)) {
|
||||||
result = (ESValue) node.jjtGetChild(i).jjtAccept(this,FOR_VALUE);
|
result = acceptNull(node.jjtGetChild(i).jjtAccept(this,FOR_VALUE));
|
||||||
i ++;
|
i ++;
|
||||||
}
|
}
|
||||||
// Normalize to primitive - could be optimized...
|
// Normalize to primitive - could be optimized...
|
||||||
|
@ -1186,10 +1194,10 @@ public class EcmaScriptEvaluateVisitor
|
||||||
int nChildren = node.jjtGetNumChildren();
|
int nChildren = node.jjtGetNumChildren();
|
||||||
ESValue result = null;
|
ESValue result = null;
|
||||||
try {
|
try {
|
||||||
result = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
|
result = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while ((!result.booleanValue()) && (i<nChildren)) {
|
while ((!result.booleanValue()) && (i<nChildren)) {
|
||||||
result = (ESValue) node.jjtGetChild(i).jjtAccept(this,FOR_VALUE);
|
result = acceptNull(node.jjtGetChild(i).jjtAccept(this,FOR_VALUE));
|
||||||
i ++;
|
i ++;
|
||||||
}
|
}
|
||||||
// Normalize to primitive - could be optimized...
|
// Normalize to primitive - could be optimized...
|
||||||
|
@ -1210,7 +1218,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
node.assertThreeChildren();
|
node.assertThreeChildren();
|
||||||
Object result = null;
|
Object result = null;
|
||||||
try {
|
try {
|
||||||
ESValue t = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
|
ESValue t = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
|
||||||
boolean test = t.booleanValue();
|
boolean test = t.booleanValue();
|
||||||
if (test) {
|
if (test) {
|
||||||
result = node.jjtGetChild(1).jjtAccept(this, FOR_VALUE);
|
result = node.jjtGetChild(1).jjtAccept(this, FOR_VALUE);
|
||||||
|
@ -1228,7 +1236,6 @@ public class EcmaScriptEvaluateVisitor
|
||||||
ESValue result = null;
|
ESValue result = null;
|
||||||
try {
|
try {
|
||||||
// Get left hand side
|
// Get left hand side
|
||||||
|
|
||||||
Object lvo = node.jjtGetChild(0).jjtAccept(this,FOR_REFERENCE);
|
Object lvo = node.jjtGetChild(0).jjtAccept(this,FOR_REFERENCE);
|
||||||
//System.out.println("REF: " + lvo);
|
//System.out.println("REF: " + lvo);
|
||||||
ESReference lv;
|
ESReference lv;
|
||||||
|
@ -1238,8 +1245,7 @@ public class EcmaScriptEvaluateVisitor
|
||||||
throw new EcmaScriptException("Value '"+lvo.toString()+"' is not an assignable object or property");
|
throw new EcmaScriptException("Value '"+lvo.toString()+"' is not an assignable object or property");
|
||||||
}
|
}
|
||||||
|
|
||||||
// get Right hand side
|
ESValue v2 = acceptNull(node.jjtGetChild(2).jjtAccept(this,FOR_VALUE));
|
||||||
ESValue v2 = (ESValue) node.jjtGetChild(2).jjtAccept(this,FOR_VALUE);
|
|
||||||
|
|
||||||
// Case analysis based on assignement operator type
|
// Case analysis based on assignement operator type
|
||||||
int operator = ((ASTOperator)(node.jjtGetChild(1))).getOperator();
|
int operator = ((ASTOperator)(node.jjtGetChild(1))).getOperator();
|
||||||
|
@ -1362,6 +1368,29 @@ public class EcmaScriptEvaluateVisitor
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To transform a null (empty) result (but not an ESNull!)
|
||||||
|
* in 'ESUndefined'. null results may be returned if a
|
||||||
|
* statement as the empty statement, missing else clause of
|
||||||
|
* an if statement, loop not executed at all, etc.. is executed
|
||||||
|
* for value (for example as the last statement of a called function
|
||||||
|
* used in an assignement). This is a programming error, and it
|
||||||
|
* may be useful to modify this function to generate an exception
|
||||||
|
* during debugging. However other implementation seem to accept
|
||||||
|
* ESUndefined in these cases. The standard is not totally clear
|
||||||
|
* to me.
|
||||||
|
* <P>An alternative would be to return ESUndefined in all cases,
|
||||||
|
* but then we lose a useful distinction (at least for debugging...).
|
||||||
|
* <P>A couple of tests are done in visit(ASTCompositeReference node, ...
|
||||||
|
* too.
|
||||||
|
*/
|
||||||
|
static protected ESValue acceptNull(Object v) {
|
||||||
|
if (v == null) {
|
||||||
|
// Accept null (could generate an optional exception).
|
||||||
|
return ESUndefined.theUndefined;
|
||||||
|
} else {
|
||||||
|
// Take advantage to convert...
|
||||||
|
return (ESValue) v;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ class FesiHashtable implements Cloneable {
|
||||||
public ESValue put(String key, int hash, boolean hidden, boolean readonly, ESValue value) {
|
public ESValue put(String key, int hash, boolean hidden, boolean readonly, ESValue value) {
|
||||||
// Make sure the value is not null
|
// Make sure the value is not null
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Makes sure the key is not already in the hashtable.
|
// Makes sure the key is not already in the hashtable.
|
||||||
|
|
|
@ -3164,14 +3164,6 @@ public class EcmaScript/*@bgen(jjtree)*/implements EcmaScriptTreeConstants, Ecma
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final private boolean jj_3R_60() {
|
|
||||||
if (jj_3R_64()) return true;
|
|
||||||
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
|
|
||||||
if (jj_3R_59()) return true;
|
|
||||||
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final private boolean jj_3R_24() {
|
final private boolean jj_3R_24() {
|
||||||
if (jj_scan_token(FOR)) return true;
|
if (jj_scan_token(FOR)) return true;
|
||||||
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
|
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
|
||||||
|
@ -3182,6 +3174,14 @@ public class EcmaScript/*@bgen(jjtree)*/implements EcmaScriptTreeConstants, Ecma
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final private boolean jj_3R_60() {
|
||||||
|
if (jj_3R_64()) return true;
|
||||||
|
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
|
||||||
|
if (jj_3R_59()) return true;
|
||||||
|
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final private boolean jj_3R_131() {
|
final private boolean jj_3R_131() {
|
||||||
if (jj_3R_138()) return true;
|
if (jj_3R_138()) return true;
|
||||||
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
|
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
|
||||||
|
|
|
@ -1654,6 +1654,13 @@ final void SkipLexicalActions(Token matchedToken)
|
||||||
{
|
{
|
||||||
switch(jjmatchedKind)
|
switch(jjmatchedKind)
|
||||||
{
|
{
|
||||||
|
case 8 :
|
||||||
|
if (image == null)
|
||||||
|
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
|
||||||
|
else
|
||||||
|
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
|
||||||
|
input_stream.backup(1);
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue