Added functions and ensured the context was being passed around correctly

This commit is contained in:
Stefan Zermatten
2020-09-18 11:52:44 +02:00
parent 06f17a6d33
commit 6570665c1e
12 changed files with 209 additions and 53 deletions

View File

@@ -6,19 +6,19 @@ export default class IndexNode extends ParseNode {
this.array = array;
this.index = index;
}
resolve(fn, scope){
let index = this.index[fn](scope);
resolve(fn, scope, context){
let index = this.index[fn](scope, context);
if (index.isInteger){
let selection = this.array.values[index.value - 1];
if (selection){
let result = selection[fn](scope);
let result = selection[fn](scope, context);
result.inheritDetails([index, this]);
return result;
}
}
return new IndexNode({
array: this.array[fn](scope),
index: this.index[fn](scope),
array: this.array[fn](scope, context),
index: this.index[fn](scope, context),
previousNodes: [this],
});
}