start delegating scope matters to the compiler(s)

slot_type_for to return the slot way to access variable
this is off course version 0.0.1 alpha, no types are checked or errors handled
This commit is contained in:
Torsten Ruger
2018-07-09 17:53:56 +03:00
parent dd544214b3
commit 4ac89ece66
3 changed files with 38 additions and 6 deletions

View File

@ -47,10 +47,28 @@ module Risc
self.new(method)
end
# determine how given name need to be accsessed.
# For methods the options are args or frame
def slot_type_for(name)
if @method.arguments_type.variable_index(name)
type = :arguments
else
type = :frame
end
[type , name]
end
def add_block_compiler(compiler)
@block_compilers << compiler
end
# return true or false if the given name is in scope (arg/local)
def in_scope?(name)
ret = true if @method.arguments_type.variable_index(name)
ret = @method.frame_type.variable_index(name) unless ret
ret
end
# convert the given mom instruction to_risc and then add it (see add_code)
# continue down the instruction chain unti depleted
# (adding moves the insertion point so the whole mom chain is added as a risc chain)