本文整理汇总了Java中com.google.javascript.rhino.Token.INC属性的典型用法代码示例。如果您正苦于以下问题:Java Token.INC属性的具体用法?Java Token.INC怎么用?Java Token.INC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.javascript.rhino.Token
的用法示例。
在下文中一共展示了Token.INC属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nodeTypeMayHaveSideEffects
/**
* Returns true if the current node's type implies side effects.
*
* This is a non-recursive version of the may have side effects
* check; used to check wherever the current node's type is one of
* the reason's why a subtree has side effects.
*/
static boolean nodeTypeMayHaveSideEffects(Node n) {
if (NodeUtil.isAssignmentOp(n)) {
return true;
}
switch(n.getType()) {
case Token.CALL:
case Token.DELPROP:
case Token.NEW:
case Token.DEC:
case Token.INC:
case Token.THROW:
return true;
case Token.NAME:
// A variable definition.
return n.hasChildren();
default:
return false;
}
}
示例2: hasNonLocalSideEffect
/**
* @return Whether the node may have non-local side-effects.
*/
private boolean hasNonLocalSideEffect(Node n) {
boolean sideEffect = false;
int type = n.getType();
// Note: Only care about changes to non-local names, specifically
// ignore VAR declaration assignments.
if (NodeUtil.isAssignmentOp(n)
|| type == Token.INC
|| type == Token.DEC) {
Node lhs = n.getFirstChild();
// Ignore changes to local names.
if (!isLocalName(lhs)) {
sideEffect = true;
}
} else if (type == Token.CALL) {
sideEffect = NodeUtil.functionCallHasSideEffects(n);
} else if (type == Token.NEW) {
sideEffect = NodeUtil.constructorCallHasSideEffects(n);
} else if (type == Token.DELPROP) {
sideEffect = true;
}
return sideEffect;
}
示例3: mayThrowException
/**
* Determines if the subtree might throw an exception.
*/
private static boolean mayThrowException(Node n) {
switch (n.getType()) {
case Token.CALL:
case Token.GETPROP:
case Token.GETELEM:
case Token.THROW:
case Token.NEW:
case Token.ASSIGN:
case Token.INC:
case Token.DEC:
case Token.INSTANCEOF:
return true;
case Token.FUNCTION:
return false;
}
for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
if (!ControlFlowGraph.isEnteringNewCfgNode(c) && mayThrowException(c)) {
return true;
}
}
return false;
}
示例4: isLvalue
boolean isLvalue() {
int parentType = parent.getType();
return (parentType == Token.VAR && nameNode.getFirstChild() != null)
|| parentType == Token.INC
|| parentType == Token.DEC
|| (NodeUtil.isAssignmentOp(parent)
&& parent.getFirstChild() == nameNode)
|| isLhsOfForInExpression(nameNode);
}
示例5: canReplaceWithGetProp
/**
* Logic for when a getprop can be replaced.
* Can't alias a call to eval per ECMA 262 spec section 15.1.2.1
* Can't be an assign -> no a.b = c;
* Can't be inc or dec -> no a.b++; or a.b--;
* Must be a GETPROP (NODE, A) where A is a reserved name
* @param propNameNode Property name node
* @param getPropNode GETPROP node
* @param parent parent node
* @return True if can be replaced
*/
private boolean canReplaceWithGetProp(Node propNameNode, Node getPropNode,
Node parent) {
boolean isCallTarget = (parent.getType() == Token.CALL)
&& (parent.getFirstChild() == getPropNode);
boolean isAssignTarget = NodeUtil.isAssignmentOp(parent)
&& (parent.getFirstChild() == getPropNode);
boolean isIncOrDec = (parent.getType() == Token.INC) ||
(parent.getType() == Token.DEC);
return (propNameNode.getType() == Token.STRING) && !isAssignTarget
&& (!isCallTarget || !"eval".equals(propNameNode.getString()))
&& !isIncOrDec
&& props.containsKey(propNameNode.getString());
}
示例6: visit
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.getType() == Token.NAME) {
String name = n.getString();
Scope.Var var = t.getScope().getVar(name);
// It's ok for var to be null since it won't be in any scope if it's
// an extern
if (var != null && var.isLocal()) {
return;
}
Property global = globals.get(name);
if (global != null) {
// If a global is being assigned to or otherwise modified, then we
// don't want to alias it.
// Using "new" with this global is not a mutator, but it's also
// something that we want to avoid when aliasing, since we may be
// dealing with external objects (e.g. ActiveXObject in MSIE)
if ((NodeUtil.isAssignmentOp(parent) &&
parent.getFirstChild() == n) ||
parent.getType() == Token.INC ||
parent.getType() == Token.DEC ||
parent.getType() == Token.NEW) {
global.recordMutator(t);
} else {
global.recordAccessor(t);
}
globalUses.add(n);
}
}
}
示例7: precedence
static int precedence(int type) {
switch (type) {
case Token.COMMA: return 0;
case Token.ASSIGN_BITOR:
case Token.ASSIGN_BITXOR:
case Token.ASSIGN_BITAND:
case Token.ASSIGN_LSH:
case Token.ASSIGN_RSH:
case Token.ASSIGN_URSH:
case Token.ASSIGN_ADD:
case Token.ASSIGN_SUB:
case Token.ASSIGN_MUL:
case Token.ASSIGN_DIV:
case Token.ASSIGN_MOD:
case Token.ASSIGN: return 1;
case Token.HOOK: return 2; // ?: operator
case Token.OR: return 3;
case Token.AND: return 4;
case Token.BITOR: return 5;
case Token.BITXOR: return 6;
case Token.BITAND: return 7;
case Token.EQ:
case Token.NE:
case Token.SHEQ:
case Token.SHNE: return 8;
case Token.LT:
case Token.GT:
case Token.LE:
case Token.GE:
case Token.INSTANCEOF:
case Token.IN: return 9;
case Token.LSH:
case Token.RSH:
case Token.URSH: return 10;
case Token.SUB:
case Token.ADD: return 11;
case Token.MUL:
case Token.MOD:
case Token.DIV: return 12;
case Token.INC:
case Token.DEC:
case Token.NEW:
case Token.DELPROP:
case Token.TYPEOF:
case Token.VOID:
case Token.NOT:
case Token.BITNOT:
case Token.POS:
case Token.NEG: return 13;
case Token.ARRAYLIT:
case Token.CALL:
case Token.EMPTY:
case Token.FALSE:
case Token.FUNCTION:
case Token.GETELEM:
case Token.GETPROP:
case Token.GET_REF:
case Token.IF:
case Token.LP:
case Token.NAME:
case Token.NULL:
case Token.NUMBER:
case Token.OBJECTLIT:
case Token.REGEXP:
case Token.RETURN:
case Token.STRING:
case Token.THIS:
case Token.TRUE:
return 15;
default: throw new Error("Unknown precedence for " +
Node.tokenToName(type) +
" (type " + type + ")");
}
}
示例8: visit
@Override
public void visit(NodeTraversal traversal, Node node, Node parent) {
if (inExterns) {
return;
}
if (!NodeUtil.nodeTypeMayHaveSideEffects(node)) {
return;
}
if (NodeUtil.isCall(node) || NodeUtil.isNew(node)) {
allFunctionCalls.add(node);
}
Node enclosingFunction = traversal.getEnclosingFunction();
if (enclosingFunction != null) {
FunctionInformation sideEffectInfo =
functionSideEffectMap.get(enclosingFunction);
Preconditions.checkNotNull(sideEffectInfo);
if (NodeUtil.isAssignmentOp(node)) {
visitAssignmentOrUnaryOperatorLhs(
sideEffectInfo, traversal.getScope(), node.getFirstChild());
} else {
switch(node.getType()) {
case Token.CALL:
case Token.NEW:
visitCall(sideEffectInfo, node);
break;
case Token.DELPROP:
case Token.DEC:
case Token.INC:
visitAssignmentOrUnaryOperatorLhs(
sideEffectInfo, traversal.getScope(), node.getFirstChild());
break;
case Token.NAME:
// Variable definition are not side effects.
// Just check that the name appears in the context of a
// variable declaration.
Preconditions.checkArgument(
NodeUtil.isVarDeclaration(node));
break;
case Token.THROW:
visitThrow(sideEffectInfo);
break;
default:
throw new IllegalArgumentException(
"Unhandled side effect node type " +
Token.name(node.getType()));
}
}
}
}
示例9: canNameValueChange
/**
* This is similar to NodeUtil.isLValue except that object properties and
* array member modification aren't important ("o" in "o.a = 2" is still "o"
* after assignment, where in as "o = x", "o" is now "x").
*
* This also looks for the redefinition of a name.
* function (x){var x;}
*
* @param n The NAME node in question.
* @param parent The parent of the node.
*/
private static boolean canNameValueChange(Node n, Node parent) {
int type = parent.getType();
return (type == Token.VAR || type == Token.INC || type == Token.DEC ||
(NodeUtil.isAssignmentOp(parent) && parent.getFirstChild() == n));
}