Remove separate block_compiler lists
both in mom and risc method complers alll just compilers now, all linked Required to move some code down into callable_compiler but all in all quite little. cleaner
This commit is contained in:
@ -16,8 +16,8 @@ module Mom
|
||||
"#{@method.self_type.name}.init"
|
||||
end
|
||||
|
||||
def to_risc(in_method)
|
||||
risc_compiler = Risc::BlockCompiler.new(@callable , in_method , mom_instructions)
|
||||
def to_risc
|
||||
risc_compiler = Risc::BlockCompiler.new(@callable , @method , mom_instructions)
|
||||
instructions_to_risc(risc_compiler)
|
||||
#recursive blocks not done
|
||||
risc_compiler
|
||||
|
@ -7,11 +7,11 @@ module Mom
|
||||
# Instructions derive from class Instruction and form a linked list
|
||||
|
||||
class CallableCompiler
|
||||
include Util::CompilerList
|
||||
|
||||
def initialize( callable )
|
||||
@callable = callable
|
||||
@constants = []
|
||||
@block_compilers = []
|
||||
@mom_instructions = Label.new(source_name, source_name)
|
||||
@current = start = @mom_instructions
|
||||
add_code Label.new( source_name, "return_label")
|
||||
@ -19,7 +19,7 @@ module Mom
|
||||
add_code Label.new( source_name, "unreachable")
|
||||
@current = start
|
||||
end
|
||||
attr_reader :mom_instructions , :constants , :block_compilers , :callable , :current
|
||||
attr_reader :mom_instructions , :constants , :callable , :current
|
||||
|
||||
def return_label
|
||||
@mom_instructions.each do |ins|
|
||||
|
@ -4,8 +4,7 @@ module Mom
|
||||
# and to instantiate the methods correctly.
|
||||
|
||||
class MethodCompiler < CallableCompiler
|
||||
include Util::CompilerList
|
||||
|
||||
|
||||
def initialize( method )
|
||||
super(method)
|
||||
end
|
||||
@ -28,9 +27,6 @@ module Mom
|
||||
def to_risc
|
||||
risc_compiler = Risc::MethodCompiler.new(@callable , mom_instructions)
|
||||
instructions_to_risc(risc_compiler)
|
||||
block_compilers.each do |m_comp|
|
||||
risc_compiler.block_compilers << m_comp.to_risc(@callable)
|
||||
end
|
||||
risc_compiler
|
||||
end
|
||||
|
||||
@ -77,10 +73,6 @@ module Mom
|
||||
return ["local#{index}".to_sym]
|
||||
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 @callable.arguments_type.variable_index(name)
|
||||
|
Reference in New Issue
Block a user