better solution for initial jump
This commit is contained in:
parent
5c90ad83e0
commit
b7164b354d
@ -74,7 +74,7 @@ module Arm
|
|||||||
operand = calculate_u8_with_rr( first )
|
operand = calculate_u8_with_rr( first )
|
||||||
raise "no fit for #{right}" unless operand
|
raise "no fit for #{right}" unless operand
|
||||||
immediate = 1
|
immediate = 1
|
||||||
@extra = ::Register::RegisterMachine.instance.add( to , to , (right.integer & 0xFF) )
|
@extra = ArmMachine.add( to , to , (right.integer & 0xFF) )
|
||||||
#TODO: this is still a hack, as it does not encode all possible values. The way it _should_ be done
|
#TODO: this is still a hack, as it does not encode all possible values. The way it _should_ be done
|
||||||
# is to check that the first part is doabe with u8_with_rr AND leaves a u8 remainder
|
# is to check that the first part is doabe with u8_with_rr AND leaves a u8 remainder
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,8 @@ module Register
|
|||||||
|
|
||||||
def link
|
def link
|
||||||
add_object(@space)
|
add_object(@space)
|
||||||
at = 4 # first jump instruction
|
@space.init.set_position(0)
|
||||||
|
at = @space.init.mem_length # first jump instruction
|
||||||
# then all functions
|
# then all functions
|
||||||
@objects.each_value do | objekt|
|
@objects.each_value do | objekt|
|
||||||
next unless objekt.is_a? Virtual::CompiledMethod
|
next unless objekt.is_a? Virtual::CompiledMethod
|
||||||
@ -41,9 +42,10 @@ module Register
|
|||||||
link
|
link
|
||||||
@stream = StringIO.new
|
@stream = StringIO.new
|
||||||
mid , main = @objects.find{|k,objekt| objekt.is_a?(Virtual::CompiledMethod) and (objekt.name == :__init__ )}
|
mid , main = @objects.find{|k,objekt| objekt.is_a?(Virtual::CompiledMethod) and (objekt.name == :__init__ )}
|
||||||
initial_jump = RegisterMain.new( main )
|
initial_jump = @space.init
|
||||||
initial_jump.set_position( 0)
|
initial_jump.codes.each do |code|
|
||||||
initial_jump.assemble( @stream )
|
code.assemble( @stream )
|
||||||
|
end
|
||||||
@objects.each_value do |objekt|
|
@objects.each_value do |objekt|
|
||||||
next unless objekt.is_a? Virtual::CompiledMethod
|
next unless objekt.is_a? Virtual::CompiledMethod
|
||||||
assemble_object( objekt )
|
assemble_object( objekt )
|
||||||
@ -188,6 +190,7 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_BootSpace(space)
|
def add_BootSpace(space)
|
||||||
|
add_object(space.main)
|
||||||
add_object(space.classes)
|
add_object(space.classes)
|
||||||
add_object(space.objects)
|
add_object(space.objects)
|
||||||
add_object(space.symbols)
|
add_object(space.symbols)
|
||||||
|
@ -17,7 +17,7 @@ module Virtual
|
|||||||
def initialize
|
def initialize
|
||||||
super()
|
super()
|
||||||
@classes = Parfait::Hash.new
|
@classes = Parfait::Hash.new
|
||||||
@main = Virtual::CompiledMethod.new("main" , [] )
|
@main = Virtual::CompiledMethod.main
|
||||||
#global objects (data)
|
#global objects (data)
|
||||||
@objects = []
|
@objects = []
|
||||||
@symbols = []
|
@symbols = []
|
||||||
@ -27,11 +27,11 @@ module Virtual
|
|||||||
@next_frame = frames.first
|
@next_frame = frames.first
|
||||||
@passes = [ "Virtual::SendImplementation" ]
|
@passes = [ "Virtual::SendImplementation" ]
|
||||||
end
|
end
|
||||||
attr_reader :main , :classes , :objects , :symbols,:messages, :next_message , :next_frame
|
attr_reader :init , :main , :classes , :objects , :symbols,:messages, :next_message , :next_frame
|
||||||
|
|
||||||
def run_passes
|
def run_passes
|
||||||
@passes.each do |pass_class|
|
@passes.each do |pass_class|
|
||||||
all = main.blocks
|
all = [@init] + main.blocks
|
||||||
@classes.values.each do |c|
|
@classes.values.each do |c|
|
||||||
c.instance_methods.each {|f| all += f.blocks }
|
c.instance_methods.each {|f| all += f.blocks }
|
||||||
end
|
end
|
||||||
@ -76,6 +76,8 @@ module Virtual
|
|||||||
# CompiledMethods are grabbed from respective modules by sending the method name. This should return the
|
# CompiledMethods are grabbed from respective modules by sending the method name. This should return the
|
||||||
# implementation of the method (ie a method object), not actually try to implement it (as that's impossible in ruby)
|
# implementation of the method (ie a method object), not actually try to implement it (as that's impossible in ruby)
|
||||||
def boot_classes!
|
def boot_classes!
|
||||||
|
@init = Virtual::Block.new(:_init_ , nil )
|
||||||
|
@init.add_code(Register::RegisterMain.new(@main))
|
||||||
# very fiddly chicken 'n egg problem. Functions need to be in the right order, and in fact we have to define some
|
# very fiddly chicken 'n egg problem. Functions need to be in the right order, and in fact we have to define some
|
||||||
# dummies, just for the other to compile
|
# dummies, just for the other to compile
|
||||||
obj = get_or_create_class :Object
|
obj = get_or_create_class :Object
|
||||||
|
@ -3,7 +3,7 @@ require "parfait/message"
|
|||||||
|
|
||||||
module Positioned
|
module Positioned
|
||||||
def position
|
def position
|
||||||
raise "position accessed but not set at #{length} for #{self.inspect}" if @position == nil
|
raise "position accessed but not set at #{length} for #{self.inspect[0...500]}" if @position == nil
|
||||||
@position
|
@position
|
||||||
end
|
end
|
||||||
def set_position pos
|
def set_position pos
|
||||||
|
Loading…
x
Reference in New Issue
Block a user