rubyx/lib/mom/macro/operator.rb
Torsten Rüger dced6b12e6 removing builtin as a concept (wip)
the "old" way of generating compilers is now obsolete
we can use ruby code with mom macros to achieve the same
Three step wip
remove old builtin
fix tests (including adding necessary methods)
fixup and inclusion of builtin code to parfait
2019-09-12 13:09:30 +03:00

26 lines
701 B
Ruby

module Mom
class IntOperator < Macro
attr_reader :operator
def initialize(name , operator)
super(name)
@operator = operator.value
end
def to_risc(compiler)
builder = compiler.builder(compiler.source)
integer_tmp = builder.allocate_int
operator = @operator # make accessible in block
builder.build do
integer! << message[:receiver]
integer.reduce_int
integer_reg! << message[:arg1] #"other"
integer_reg.reduce_int
integer.op operator , integer_reg
integer_tmp[Parfait::Integer.integer_index] << integer
message[:return_value] << integer_tmp
end
return compiler
end
end
end