fix the initial jump
This commit is contained in:
parent
1c8ed44e84
commit
6f111a5ae0
@ -1,6 +1,8 @@
|
||||
module Arm
|
||||
|
||||
# "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
|
||||
def run block
|
||||
|
@ -28,7 +28,10 @@ module Register
|
||||
# should be fill_to_length (with zeros)
|
||||
objekt.code.set_length(objekt.info.byte_length , 0)
|
||||
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
|
||||
@machine.objects.each do |objekt|
|
||||
next unless objekt.is_a? Parfait::BinaryCode
|
||||
@ -65,11 +68,10 @@ module Register
|
||||
assemble_binary_method(objekt)
|
||||
end
|
||||
@stream = StringIO.new
|
||||
#TODOmid , main = @objects.find{|k,objekt| objekt.is_a?(Virtual::CompiledMethod) and (objekt.name == :__init__ )}
|
||||
# initial_jump = @machine.init
|
||||
# initial_jump.codes.each do |code|
|
||||
# code.assemble( @stream )
|
||||
# end
|
||||
@machine.init.codes.each do |code|
|
||||
code.assemble( @stream )
|
||||
end
|
||||
|
||||
# then write the methods to file
|
||||
@machine.objects.each do |objekt|
|
||||
next unless objekt.is_a? Parfait::BinaryCode
|
||||
|
@ -1,14 +1,19 @@
|
||||
module Register
|
||||
|
||||
# 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
|
||||
# we make good use of it, ie give things descriptive names (what they do, not how)
|
||||
|
||||
class RegisterMain < Instruction
|
||||
include Positioned
|
||||
|
||||
def initialize method
|
||||
@method = method
|
||||
end
|
||||
attr_reader :method
|
||||
def word_length
|
||||
4
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -113,10 +113,6 @@ module Virtual
|
||||
obj.add_instance_method Builtin::Integer.send(f , nil)
|
||||
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
|
||||
|
@ -44,6 +44,8 @@ module Virtual
|
||||
attr_reader :passes , :space , :class_mappings , :init , :objects
|
||||
|
||||
def run_passes
|
||||
@init = Block.new("init",nil)
|
||||
@init.add_code Register::RegisterMain.new( self.space.get_main )
|
||||
Minimizer.new.run
|
||||
Collector.new.run
|
||||
@passes.each do |pass_class|
|
||||
@ -51,12 +53,12 @@ module Virtual
|
||||
@space.classes.values.each do |c|
|
||||
c.instance_methods.each do |f|
|
||||
nb = f.info.blocks
|
||||
raise "nil blocks " unless nb
|
||||
blocks += nb
|
||||
end
|
||||
end
|
||||
#puts "running #{pass_class}"
|
||||
blocks.each do |block|
|
||||
raise "nil block " unless block
|
||||
pass = eval pass_class
|
||||
raise "no such pass-class as #{pass_class}" unless pass
|
||||
pass.new.run(block)
|
||||
|
Loading…
Reference in New Issue
Block a user