Implemented boolean operators
This commit is contained in:
examples/hello
src/build/core
tests
@ -9,16 +9,16 @@ import (
|
||||
|
||||
// CompileIf compiles a branch instruction.
|
||||
func (f *Function) CompileIf(branch *ast.If) error {
|
||||
startLabel := fmt.Sprintf("%s_if_start_%d", f.Name, f.count.branch)
|
||||
endLabel := fmt.Sprintf("%s_if_end_%d", f.Name, f.count.branch)
|
||||
err := f.CompileCondition(branch.Condition, startLabel, endLabel)
|
||||
success := fmt.Sprintf("%s_if_%d_true", f.Name, f.count.branch)
|
||||
fail := fmt.Sprintf("%s_if_%d_false", f.Name, f.count.branch)
|
||||
err := f.CompileCondition(branch.Condition, success, fail)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
f.assembler.Label(asm.LABEL, startLabel)
|
||||
defer f.assembler.Label(asm.LABEL, endLabel)
|
||||
f.assembler.Label(asm.LABEL, success)
|
||||
defer f.assembler.Label(asm.LABEL, fail)
|
||||
f.count.branch++
|
||||
return f.CompileAST(branch.Body)
|
||||
}
|
||||
|
Reference in New Issue
Block a user