@@ -6813,6 +6813,35 @@ class FunctionRef extends expression_1.Expression {
68136813 this.library = json.libraryName;
68146814 this.functionDefs = null;
68156815 }
6816+ async exec(ctx) {
6817+ const args = await this.execArgs(ctx);
6818+ // Filter out functions w/ wrong number of arguments.
6819+ const fDefs = this.getFunctionDefs(ctx, args);
6820+ // If there is still > 1 matching function, calculate a score based on quality of matches
6821+ if (fDefs.length > 1) {
6822+ // TODO
6823+ }
6824+ if (fDefs.length === 0) {
6825+ throw new Error('no function with matching signature could be found');
6826+ }
6827+ // Moved context creation below the functionDef checks because it's not needed if
6828+ // there are no matching function defs
6829+ let child_ctx;
6830+ if (this.library) {
6831+ const libCtx = ctx.getLibraryContext(this.library);
6832+ child_ctx = libCtx ? libCtx.childContext() : undefined;
6833+ }
6834+ else {
6835+ child_ctx = ctx.childContext();
6836+ }
6837+ // By this point, we should have only one function, but until implementation is completed,
6838+ // use the last one (no matter how many still remain)
6839+ const functionDef = fDefs[fDefs.length - 1];
6840+ for (let i = 0; i < functionDef.parameters.length; i++) {
6841+ child_ctx.set(functionDef.parameters[i].name, args[i]);
6842+ }
6843+ return functionDef.expression.execute(child_ctx);
6844+ }
68166845 getFunctionDefs(ctx, args) {
68176846 if (this.functionDefs != null) {
68186847 // cache hit
@@ -6850,35 +6879,6 @@ class FunctionRef extends expression_1.Expression {
68506879 this.functionDefs = functionDefs;
68516880 return functionDefs;
68526881 }
6853- async exec(ctx) {
6854- const args = await this.execArgs(ctx);
6855- // Filter out functions w/ wrong number of arguments.
6856- const fDefs = this.getFunctionDefs(ctx, args);
6857- // If there is still > 1 matching function, calculate a score based on quality of matches
6858- if (fDefs.length > 1) {
6859- // TODO
6860- }
6861- if (fDefs.length === 0) {
6862- throw new Error('no function with matching signature could be found');
6863- }
6864- // Moved context creation below the functionDef checks because it's not needed if
6865- // there are no matching function defs
6866- let child_ctx;
6867- if (this.library) {
6868- const libCtx = ctx.getLibraryContext(this.library);
6869- child_ctx = libCtx ? libCtx.childContext() : undefined;
6870- }
6871- else {
6872- child_ctx = ctx.childContext();
6873- }
6874- // By this point, we should have only one function, but until implementation is completed,
6875- // use the last one (no matter how many still remain)
6876- const functionDef = fDefs[fDefs.length - 1];
6877- for (let i = 0; i < functionDef.parameters.length; i++) {
6878- child_ctx.set(functionDef.parameters[i].name, args[i]);
6879- }
6880- return functionDef.expression.execute(child_ctx);
6881- }
68826882}
68836883exports.FunctionRef = FunctionRef;
68846884class OperandRef extends expression_1.Expression {
0 commit comments