本文整理汇总了Java中org.mozilla.javascript.ast.NumberLiteral类的典型用法代码示例。如果您正苦于以下问题:Java NumberLiteral类的具体用法?Java NumberLiteral怎么用?Java NumberLiteral使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NumberLiteral类属于org.mozilla.javascript.ast包,在下文中一共展示了NumberLiteral类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: possiblyAMethodTerm
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
/**
* conservative check that returns false only for terms that obviously do not represent methods
*
* TODO move this code inside ITypeTerm??
* @param t
* @return
*/
private boolean possiblyAMethodTerm(ITypeTerm t) {
if (ConstraintGenUtil.isNullUndefinedLitOrVoidOp(t)) {
return false;
}
if (t instanceof ExpressionTerm) {
ExpressionTerm et = (ExpressionTerm) t;
AstNode node = et.getNode();
if (node != null) {
return !(node instanceof NumberLiteral
|| node instanceof StringLiteral);
}
}
return !(t instanceof ArrayLiteralTerm
|| t instanceof MapLiteralTerm
|| t instanceof ObjectLiteralTerm
|| t instanceof TypeConstantTerm);
}
示例2: decompile
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
void decompile(AstNode node) {
switch (node.getType()) {
case Token.ARRAYLIT:
decompileArrayLiteral((ArrayLiteral)node);
break;
case Token.OBJECTLIT:
decompileObjectLiteral((ObjectLiteral)node);
break;
case Token.STRING:
decompiler.addString(((StringLiteral)node).getValue());
break;
case Token.NAME:
decompiler.addName(((Name)node).getIdentifier());
break;
case Token.NUMBER:
decompiler.addNumber(((NumberLiteral)node).getNumber());
break;
case Token.GETPROP:
decompilePropertyGet((PropertyGet)node);
break;
case Token.EMPTY:
break;
case Token.GETELEM:
decompileElementGet((ElementGet) node);
break;
case Token.THIS:
decompiler.addToken(node.getType());
break;
default:
Kit.codeBug("unexpected token: "
+ Token.typeToName(node.getType()));
}
}
示例3: numberLiteral
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
/**
* Return number literal value.
*/
private double numberLiteral(final AstNode node) {
checkState(node instanceof NumberLiteral, node, "Expected number literal only");
//noinspection ConstantConditions
NumberLiteral number = (NumberLiteral) node;
return number.getNumber();
}
示例4: safeGetString
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
protected static String safeGetString(AstNode node){
if(node.getType() == Token.STRING){
StringLiteral sl = (StringLiteral)node;
return sl.getValue();
}else if(node.getType()==Token.NUMBER){
NumberLiteral nl = (NumberLiteral)node;
return nl.getValue();
}else{
return node.getString();
}
}
示例5: transformNumber
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
private Node transformNumber(NumberLiteral node) {
decompiler.addNumber(node.getNumber());
return node;
}
示例6: newNumber
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
public static Node newNumber(double number) {
NumberLiteral n = new NumberLiteral();
n.setNumber(number);
return n;
}
示例7: getDouble
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
/** Can only be called when <tt>getType() == Token.NUMBER</tt> */
public final double getDouble() {
return ((NumberLiteral)this).getNumber();
}
示例8: setDouble
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
public final void setDouble(double number) {
((NumberLiteral)this).setNumber(number);
}
示例9: visit
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
/**
* This method generates constraints for all relevant AstNodes. It delegates its work to various
* processXXX() methods that handle AstNodes of type XXX.
*/
@Override
public boolean visit(AstNode node) {
if (node instanceof VariableInitializer){
processVariableInitializer(node);
} else if (node instanceof ReturnStatement){
processReturnStatement((ReturnStatement)node);
} else if (node instanceof ExpressionStatement){
processExpressionStatement((ExpressionStatement)node);
} else if (node instanceof ForLoop){
processForLoop((ForLoop)node);
} else if (node instanceof ForInLoop){
processForInLoop((ForInLoop)node);
}else if (node instanceof WhileLoop){
processWhileLoop((WhileLoop)node);
} else if (node instanceof DoLoop){
processDoLoop((DoLoop)node);
} else if (node instanceof NewExpression){
processNewExpression((NewExpression)node);
} else if (node instanceof FunctionCall){
processFunctionCall((FunctionCall)node);
} else if (node instanceof ElementGet){
processElementGet((ElementGet)node);
} else if (node instanceof FunctionNode){
processFunctionNode((FunctionNode)node);
} else if (node instanceof IfStatement){
processIfStatement((IfStatement)node);
} else if (node instanceof KeywordLiteral){
processKeywordLiteral((KeywordLiteral)node);
} else if (node instanceof SwitchStatement){
processSwitchStatement((SwitchStatement)node);
} else if (node instanceof SwitchCase){
processSwitchCase((SwitchCase)node);
} else if ((node instanceof AstRoot) || //AstRoot: no constraints need to be generated
(node instanceof BreakStatement) || //BreakStatement: no constraints need to be generated
(node instanceof VariableDeclaration) || //VariableDeclaration: we generate constraints for its constituent VariableInitializer nodes
(node instanceof Name) || //Name: generate constraints for complex expressions that refer to names
(node instanceof NumberLiteral) || //NumberLiteral: generate constraints for complex expressions that refer to names
(node instanceof StringLiteral) || //StringLiteral: generate constraints for complex expressions that refer to names
(node instanceof Assignment) || // Assignment is a special case of InfixExpression
(node instanceof ArrayLiteral) ||
(node instanceof UnaryExpression) ||
(node instanceof InfixExpression) ||
(node instanceof ConditionalExpression) ||
(node instanceof ParenthesizedExpression) ||
(node instanceof EmptyExpression) ||
(node instanceof ObjectLiteral) ||
(node instanceof EmptyStatement) ||
(node instanceof ContinueStatement) ||
(node instanceof Scope) ||
(node instanceof Block)){ // // occurs in programs with for loops -- nothing to be done here?
/* nothing */
} else {
error("unsupported node " + node.toSource().trim() + " of type: " + node.getClass().getName(), node);
}
return true;
}
示例10: processExpression
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
/**
* Creates constraints for the subtree rooted at a designated expression node,
* and returns a constraint variable corresponding to the root of the tree.
*/
private ITypeTerm processExpression(AstNode n){
ITypeTerm cached = theMap.get(n);
if (cached != null) return cached;
if (n instanceof Name){
return processVariableReference((Name)n);
} else if (n instanceof NumberLiteral){
return processNumericConstant((NumberLiteral)n);
} else if (n instanceof StringLiteral){
return processStringLiteral((StringLiteral)n);
} else if (ConstraintGenUtil.isBooleanConstant(n)){
return processBooleanConstant(n);
} else if (n instanceof UnaryExpression){
return processUnaryExpression((UnaryExpression)n);
} else if (n instanceof InfixExpression){
return processInfixExpression((InfixExpression)n);
} else if (n instanceof FunctionCall){
return processFunctionCallExpression((FunctionCall)n);
} else if (n instanceof ArrayLiteral){
return processArrayLiteral((ArrayLiteral)n);
} else if (n instanceof ElementGet){
return processElementGet((ElementGet)n);
} else if (n instanceof ParenthesizedExpression) {
return processParenthesizedExpression((ParenthesizedExpression)n);
} else if (n instanceof ConditionalExpression) {
return processConditionalExpression((ConditionalExpression)n);
} else if (n instanceof ObjectLiteral) {
return processObjectLiteral((ObjectLiteral)n);
} else if (n instanceof KeywordLiteral){
return processKeywordLiteral((KeywordLiteral)n);
} else if (n instanceof FunctionNode){
return processFunctionNode((FunctionNode)n);
} else if (n instanceof EmptyExpression){
return processEmptyExpression((EmptyExpression)n);
} else {
System.err.println(n.toSource());
return expError("unimplemented case in findOrCreateExpressionVariable: " + n.getClass().getName(), n);
}
}
示例11: print
import org.mozilla.javascript.ast.NumberLiteral; //导入依赖的package包/类
private void print(NumberLiteral node) throws IOException {
writer.append(node.getValue());
}