fix while syntax and test
This commit is contained in:
parent
99cff3aa32
commit
db5c37bc55
@ -14,7 +14,8 @@ module Phisol
|
||||
|
||||
cond = process(condition)
|
||||
|
||||
@method.source.add_code Register::IsZero.new(condition,merge)
|
||||
branch_class = Object.const_get "Register::Is#{branch_type.capitalize}"
|
||||
@method.source.add_code branch_class.new( condition , merge )
|
||||
|
||||
last = process_all(statements).last
|
||||
|
||||
|
@ -15,7 +15,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn],[LoadConstant,IsZero,LoadConstant,Branch],
|
||||
@expect = [[SaveReturn],[LoadConstant,IsPlus,LoadConstant,Branch],
|
||||
[],[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
check
|
||||
end
|
||||
@ -25,14 +25,14 @@ HERE
|
||||
class Object
|
||||
int main()
|
||||
int n = 5
|
||||
while_minus(n > 0)
|
||||
while_plus(n)
|
||||
n = n - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot],[GetSlot,GetSlot,LoadConstant,OperatorInstruction,
|
||||
IsZero,GetSlot,GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,Branch],
|
||||
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot],[GetSlot,GetSlot, IsPlus,GetSlot,
|
||||
GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,Branch],
|
||||
[],[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
check
|
||||
end
|
||||
@ -43,7 +43,7 @@ HERE
|
||||
class Object
|
||||
int main()
|
||||
int n = 10
|
||||
while_notzero( n > 5)
|
||||
while_plus( n - 5)
|
||||
n = n + 1
|
||||
return n
|
||||
end
|
||||
@ -51,7 +51,7 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot],
|
||||
[GetSlot,GetSlot,LoadConstant,OperatorInstruction,IsZero,GetSlot,
|
||||
[GetSlot,GetSlot,LoadConstant,OperatorInstruction,IsPlus,GetSlot,
|
||||
GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,GetSlot,
|
||||
GetSlot,Branch] ,
|
||||
[],[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
|
Loading…
Reference in New Issue
Block a user