本文整理汇总了Java中com.google.javascript.rhino.Token.FALSE属性的典型用法代码示例。如果您正苦于以下问题:Java Token.FALSE属性的具体用法?Java Token.FALSE怎么用?Java Token.FALSE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.javascript.rhino.Token
的用法示例。
在下文中一共展示了Token.FALSE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isImmutableValue
/**
* Returns true if this is an immutable value.
*/
static boolean isImmutableValue(Node n) {
switch (n.getType()) {
case Token.STRING:
case Token.NUMBER:
case Token.NULL:
case Token.TRUE:
case Token.FALSE:
case Token.VOID:
return true;
case Token.NEG:
return isImmutableValue(n.getFirstChild());
case Token.NAME:
String name = n.getString();
// We assume here that programs don't change the value of the keyword
// undefined to something other than the value undefined.
return "undefined".equals(name)
|| "Infinity".equals(name)
|| "NaN".equals(name);
}
return false;
}
示例2: isCollapsibleValue
/**
* Determines whether we know enough about the given value to be able
* to collapse it into subsequent expressions.
*
* For example, we can collapse booleans and variable names:
* <code>
* x = 3; y = x; // y = x = 3;
* a = true; b = true; // b = a = true;
* <code>
* But we won't try to collapse complex expressions.
*
* @param value The value node.
* @param isLValue Whether it's on the left-hand side of an expr.
*/
private boolean isCollapsibleValue(Node value, boolean isLValue) {
switch (value.getType()) {
case Token.GETPROP:
// Do not collapse GETPROPs on arbitrary objects, because
// they may be implemented setter functions, and oftentimes
// setter functions fail on native objects. This is ok for "THIS"
// objects, because we assume that they are non-native.
return !isLValue || value.getFirstChild().getType() == Token.THIS;
case Token.NAME:
case Token.NUMBER:
case Token.TRUE:
case Token.FALSE:
case Token.NULL:
case Token.STRING:
return true;
}
return false;
}
示例3: determineType
@Override
public TypeInfo determineType() {
if(node.getType() == Token.NUMBER) return new TypeInfo(this, JavaScriptDictionary.NUMBER);
else if(node.getType() == Token.STRING) return new TypeInfo(this, JavaScriptDictionary.STRING);
else if(node.getType() == Token.TRUE || node.getType() == Token.FALSE) return new TypeInfo(this, JavaScriptDictionary.BOOL);
else if(node.getType() == Token.THIS) {
// Is this "this" reference declared in a function declared in an object literal? If so, it's type info
// should include the scope of the object literal, so that functions called with respect to "this" first
// search the object literal for matching functions. Not infallible, but a good guess.
CFGFunction function = getFunction();
ScriptOrFnNode funNode = function.getFunctionNode();
if(funNode.getParent() != null && funNode.getParent().getType() == Token.OBJECTLIT) {
JavaScriptType type = getFunction().getFeedlack().getObjectLiteralType(funNode.getParent());
if(type != null)
return new TypeInfo(this, type);
}
return new TypeInfo(this, JavaScriptDictionary.NONE);
}
else return new TypeInfo(this, JavaScriptDictionary.NONE);
}
示例4: getBooleanValue
/**
* Gets the boolean value of a node that represents a literal. This method
* effectively emulates the <code>Boolean()</code> JavaScript cast function.
*
* @throws IllegalArgumentException If {@code n} is not a literal value
*/
static boolean getBooleanValue(Node n) {
switch (n.getType()) {
case Token.STRING:
return n.getString().length() > 0;
case Token.NUMBER:
return n.getDouble() != 0;
case Token.NULL:
case Token.FALSE:
case Token.VOID:
return false;
case Token.NAME:
String name = n.getString();
if ("undefined".equals(name)
|| "NaN".equals(name)) {
// We assume here that programs don't change the value of the keyword
// undefined to something other than the value undefined.
return false;
} else if ("Infinity".equals(name)) {
return true;
}
break;
case Token.TRUE:
case Token.ARRAYLIT:
case Token.OBJECTLIT:
case Token.REGEXP:
return true;
}
throw new IllegalArgumentException("Non-literal value: " + n);
}
示例5: getStringValue
/**
* Gets the value of a node as a String, or null if it cannot be converted.
* When it returns a non-null String, this method effectively emulates the
* <code>String()</code> JavaScript cast function.
*/
static String getStringValue(Node n) {
// TODO(user): Convert constant array, object, and regex literals as well.
switch (n.getType()) {
case Token.NAME:
case Token.STRING:
return n.getString();
case Token.NUMBER:
double value = n.getDouble();
long longValue = (long) value;
// Return "1" instead of "1.0"
if (longValue == value) {
return Long.toString(longValue);
} else {
return Double.toString(n.getDouble());
}
case Token.FALSE:
case Token.TRUE:
case Token.NULL:
return Node.tokenToName(n.getType());
case Token.VOID:
return "undefined";
}
return null;
}
示例6: isValidDefineValue
/**
* Determines whether the given value may be assigned to a define.
*
* @param val The value being assigned.
* @param defines The list of names of existing defines.
*/
static boolean isValidDefineValue(Node val, Set<String> defines) {
switch (val.getType()) {
case Token.STRING:
case Token.NUMBER:
case Token.TRUE:
case Token.FALSE:
return true;
// Single operators are valid if the child is valid.
case Token.BITAND:
case Token.BITNOT:
case Token.BITOR:
case Token.BITXOR:
case Token.NOT:
case Token.NEG:
return isValidDefineValue(val.getFirstChild(), defines);
// Names are valid if and only if they are defines themselves.
case Token.NAME:
case Token.GETPROP:
if (val.isQualifiedName()) {
return defines.contains(val.getQualifiedName());
}
}
return false;
}
示例7: testMemoization
public void testMemoization() throws Exception {
Node trueNode = new Node(Token.TRUE);
Node falseNode = new Node(Token.FALSE);
// Wow, is there really a circular dependency between JSCompiler and
// SyntacticScopeCreator?
ScopeCreator creator = new MemoizedScopeCreator(
new SyntacticScopeCreator(new Compiler()));
Scope scopeA = creator.createScope(trueNode, null);
assertSame(scopeA, creator.createScope(trueNode, null));
assertNotSame(scopeA, creator.createScope(falseNode, null));
}
示例8: 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 + ")");
}
}