assembles more already
This commit is contained in:
parent
3cdb3d513c
commit
4ddfcc4900
@ -24,5 +24,9 @@ module Parfait
|
||||
def to_s
|
||||
"BinaryCode #{@name}"
|
||||
end
|
||||
|
||||
def == other
|
||||
self.object_id == other.object_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -28,6 +28,10 @@ module Parfait
|
||||
@object_class = object_class
|
||||
end
|
||||
|
||||
def == other
|
||||
self.object_id == other.object_id
|
||||
end
|
||||
|
||||
# add the name of an instance variable
|
||||
# The index will be returned and can subsequently be searched with index_of
|
||||
# The index of the name is the index of the data in the object
|
||||
|
@ -61,7 +61,7 @@ module Parfait
|
||||
index = has_local name
|
||||
return index if index
|
||||
@locals.push name
|
||||
@locals.length
|
||||
@locals.get_length
|
||||
end
|
||||
|
||||
def get_var name
|
||||
|
@ -23,6 +23,10 @@ module Parfait
|
||||
object
|
||||
end
|
||||
|
||||
def == other
|
||||
self.object_id == other.object_id
|
||||
end
|
||||
|
||||
def get_type_of( index )
|
||||
type_word = internal_object_get( TYPE_WORD )
|
||||
res = type_word >> (index*4)
|
||||
|
@ -24,7 +24,7 @@ module Register
|
||||
# binary code (array) to right length
|
||||
@machine.objects.each do |objekt|
|
||||
next unless objekt.is_a? Parfait::Method
|
||||
objekt.code.set_length(objekt.info.mem_length / 4 , 0)
|
||||
objekt.code.set_length(objekt.info.mem_length , 0)
|
||||
end
|
||||
at = 0
|
||||
# then we make sure we really get the binary codes first
|
||||
@ -100,10 +100,13 @@ module Register
|
||||
end
|
||||
method.code.fill_with 0
|
||||
index = 1
|
||||
stream.rewind
|
||||
puts "Assembled #{method.name} with length #{stream.length}"
|
||||
raise "length error #{method.code.length} != #{method.info.mem_length}" if method.code.length != method.info.mem_length
|
||||
raise "length error #{stream.length} != #{method.info.mem_length}" if method.info.mem_length - stream.length > 32
|
||||
stream.each_byte do |b|
|
||||
method.set_char(index , b )
|
||||
method.code.set_char(index , b )
|
||||
index = index + 1
|
||||
raise "length error #{method.code.get_length}" if index > method.info.get_length
|
||||
end
|
||||
end
|
||||
|
||||
@ -203,13 +206,14 @@ module Register
|
||||
end
|
||||
|
||||
def assemble_String( string )
|
||||
str = string.to_s if string.is_a? Parfait::Word
|
||||
str = string.to_string if string.is_a? Parfait::Word
|
||||
str = string.to_s if string.is_a? Symbol
|
||||
word = (str.length + 7) / 32 # all object are multiple of 8 words (7 for header)
|
||||
raise "String too long (implement split string!) #{word}" if word > 15
|
||||
# first line is integers, convention is that following lines are the same
|
||||
TYPE_LENGTH.times { word = ((word << TYPE_BITS) + TYPE_INT) }
|
||||
@stream.write_uint32( word )
|
||||
puts "String is #{string} at #{string.position} length #{string.length}"
|
||||
write_ref_for( string.get_layout ) #ref
|
||||
@stream.write str
|
||||
pad_after(str.length)
|
||||
|
@ -198,7 +198,7 @@ module Parfait
|
||||
as_string == other
|
||||
end
|
||||
|
||||
def to_s
|
||||
def to_string
|
||||
string = ""
|
||||
index = 1
|
||||
while( index <= self.length)
|
||||
|
Loading…
Reference in New Issue
Block a user