本文整理汇总了Java中org.nfunk.jep.ASTVarNode类的典型用法代码示例。如果您正苦于以下问题:Java ASTVarNode类的具体用法?Java ASTVarNode怎么用?Java ASTVarNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ASTVarNode类属于org.nfunk.jep包,在下文中一共展示了ASTVarNode类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: set
import org.nfunk.jep.ASTVarNode; //导入依赖的package包/类
public void set(EvaluatorI pv, Node node, Object value) throws ParseException {
Node lhsNode = node.jjtGetChild(0);
if (!(lhsNode instanceof ASTVarNode))
throw new ParseException("Ele: lhs must be a variable");
ASTVarNode vn = (ASTVarNode) lhsNode;
Variable var = vn.getVar();
Object rhs = pv.eval(node.jjtGetChild(1));
int index = -1;
if (rhs instanceof Number) {
index = ((Number) rhs).intValue() - 1;
} else if (rhs instanceof Vector) {
Vector vec = (Vector) rhs;
if (vec.size() != 1)
throw new ParseException("Ele: only single dimension arrays supported in JEP");
index = ((Number) vec.firstElement()).intValue() - 1;
} else
throw new ParseException("Ele: rhs must be a number");
Object oldVarVal = var.getValue();
if (!(oldVarVal instanceof Vector))
throw new ParseException("Ele: the value of the variable must be a Vector");
Vector newVarVal = (Vector) ((Vector) oldVarVal).clone();
newVarVal.set(index, value);
var.setValue(newVarVal);
}
开发者ID:dynamo2,项目名称:tianma,代码行数:26,代码来源:Ele.java
示例2: set
import org.nfunk.jep.ASTVarNode; //导入依赖的package包/类
public void set(EvaluatorI pv, Node node, Object value)
throws ParseException {
Node lhsNode = node.jjtGetChild(0);
if(!(lhsNode instanceof ASTVarNode))
throw new ParseException("Ele: lhs must be a variable");
ASTVarNode vn = (ASTVarNode) lhsNode;
Variable var = pv.getSymbolTable().getVar(vn.getVarName());
Object rhs = pv.eval(node.jjtGetChild(1));
int index=-1;
if(rhs instanceof Number)
{
index=((Number) rhs).intValue()-1;
}
else if(rhs instanceof Vector)
{
Vector vec = (Vector) rhs;
if(vec.size()!=1) throw new ParseException("Ele: only single dimension arrays supported in JEP");
index = ((Number) vec.firstElement()).intValue()-1;
}
else throw new ParseException("Ele: rhs must be a number");
Object oldVarVal = var.getValue();
if(!(oldVarVal instanceof Vector))
throw new ParseException("Ele: the value of the variable must be a Vector");
Vector newVarVal = (Vector) ((Vector) oldVarVal).clone();
newVarVal.set(index,value);
var.setValue(newVarVal);
}
开发者ID:dbunibas,项目名称:spicy,代码行数:29,代码来源:Ele.java
示例3: set
import org.nfunk.jep.ASTVarNode; //导入依赖的package包/类
public void set(EvaluatorI pv, Node node, Object value)
throws ParseException {
Node lhsNode = node.jjtGetChild(0);
if(!(lhsNode instanceof ASTVarNode))
throw new ParseException("Ele: lhs must be a variable");
ASTVarNode vn = (ASTVarNode) lhsNode;
Variable var = vn.getVar();
Object rhs = pv.eval(node.jjtGetChild(1));
int index=-1;
if(rhs instanceof Number)
{
index=((Number) rhs).intValue()-1;
}
else if(rhs instanceof Vector)
{
Vector vec = (Vector) rhs;
if(vec.size()!=1) throw new ParseException("Ele: only single dimension arrays supported in JEP");
index = ((Number) vec.firstElement()).intValue()-1;
}
else throw new ParseException("Ele: rhs must be a number");
Object oldVarVal = var.getValue();
if(!(oldVarVal instanceof Vector))
throw new ParseException("Ele: the value of the variable must be a Vector");
Vector newVarVal = (Vector) ((Vector) oldVarVal).clone();
newVarVal.set(index,value);
var.setValue(newVarVal);
}
开发者ID:maths,项目名称:dragmath,代码行数:29,代码来源:Ele.java
注:本文中的org.nfunk.jep.ASTVarNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论