generalise the operator handling

ie passing them through
implementing more
This commit is contained in:
Torsten Ruger
2018-04-19 22:13:52 +03:00
parent 7d9132ee36
commit 9e21719aeb
6 changed files with 24 additions and 29 deletions

View File

@ -1,5 +1,8 @@
module Risc
def self.operators
[:+, :-, :>>, :<<, :*, :&, :|]
end
# Destructive operator instructions on the two registers given
#
# left = left OP right
@ -11,7 +14,7 @@ module Risc
def initialize( source , operator , left , right )
super(source)
@operator = operator
raise "unsuported operator :#{operator}:" unless [:+, :-, :>>, :<<, :*, :&, :|, :==].include?(operator)
raise "unsuported operator :#{operator}:" unless Risc.operators.include?(operator)
@left = left
@right = right
raise "Not register #{left}" unless RiscValue.look_like_reg(left)