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