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
|
||||
@object_machine.space.classes.values.each do |clazz|
|
||||
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
|
||||
end
|
||||
end
|
||||
|
@ -144,7 +144,7 @@ module Interpreter
|
||||
def execute_FunctionCall
|
||||
@link = @instruction
|
||||
#puts "Call link #{@link}"
|
||||
set_instruction @instruction.method.source.instructions
|
||||
set_instruction @instruction.method.instructions
|
||||
false
|
||||
end
|
||||
|
||||
|
@ -107,9 +107,9 @@ module Register
|
||||
#puts "Method #{method.source.instructions.to_ac}"
|
||||
begin
|
||||
#puts "assemble #{method.source.instructions}"
|
||||
method.source.instructions.assemble_all( stream )
|
||||
method.instructions.assemble_all( stream )
|
||||
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
|
||||
end
|
||||
index = 1
|
||||
|
@ -9,7 +9,7 @@ module Register
|
||||
function = MethodSource.create_method(:Kernel,:__init__ , [])
|
||||
# no method enter or return (automatically added), remove
|
||||
new_start = Label.new(function , "__init__" )
|
||||
function.source.instructions = new_start
|
||||
function.instructions = new_start
|
||||
function.source.current = new_start
|
||||
|
||||
#Set up the Space as self upon init
|
||||
|
@ -34,7 +34,7 @@ module Register
|
||||
end
|
||||
end
|
||||
methods.each do |method|
|
||||
instruction = method.instructions
|
||||
instruction = method.method.instructions
|
||||
while instruction.next
|
||||
nekst = instruction.next
|
||||
t = translator.translate(nekst) # returning nil means no replace
|
||||
@ -54,7 +54,8 @@ module Register
|
||||
# Objects are data and get assembled after functions
|
||||
def add_object o
|
||||
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
|
||||
@objects[o.object_id] = o
|
||||
true
|
||||
@ -62,7 +63,7 @@ module Register
|
||||
|
||||
def boot
|
||||
boot_parfait!
|
||||
@init = Branch.new( "__init__" , self.space.get_init.source.instructions )
|
||||
@init = Branch.new( "__init__" , self.space.get_init.instructions )
|
||||
@booted = true
|
||||
self
|
||||
end
|
||||
|
@ -45,7 +45,9 @@ module Register
|
||||
end
|
||||
|
||||
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 Label.new( method, "return")
|
||||
# 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) )
|
||||
@current = enter
|
||||
end
|
||||
attr_accessor :current , :instructions
|
||||
attr_accessor :current , :method
|
||||
|
||||
# add an instruction after the current (insertion point)
|
||||
# the added instruction will become the new insertion point
|
||||
@ -76,13 +78,13 @@ module Register
|
||||
end
|
||||
|
||||
def total_byte_length
|
||||
@instructions.total_byte_length
|
||||
@method.instructions.total_byte_length
|
||||
end
|
||||
|
||||
# position of the function is the position of the entry block, is where we call
|
||||
def set_position at
|
||||
at += 8 #for the 2 header words
|
||||
@instructions.set_position at
|
||||
@method.instructions.set_position at
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -10,8 +10,8 @@ module Statements
|
||||
produced = Register.machine.space.get_main.source
|
||||
assert @expect , "No output given"
|
||||
#assert_equal @expect.length , produced.instructions.length , "instructions length #{produced.instructions.to_ac}"
|
||||
compare_instructions produced.instructions , @expect
|
||||
produced.instructions
|
||||
compare_instructions produced.method.instructions , @expect
|
||||
produced.method.instructions
|
||||
end
|
||||
|
||||
def compare_instructions instruction , expect
|
||||
|
Loading…
Reference in New Issue
Block a user