diff options
-rw-r--r-- | internal/compile/compile.go | 5 | ||||
-rw-r--r-- | starlark/value.go | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/internal/compile/compile.go b/internal/compile/compile.go index 99e9d54..8da415b 100644 --- a/internal/compile/compile.go +++ b/internal/compile/compile.go @@ -152,6 +152,7 @@ var opcodeNames = [...]string{ DUP2: "dup2", DUP: "dup", EQL: "eql", + EXCH: "exch", FALSE: "false", FREE: "free", GE: "ge", @@ -271,7 +272,9 @@ var stackEffect = [...]int8{ func (op Opcode) String() string { if op < OpcodeMax { - return opcodeNames[op] + if name := opcodeNames[op]; name != "" { + return name + } } return fmt.Sprintf("illegal op (%d)", op) } diff --git a/starlark/value.go b/starlark/value.go index 880329a..9ec67c8 100644 --- a/starlark/value.go +++ b/starlark/value.go @@ -547,6 +547,9 @@ func (fn *Function) Globals() StringDict { func (fn *Function) Position() syntax.Position { return fn.funcode.Pos } func (fn *Function) NumParams() int { return fn.funcode.NumParams } + +// Param returns the name and position of the ith parameter, +// where 0 <= i < NumParams(). func (fn *Function) Param(i int) (string, syntax.Position) { id := fn.funcode.Locals[i] return id.Name, id.Pos |