first while test working

fixed logic error in test framework
This commit is contained in:
Torsten Ruger
2018-03-16 12:33:11 +05:30
parent ea882f403a
commit 35a0952943
9 changed files with 71 additions and 58 deletions

View File

@ -1,10 +1,21 @@
module Mom
# A base class for conditions in MOM
# Just a marker, no real functionality for now
# Checks (if in code, compare in assm) jump or not, depending
# The logic we choose is closer to the code logic (the asm is reversed)
# When we write an if, the true is the next code, so the Check logic is
# that if the check passes, no jump happens
# This means you need to pass the false label, where to jump to if the
# check does not pass
# Note: In assembler a branch on 0 does just that, it branches if the condition
# is met. This means that the asm implementation is somewhat the reverse
# of the Mom names. But it's easier to understand (imho)
class Check < Instruction
attr_reader :false_jump
def initialize(false_jump)
@false_jump = false_jump
raise "Jump target must be a label #{false_jump}" unless false_jump.is_a?(Label)
end
end
# The funny thing about the ruby truth is that is is anything but false or nil
@ -15,8 +26,10 @@ module Mom
class TruthCheck < Check
attr_reader :condition
def initialize(condition)
def initialize(condition , false_jump)
super(false_jump)
@condition = condition
raise "condition must be slot_definition #{condition}" unless condition.is_a?(SlotDefinition)
end
def to_risc(compiler)