remove unused set instruction
This commit is contained in:
parent
5e04ee7212
commit
9ae850e3b2
@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
module Register
|
|
||||||
# This implements setting of the various slot variables the vm defines.
|
|
||||||
|
|
||||||
class SetImplementation
|
|
||||||
def run block
|
|
||||||
block.codes.dup.each do |code|
|
|
||||||
next unless code.is_a? Virtual::Set
|
|
||||||
# need a temporay place because of indexed load/store
|
|
||||||
tmp = Register.tmp_reg :int
|
|
||||||
# for constants we have to "move" the constants value
|
|
||||||
if( code.from.is_a?(Parfait::Value) or code.from.is_a?(Symbol) or code.from.is_a?(Fixnum) )
|
|
||||||
move1 = LoadConstant.new(code, code.from , tmp )
|
|
||||||
else # while otherwise we "load"
|
|
||||||
puts "from #{code.from}"
|
|
||||||
move1 = Register.get_slot(code, code.from.object_name , get_index(code.from) , tmp )
|
|
||||||
end
|
|
||||||
#puts "to #{code.to}"
|
|
||||||
move2 = Register.set_slot( code , tmp , code.to.object_name , get_index(code.to) )
|
|
||||||
block.replace(code , [move1,move2] )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_index from
|
|
||||||
case from
|
|
||||||
when Virtual::Self , Virtual::NewSelf
|
|
||||||
return Register.resolve_index( :message , :receiver)
|
|
||||||
when Virtual::MessageName , Virtual::NewMessageName
|
|
||||||
return Register.resolve_index( :message , :name)
|
|
||||||
when Virtual::Return
|
|
||||||
return Register.resolve_index( :message , :return_value)
|
|
||||||
when Virtual::ArgSlot , Virtual::NewArgSlot
|
|
||||||
#puts "from: #{from.index}"
|
|
||||||
return Register.resolve_index( :message , :name) + from.index
|
|
||||||
when Virtual::FrameSlot
|
|
||||||
#puts "from: #{from.index}"
|
|
||||||
return Register.resolve_index( :frame , :next_frame) + from.index
|
|
||||||
else
|
|
||||||
raise "not implemented for #{from.class}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Virtual.machine.add_pass "Register::SetImplementation"
|
|
||||||
end
|
|
@ -2,7 +2,6 @@ require_relative "instruction"
|
|||||||
require_relative "register_value"
|
require_relative "register_value"
|
||||||
require_relative "assembler"
|
require_relative "assembler"
|
||||||
require_relative "passes/frame_implementation"
|
require_relative "passes/frame_implementation"
|
||||||
require_relative "passes/set_implementation"
|
|
||||||
require_relative "passes/return_implementation"
|
require_relative "passes/return_implementation"
|
||||||
require_relative "passes/call_implementation"
|
require_relative "passes/call_implementation"
|
||||||
|
|
||||||
|
@ -18,4 +18,3 @@ require_relative "instructions/method_call"
|
|||||||
require_relative "instructions/method_enter"
|
require_relative "instructions/method_enter"
|
||||||
require_relative "instructions/method_return"
|
require_relative "instructions/method_return"
|
||||||
require_relative "instructions/new_frame"
|
require_relative "instructions/new_frame"
|
||||||
require_relative "instructions/set"
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
module Virtual
|
|
||||||
|
|
||||||
# class for Set instructions, A set is basically a mem move.
|
|
||||||
# to and from are indexes into the known objects(frame,message,self and new_message),
|
|
||||||
# these are represented as slots (see there)
|
|
||||||
# from may be a Constant (Object,Integer,String,Class)
|
|
||||||
class Set < Instruction
|
|
||||||
def initialize from , to
|
|
||||||
raise "no to slot #{to.inspect}" unless to.is_a? Slot
|
|
||||||
@from = from
|
|
||||||
@to = to
|
|
||||||
end
|
|
||||||
attr_reader :from , :to
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user