use compiler base class for blocks too

can now go to mom level and add
test harness still looks overly complicated, but works
first block tests at mom level
This commit is contained in:
Torsten Ruger
2018-07-10 22:03:32 +03:00
parent a3e758357c
commit 27a142f2a3
4 changed files with 34 additions and 12 deletions

View File

@ -2,19 +2,18 @@ module Risc
# A BlockCompiler is much like a Mehtodcompiler, exept for blocks
#
class BlockCompiler
class BlockCompiler < CallableCompiler
attr_reader :block , :risc_instructions , :constants
def initialize( block , method)
@method = method
@regs = []
@block = block
name = "#{method.self_type.name}.init"
@risc_instructions = Risc.label(name, name)
@risc_instructions << Risc.label( name, "unreachable")
@current = @risc_instructions
@constants = []
super()
end
def source_name
"#{@method.self_type.name}.init"
end
# determine how given name need to be accsessed.
@ -35,5 +34,20 @@ module Risc
slot_def << name
end
# resolve a symbol to a type. Allowed symbols are :frame , :receiver and arguments
# which return the respective types, otherwise nil
def resolve_type( name )
case name
when :frame
return @block.frame_type
when :arguments
return @block.arguments_type
when :receiver
return @block.self_type
else
return nil
end
end
end
end

View File

@ -24,7 +24,7 @@ module Vool
block_compiler = Risc::BlockCompiler.new( parfait_block , compiler.get_method )
compiler.add_block_compiler(block_compiler)
head = body.to_mom( block_compiler )
#block_compiler.add_mom(head)
block_compiler.add_mom(head)
block_compiler
end