pass a source into the builder
for debugging
This commit is contained in:
parent
df08cb78e2
commit
059ff4a868
@ -27,7 +27,7 @@ module Mom
|
||||
# Move method name, frame and arguemnt types from the method to the next_message
|
||||
# Get the message from Space and link it.
|
||||
def to_risc(compiler)
|
||||
builder = compiler.builder(false)
|
||||
builder = compiler.builder(false, self)
|
||||
build_with(builder)
|
||||
end
|
||||
|
||||
|
@ -32,7 +32,7 @@ module Mom
|
||||
def to_risc( compiler )
|
||||
name_ = @name
|
||||
cache_entry_ = @cache_entry
|
||||
builder = compiler.builder(false)
|
||||
builder = compiler.builder(false, self)
|
||||
builder.build do
|
||||
word << name_
|
||||
cache_entry << cache_entry_
|
||||
|
@ -12,10 +12,12 @@ module Risc
|
||||
# pass a compiler, to which instruction are added (usually)
|
||||
# second arg determines weather instructions are added (default true)
|
||||
# call build with a block to build
|
||||
def initialize(compiler, auto_add)
|
||||
def initialize(compiler, auto_add , for_source)
|
||||
@compiler = compiler
|
||||
@auto_add = auto_add
|
||||
@built = nil
|
||||
@source = for_source
|
||||
@source_used = false
|
||||
@names = {}
|
||||
end
|
||||
|
||||
|
@ -8,7 +8,7 @@ module Risc
|
||||
def mod4(context)
|
||||
source = "mod4"
|
||||
compiler = compiler_for(:Integer,:mod4 ,{})
|
||||
builder = compiler.builder(true)
|
||||
builder = compiler.builder(true, compiler.method)
|
||||
me = builder.add_known( :receiver )
|
||||
builder.reduce_int( source , me )
|
||||
two = compiler.use_reg :fixnum , 2
|
||||
@ -35,7 +35,7 @@ module Risc
|
||||
end
|
||||
def operator_method(op_name , op_sym )
|
||||
compiler = compiler_for(:Integer, op_sym ,{other: :Integer})
|
||||
builder = compiler.builder(true)
|
||||
builder = compiler.builder(true, compiler.method)
|
||||
me , other = builder.self_and_int_arg(op_name + "load receiver and arg")
|
||||
builder.reduce_int( op_name + " fix me", me )
|
||||
builder.reduce_int( op_name + " fix arg", other )
|
||||
@ -48,7 +48,7 @@ module Risc
|
||||
def div10( context )
|
||||
s = "div_10 "
|
||||
compiler = compiler_for(:Integer,:div10 ,{})
|
||||
builder = compiler.builder(true)
|
||||
builder = compiler.builder(true, compiler.method)
|
||||
#FIX: this could load receiver once, reduce and then transfer twice
|
||||
me = builder.add_known( :receiver )
|
||||
tmp = builder.add_known( :receiver )
|
||||
|
@ -9,7 +9,7 @@ module Risc
|
||||
# (this method returns a new method off course, like all builtin)
|
||||
def get_internal_word( context )
|
||||
compiler = compiler_for(:Object , :get_internal_word ,{at: :Integer})
|
||||
builder = compiler.builder(true)
|
||||
builder = compiler.builder(true, compiler.method)
|
||||
source = "get_internal_word"
|
||||
me , index = builder.self_and_int_arg(source)
|
||||
# reduce me to me[index]
|
||||
@ -25,7 +25,7 @@ module Risc
|
||||
def set_internal_word( context )
|
||||
compiler = compiler_for(:Object , :set_internal_word , {at: :Integer, :value => :Object} )
|
||||
source = "set_internal_word"
|
||||
builder = compiler.builder(true)
|
||||
builder = compiler.builder(true, compiler.method)
|
||||
me , index = builder.self_and_int_arg(source)
|
||||
value = builder.load_int_arg_at(source , 2)
|
||||
|
||||
@ -39,7 +39,7 @@ module Risc
|
||||
# Even if it's just this one, sys_exit (later raise)
|
||||
def _method_missing( context )
|
||||
compiler = compiler_for(:Object,:method_missing ,{})
|
||||
emit_syscall( compiler.builder(true) , :exit )
|
||||
emit_syscall( compiler.builder(true, compiler.method) , :exit )
|
||||
return compiler.method
|
||||
end
|
||||
# this is the really really first place the machine starts (apart from the jump here)
|
||||
@ -48,7 +48,7 @@ module Risc
|
||||
def __init__ context
|
||||
compiler = Risc::MethodCompiler.create_method(:Object,:__init__ ,
|
||||
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
||||
builder = compiler.builder(true)
|
||||
builder = compiler.builder(true, compiler.method)
|
||||
builder.build do
|
||||
space << Parfait.object_space
|
||||
message << space[:first_message]
|
||||
@ -78,7 +78,7 @@ module Risc
|
||||
|
||||
def exit( context )
|
||||
compiler = compiler_for(:Object,:exit ,{})
|
||||
emit_syscall( compiler.builder(true) , :exit )
|
||||
emit_syscall( compiler.builder(true, compiler.method) , :exit )
|
||||
return compiler.method
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Risc
|
||||
|
||||
def putstring( context)
|
||||
compiler = compiler_for(:Word , :putstring ,{})
|
||||
builder = compiler.builder(true)
|
||||
builder = compiler.builder(true, compiler.method)
|
||||
builder.add_slot_to_reg( "putstring" , :message , :receiver , :new_message )
|
||||
index = Parfait::Word.get_length_index
|
||||
reg = RiscValue.new(:r2 , :Integer)
|
||||
@ -21,7 +21,7 @@ module Risc
|
||||
def get_internal_byte( context)
|
||||
compiler = compiler_for(:Word , :get_internal_byte , {at: :Integer})
|
||||
source = "get_internal_byte"
|
||||
builder = compiler.builder(true)
|
||||
builder = compiler.builder(true, compiler.method)
|
||||
me , index = builder.self_and_int_arg(source)
|
||||
builder.reduce_int( source + " fix arg", index )
|
||||
# reduce me to me[index]
|
||||
@ -39,7 +39,7 @@ module Risc
|
||||
def set_internal_byte( context )
|
||||
compiler = compiler_for(:Word, :set_internal_byte , {at: :Integer , :value => :Integer} )
|
||||
source = "set_internal_byte"
|
||||
builder = compiler.builder(true)
|
||||
builder = compiler.builder(true, compiler.method)
|
||||
me , index = builder.self_and_int_arg(source)
|
||||
value = builder.load_int_arg_at(source , 2 )
|
||||
builder.reduce_int( source + " fix me", value )
|
||||
|
@ -110,8 +110,9 @@ module Risc
|
||||
|
||||
# return a new builder that uses this compiler
|
||||
# must specify weather to add code automatically to compiler
|
||||
def builder( auto_add )
|
||||
Builder.new(self , auto_add)
|
||||
# second arg is the source for which to build, either method or mom::instruction
|
||||
def builder( auto_add , source)
|
||||
Builder.new(self , auto_add , source)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ module Risc
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
init = Parfait.object_space.get_init
|
||||
@builder = Risc::MethodCompiler.new( init ).builder(false)
|
||||
@builder = Risc::MethodCompiler.new( init ).builder(false , init)
|
||||
@label = Risc::Label.new("source","name")
|
||||
end
|
||||
def test_has_build
|
||||
@ -102,7 +102,7 @@ module Risc
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@init = Parfait.object_space.get_init
|
||||
@builder = Risc::MethodCompiler.new( @init ).builder(true)
|
||||
@builder = Risc::MethodCompiler.new( @init ).builder(true, @init)
|
||||
end
|
||||
def test_inserts_built
|
||||
r1 = RiscValue.new(:r1 , :Space)
|
||||
|
Loading…
Reference in New Issue
Block a user