diff options
| -rw-r--r-- | parser/compiler.go | 6 | ||||
| -rw-r--r-- | readme.md | 18 |
2 files changed, 6 insertions, 18 deletions
diff --git a/parser/compiler.go b/parser/compiler.go index 7a60565..82228ed 100644 --- a/parser/compiler.go +++ b/parser/compiler.go @@ -115,10 +115,10 @@ func (c *Compiler) Codegen(tokens Tokens) (err error) { emit(int64(t.Pos), vm.Call) case lang.CallX: - typ := pop().Type + rtyp := pop().value.Data.Type() // TODO: pop input types (careful with variadic function) - for i := 0; i < typ.Rtype.NumOut(); i++ { - push(&symbol{Type: typ.Out(i)}) + for i := 0; i < rtyp.NumOut(); i++ { + push(&symbol{Type: &vm.Type{Rtype: rtyp.Out(i)}}) } emit(int64(t.Pos), vm.CallX, int64(t.Beg)) @@ -6,23 +6,11 @@ languages and virtual machines. The first language definition is a subset of Go, enough to implement simple benchmarks, as fibonacci numbers. -The first VM is a stack machine, operated by walking directly the AST. - -The next step is to add a byte-code based VM and the corresponding byte code -generator. - -Further steps is to get closer to full Go spec and / or introduce new -languages definitions and new VM implementations. +A byte-code based VM and the corresponding byte code generator are +provided. Note: this is highly experimental and unstable. - ## Usage -`go run ./cmd/gint < ./samples/fib` - -To debug visually the AST, you can set the `DOT` env to a command able -to a display a graphviz dot input, such as `dot -Txlib` or `dotty -` -(for old graphviz versions like mine): - -`DOT="dot -Txlib" go run ./cmd/gint < ./samples/fib` +`go run . ./samples/fib` |
