Skip to content

Commit 38c7c5e

Browse files
committed
flatten interpreter generation
1 parent cabf6b8 commit 38c7c5e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

interpreter.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,14 +1339,14 @@ func buildObject(hide ast.ObjectFieldHide, fields map[string]value) *valueObject
13391339
return makeValueSimpleObject(bindingFrame{}, fieldMap, nil, nil)
13401340
}
13411341

1342-
func buildInterpreter(ext vmExtMap, nativeFuncs map[string]*NativeFunction, maxStack int, ic *importCache, traceOut io.Writer, evalHook EvalHook, profilerOpts StackProfilerOpts) (*interpreter, error) {
1342+
func buildInterpreter(vm *VM) (*interpreter, error) {
13431343
i := interpreter{
1344-
stack: makeCallStack(maxStack),
1345-
importCache: ic,
1346-
traceOut: traceOut,
1347-
nativeFuncs: nativeFuncs,
1348-
evalHook: evalHook,
1349-
profilerOpts: profilerOpts,
1344+
stack: makeCallStack(vm.MaxStack),
1345+
importCache: vm.importCache,
1346+
traceOut: vm.traceOut,
1347+
nativeFuncs: vm.nativeFuncs,
1348+
evalHook: vm.EvalHook,
1349+
profilerOpts: vm.profilerOpts,
13501350
}
13511351

13521352
stdObj, err := buildStdObject(&i)
@@ -1356,7 +1356,7 @@ func buildInterpreter(ext vmExtMap, nativeFuncs map[string]*NativeFunction, maxS
13561356

13571357
i.baseStd = stdObj
13581358

1359-
i.extVars = prepareExtVars(&i, ext, "extvar")
1359+
i.extVars = prepareExtVars(&i, vm.ext, "extvar")
13601360

13611361
return &i, nil
13621362
}
@@ -1419,7 +1419,7 @@ func evaluateAux(i *interpreter, node ast.Node, tla vmExtMap) (value, error) {
14191419

14201420
// Evaluate ast node with the given VM
14211421
func evaluate(node ast.Node, vm *VM) (string, error) {
1422-
i, err := buildInterpreter(vm.ext, vm.nativeFuncs, vm.MaxStack, vm.importCache, vm.traceOut, vm.EvalHook, vm.profilerOpts)
1422+
i, err := buildInterpreter(vm)
14231423
if err != nil {
14241424
return "", err
14251425
}
@@ -1445,7 +1445,7 @@ func evaluate(node ast.Node, vm *VM) (string, error) {
14451445
}
14461446

14471447
func evaluateMulti(node ast.Node, vm *VM) (map[string]string, error) {
1448-
i, err := buildInterpreter(vm.ext, vm.nativeFuncs, vm.MaxStack, vm.importCache, vm.traceOut, vm.EvalHook, vm.profilerOpts)
1448+
i, err := buildInterpreter(vm)
14491449
if err != nil {
14501450
return nil, err
14511451
}
@@ -1462,7 +1462,7 @@ func evaluateMulti(node ast.Node, vm *VM) (map[string]string, error) {
14621462
}
14631463

14641464
func evaluateStream(node ast.Node, vm *VM) ([]string, error) {
1465-
i, err := buildInterpreter(vm.ext, vm.nativeFuncs, vm.MaxStack, vm.importCache, vm.traceOut, vm.EvalHook, vm.profilerOpts)
1465+
i, err := buildInterpreter(vm)
14661466
if err != nil {
14671467
return nil, err
14681468
}

0 commit comments

Comments
 (0)