本文整理了Java中de.gaalop.dfg.Expression.replaceExpression()
方法的一些代码示例,展示了Expression.replaceExpression()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Expression.replaceExpression()
方法的具体详情如下:
包路径:de.gaalop.dfg.Expression
类名称:Expression
方法名:replaceExpression
[英]Replaces the old expression recursively by the given new one, iff the old one can be found in the DFG hierarchy.
[中]如果可以在DFG层次结构中找到旧表达式,则用给定的新表达式递归替换旧表达式。
代码示例来源:origin: CallForSanity/Gaalop
@Override
public void replaceExpression(Expression old, Expression newExpression) {
if (variable == old && newExpression instanceof Variable) {
variable = (Variable) newExpression;
}
if (value == old) {
value = newExpression;
} else {
// recursively try to replace expression
value.replaceExpression(old, newExpression);
}
}
代码示例来源:origin: CallForSanity/Gaalop
@Override
public void replaceExpression(Expression old, Expression newExpression) {
if (expression == old) {
expression = newExpression;
} else {
expression.replaceExpression(old, newExpression);
}
}
代码示例来源:origin: CallForSanity/Gaalop
@Override
public void replaceExpression(Expression old, Expression newExpression) {
if (old == operand) {
operand = newExpression;
} else {
operand.replaceExpression(old, newExpression);
}
}
代码示例来源:origin: CallForSanity/Gaalop
@Override
public void replaceExpression(Expression old, Expression newExpression) {
for (int i = 0; i < args.size(); i++) {
Expression arg = args.get(i);
if (arg == old) {
args.set(i, newExpression);
} else {
arg.replaceExpression(old, newExpression);
}
}
}
代码示例来源:origin: CallForSanity/Gaalop
left = newExpression;
} else if (left.isComposite()) {
left.replaceExpression(old, newExpression);
right = newExpression;
} else if (right.isComposite()) {
right.replaceExpression(old, newExpression);
代码示例来源:origin: CallForSanity/Gaalop
@Override
public void replaceExpression(Expression old, Expression newExpression) {
if (condition == old) {
condition = newExpression;
} else {
condition.replaceExpression(old, newExpression);
}
replaceSubtree(positive, old, newExpression);
if (negative != null) {
replaceSubtree(negative, old, newExpression);
}
}
代码示例来源:origin: CallForSanity/Gaalop
/**
* Performs constant propagtion on an expression and returns the result expression
* @param expression the expression for constant propagtion
* @return the result expression, where constant variables are constant
*/
private Expression performConstantPropagationOnExpression(Expression expression) {
dfgVisitorUsedVariables.getVariables().clear();
expression.accept(dfgVisitorUsedVariables);
for (VariableComponent varComp : dfgVisitorUsedVariables.getVariables()) {
if (mapConstants.containsKey(varComp)) {
// replace variable with constant
if (expression == varComp.getReferredExpression()) {
expression = mapConstants.get(varComp);
} else {
expression.replaceExpression(varComp.getReferredExpression(), mapConstants.get(varComp));
}
setGraphModified();
}
}
// do a constant folding on the value
expression.accept(constantFolding);
if (constantFolding.isGraphModified()) {
setGraphModified();
}
return constantFolding.getResultExpr();
}
内容来源于网络,如有侵权,请联系作者删除!