2017-09-14 15:07:02 +02:00
|
|
|
module Mom
|
|
|
|
|
|
|
|
# Mom internal check, as the name says to see if two values are not the same
|
|
|
|
# In other words, we this checks identity, bit-values, pointers
|
|
|
|
#
|
|
|
|
# The values that are compared are defined as SlotDefinitions, ie can be anything
|
|
|
|
# available to the machine through frame message or self
|
|
|
|
#
|
2018-03-24 16:54:15 +01:00
|
|
|
# Acording to Mom::Check logic, we jump to the given label is the values are the same
|
|
|
|
#
|
2017-09-14 15:07:02 +02:00
|
|
|
class NotSameCheck < Check
|
|
|
|
attr_reader :left , :right
|
|
|
|
|
2018-03-21 08:08:28 +01:00
|
|
|
def initialize(left, right , label)
|
|
|
|
super(label)
|
2017-09-14 15:07:02 +02:00
|
|
|
@left , @right = left , right
|
|
|
|
end
|
2018-03-13 11:46:06 +01:00
|
|
|
|
2018-04-17 19:26:15 +02:00
|
|
|
def to_s
|
|
|
|
"NotSameCheck: #{left}:#{right}"
|
|
|
|
end
|
|
|
|
|
2018-03-24 16:54:15 +01:00
|
|
|
# basically move both left and right values into register
|
|
|
|
# subtract them and see if IsZero comparison
|
2018-03-21 08:08:28 +01:00
|
|
|
def to_risc(compiler)
|
|
|
|
l_val = left.to_register(compiler, self)
|
|
|
|
r_val = right.to_register(compiler, self)
|
2018-03-24 16:54:15 +01:00
|
|
|
check = Risc.op( self , :- , l_val.register , r_val.register)
|
|
|
|
check << Risc::IsZero.new( self, false_jump.to_risc(compiler))
|
2018-03-21 08:08:28 +01:00
|
|
|
l_val << r_val << check
|
2018-03-13 11:46:06 +01:00
|
|
|
end
|
2017-09-14 15:07:02 +02:00
|
|
|
end
|
|
|
|
end
|