redid get_set internal byte with builder
trying to change style, get rid of some of builders functions
This commit is contained in:
parent
0d52b620ed
commit
7002956e81
@ -137,6 +137,7 @@ module Parfait
|
|||||||
def range_correct_index( at )
|
def range_correct_index( at )
|
||||||
index = at
|
index = at
|
||||||
# index = self.length + at if at < 0
|
# index = self.length + at if at < 0
|
||||||
|
raise "index not integer #{at.class}" unless at.is_a?(Fixnum)
|
||||||
raise "index must be positive , not #{at}" if (index < 0)
|
raise "index must be positive , not #{at}" if (index < 0)
|
||||||
raise "index too large #{at} > #{self.length}" if (index >= self.length )
|
raise "index too large #{at} > #{self.length}" if (index >= self.length )
|
||||||
return index + 11
|
return index + 11
|
||||||
|
@ -9,13 +9,14 @@ module Risc
|
|||||||
# (this method returns a new method off course, like all builtin)
|
# (this method returns a new method off course, like all builtin)
|
||||||
def get_internal_word( context )
|
def get_internal_word( context )
|
||||||
compiler = compiler_for(:Object , :get_internal_word ,{at: :Integer})
|
compiler = compiler_for(:Object , :get_internal_word ,{at: :Integer})
|
||||||
builder = compiler.compiler_builder(compiler.source)
|
compiler.compiler_builder(compiler.source).build do
|
||||||
source = "get_internal_word"
|
object << message[:receiver]
|
||||||
me , index = builder.self_and_int_arg(source)
|
integer << message[:arguments]
|
||||||
# reduce me to me[index]
|
integer << integer_reg[1]
|
||||||
builder.add_slot_to_reg( source , me , index , me)
|
integer.reduce_int
|
||||||
# and put it back into the return value
|
object << object[integer]
|
||||||
builder.add_reg_to_slot( source , me , Risc.message_reg , :return_value)
|
message[:return_value] << object
|
||||||
|
end
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler
|
return compiler
|
||||||
end
|
end
|
||||||
@ -24,12 +25,15 @@ module Risc
|
|||||||
# no return
|
# no return
|
||||||
def set_internal_word( context )
|
def set_internal_word( context )
|
||||||
compiler = compiler_for(:Object , :set_internal_word , {at: :Integer, :value => :Object} )
|
compiler = compiler_for(:Object , :set_internal_word , {at: :Integer, :value => :Object} )
|
||||||
source = "set_internal_word"
|
compiler.compiler_builder(compiler.source).build do
|
||||||
builder = compiler.compiler_builder(compiler.source)
|
object << message[:receiver]
|
||||||
me , index = builder.self_and_int_arg(source)
|
integer << message[:arguments]
|
||||||
value = builder.load_int_arg_at(source , 1)
|
object_reg << integer[ 2]
|
||||||
# do the set
|
integer << integer[ 1]
|
||||||
builder.add_reg_to_slot( source , value , me , index)
|
integer.reduce_int
|
||||||
|
object[integer] << object_reg
|
||||||
|
message[:return_value] << object_reg
|
||||||
|
end
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler
|
return compiler
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user