本文整理汇总了Java中com.google.javascript.rhino.Token.REF_SPECIAL属性的典型用法代码示例。如果您正苦于以下问题:Java Token.REF_SPECIAL属性的具体用法?Java Token.REF_SPECIAL怎么用?Java Token.REF_SPECIAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.javascript.rhino.Token
的用法示例。
在下文中一共展示了Token.REF_SPECIAL属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAssignmentActions
/**
* Returns an action for assigning the right-hand-side to the left or null
* if this assignment should be ignored.
*/
private List<Action> createAssignmentActions(
Node lhs, Node rhs, Node parent) {
switch (lhs.getType()) {
case Token.NAME:
ConcreteSlot var = (ConcreteSlot) scope.getSlot(lhs.getString());
Preconditions.checkState(var != null,
"Type tightener could not find variable with name %s",
lhs.getString());
return Lists.<Action>newArrayList(
new VariableAssignAction(var, rhs));
case Token.GETPROP:
Node receiver = lhs.getFirstChild();
return Lists.<Action>newArrayList(
new PropertyAssignAction(receiver, rhs));
case Token.GETELEM:
return Lists.newArrayList();
case Token.GET_REF:
// We ignore ref specials as their types should not be computed.
if (lhs.getFirstChild().getType() == Token.REF_SPECIAL) {
return Lists.newArrayList();
} else {
throw new AssertionError(
"Bad LHS for getref: " + parent.toStringTree());
}
default:
throw new AssertionError(
"Bad LHS for assignment: " + parent.toStringTree());
}
}
示例2: visit
@SuppressWarnings("fallthrough")
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
switch (n.getType()) {
case Token.NAME:
case Token.GETPROP:
if (NodeUtil.isGetProp(parent) ||
parent.getType() == Token.REF_SPECIAL) {
// We will resolve this when we visit parent later in the traversal.
return;
} else if (NodeUtil.isFunction(parent)) {
// Function declarations have been taken care of in enterScope();
return;
} else if (NodeUtil.isAssign(parent)) {
// Handled below.
return;
}
if (isLocalNameReference(t, n)) {
// Ignore all local variable references unless is creates a closure.
return;
}
if (isPrototypeNameReference(n)) {
recordPrototypePropUse(t, n, parent);
} else if (isStaticNameReference(n, t.getScope())) {
recordStaticNameUse(t, n, parent);
} else {
recordUnknownUse(t, n, parent);
}
break;
case Token.ASSIGN:
Node lhs = n.getFirstChild();
Node rhs = n.getLastChild();
if (NodeUtil.isFunction(rhs)) {
// These are recorded when entering the scope.
return;
}
if (NodeUtil.isName(lhs) ||
NodeUtil.isGetProp(lhs) ||
NodeUtil.isGetProp(rhs)) {
if (NodeUtil.isPrototypeProperty(lhs)) {
Name name = recordPrototypePropDefinition(
t, lhs, getType(rhs), n, parent, parent.getParent());
name.setAliased(true);
}
}
maybeAliasNamesOnAssign(lhs, rhs);
break;
case Token.VAR:
// var foo = bar;
Node varName = n.getFirstChild();
Node assignedValue = varName.getFirstChild();
if (assignedValue == null) {
return;
}
maybeAliasNamesOnAssign(varName, assignedValue);
break;
case Token.CALL:
Node param = n.getFirstChild();
// We need to alias every name that is passed as a parameter because
// they have different names inside the function's scope.
while ((param = param.getNext()) != null) {
if (NodeUtil.isName(param) || NodeUtil.isGetProp(param)) {
safeAlias(param);
}
}
maybeRecordExport(n);
break;
}
}