本文整理汇总了C#中Node.GetNext方法的典型用法代码示例。如果您正苦于以下问题:C# Node.GetNext方法的具体用法?C# Node.GetNext怎么用?C# Node.GetNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node.GetNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitIfJumpEqOp
private void VisitIfJumpEqOp(Node node, Node child, int trueGOTO, int falseGOTO)
{
if (trueGOTO == -1 || falseGOTO == -1)
{
throw Codegen.BadTree();
}
short stackInitial = cfw.GetStackTop();
int type = node.GetType();
Node rChild = child.GetNext();
// Optimize if one of operands is null
if (child.GetType() == Token.NULL || rChild.GetType() == Token.NULL)
{
// eq is symmetric in this case
if (child.GetType() == Token.NULL)
{
child = rChild;
}
GenerateExpression(child, node);
if (type == Token.SHEQ || type == Token.SHNE)
{
int testCode = (type == Token.SHEQ) ? ByteCode.IFNULL : ByteCode.IFNONNULL;
cfw.Add(testCode, trueGOTO);
}
else
{
if (type != Token.EQ)
{
// swap false/true targets for !=
if (type != Token.NE)
{
throw Codegen.BadTree();
}
int tmp = trueGOTO;
trueGOTO = falseGOTO;
falseGOTO = tmp;
}
cfw.Add(ByteCode.DUP);
int undefCheckLabel = cfw.AcquireLabel();
cfw.Add(ByteCode.IFNONNULL, undefCheckLabel);
short stack = cfw.GetStackTop();
cfw.Add(ByteCode.POP);
cfw.Add(ByteCode.GOTO, trueGOTO);
cfw.MarkLabel(undefCheckLabel, stack);
Codegen.PushUndefined(cfw);
cfw.Add(ByteCode.IF_ACMPEQ, trueGOTO);
}
cfw.Add(ByteCode.GOTO, falseGOTO);
}
else
{
int child_dcp_register = NodeIsDirectCallParameter(child);
if (child_dcp_register != -1 && rChild.GetType() == Token.TO_OBJECT)
{
Node convertChild = rChild.GetFirstChild();
if (convertChild.GetType() == Token.NUMBER)
{
cfw.AddALoad(child_dcp_register);
cfw.Add(ByteCode.GETSTATIC, "java/lang/Void", "TYPE", "Ljava/lang/Class;");
int notNumbersLabel = cfw.AcquireLabel();
cfw.Add(ByteCode.IF_ACMPNE, notNumbersLabel);
cfw.AddDLoad(child_dcp_register + 1);
cfw.AddPush(convertChild.GetDouble());
cfw.Add(ByteCode.DCMPL);
if (type == Token.EQ)
{
cfw.Add(ByteCode.IFEQ, trueGOTO);
}
else
{
cfw.Add(ByteCode.IFNE, trueGOTO);
}
cfw.Add(ByteCode.GOTO, falseGOTO);
cfw.MarkLabel(notNumbersLabel);
}
}
// fall thru into generic handling
GenerateExpression(child, node);
GenerateExpression(rChild, node);
string name;
int testCode;
switch (type)
{
case Token.EQ:
{
name = "eq";
testCode = ByteCode.IFNE;
break;
}
case Token.NE:
{
name = "eq";
testCode = ByteCode.IFEQ;
break;
}
case Token.SHEQ:
{
name = "shallowEq";
testCode = ByteCode.IFNE;
//.........这里部分代码省略.........
示例2: VisitBitOp
private void VisitBitOp(Node node, int type, Node child)
{
int childNumberFlag = node.GetIntProp(Node.ISNUMBER_PROP, -1);
GenerateExpression(child, node);
// special-case URSH; work with the target arg as a long, so
// that we can return a 32-bit unsigned value, and call
// toUint32 instead of toInt32.
if (type == Token.URSH)
{
AddScriptRuntimeInvoke("toUint32", "(Ljava/lang/Object;)J");
GenerateExpression(child.GetNext(), node);
AddScriptRuntimeInvoke("toInt32", "(Ljava/lang/Object;)I");
// Looks like we need to explicitly mask the shift to 5 bits -
// LUSHR takes 6 bits.
cfw.AddPush(31);
cfw.Add(ByteCode.IAND);
cfw.Add(ByteCode.LUSHR);
cfw.Add(ByteCode.L2D);
AddDoubleWrap();
return;
}
if (childNumberFlag == -1)
{
AddScriptRuntimeInvoke("toInt32", "(Ljava/lang/Object;)I");
GenerateExpression(child.GetNext(), node);
AddScriptRuntimeInvoke("toInt32", "(Ljava/lang/Object;)I");
}
else
{
AddScriptRuntimeInvoke("toInt32", "(D)I");
GenerateExpression(child.GetNext(), node);
AddScriptRuntimeInvoke("toInt32", "(D)I");
}
switch (type)
{
case Token.BITOR:
{
cfw.Add(ByteCode.IOR);
break;
}
case Token.BITXOR:
{
cfw.Add(ByteCode.IXOR);
break;
}
case Token.BITAND:
{
cfw.Add(ByteCode.IAND);
break;
}
case Token.RSH:
{
cfw.Add(ByteCode.ISHR);
break;
}
case Token.LSH:
{
cfw.Add(ByteCode.ISHL);
break;
}
default:
{
throw Codegen.BadTree();
}
}
cfw.Add(ByteCode.I2D);
if (childNumberFlag == -1)
{
AddDoubleWrap();
}
}
示例3: VisitIfJumpRelOp
private void VisitIfJumpRelOp(Node node, Node child, int trueGOTO, int falseGOTO)
{
if (trueGOTO == -1 || falseGOTO == -1)
{
throw Codegen.BadTree();
}
int type = node.GetType();
Node rChild = child.GetNext();
if (type == Token.INSTANCEOF || type == Token.IN)
{
GenerateExpression(child, node);
GenerateExpression(rChild, node);
cfw.AddALoad(contextLocal);
AddScriptRuntimeInvoke((type == Token.INSTANCEOF) ? "instanceOf" : "in", "(Ljava/lang/Object;" + "Ljava/lang/Object;" + "Lorg/mozilla/javascript/Context;" + ")Z");
cfw.Add(ByteCode.IFNE, trueGOTO);
cfw.Add(ByteCode.GOTO, falseGOTO);
return;
}
int childNumberFlag = node.GetIntProp(Node.ISNUMBER_PROP, -1);
int left_dcp_register = NodeIsDirectCallParameter(child);
int right_dcp_register = NodeIsDirectCallParameter(rChild);
if (childNumberFlag != -1)
{
// Force numeric context on both parameters and optimize
// direct call case as Optimizer currently does not handle it
if (childNumberFlag != Node.RIGHT)
{
// Left already has number content
GenerateExpression(child, node);
}
else
{
if (left_dcp_register != -1)
{
DcpLoadAsNumber(left_dcp_register);
}
else
{
GenerateExpression(child, node);
AddObjectToDouble();
}
}
if (childNumberFlag != Node.LEFT)
{
// Right already has number content
GenerateExpression(rChild, node);
}
else
{
if (right_dcp_register != -1)
{
DcpLoadAsNumber(right_dcp_register);
}
else
{
GenerateExpression(rChild, node);
AddObjectToDouble();
}
}
GenSimpleCompare(type, trueGOTO, falseGOTO);
}
else
{
if (left_dcp_register != -1 && right_dcp_register != -1)
{
// Generate code to dynamically check for number content
// if both operands are dcp
short stack = cfw.GetStackTop();
int leftIsNotNumber = cfw.AcquireLabel();
cfw.AddALoad(left_dcp_register);
cfw.Add(ByteCode.GETSTATIC, "java/lang/Void", "TYPE", "Ljava/lang/Class;");
cfw.Add(ByteCode.IF_ACMPNE, leftIsNotNumber);
cfw.AddDLoad(left_dcp_register + 1);
DcpLoadAsNumber(right_dcp_register);
GenSimpleCompare(type, trueGOTO, falseGOTO);
if (stack != cfw.GetStackTop())
{
throw Codegen.BadTree();
}
cfw.MarkLabel(leftIsNotNumber);
int rightIsNotNumber = cfw.AcquireLabel();
cfw.AddALoad(right_dcp_register);
cfw.Add(ByteCode.GETSTATIC, "java/lang/Void", "TYPE", "Ljava/lang/Class;");
cfw.Add(ByteCode.IF_ACMPNE, rightIsNotNumber);
cfw.AddALoad(left_dcp_register);
AddObjectToDouble();
cfw.AddDLoad(right_dcp_register + 1);
GenSimpleCompare(type, trueGOTO, falseGOTO);
if (stack != cfw.GetStackTop())
{
throw Codegen.BadTree();
}
cfw.MarkLabel(rightIsNotNumber);
// Load both register as objects to call generic cmp_*
cfw.AddALoad(left_dcp_register);
cfw.AddALoad(right_dcp_register);
}
else
{
GenerateExpression(child, node);
//.........这里部分代码省略.........
示例4: VisitDotQuery
private void VisitDotQuery(Node node, Node child)
{
UpdateLineNumber(node);
GenerateExpression(child, node);
cfw.AddALoad(variableObjectLocal);
AddScriptRuntimeInvoke("enterDotQuery", "(Ljava/lang/Object;" + "Lorg/mozilla/javascript/Scriptable;" + ")Lorg/mozilla/javascript/Scriptable;");
cfw.AddAStore(variableObjectLocal);
// add push null/pop with label in between to simplify code for loop
// continue when it is necessary to pop the null result from
// updateDotQuery
cfw.Add(ByteCode.ACONST_NULL);
int queryLoopStart = cfw.AcquireLabel();
cfw.MarkLabel(queryLoopStart);
// loop continue jumps here
cfw.Add(ByteCode.POP);
GenerateExpression(child.GetNext(), node);
AddScriptRuntimeInvoke("toBoolean", "(Ljava/lang/Object;)Z");
cfw.AddALoad(variableObjectLocal);
AddScriptRuntimeInvoke("updateDotQuery", "(Z" + "Lorg/mozilla/javascript/Scriptable;" + ")Ljava/lang/Object;");
cfw.Add(ByteCode.DUP);
cfw.Add(ByteCode.IFNULL, queryLoopStart);
// stack: ... non_null_result_of_updateDotQuery
cfw.AddALoad(variableObjectLocal);
AddScriptRuntimeInvoke("leaveDotQuery", "(Lorg/mozilla/javascript/Scriptable;" + ")Lorg/mozilla/javascript/Scriptable;");
cfw.AddAStore(variableObjectLocal);
}
示例5: VisitLiteral
private void VisitLiteral(Node node, Node child)
{
int type = node.GetType();
int count;
object[] propertyIds = null;
if (type == Token.ARRAYLIT)
{
count = 0;
for (Node n = child; n != null; n = n.GetNext())
{
++count;
}
}
else
{
if (type == Token.OBJECTLIT)
{
propertyIds = (object[])node.GetProp(Node.OBJECT_IDS_PROP);
count = propertyIds.Length;
}
else
{
throw BadTree(node);
}
}
AddIndexOp(Icode_LITERAL_NEW, count);
StackChange(2);
while (child != null)
{
int childType = child.GetType();
if (childType == Token.GET)
{
VisitExpression(child.GetFirstChild(), 0);
AddIcode(Icode_LITERAL_GETTER);
}
else
{
if (childType == Token.SET)
{
VisitExpression(child.GetFirstChild(), 0);
AddIcode(Icode_LITERAL_SETTER);
}
else
{
VisitExpression(child, 0);
AddIcode(Icode_LITERAL_SET);
}
}
StackChange(-1);
child = child.GetNext();
}
if (type == Token.ARRAYLIT)
{
int[] skipIndexes = (int[])node.GetProp(Node.SKIP_INDEXES_PROP);
if (skipIndexes == null)
{
AddToken(Token.ARRAYLIT);
}
else
{
int index = literalIds.Size();
literalIds.Add(skipIndexes);
AddIndexOp(Icode_SPARE_ARRAYLIT, index);
}
}
else
{
int index = literalIds.Size();
literalIds.Add(propertyIds);
AddIndexOp(Token.OBJECTLIT, index);
}
StackChange(-1);
}
示例6: VisitSetConstVar
private void VisitSetConstVar(Node node, Node child, bool needValue)
{
if (!hasVarsInRegs)
{
Kit.CodeBug();
}
int varIndex = fnCurrent.GetVarIndex(node);
GenerateExpression(child.GetNext(), node);
bool isNumber = (node.GetIntProp(Node.ISNUMBER_PROP, -1) != -1);
short reg = varRegisters[varIndex];
int beyond = cfw.AcquireLabel();
int noAssign = cfw.AcquireLabel();
if (isNumber)
{
cfw.AddILoad(reg + 2);
cfw.Add(ByteCode.IFNE, noAssign);
short stack = cfw.GetStackTop();
cfw.AddPush(1);
cfw.AddIStore(reg + 2);
cfw.AddDStore(reg);
if (needValue)
{
cfw.AddDLoad(reg);
cfw.MarkLabel(noAssign, stack);
}
else
{
cfw.Add(ByteCode.GOTO, beyond);
cfw.MarkLabel(noAssign, stack);
cfw.Add(ByteCode.POP2);
}
}
else
{
cfw.AddILoad(reg + 1);
cfw.Add(ByteCode.IFNE, noAssign);
short stack = cfw.GetStackTop();
cfw.AddPush(1);
cfw.AddIStore(reg + 1);
cfw.AddAStore(reg);
if (needValue)
{
cfw.AddALoad(reg);
cfw.MarkLabel(noAssign, stack);
}
else
{
cfw.Add(ByteCode.GOTO, beyond);
cfw.MarkLabel(noAssign, stack);
cfw.Add(ByteCode.POP);
}
}
cfw.MarkLabel(beyond);
}
示例7: VisitSetProp
private void VisitSetProp(int type, Node node, Node child)
{
Node objectChild = child;
GenerateExpression(child, node);
child = child.GetNext();
if (type == Token.SETPROP_OP)
{
cfw.Add(ByteCode.DUP);
}
Node nameChild = child;
GenerateExpression(child, node);
child = child.GetNext();
if (type == Token.SETPROP_OP)
{
// stack: ... object object name -> ... object name object name
cfw.Add(ByteCode.DUP_X1);
//for 'this.foo += ...' we call thisGet which can skip some
//casting overhead.
if (objectChild.GetType() == Token.THIS && nameChild.GetType() == Token.STRING)
{
cfw.AddALoad(contextLocal);
AddScriptRuntimeInvoke("getObjectProp", "(Lorg/mozilla/javascript/Scriptable;" + "Ljava/lang/String;" + "Lorg/mozilla/javascript/Context;" + ")Ljava/lang/Object;");
}
else
{
cfw.AddALoad(contextLocal);
AddScriptRuntimeInvoke("getObjectProp", "(Ljava/lang/Object;" + "Ljava/lang/String;" + "Lorg/mozilla/javascript/Context;" + ")Ljava/lang/Object;");
}
}
GenerateExpression(child, node);
cfw.AddALoad(contextLocal);
AddScriptRuntimeInvoke("setObjectProp", "(Ljava/lang/Object;" + "Ljava/lang/String;" + "Ljava/lang/Object;" + "Lorg/mozilla/javascript/Context;" + ")Ljava/lang/Object;");
}
示例8: VisitOptimizedCall
private void VisitOptimizedCall(Node node, OptFunctionNode target, int type, Node child)
{
Node firstArgChild = child.GetNext();
string className = codegen.mainClassName;
short thisObjLocal = 0;
if (type == Token.NEW)
{
GenerateExpression(child, node);
}
else
{
GenerateFunctionAndThisObj(child, node);
thisObjLocal = GetNewWordLocal();
cfw.AddAStore(thisObjLocal);
}
// stack: ... functionObj
int beyond = cfw.AcquireLabel();
int regularCall = cfw.AcquireLabel();
cfw.Add(ByteCode.DUP);
cfw.Add(ByteCode.INSTANCEOF, className);
cfw.Add(ByteCode.IFEQ, regularCall);
cfw.Add(ByteCode.CHECKCAST, className);
cfw.Add(ByteCode.DUP);
cfw.Add(ByteCode.GETFIELD, className, Codegen.ID_FIELD_NAME, "I");
cfw.AddPush(codegen.GetIndex(target.fnode));
cfw.Add(ByteCode.IF_ICMPNE, regularCall);
// stack: ... directFunct
cfw.AddALoad(contextLocal);
cfw.AddALoad(variableObjectLocal);
// stack: ... directFunc cx scope
if (type == Token.NEW)
{
cfw.Add(ByteCode.ACONST_NULL);
}
else
{
cfw.AddALoad(thisObjLocal);
}
// stack: ... directFunc cx scope thisObj
Node argChild = firstArgChild;
while (argChild != null)
{
int dcp_register = NodeIsDirectCallParameter(argChild);
if (dcp_register >= 0)
{
cfw.AddALoad(dcp_register);
cfw.AddDLoad(dcp_register + 1);
}
else
{
if (argChild.GetIntProp(Node.ISNUMBER_PROP, -1) == Node.BOTH)
{
cfw.Add(ByteCode.GETSTATIC, "java/lang/Void", "TYPE", "Ljava/lang/Class;");
GenerateExpression(argChild, node);
}
else
{
GenerateExpression(argChild, node);
cfw.AddPush(0.0);
}
}
argChild = argChild.GetNext();
}
cfw.Add(ByteCode.GETSTATIC, "org/mozilla/javascript/ScriptRuntime", "emptyArgs", "[Ljava/lang/Object;");
cfw.AddInvoke(ByteCode.INVOKESTATIC, codegen.mainClassName, (type == Token.NEW) ? codegen.GetDirectCtorName(target.fnode) : codegen.GetBodyMethodName(target.fnode), codegen.GetBodyMethodSignature(target.fnode));
cfw.Add(ByteCode.GOTO, beyond);
cfw.MarkLabel(regularCall);
// stack: ... functionObj
cfw.AddALoad(contextLocal);
cfw.AddALoad(variableObjectLocal);
// stack: ... functionObj cx scope
if (type != Token.NEW)
{
cfw.AddALoad(thisObjLocal);
ReleaseWordLocal(thisObjLocal);
}
// stack: ... functionObj cx scope thisObj
// XXX: this will generate code for the child array the second time,
// so expression code generation better not to alter tree structure...
GenerateCallArgArray(node, firstArgChild, true);
if (type == Token.NEW)
{
AddScriptRuntimeInvoke("newObject", "(Ljava/lang/Object;" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "[Ljava/lang/Object;" + ")Lorg/mozilla/javascript/Scriptable;");
}
else
{
cfw.AddInvoke(ByteCode.INVOKEINTERFACE, "org/mozilla/javascript/Callable", "call", "(Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "Lorg/mozilla/javascript/Scriptable;" + "[Ljava/lang/Object;" + ")Ljava/lang/Object;");
}
cfw.MarkLabel(beyond);
}
示例9: GenerateCallArgArray
private void GenerateCallArgArray(Node node, Node argChild, bool directCall)
{
int argCount = 0;
for (Node child = argChild; child != null; child = child.GetNext())
{
++argCount;
}
// load array object to set arguments
if (argCount == 1 && itsOneArgArray >= 0)
{
cfw.AddALoad(itsOneArgArray);
}
else
{
AddNewObjectArray(argCount);
}
// Copy arguments into it
for (int i = 0; i != argCount; ++i)
{
// If we are compiling a generator an argument could be the result
// of a yield. In that case we will have an immediate on the stack
// which we need to avoid
if (!isGenerator)
{
cfw.Add(ByteCode.DUP);
cfw.AddPush(i);
}
if (!directCall)
{
GenerateExpression(argChild, node);
}
else
{
// If this has also been a directCall sequence, the Number
// flag will have remained set for any parameter so that
// the values could be copied directly into the outgoing
// args. Here we want to force it to be treated as not in
// a Number context, so we set the flag off.
int dcp_register = NodeIsDirectCallParameter(argChild);
if (dcp_register >= 0)
{
DcpLoadAsObject(dcp_register);
}
else
{
GenerateExpression(argChild, node);
int childNumberFlag = argChild.GetIntProp(Node.ISNUMBER_PROP, -1);
if (childNumberFlag == Node.BOTH)
{
AddDoubleWrap();
}
}
}
// When compiling generators, any argument to a method may be a
// yield expression. Hence we compile the argument first and then
// load the argument index and assign the value to the args array.
if (isGenerator)
{
short tempLocal = GetNewWordLocal();
cfw.AddAStore(tempLocal);
cfw.Add(ByteCode.CHECKCAST, "[Ljava/lang/Object;");
cfw.Add(ByteCode.DUP);
cfw.AddPush(i);
cfw.AddALoad(tempLocal);
ReleaseWordLocal(tempLocal);
}
cfw.Add(ByteCode.AASTORE);
argChild = argChild.GetNext();
}
}
示例10: VisitStandardCall
private void VisitStandardCall(Node node, Node child)
{
if (node.GetType() != Token.CALL)
{
throw Codegen.BadTree();
}
Node firstArgChild = child.GetNext();
int childType = child.GetType();
string methodName;
string signature;
if (firstArgChild == null)
{
if (childType == Token.NAME)
{
// name() call
string name = child.GetString();
cfw.AddPush(name);
methodName = "callName0";
signature = "(Ljava/lang/String;" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + ")Ljava/lang/Object;";
}
else
{
if (childType == Token.GETPROP)
{
// x.name() call
Node propTarget = child.GetFirstChild();
GenerateExpression(propTarget, node);
Node id = propTarget.GetNext();
string property = id.GetString();
cfw.AddPush(property);
methodName = "callProp0";
signature = "(Ljava/lang/Object;" + "Ljava/lang/String;" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + ")Ljava/lang/Object;";
}
else
{
if (childType == Token.GETPROPNOWARN)
{
throw Kit.CodeBug();
}
else
{
GenerateFunctionAndThisObj(child, node);
methodName = "call0";
signature = "(Lorg/mozilla/javascript/Callable;" + "Lorg/mozilla/javascript/Scriptable;" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + ")Ljava/lang/Object;";
}
}
}
}
else
{
if (childType == Token.NAME)
{
// XXX: this optimization is only possible if name
// resolution
// is not affected by arguments evaluation and currently
// there are no checks for it
string name = child.GetString();
GenerateCallArgArray(node, firstArgChild, false);
cfw.AddPush(name);
methodName = "callName";
signature = "([Ljava/lang/Object;" + "Ljava/lang/String;" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + ")Ljava/lang/Object;";
}
else
{
int argCount = 0;
for (Node arg = firstArgChild; arg != null; arg = arg.GetNext())
{
++argCount;
}
GenerateFunctionAndThisObj(child, node);
// stack: ... functionObj thisObj
if (argCount == 1)
{
GenerateExpression(firstArgChild, node);
methodName = "call1";
signature = "(Lorg/mozilla/javascript/Callable;" + "Lorg/mozilla/javascript/Scriptable;" + "Ljava/lang/Object;" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + ")Ljava/lang/Object;";
}
else
{
if (argCount == 2)
{
GenerateExpression(firstArgChild, node);
GenerateExpression(firstArgChild.GetNext(), node);
methodName = "call2";
signature = "(Lorg/mozilla/javascript/Callable;" + "Lorg/mozilla/javascript/Scriptable;" + "Ljava/lang/Object;" + "Ljava/lang/Object;" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + ")Ljava/lang/Object;";
}
else
{
GenerateCallArgArray(node, firstArgChild, false);
methodName = "callN";
signature = "(Lorg/mozilla/javascript/Callable;" + "Lorg/mozilla/javascript/Scriptable;" + "[Ljava/lang/Object;" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + ")Ljava/lang/Object;";
}
}
}
}
cfw.AddALoad(contextLocal);
cfw.AddALoad(variableObjectLocal);
AddOptRuntimeInvoke(methodName, signature);
}
示例11: VisitStandardNew
private void VisitStandardNew(Node node, Node child)
{
if (node.GetType() != Token.NEW)
{
throw Codegen.BadTree();
}
Node firstArgChild = child.GetNext();
GenerateExpression(child, node);
// stack: ... functionObj
cfw.AddALoad(contextLocal);
cfw.AddALoad(variableObjectLocal);
// stack: ... functionObj cx scope
GenerateCallArgArray(node, firstArgChild, false);
AddScriptRuntimeInvoke("newObject", "(Ljava/lang/Object;" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "[Ljava/lang/Object;" + ")Lorg/mozilla/javascript/Scriptable;");
}
示例12: VisitSpecialCall
private void VisitSpecialCall(Node node, int type, int specialType, Node child)
{
cfw.AddALoad(contextLocal);
if (type == Token.NEW)
{
GenerateExpression(child, node);
}
else
{
// stack: ... cx functionObj
GenerateFunctionAndThisObj(child, node);
}
// stack: ... cx functionObj thisObj
child = child.GetNext();
GenerateCallArgArray(node, child, false);
string methodName;
string callSignature;
if (type == Token.NEW)
{
methodName = "newObjectSpecial";
callSignature = "(Lorg/mozilla/javascript/Context;" + "Ljava/lang/Object;" + "[Ljava/lang/Object;" + "Lorg/mozilla/javascript/Scriptable;" + "Lorg/mozilla/javascript/Scriptable;" + "I" + ")Ljava/lang/Object;";
// call type
cfw.AddALoad(variableObjectLocal);
cfw.AddALoad(thisObjLocal);
cfw.AddPush(specialType);
}
else
{
methodName = "callSpecial";
callSignature = "(Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Callable;" + "Lorg/mozilla/javascript/Scriptable;" + "[Ljava/lang/Object;" + "Lorg/mozilla/javascript/Scriptable;" + "Lorg/mozilla/javascript/Scriptable;" + "I" + "Ljava/lang/String;I" + ")Ljava/lang/Object;";
// call type
// filename, linenumber
cfw.AddALoad(variableObjectLocal);
cfw.AddALoad(thisObjLocal);
cfw.AddPush(specialType);
string sourceName = scriptOrFn.GetSourceName();
cfw.AddPush(sourceName == null ? string.Empty : sourceName);
cfw.AddPush(itsLineNumber);
}
AddOptRuntimeInvoke(methodName, callSignature);
}
示例13: VisitObjectLiteral
private void VisitObjectLiteral(Node node, Node child, bool topLevel)
{
object[] properties = (object[])node.GetProp(Node.OBJECT_IDS_PROP);
int count = properties.Length;
// If code budget is tight swap out literals into separate method
if (!topLevel && (count > 10 || cfw.GetCurrentCodeOffset() > 30000) && !hasVarsInRegs && !isGenerator && !inLocalBlock)
{
if (literals == null)
{
literals = new List<Node>();
}
literals.Add(node);
string methodName = codegen.GetBodyMethodName(scriptOrFn) + "_literal" + literals.Count;
cfw.AddALoad(funObjLocal);
cfw.AddALoad(contextLocal);
cfw.AddALoad(variableObjectLocal);
cfw.AddALoad(thisObjLocal);
cfw.AddALoad(argsLocal);
cfw.AddInvoke(ByteCode.INVOKEVIRTUAL, codegen.mainClassName, methodName, "(Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "Lorg/mozilla/javascript/Scriptable;" + "[Ljava/lang/Object;" + ")Lorg/mozilla/javascript/Scriptable;");
return;
}
// load array with property ids
AddNewObjectArray(count);
for (int i = 0; i != count; ++i)
{
cfw.Add(ByteCode.DUP);
cfw.AddPush(i);
object id = properties[i];
if (id is string)
{
cfw.AddPush((string)id);
}
else
{
cfw.AddPush(System.Convert.ToInt32(((int)id)));
AddScriptRuntimeInvoke("wrapInt", "(I)Ljava/lang/Integer;");
}
cfw.Add(ByteCode.AASTORE);
}
// load array with property values
AddNewObjectArray(count);
Node child2 = child;
for (int i_1 = 0; i_1 != count; ++i_1)
{
cfw.Add(ByteCode.DUP);
cfw.AddPush(i_1);
int childType = child2.GetType();
if (childType == Token.GET || childType == Token.SET)
{
GenerateExpression(child2.GetFirstChild(), node);
}
else
{
GenerateExpression(child2, node);
}
cfw.Add(ByteCode.AASTORE);
child2 = child2.GetNext();
}
// check if object literal actually has any getters or setters
bool hasGetterSetters = false;
child2 = child;
for (int i_2 = 0; i_2 != count; ++i_2)
{
int childType = child2.GetType();
if (childType == Token.GET || childType == Token.SET)
{
hasGetterSetters = true;
break;
}
child2 = child2.GetNext();
}
// create getter/setter flag array
if (hasGetterSetters)
{
cfw.AddPush(count);
cfw.Add(ByteCode.NEWARRAY, ByteCode.T_INT);
child2 = child;
for (int i_3 = 0; i_3 != count; ++i_3)
{
cfw.Add(ByteCode.DUP);
cfw.AddPush(i_3);
int childType = child2.GetType();
if (childType == Token.GET)
{
cfw.Add(ByteCode.ICONST_M1);
}
else
{
if (childType == Token.SET)
{
cfw.Add(ByteCode.ICONST_1);
}
else
{
cfw.Add(ByteCode.ICONST_0);
}
}
cfw.Add(ByteCode.IASTORE);
child2 = child2.GetNext();
}
//.........这里部分代码省略.........
示例14: VisitArrayLiteral
private void VisitArrayLiteral(Node node, Node child, bool topLevel)
{
int count = 0;
for (Node cursor = child; cursor != null; cursor = cursor.GetNext())
{
++count;
}
// If code budget is tight swap out literals into separate method
if (!topLevel && (count > 10 || cfw.GetCurrentCodeOffset() > 30000) && !hasVarsInRegs && !isGenerator && !inLocalBlock)
{
if (literals == null)
{
literals = new List<Node>();
}
literals.Add(node);
string methodName = codegen.GetBodyMethodName(scriptOrFn) + "_literal" + literals.Count;
cfw.AddALoad(funObjLocal);
cfw.AddALoad(contextLocal);
cfw.AddALoad(variableObjectLocal);
cfw.AddALoad(thisObjLocal);
cfw.AddALoad(argsLocal);
cfw.AddInvoke(ByteCode.INVOKEVIRTUAL, codegen.mainClassName, methodName, "(Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "Lorg/mozilla/javascript/Scriptable;" + "[Ljava/lang/Object;" + ")Lorg/mozilla/javascript/Scriptable;");
return;
}
// load array to store array literal objects
AddNewObjectArray(count);
for (int i = 0; i != count; ++i)
{
cfw.Add(ByteCode.DUP);
cfw.AddPush(i);
GenerateExpression(child, node);
cfw.Add(ByteCode.AASTORE);
child = child.GetNext();
}
int[] skipIndexes = (int[])node.GetProp(Node.SKIP_INDEXES_PROP);
if (skipIndexes == null)
{
cfw.Add(ByteCode.ACONST_NULL);
cfw.Add(ByteCode.ICONST_0);
}
else
{
cfw.AddPush(OptRuntime.EncodeIntArray(skipIndexes));
cfw.AddPush(skipIndexes.Length);
}
cfw.AddALoad(contextLocal);
cfw.AddALoad(variableObjectLocal);
AddOptRuntimeInvoke("newArrayLiteral", "([Ljava/lang/Object;" + "Ljava/lang/String;" + "I" + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + ")Lorg/mozilla/javascript/Scriptable;");
}
示例15: VisitSetConst
private void VisitSetConst(Node node, Node child)
{
string name = node.GetFirstChild().GetString();
while (child != null)
{
GenerateExpression(child, node);
child = child.GetNext();
}
cfw.AddALoad(contextLocal);
cfw.AddPush(name);
AddScriptRuntimeInvoke("setConst", "(Lorg/mozilla/javascript/Scriptable;" + "Ljava/lang/Object;" + "Lorg/mozilla/javascript/Context;" + "Ljava/lang/String;" + ")Ljava/lang/Object;");
}