extract base class from method_compiler

to be used for blocks too
This commit is contained in:
Torsten Ruger
2018-07-10 22:02:11 +03:00
parent edea9ac080
commit a3e758357c
3 changed files with 110 additions and 14 deletions

View File

@ -4,25 +4,16 @@ module Risc
# and to instantiate the methods correctly. Most of the init is typed layer stuff,
# but there is some logic too.
# - risc_instructions: The sequence of risc level instructions that mom was compiled to
# - cpu_instructions: The sequence of cpu specific instructions that the
# risc_instructions was compiled to
# Instructions derive from class Instruction and form a linked list
class MethodCompiler
class MethodCompiler < CallableCompiler
def initialize( method )
@regs = []
@method = method
name = "#{method.self_type.name}.#{method.name}"
@risc_instructions = Risc.label(name, name)
@risc_instructions << Risc.label( name, "unreachable")
@current = @risc_instructions
@constants = []
@block_compilers = []
super()
end
attr_reader :risc_instructions , :constants
def source_name
"#{@method.self_type.name}.#{@method.name}"
end
def get_method
@method
end