Everything is a closure
Some checks failed
Build / build (push) Failing after 1m56s
Test / build (push) Failing after 2m33s

This commit is contained in:
Chuck Smith
2024-03-13 17:08:17 -04:00
parent e373e9f68a
commit 78b560e457
7 changed files with 132 additions and 81 deletions

View File

@@ -38,6 +38,7 @@ const (
OpGetLocal
OpSetLocal
OpGetBuiltin
OpClosure
)
type Definition struct {
@@ -73,6 +74,7 @@ var definitions = map[Opcode]*Definition{
OpGetLocal: {"OpGetLocal", []int{1}},
OpSetLocal: {"OpSetLocal", []int{1}},
OpGetBuiltin: {"OpGetBuiltin", []int{1}},
OpClosure: {"OpClosure", []int{2, 1}},
}
func Lookup(op byte) (*Definition, error) {
@@ -146,6 +148,9 @@ func (ins Instructions) fmtInstruction(def *Definition, operands []int) string {
return def.Name
case 1:
return fmt.Sprintf("%s %d", def.Name, operands[0])
case 2:
return fmt.Sprintf("%s %d %d", def.Name, operands[0], operands[1])
}
return fmt.Sprintf("ERROR: unhandled operandCount for %s\n", def.Name)