Module: RMasm::ExpressionOperations

Included in:
ExpressionElement, Symbol
Defined in:
lib/rmasm/expression.rb

Overview

Operations on assembler elements: register, symbols, numbers

Instance Method Summary collapse

Instance Method Details

#*(arg) ⇒ Object



25
26
27
# File 'lib/rmasm/expression.rb', line 25

def *(arg)
  BinaryExpression.new(self, check_arg(arg,:*), :*)
end

#+(arg) ⇒ Object



29
30
31
# File 'lib/rmasm/expression.rb', line 29

def +(arg)
  BinaryExpression.new(self, check_arg(arg,:+), :+)
end

#-(arg) ⇒ Object



33
34
35
# File 'lib/rmasm/expression.rb', line 33

def -(arg)
  BinaryExpression.new(self, check_arg(arg,:-), :-)
end

#/(arg) ⇒ Object



37
38
39
# File 'lib/rmasm/expression.rb', line 37

def /(arg)
  BinaryExpression.new(self, check_arg(arg,:/), :/)
end

#check_arg(arg, op) ⇒ Object



46
47
48
49
50
51
# File 'lib/rmasm/expression.rb', line 46

def check_arg(arg,op)
  if (!(arg.is_a?(Integer) || arg.is_a?(ExpressionOperations) || arg.is_a?(Symbol)) )
    Report.error("Invalid argument type #{arg.inspect} in expression => #{self} #{op} #{arg.inspect}")
  end
  arg
end

#coerce(other) ⇒ Object

Always put self first in order to support number + AsmElementOperation



42
43
44
# File 'lib/rmasm/expression.rb', line 42

def coerce(other)
  [self, other]
end