Implemented if statements
This commit is contained in:
@ -45,7 +45,7 @@ func NewFunction(name string, file *fs.File, body token.List) *Function {
|
||||
// Compile turns a function into machine code.
|
||||
func (f *Function) Compile() {
|
||||
defer close(f.finished)
|
||||
f.assembler.Label(f.Name)
|
||||
f.assembler.Label(asm.LABEL, f.Name)
|
||||
f.err = f.CompileTokens(f.Body)
|
||||
f.assembler.Return()
|
||||
}
|
||||
@ -90,6 +90,9 @@ func (f *Function) CompileASTNode(node ast.Node) error {
|
||||
case *ast.Return:
|
||||
return f.CompileReturn(node)
|
||||
|
||||
case *ast.If:
|
||||
return f.CompileIf(node)
|
||||
|
||||
case *ast.Loop:
|
||||
return f.CompileLoop(node)
|
||||
|
||||
|
Reference in New Issue
Block a user