change operators to symbols

This commit is contained in:
Torsten Ruger
2018-03-24 17:53:27 +02:00
parent 3ceb2c2f69
commit 793fa313a5
3 changed files with 37 additions and 29 deletions

View File

@ -1,9 +1,17 @@
module Risc
# Destructive operator instructions on the two registers given
#
# left = left OP right
#
# With OP being the normal logical and mathematical operations provided by
# cpus. Ie "+" , "-", ">>", "<<", "*", "&", "|"
#
class OperatorInstruction < Instruction
def initialize source , operator , left , right
def initialize( source , operator , left , right )
super(source)
@operator = operator
raise "unsuported operator :#{operator}:" unless [:+, :-, :>>, :<<, :*, :&, :|, :==].include?(operator)
@left = left
@right = right
end
@ -14,8 +22,8 @@ module Risc
end
end
def self.op source , operator , left , right
OperatorInstruction.new source , operator , left , right
def self.op( source , operator , left , right )
OperatorInstruction.new( source , operator , left , right )
end
end