changed Set order

from to seems more logical than to,from
This commit is contained in:
Torsten Ruger 2015-06-21 13:29:27 +03:00
parent 6867175bd1
commit cdf17a73b2
5 changed files with 15 additions and 15 deletions

View File

@ -10,7 +10,7 @@ module Builtin
function.info.return_type = Virtual::Integer
main = Virtual.machine.space.get_main
me = Virtual::Self.new(Virtual::Reference)
code = Virtual::Set.new(Virtual::Self.new(me.type), me)
code = Virtual::Set.new(me , Virtual::Self.new(me.type))
function.info.add_code(code)
function.info.add_code Virtual::MethodCall.new(main)
return function

View File

@ -15,25 +15,25 @@ module Virtual
def self.compile_integer expression , method
int = expression.value
to = Return.new(Integer , int)
method.info.add_code Set.new( to , int)
method.info.add_code Set.new( int , to )
to
end
def self.compile_true expression , method
to = Return.new(Reference , true )
method.info.add_code Set.new( to , true )
method.info.add_code Set.new( true , to )
to
end
def self.compile_false expression , method
to = Return.new(Reference , false)
method.info.add_code Set.new( to , false )
method.info.add_code Set.new( false , to )
to
end
def self.compile_nil expression , method
to = Return.new(Reference , nil)
method.info.add_code Set.new( to , nil )
method.info.add_code Set.new( nil , to )
to
end
@ -62,7 +62,7 @@ module Virtual
clazz = Space.space.get_class_by_name name
raise "uups #{clazz}.#{name}" unless clazz
to = Return.new(Reference , clazz )
method.info.add_code Set.new( to , clazz )
method.info.add_code Set.new( clazz , to )
to
end
@ -72,7 +72,7 @@ module Virtual
value = expression.string.to_sym
to = Return.new(Reference , value)
method.info.constants << value
method.info.add_code Set.new( to , value )
method.info.add_code Set.new( value , to )
to
end
@ -85,10 +85,10 @@ module Virtual
raise "oh noo, nil from where #{expression.right.inspect}" unless r
index = method.has_arg(expression.left.name.to_sym)
if index
method.info.add_code Set.new(Return.new , MessageSlot.new(index , r,type , r ))
method.info.add_code Set.new(MessageSlot.new(index , r,type , r ) , Return.new)
else
index = method.ensure_local(expression.left.name.to_sym)
method.info.add_code Set.new(Return.new , FrameSlot.new(index , r.type , r ))
method.info.add_code Set.new(FrameSlot.new(index , r.type , r ) , Return.new)
end
r
end

View File

@ -7,8 +7,8 @@ module Virtual
def self.compile_callsite expession , method
me = Compiler.compile( expession.receiver , method )
method.info.add_code NewMessage.new
method.info.add_code Set.new(NextSelf.new(me.type), me)
method.info.add_code Set.new(NextMessageName.new(), expession.name.to_sym)
method.info.add_code Set.new( me , NextSelf.new(me.type))
method.info.add_code Set.new( expession.name.to_sym , NextMessageName.new())
compiled_args = []
expession.args.each_with_index do |arg , i|
#compile in the running method, ie before passing control
@ -16,7 +16,7 @@ module Virtual
# move the compiled value to it's slot in the new message
to = NextMessageSlot.new(i ,val.type , val)
# (doing this immediately, not after the loop, so if it's a return it won't get overwritten)
method.info.add_code Set.new(to , val )
method.info.add_code Set.new( val , to )
compiled_args << to
end
method.info.add_code MessageSend.new(expession.name , me , compiled_args) #and pass control

View File

@ -5,9 +5,9 @@ module Virtual
# these are represented as slots (see there)
# from may be a Constant (Object,Integer,String,Class)
class Set < Instruction
def initialize to , from
@to = to
def initialize from , to
@from = from
@to = to
end
attr_reader :from , :to
end

View File

@ -37,4 +37,4 @@ end
require_relative "message_slot"
require_relative "self_slot"
require_relative "frame_slot"
require_relative "new_message_slot"
require_relative "next_message_slot"