Computation engine rewrite continues

This commit is contained in:
Stefan Zermatten
2021-09-10 19:51:03 +02:00
parent 28ec7082ee
commit b877a8b45f
15 changed files with 235 additions and 28 deletions

View File

@@ -0,0 +1,11 @@
import { CompilationContext } from '/imports/parser/parser.js';
export default function evaluateCalculation(calculation, scope){
const context = new CompilationContext();
const parseNode = calculation._parsedCalculation;
const fn = calculation._parseLevel || 'reduce';
const calculationScope = {...calculation._localScope, ...scope};
const result = parseNode[fn](calculationScope, context);
calculation.value = result;
calculation.errors = context.errors;
}