Improved code generation
This commit is contained in:
@ -25,7 +25,7 @@ func (f *Function) CompileCondition(condition *expression.Expression, successLab
|
||||
f.JumpIfTrue(left.Token.Text(), successLabel)
|
||||
|
||||
// Right
|
||||
f.assembler.Label(asm.LABEL, leftFailLabel)
|
||||
f.AddLabel(leftFailLabel)
|
||||
right := condition.Children[1]
|
||||
err = f.CompileCondition(right, successLabel, failLabel)
|
||||
|
||||
@ -52,7 +52,7 @@ func (f *Function) CompileCondition(condition *expression.Expression, successLab
|
||||
f.JumpIfFalse(left.Token.Text(), failLabel)
|
||||
|
||||
// Right
|
||||
f.assembler.Label(asm.LABEL, leftSuccessLabel)
|
||||
f.AddLabel(leftSuccessLabel)
|
||||
right := condition.Children[1]
|
||||
err = f.CompileCondition(right, successLabel, failLabel)
|
||||
|
||||
@ -79,17 +79,17 @@ func (f *Function) CompileCondition(condition *expression.Expression, successLab
|
||||
func (f *Function) JumpIfFalse(operator string, label string) {
|
||||
switch operator {
|
||||
case "==":
|
||||
f.assembler.Label(asm.JNE, label)
|
||||
f.Jump(asm.JNE, label)
|
||||
case "!=":
|
||||
f.assembler.Label(asm.JE, label)
|
||||
f.Jump(asm.JE, label)
|
||||
case ">":
|
||||
f.assembler.Label(asm.JLE, label)
|
||||
f.Jump(asm.JLE, label)
|
||||
case "<":
|
||||
f.assembler.Label(asm.JGE, label)
|
||||
f.Jump(asm.JGE, label)
|
||||
case ">=":
|
||||
f.assembler.Label(asm.JL, label)
|
||||
f.Jump(asm.JL, label)
|
||||
case "<=":
|
||||
f.assembler.Label(asm.JG, label)
|
||||
f.Jump(asm.JG, label)
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,16 +97,16 @@ func (f *Function) JumpIfFalse(operator string, label string) {
|
||||
func (f *Function) JumpIfTrue(operator string, label string) {
|
||||
switch operator {
|
||||
case "==":
|
||||
f.assembler.Label(asm.JE, label)
|
||||
f.Jump(asm.JE, label)
|
||||
case "!=":
|
||||
f.assembler.Label(asm.JNE, label)
|
||||
f.Jump(asm.JNE, label)
|
||||
case ">":
|
||||
f.assembler.Label(asm.JG, label)
|
||||
f.Jump(asm.JG, label)
|
||||
case "<":
|
||||
f.assembler.Label(asm.JL, label)
|
||||
f.Jump(asm.JL, label)
|
||||
case ">=":
|
||||
f.assembler.Label(asm.JGE, label)
|
||||
f.Jump(asm.JGE, label)
|
||||
case "<=":
|
||||
f.assembler.Label(asm.JLE, label)
|
||||
f.Jump(asm.JLE, label)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user