add initial jump instruction
This commit is contained in:
parent
e1aa3fd843
commit
5c90ad83e0
@ -119,3 +119,4 @@ require_relative "passes/get_implementation"
|
|||||||
require_relative "passes/set_implementation"
|
require_relative "passes/set_implementation"
|
||||||
require_relative "passes/return_implementation"
|
require_relative "passes/return_implementation"
|
||||||
require_relative "passes/constant_implementation"
|
require_relative "passes/constant_implementation"
|
||||||
|
require_relative "passes/main_implementation"
|
||||||
|
15
lib/arm/passes/main_implementation.rb
Normal file
15
lib/arm/passes/main_implementation.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
module Arm
|
||||||
|
|
||||||
|
# "Boot" the register machine at the function given
|
||||||
|
|
||||||
|
class MainImplementation
|
||||||
|
def run block
|
||||||
|
block.codes.dup.each do |code|
|
||||||
|
next unless code.is_a? Register::RegisterMain
|
||||||
|
call = ArmMachine.b( code.method )
|
||||||
|
block.replace(code , call )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::BootSpace.space.add_pass "Arm::MainImplementation"
|
||||||
|
end
|
@ -41,7 +41,7 @@ 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 = RegisterMachine.instance.b( main )
|
initial_jump = RegisterMain.new( main )
|
||||||
initial_jump.set_position( 0)
|
initial_jump.set_position( 0)
|
||||||
initial_jump.assemble( @stream )
|
initial_jump.assemble( @stream )
|
||||||
@objects.each_value do |objekt|
|
@objects.each_value do |objekt|
|
||||||
|
@ -37,3 +37,4 @@ require_relative "instructions/function_call"
|
|||||||
require_relative "instructions/function_return"
|
require_relative "instructions/function_return"
|
||||||
require_relative "instructions/save_return"
|
require_relative "instructions/save_return"
|
||||||
require_relative "instructions/register_transfer"
|
require_relative "instructions/register_transfer"
|
||||||
|
require_relative "instructions/register_main"
|
||||||
|
14
lib/register/instructions/register_main.rb
Normal file
14
lib/register/instructions/register_main.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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
|
||||||
|
def initialize method
|
||||||
|
@method = method
|
||||||
|
end
|
||||||
|
attr_reader :method
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user