fix the initial jump
This commit is contained in:
parent
1c8ed44e84
commit
6f111a5ae0
@ -1,6 +1,8 @@
|
|||||||
module Arm
|
module Arm
|
||||||
|
|
||||||
# "Boot" the register machine at the function given
|
# "Boot" the register machine at the function given
|
||||||
|
# meaning jump to that function currently. Maybe better to do some machine setup
|
||||||
|
# and possibly some cleanup/exit has to tie in, but that is not this day
|
||||||
|
|
||||||
class MainImplementation
|
class MainImplementation
|
||||||
def run block
|
def run block
|
||||||
|
@ -28,7 +28,10 @@ module Register
|
|||||||
# should be fill_to_length (with zeros)
|
# should be fill_to_length (with zeros)
|
||||||
objekt.code.set_length(objekt.info.byte_length , 0)
|
objekt.code.set_length(objekt.info.byte_length , 0)
|
||||||
end
|
end
|
||||||
at = 0
|
#need the initial jump at 0 and then functions
|
||||||
|
@machine.init.set_position(0)
|
||||||
|
at = @machine.init.byte_length
|
||||||
|
|
||||||
# then we make sure we really get the binary codes first
|
# then we make sure we really get the binary codes first
|
||||||
@machine.objects.each do |objekt|
|
@machine.objects.each do |objekt|
|
||||||
next unless objekt.is_a? Parfait::BinaryCode
|
next unless objekt.is_a? Parfait::BinaryCode
|
||||||
@ -65,11 +68,10 @@ module Register
|
|||||||
assemble_binary_method(objekt)
|
assemble_binary_method(objekt)
|
||||||
end
|
end
|
||||||
@stream = StringIO.new
|
@stream = StringIO.new
|
||||||
#TODOmid , main = @objects.find{|k,objekt| objekt.is_a?(Virtual::CompiledMethod) and (objekt.name == :__init__ )}
|
@machine.init.codes.each do |code|
|
||||||
# initial_jump = @machine.init
|
code.assemble( @stream )
|
||||||
# initial_jump.codes.each do |code|
|
end
|
||||||
# code.assemble( @stream )
|
|
||||||
# end
|
|
||||||
# then write the methods to file
|
# then write the methods to file
|
||||||
@machine.objects.each do |objekt|
|
@machine.objects.each do |objekt|
|
||||||
next unless objekt.is_a? Parfait::BinaryCode
|
next unless objekt.is_a? Parfait::BinaryCode
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
module Register
|
module Register
|
||||||
|
|
||||||
# This starts the register machine machine at the given function.
|
# This starts the register machine machine at the given function.
|
||||||
|
|
||||||
# The implementation is most likely a jump/branch , but since we have the extra layer
|
# The implementation is most likely a jump/branch , but since we have the extra layer
|
||||||
# we make good use of it, ie give things descriptive names (what they do, not how)
|
# we make good use of it, ie give things descriptive names (what they do, not how)
|
||||||
|
|
||||||
class RegisterMain < Instruction
|
class RegisterMain < Instruction
|
||||||
|
include Positioned
|
||||||
|
|
||||||
def initialize method
|
def initialize method
|
||||||
@method = method
|
@method = method
|
||||||
end
|
end
|
||||||
attr_reader :method
|
attr_reader :method
|
||||||
|
def word_length
|
||||||
|
4
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -113,10 +113,6 @@ module Virtual
|
|||||||
obj.add_instance_method Builtin::Integer.send(f , nil)
|
obj.add_instance_method Builtin::Integer.send(f , nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
# and the @init block in turn _jumps_ to __init__
|
|
||||||
# the point of which is that by the time main executes, all is :normal:
|
|
||||||
@init = Block.new(:_init_ , nil )
|
|
||||||
@init.add_code(Register::RegisterMain.new(underscore_init))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -44,6 +44,8 @@ module Virtual
|
|||||||
attr_reader :passes , :space , :class_mappings , :init , :objects
|
attr_reader :passes , :space , :class_mappings , :init , :objects
|
||||||
|
|
||||||
def run_passes
|
def run_passes
|
||||||
|
@init = Block.new("init",nil)
|
||||||
|
@init.add_code Register::RegisterMain.new( self.space.get_main )
|
||||||
Minimizer.new.run
|
Minimizer.new.run
|
||||||
Collector.new.run
|
Collector.new.run
|
||||||
@passes.each do |pass_class|
|
@passes.each do |pass_class|
|
||||||
@ -51,12 +53,12 @@ module Virtual
|
|||||||
@space.classes.values.each do |c|
|
@space.classes.values.each do |c|
|
||||||
c.instance_methods.each do |f|
|
c.instance_methods.each do |f|
|
||||||
nb = f.info.blocks
|
nb = f.info.blocks
|
||||||
raise "nil blocks " unless nb
|
|
||||||
blocks += nb
|
blocks += nb
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#puts "running #{pass_class}"
|
#puts "running #{pass_class}"
|
||||||
blocks.each do |block|
|
blocks.each do |block|
|
||||||
|
raise "nil block " unless block
|
||||||
pass = eval pass_class
|
pass = eval pass_class
|
||||||
raise "no such pass-class as #{pass_class}" unless pass
|
raise "no such pass-class as #{pass_class}" unless pass
|
||||||
pass.new.run(block)
|
pass.new.run(block)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user