Moved register state to scopes
This commit is contained in:
@ -36,7 +36,9 @@ func NewFunction(name string, file *fs.File, body token.List) *Function {
|
||||
Syscall: x64.SyscallRegisters,
|
||||
Output: x64.ReturnValueRegisters,
|
||||
},
|
||||
scopes: []Scope{{}},
|
||||
scopes: []*Scope{
|
||||
{variables: map[string]*Variable{}},
|
||||
},
|
||||
finished: make(chan struct{}),
|
||||
},
|
||||
}
|
||||
@ -52,14 +54,14 @@ func (f *Function) Compile() {
|
||||
|
||||
// CompileTokens compiles a token list.
|
||||
func (f *Function) CompileTokens(tokens token.List) error {
|
||||
tree, err := ast.Parse(tokens)
|
||||
body, err := ast.Parse(tokens)
|
||||
|
||||
if err != nil {
|
||||
err.(*errors.Error).File = f.File
|
||||
return err
|
||||
}
|
||||
|
||||
return f.CompileAST(tree)
|
||||
return f.CompileAST(body)
|
||||
}
|
||||
|
||||
// CompileAST compiles an abstract syntax tree.
|
||||
@ -97,7 +99,7 @@ func (f *Function) CompileASTNode(node ast.Node) error {
|
||||
return f.CompileLoop(node)
|
||||
|
||||
default:
|
||||
panic("Unknown AST type")
|
||||
panic("unknown AST type")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user