remove MethodEnter Instructions
only resolved to SaveReturn anyway also Halt instruction wasn’t used, gone passes changed to start at register
This commit is contained in:
@ -11,7 +11,6 @@ require "virtual/method_source"
|
||||
# the passes _are_ order dependant
|
||||
require "virtual/passes/minimizer"
|
||||
require "virtual/passes/collector"
|
||||
require "virtual/passes/enter_implementation"
|
||||
|
||||
|
||||
class Fixnum
|
||||
|
@ -13,6 +13,4 @@ module Virtual
|
||||
|
||||
end
|
||||
|
||||
require_relative "instructions/halt"
|
||||
require_relative "instructions/method_call"
|
||||
require_relative "instructions/method_enter"
|
||||
|
@ -1,12 +0,0 @@
|
||||
module Virtual
|
||||
|
||||
|
||||
# the first instruction we need is to stop. Off course in a real machine this would be a syscall,
|
||||
# but that is just an implementation (in a programm it would be a function).
|
||||
# But in a virtual machine, not only do we need this instruction,
|
||||
# it is indeed the first instruction as just this instruction is the smallest possible programm
|
||||
# for the machine.
|
||||
# As such it is the next instruction for any first instruction that we generate.
|
||||
class Halt < Instruction
|
||||
end
|
||||
end
|
@ -1,12 +0,0 @@
|
||||
module Virtual
|
||||
|
||||
# following classes are stubs. currently in brainstorming mode, so anything may change anytime
|
||||
class MethodEnter < Instruction
|
||||
def initialize method
|
||||
@method = method
|
||||
end
|
||||
|
||||
attr_reader :method
|
||||
end
|
||||
|
||||
end
|
@ -36,8 +36,7 @@ module Virtual
|
||||
|
||||
class Machine
|
||||
|
||||
FIRST_PASS = "Virtual::EnterImplementation"
|
||||
LAST_PASS = "Virtual::SetOptimisation"
|
||||
FIRST_PASS = "Register::CallImplementation"
|
||||
|
||||
def initialize
|
||||
@parser = Parser::Salama.new
|
||||
|
@ -56,7 +56,8 @@ module Virtual
|
||||
|
||||
def init method , return_type = nil
|
||||
# first block we have to create with .new , as new_block assumes a current
|
||||
enter = Block.new( "enter" , method ).add_code(MethodEnter.new( method ))
|
||||
enter = Block.new( "enter" , method )
|
||||
enter.add_code Register.save_return(self, :message , :return_address)
|
||||
set_return_type( return_type )
|
||||
@blocks = [enter]
|
||||
@current = enter
|
||||
|
@ -1,15 +0,0 @@
|
||||
module Virtual
|
||||
|
||||
class EnterImplementation
|
||||
def run block
|
||||
block.codes.dup.each do |code|
|
||||
next unless code.is_a? Virtual::MethodEnter
|
||||
new_codes = []
|
||||
# save return register to the message at instance return_address
|
||||
new_codes << Register.save_return(code, :message , :return_address)
|
||||
block.replace(code , new_codes )
|
||||
end
|
||||
end
|
||||
end
|
||||
Virtual.machine.add_pass "Virtual::EnterImplementation"
|
||||
end
|
Reference in New Issue
Block a user