2014-06-14 20:29:57 +02:00
|
|
|
module Vm
|
2014-06-26 17:39:02 +02:00
|
|
|
class Integer
|
2014-06-14 20:29:57 +02:00
|
|
|
|
|
|
|
def less_or_equal block , right
|
|
|
|
block.cmp( self , right )
|
2014-06-26 16:52:15 +02:00
|
|
|
Virtual::BranchCondition.new :le
|
2014-06-14 20:29:57 +02:00
|
|
|
end
|
|
|
|
def greater_or_equal block , right
|
|
|
|
block.cmp( self , right )
|
2014-06-26 16:52:15 +02:00
|
|
|
Virtual::BranchCondition.new :ge
|
2014-06-14 20:29:57 +02:00
|
|
|
end
|
|
|
|
def greater_than block , right
|
|
|
|
block.cmp( self , right )
|
2014-06-26 16:52:15 +02:00
|
|
|
Virtual::BranchCondition.new :gt
|
2014-06-14 20:29:57 +02:00
|
|
|
end
|
|
|
|
def less_than block , right
|
|
|
|
block.cmp( self , right )
|
2014-06-26 16:52:15 +02:00
|
|
|
Virtual::BranchCondition.new :lt
|
2014-06-14 20:29:57 +02:00
|
|
|
end
|
|
|
|
def plus block , first , right
|
|
|
|
block.add( self , left , right )
|
|
|
|
self
|
|
|
|
end
|
|
|
|
def minus block , left , right
|
|
|
|
block.sub( self , left , right )
|
|
|
|
self
|
|
|
|
end
|
2014-06-14 22:48:12 +02:00
|
|
|
def left_shift block , left , right
|
2014-06-14 20:29:57 +02:00
|
|
|
block.mov( self , left , shift_lsr: right )
|
|
|
|
self
|
|
|
|
end
|
|
|
|
def equals block , right
|
|
|
|
block.cmp( self , right )
|
2014-06-26 16:52:15 +02:00
|
|
|
Virtual::BranchCondition.new :eq
|
2014-06-14 20:29:57 +02:00
|
|
|
end
|
|
|
|
|
2014-06-24 11:24:36 +02:00
|
|
|
def is_true? function
|
|
|
|
function.cmp( self , 0 )
|
2014-06-26 16:52:15 +02:00
|
|
|
Virtual::BranchCondition.new :ne
|
2014-06-24 11:24:36 +02:00
|
|
|
end
|
|
|
|
|
2014-06-14 20:29:57 +02:00
|
|
|
def move block , right
|
|
|
|
block.mov( self , right )
|
|
|
|
self
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|