A good start on the macro idea

I call it macro because it lets you insert basically arbitrary risc code into the ruby level. The way it works:
Reserve namespace X
map any X.some_call to a Mom instruction
by the name SomeCall
which must take the same args in constructor as given
And obviously produce whatever risc it wants
Hoping to rewrite builtin around this idea (with the existing Mom builtn instructions)
This commit is contained in:
2019-08-25 14:40:59 +03:00
parent c0a3c9b65c
commit b9bdc55059
10 changed files with 158 additions and 8 deletions

View File

@ -17,13 +17,11 @@ module Vool
# - store the given return value, this is a SlotMove
# - activate return sequence (reinstantiate old message and jump to return address)
def to_mom( compiler )
load = Mom::SlotLoad.new( self , [:message , :return_value] ,
@return_value.to_slot(compiler) )
if @return_value.is_a?(CallStatement)
ret = @return_value.to_mom(compiler)
ret << load
ret << slot_load(compiler)
else
ret = load
ret = slot_load(compiler)
end
ret << Mom::ReturnJump.new(self , compiler.return_label )
end
@ -31,5 +29,10 @@ module Vool
def to_s(depth = 0)
at_depth(depth , "return #{@return_value.to_s}")
end
def slot_load(compiler)
Mom::SlotLoad.new( self , [:message , :return_value] ,
@return_value.to_slot(compiler) )
end
end
end