just checking which part of unimplemented i hit
This commit is contained in:
parent
c51dbf51e1
commit
bdd4a3d6ad
@ -64,7 +64,7 @@ module Ast
|
|||||||
|
|
||||||
def compile method , message
|
def compile method , message
|
||||||
to = Virtual::Return.new(Virtual::Reference)
|
to = Virtual::Return.new(Virtual::Reference)
|
||||||
clazz = ::Virtual::BootSpace.space.get_or_create_class name
|
clazz = Virtual::BootSpace.space.get_or_create_class name
|
||||||
raise "uups #{clazz}.#{name}" unless clazz
|
raise "uups #{clazz}.#{name}" unless clazz
|
||||||
method.add_code Virtual::Set.new( to , clazz )
|
method.add_code Virtual::Set.new( to , clazz )
|
||||||
to
|
to
|
||||||
|
@ -7,7 +7,7 @@ module Ast
|
|||||||
def compile method , message
|
def compile method , message
|
||||||
me = receiver.compile( method, message )
|
me = receiver.compile( method, message )
|
||||||
method.add_code Virtual::Set.new(Virtual::NewSelf.new(me.type), me)
|
method.add_code Virtual::Set.new(Virtual::NewSelf.new(me.type), me)
|
||||||
method.add_code Virtual::Set.new(Virtual::NewName.new(), name)
|
method.add_code Virtual::Set.new(Virtual::NewName.new(), Virtual::StringConstant.new(name))
|
||||||
compiled_args = []
|
compiled_args = []
|
||||||
args.each_with_index do |arg , i|
|
args.each_with_index do |arg , i|
|
||||||
#compile in the running method, ie before passing control
|
#compile in the running method, ie before passing control
|
||||||
|
@ -1,3 +1,24 @@
|
|||||||
|
Virtual::MessageSlot.class_eval do
|
||||||
|
def reg
|
||||||
|
Register::RegisterReference.new(Virtual::Message::MESSAGE_REG )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::FrameSlot.class_eval do
|
||||||
|
def reg
|
||||||
|
Register::RegisterReference.new(Virtual::Message::FRAME_REG )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::SelfSlot.class_eval do
|
||||||
|
def reg
|
||||||
|
Register::RegisterReference.new(Virtual::Message::SELF_REG )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::NewMessageSlot.class_eval do
|
||||||
|
def reg
|
||||||
|
Register::RegisterReference.new(Virtual::Message::NEW_MESSAGE_REG )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module Register
|
module Register
|
||||||
# This implements setting of the various slot variables the vm defines.
|
# This implements setting of the various slot variables the vm defines.
|
||||||
# Basic mem moves, but have to shuffle the type nibbles
|
# Basic mem moves, but have to shuffle the type nibbles
|
||||||
@ -6,18 +27,18 @@ module Register
|
|||||||
def run block
|
def run block
|
||||||
block.codes.dup.each do |code|
|
block.codes.dup.each do |code|
|
||||||
next unless code.is_a? Virtual::Set
|
next unless code.is_a? Virtual::Set
|
||||||
|
# resolve the register and offset that we need to move to
|
||||||
|
to = code.to.reg
|
||||||
|
# need a temporay place because of indexed load/store
|
||||||
tmp = RegisterReference.new(Virtual::Message::TMP_REG)
|
tmp = RegisterReference.new(Virtual::Message::TMP_REG)
|
||||||
if( code.to.is_a? Virtual::NewMessageSlot)
|
# for constants we have to "move" the constants value
|
||||||
to = Virtual::Message::NEW_MESSAGE_REG
|
if( code.from.is_a? Virtual::Constant)
|
||||||
move = RegisterMachine.instance.ldr( to , tmp , code.to.index )
|
move1 = RegisterMachine.instance.mov( tmp , code.from )
|
||||||
block.replace(code , move )
|
else # while otherwise we "load"
|
||||||
elsif( code.to.is_a? Virtual::Self)
|
move1 = RegisterMachine.instance.ldr( tmp , code.from.reg , code.from.index )
|
||||||
to = RegisterReference.new(Virtual::Message::SELF_REG)
|
|
||||||
move = RegisterMachine.instance.ldr( to , tmp , code.to.index )
|
|
||||||
block.replace(code , move )
|
|
||||||
else
|
|
||||||
raise "Start coding #{code.inspect}"
|
|
||||||
end
|
end
|
||||||
|
move2 = RegisterMachine.instance.str( tmp , to , code.to.index )
|
||||||
|
block.replace(code , [move1,move2] )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -89,6 +89,8 @@ module Virtual
|
|||||||
class Set < Instruction
|
class Set < Instruction
|
||||||
def initialize to , from
|
def initialize to , from
|
||||||
@to = to
|
@to = to
|
||||||
|
# hard to find afterwards where it came from, so ensure it doesn't happen
|
||||||
|
raise "From must be slot or constant, not symbol #{from}" if from.is_a? Symbol
|
||||||
@from = from
|
@from = from
|
||||||
end
|
end
|
||||||
attr_reader :to , :from
|
attr_reader :to , :from
|
||||||
|
@ -7,10 +7,10 @@ module Virtual
|
|||||||
block.codes.dup.each do |code|
|
block.codes.dup.each do |code|
|
||||||
next unless code.is_a? MessageSend
|
next unless code.is_a? MessageSend
|
||||||
me = code.me
|
me = code.me
|
||||||
next unless ( me.type == Reference)
|
raise "ahm" unless ( me.type == Reference)
|
||||||
if( me.is_a? Constant)
|
if( me.is_a? Constant)
|
||||||
if( me.is_a? BootClass )
|
if( me.is_a? BootClass )
|
||||||
raise "unimplemented"
|
raise "unimplemented #{code}"
|
||||||
elsif( me.is_a? ObjectConstant )
|
elsif( me.is_a? ObjectConstant )
|
||||||
clazz = me.clazz
|
clazz = me.clazz
|
||||||
method = clazz.get_instance_method code.name
|
method = clazz.get_instance_method code.name
|
||||||
@ -18,8 +18,10 @@ module Virtual
|
|||||||
call = FunctionCall.new( method )
|
call = FunctionCall.new( method )
|
||||||
block.replace(code , call )
|
block.replace(code , call )
|
||||||
else
|
else
|
||||||
raise "unimplemented"
|
raise "unimplemented #{code}"
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
raise "unimplemented #{code.me}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user