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