mirror of
https://github.com/DanilaFe/abacus
synced 2025-12-28 03:31:08 +00:00
Switch Abacus to returning an EvaluationResult with the context.
This commit is contained in:
@@ -20,6 +20,7 @@ import org.nwapw.abacus.plugin.ClassFinder;
|
||||
import org.nwapw.abacus.plugin.PluginListener;
|
||||
import org.nwapw.abacus.plugin.PluginManager;
|
||||
import org.nwapw.abacus.plugin.StandardPlugin;
|
||||
import org.nwapw.abacus.tree.EvaluationResult;
|
||||
import org.nwapw.abacus.tree.TreeNode;
|
||||
|
||||
import java.io.File;
|
||||
@@ -144,12 +145,14 @@ public class AbacusController implements PluginListener {
|
||||
if (constructedTree == null) {
|
||||
return ERR_SYNTAX;
|
||||
}
|
||||
NumberInterface evaluatedNumber = abacus.evaluateTree(constructedTree);
|
||||
EvaluationResult result = abacus.evaluateTree(constructedTree);
|
||||
NumberInterface evaluatedNumber = result.getValue();
|
||||
if (evaluatedNumber == null) {
|
||||
return ERR_EVAL;
|
||||
}
|
||||
String resultingString = evaluatedNumber.toString();
|
||||
historyData.add(new HistoryModel(inputField.getText(), constructedTree.toString(), resultingString));
|
||||
abacus.applyToContext(result.getResultingContext());
|
||||
return resultingString;
|
||||
} catch (ComputationInterruptedException exception) {
|
||||
return ERR_STOP;
|
||||
|
||||
Reference in New Issue
Block a user