use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class Blank method isConditionMatched.
@Override
public boolean isConditionMatched(final IExpr expr, PatternMap patternMap) {
if (fCondition == null || expr.head().equals(fCondition)) {
patternMap.setValue(this, expr);
return true;
}
EvalEngine engine = EvalEngine.get();
boolean traceMode = false;
try {
traceMode = engine.isTraceMode();
engine.setTraceMode(false);
final Predicate<IExpr> matcher = Predicates.isTrue(engine, fCondition);
if (matcher.test(expr)) {
patternMap.setValue(this, expr);
return true;
}
} finally {
if (traceMode) {
engine.setTraceMode(true);
}
}
return false;
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class Symbol method clearAttributes.
/** {@inheritDoc} */
@Override
public final void clearAttributes(final int attributes) {
fAttributes &= (0xffff ^ attributes);
if (fSymbolName.charAt(0) == '$' && Config.SERVER_MODE) {
EvalEngine engine = EvalEngine.get();
engine.addModifiedVariable(this);
}
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class Symbol method addAttributes.
/** {@inheritDoc} */
@Override
public final void addAttributes(final int attributes) {
fAttributes |= attributes;
if (fSymbolName.charAt(0) == '$' && Config.SERVER_MODE) {
EvalEngine engine = EvalEngine.get();
engine.addModifiedVariable(this);
}
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class Pattern method isConditionMatched.
@Override
public boolean isConditionMatched(final IExpr expr, PatternMap patternMap) {
if (fCondition == null || expr.head().equals(fCondition)) {
return true;
}
EvalEngine engine = EvalEngine.get();
boolean traceMode = false;
try {
traceMode = engine.isTraceMode();
engine.setTraceMode(false);
final Predicate<IExpr> matcher = Predicates.isTrue(engine, fCondition);
if (matcher.test(expr)) {
return true;
}
} finally {
if (traceMode) {
engine.setTraceMode(true);
}
}
return false;
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class PatternSequence method isConditionMatchedSequence.
@Override
public boolean isConditionMatchedSequence(final IAST sequence, PatternMap patternMap) {
if (fCondition == null) {
patternMap.setValue(this, sequence);
return true;
}
EvalEngine engine = EvalEngine.get();
boolean traceMode = false;
traceMode = engine.isTraceMode();
final Predicate<IExpr> matcher = Predicates.isTrue(engine, fCondition);
try {
for (int i = 1; i < sequence.size(); i++) {
if (sequence.get(i).head().equals(fCondition)) {
continue;
}
engine.setTraceMode(false);
if (matcher.test(sequence.get(i))) {
continue;
}
return false;
}
patternMap.setValue(this, sequence);
return true;
} finally {
if (traceMode) {
engine.setTraceMode(true);
}
}
}
Aggregations