本文整理汇总了C#中EcmaScript.NET.Node.putIntProp方法的典型用法代码示例。如果您正苦于以下问题:C# Node.putIntProp方法的具体用法?C# Node.putIntProp怎么用?C# Node.putIntProp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EcmaScript.NET.Node
的用法示例。
在下文中一共展示了Node.putIntProp方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitStatement
void VisitStatement (Node node)
{
int type = node.Type;
Node child = node.FirstChild;
switch (type) {
case Token.FUNCTION: {
int fnIndex = node.getExistingIntProp (Node.FUNCTION_PROP);
int fnType = scriptOrFn.getFunctionNode (fnIndex).FunctionType;
// Only function expressions or function expression
// statements needs closure code creating new function
// object on stack as function statements are initialized
// at script/function start
// In addition function expression can not present here
// at statement level, they must only present as expressions.
if (fnType == FunctionNode.FUNCTION_EXPRESSION_STATEMENT) {
addIndexOp (Icode_CLOSURE_STMT, fnIndex);
}
else {
if (fnType != FunctionNode.FUNCTION_STATEMENT) {
throw Context.CodeBug ();
}
}
}
break;
case Token.SCRIPT:
case Token.LABEL:
case Token.LOOP:
case Token.BLOCK:
case Token.EMPTY:
case Token.WITH:
updateLineNumber (node);
while (child != null) {
VisitStatement (child);
child = child.Next;
}
break;
case Token.ENTERWITH:
VisitExpression (child, 0);
addToken (Token.ENTERWITH);
stackChange (-1);
break;
case Token.LEAVEWITH:
addToken (Token.LEAVEWITH);
break;
case Token.LOCAL_BLOCK: {
int local = allocLocal ();
node.putIntProp (Node.LOCAL_PROP, local);
updateLineNumber (node);
while (child != null) {
VisitStatement (child);
child = child.Next;
}
addIndexOp (Icode_LOCAL_CLEAR, local);
releaseLocal (local);
}
break;
case Token.DEBUGGER:
updateLineNumber (node);
addIcode (Icode_DEBUGGER);
break;
case Token.SWITCH:
updateLineNumber (node); {
// See comments in IRFactory.createSwitch() for description
// of SWITCH node
Node switchNode = (Node.Jump)node;
VisitExpression (child, 0);
for (Node.Jump caseNode = (Node.Jump)child.Next; caseNode != null; caseNode = (Node.Jump)caseNode.Next) {
if (caseNode.Type != Token.CASE)
throw badTree (caseNode);
Node test = caseNode.FirstChild;
addIcode (Icode_DUP);
stackChange (1);
VisitExpression (test, 0);
addToken (Token.SHEQ);
stackChange (-1);
// If true, Icode_IFEQ_POP will jump and remove case
// value from stack
addGoto (caseNode.target, Icode_IFEQ_POP);
stackChange (-1);
}
addIcode (Icode_POP);
stackChange (-1);
}
break;
case Token.TARGET:
markTargetLabel (node);
//.........这里部分代码省略.........
示例2: CreateTryCatchFinally
//.........这里部分代码省略.........
// ...
// with (newCatchScope(e, x)) {
// if (conditionN) {
// somethingN;
// goto after_catch;
// }
// }
// with (newCatchScope(e, x)) {
// somethingDefault;
// goto after_catch;
// }
// }
// after_catch:
//
// If there is no default catch, then the last with block
// arround "somethingDefault;" is replaced by "rethrow;"
// It is assumed that catch handler generation will store
// exeception object in handlerBlock register
// Block with local for exception scope objects
Node catchScopeBlock = new Node (Token.LOCAL_BLOCK);
// expects catchblocks children to be (cond block) pairs.
Node cb = catchBlocks.FirstChild;
bool hasDefault = false;
int scopeIndex = 0;
while (cb != null) {
int catchLineNo = cb.Lineno;
Node name = cb.FirstChild;
Node cond = name.Next;
Node catchStatement = cond.Next;
cb.removeChild (name);
cb.removeChild (cond);
cb.removeChild (catchStatement);
// Add goto to the catch statement to jump out of catch
// but prefix it with LEAVEWITH since try..catch produces
// "with"code in order to limit the scope of the exception
// object.
catchStatement.addChildToBack (new Node (Token.LEAVEWITH));
catchStatement.addChildToBack (makeJump (Token.GOTO, endCatch));
// Create condition "if" when present
Node condStmt;
if (cond.Type == Token.EMPTY) {
condStmt = catchStatement;
hasDefault = true;
}
else {
condStmt = CreateIf (cond, catchStatement, null, catchLineNo);
}
// Generate code to Create the scope object and store
// it in catchScopeBlock register
Node catchScope = new Node (Token.CATCH_SCOPE, name, CreateUseLocal (handlerBlock));
catchScope.putProp (Node.LOCAL_BLOCK_PROP, catchScopeBlock);
catchScope.putIntProp (Node.CATCH_SCOPE_PROP, scopeIndex);
catchScopeBlock.addChildToBack (catchScope);
// Add with statement based on catch scope object
catchScopeBlock.addChildToBack (CreateWith (CreateUseLocal (catchScopeBlock), condStmt, catchLineNo));
// move to next cb
cb = cb.Next;
++scopeIndex;
}
pn.addChildToBack (catchScopeBlock);
if (!hasDefault) {
// Generate code to rethrow if no catch clause was executed
Node rethrow = new Node (Token.RETHROW);
rethrow.putProp (Node.LOCAL_BLOCK_PROP, handlerBlock);
pn.addChildToBack (rethrow);
}
pn.addChildToBack (endCatch);
}
if (hasFinally) {
Node finallyTarget = Node.newTarget ();
pn.Finally = finallyTarget;
// add jsr finally to the try block
pn.addChildToBack (makeJump (Token.JSR, finallyTarget));
// jump around finally code
Node finallyEnd = Node.newTarget ();
pn.addChildToBack (makeJump (Token.GOTO, finallyEnd));
pn.addChildToBack (finallyTarget);
Node fBlock = new Node (Token.FINALLY, finallyBlock);
fBlock.putProp (Node.LOCAL_BLOCK_PROP, handlerBlock);
pn.addChildToBack (fBlock);
pn.addChildToBack (finallyEnd);
}
handlerBlock.addChildToBack (pn);
return handlerBlock;
}
示例3: CreateIncDec
internal Node CreateIncDec(int nodeType, bool post, Node child)
{
child = makeReference (child);
if (child == null) {
string msg;
if (nodeType == Token.DEC) {
msg = "msg.bad.decr";
}
else {
msg = "msg.bad.incr";
}
parser.ReportError (msg);
return null;
}
int childType = child.Type;
switch (childType) {
case Token.NAME:
case Token.GETPROP:
case Token.GETELEM:
case Token.GET_REF: {
Node n = new Node (nodeType, child);
int incrDecrMask = 0;
if (nodeType == Token.DEC) {
incrDecrMask |= Node.DECR_FLAG;
}
if (post) {
incrDecrMask |= Node.POST_FLAG;
}
n.putIntProp (Node.INCRDECR_PROP, incrDecrMask);
return n;
}
}
throw Context.CodeBug ();
}
示例4: CreateRegExp
/// <summary> Regular expressions</summary>
internal Node CreateRegExp(int regexpIndex)
{
Node n = new Node (Token.REGEXP);
n.putIntProp (Node.REGEXP_PROP, regexpIndex);
return n;
}
示例5: CreateCallOrNew
internal Node CreateCallOrNew(int nodeType, Node child)
{
int type = Node.NON_SPECIALCALL;
if (child.Type == Token.NAME) {
string name = child.String;
if (name.Equals ("eval")) {
type = Node.SPECIALCALL_EVAL;
}
else if (name.Equals ("With")) {
type = Node.SPECIALCALL_WITH;
}
}
else if (child.Type == Token.GETPROP) {
string name = child.LastChild.String;
if (name.Equals ("eval")) {
type = Node.SPECIALCALL_EVAL;
}
}
Node node = new Node (nodeType, child);
if (type != Node.NON_SPECIALCALL) {
// Calls to these functions require activation objects.
setRequiresActivation ();
node.putIntProp (Node.SPECIALCALL_PROP, type);
}
return node;
}