use instruction steam from message
had been attached there last week, but was still used mainly through the source (which i’m trying to remove)
This commit is contained in:
parent
72b790c107
commit
ef6cb2a069
@ -24,7 +24,7 @@ module Elf
|
|||||||
# for debug add labels to the block positions
|
# for debug add labels to the block positions
|
||||||
@object_machine.space.classes.values.each do |clazz|
|
@object_machine.space.classes.values.each do |clazz|
|
||||||
clazz.instance_methods.each do |f|
|
clazz.instance_methods.each do |f|
|
||||||
f.source.instructions.each_label do |label|
|
f.instructions.each_label do |label|
|
||||||
add_symbol "#{clazz.name}::#{f.name}:#{label.name}" , label.position
|
add_symbol "#{clazz.name}::#{f.name}:#{label.name}" , label.position
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -144,7 +144,7 @@ module Interpreter
|
|||||||
def execute_FunctionCall
|
def execute_FunctionCall
|
||||||
@link = @instruction
|
@link = @instruction
|
||||||
#puts "Call link #{@link}"
|
#puts "Call link #{@link}"
|
||||||
set_instruction @instruction.method.source.instructions
|
set_instruction @instruction.method.instructions
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,9 +107,9 @@ module Register
|
|||||||
#puts "Method #{method.source.instructions.to_ac}"
|
#puts "Method #{method.source.instructions.to_ac}"
|
||||||
begin
|
begin
|
||||||
#puts "assemble #{method.source.instructions}"
|
#puts "assemble #{method.source.instructions}"
|
||||||
method.source.instructions.assemble_all( stream )
|
method.instructions.assemble_all( stream )
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "Assembly error #{method.name}\n#{Sof.write(method.source.instructions).to_s[0...2000]}"
|
puts "Assembly error #{method.name}\n#{Sof.write(method.instructions).to_s[0...2000]}"
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
index = 1
|
index = 1
|
||||||
|
@ -9,7 +9,7 @@ module Register
|
|||||||
function = MethodSource.create_method(:Kernel,:__init__ , [])
|
function = MethodSource.create_method(:Kernel,:__init__ , [])
|
||||||
# no method enter or return (automatically added), remove
|
# no method enter or return (automatically added), remove
|
||||||
new_start = Label.new(function , "__init__" )
|
new_start = Label.new(function , "__init__" )
|
||||||
function.source.instructions = new_start
|
function.instructions = new_start
|
||||||
function.source.current = new_start
|
function.source.current = new_start
|
||||||
|
|
||||||
#Set up the Space as self upon init
|
#Set up the Space as self upon init
|
||||||
|
@ -34,7 +34,7 @@ module Register
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
methods.each do |method|
|
methods.each do |method|
|
||||||
instruction = method.instructions
|
instruction = method.method.instructions
|
||||||
while instruction.next
|
while instruction.next
|
||||||
nekst = instruction.next
|
nekst = instruction.next
|
||||||
t = translator.translate(nekst) # returning nil means no replace
|
t = translator.translate(nekst) # returning nil means no replace
|
||||||
@ -54,7 +54,8 @@ module Register
|
|||||||
# Objects are data and get assembled after functions
|
# Objects are data and get assembled after functions
|
||||||
def add_object o
|
def add_object o
|
||||||
return false if @objects[o.object_id]
|
return false if @objects[o.object_id]
|
||||||
return if o.is_a? Fixnum
|
return true if o.is_a? Fixnum
|
||||||
|
return true if o.is_a? Register::Label
|
||||||
raise "adding non parfait #{o.class}" unless o.is_a? Parfait::Object or o.is_a? Symbol
|
raise "adding non parfait #{o.class}" unless o.is_a? Parfait::Object or o.is_a? Symbol
|
||||||
@objects[o.object_id] = o
|
@objects[o.object_id] = o
|
||||||
true
|
true
|
||||||
@ -62,7 +63,7 @@ module Register
|
|||||||
|
|
||||||
def boot
|
def boot
|
||||||
boot_parfait!
|
boot_parfait!
|
||||||
@init = Branch.new( "__init__" , self.space.get_init.source.instructions )
|
@init = Branch.new( "__init__" , self.space.get_init.instructions )
|
||||||
@booted = true
|
@booted = true
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,9 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def init method
|
def init method
|
||||||
@instructions = @current = Label.new(self, "#{method.for_class.name}_#{method.name}")
|
@method = method
|
||||||
|
method.instructions = Label.new(self, "#{method.for_class.name}_#{method.name}")
|
||||||
|
@current = method.instructions
|
||||||
add_code enter = Register.save_return(self, :message , :return_address)
|
add_code enter = Register.save_return(self, :message , :return_address)
|
||||||
add_code Label.new( method, "return")
|
add_code Label.new( method, "return")
|
||||||
# move the current message to new_message
|
# move the current message to new_message
|
||||||
@ -56,7 +58,7 @@ module Register
|
|||||||
add_code FunctionReturn.new( self , Register.new_message_reg , Register.resolve_index(:message , :return_address) )
|
add_code FunctionReturn.new( self , Register.new_message_reg , Register.resolve_index(:message , :return_address) )
|
||||||
@current = enter
|
@current = enter
|
||||||
end
|
end
|
||||||
attr_accessor :current , :instructions
|
attr_accessor :current , :method
|
||||||
|
|
||||||
# add an instruction after the current (insertion point)
|
# add an instruction after the current (insertion point)
|
||||||
# the added instruction will become the new insertion point
|
# the added instruction will become the new insertion point
|
||||||
@ -76,13 +78,13 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def total_byte_length
|
def total_byte_length
|
||||||
@instructions.total_byte_length
|
@method.instructions.total_byte_length
|
||||||
end
|
end
|
||||||
|
|
||||||
# position of the function is the position of the entry block, is where we call
|
# position of the function is the position of the entry block, is where we call
|
||||||
def set_position at
|
def set_position at
|
||||||
at += 8 #for the 2 header words
|
at += 8 #for the 2 header words
|
||||||
@instructions.set_position at
|
@method.instructions.set_position at
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -10,8 +10,8 @@ module Statements
|
|||||||
produced = Register.machine.space.get_main.source
|
produced = Register.machine.space.get_main.source
|
||||||
assert @expect , "No output given"
|
assert @expect , "No output given"
|
||||||
#assert_equal @expect.length , produced.instructions.length , "instructions length #{produced.instructions.to_ac}"
|
#assert_equal @expect.length , produced.instructions.length , "instructions length #{produced.instructions.to_ac}"
|
||||||
compare_instructions produced.instructions , @expect
|
compare_instructions produced.method.instructions , @expect
|
||||||
produced.instructions
|
produced.method.instructions
|
||||||
end
|
end
|
||||||
|
|
||||||
def compare_instructions instruction , expect
|
def compare_instructions instruction , expect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user