misc
This commit is contained in:
parent
5670f07eac
commit
4d0773ebae
@ -52,11 +52,16 @@ module Virtual
|
||||
|
||||
# position is what another block uses to jump to. this is determined by the assembler
|
||||
# the assembler allso assembles and assumes a linear instruction sequence
|
||||
# Note: this will have to change for plocks and maybe anyway. back to oo, no more visitors
|
||||
# Note: this will have to change for plocks and maybe anyway.
|
||||
def set_position at
|
||||
@position = at
|
||||
@codes.each do |code|
|
||||
code.set_position( at)
|
||||
begin
|
||||
code.set_position( at)
|
||||
rescue => e
|
||||
puts "BLOCK #{self}"
|
||||
raise e
|
||||
end
|
||||
raise code.inspect unless code.mem_length
|
||||
at += code.mem_length
|
||||
end
|
||||
@ -66,6 +71,10 @@ module Virtual
|
||||
@codes.inject(0){|count , instruction| count += instruction.mem_length }
|
||||
end
|
||||
|
||||
def to_s
|
||||
Sof::Writer.write(self)
|
||||
end
|
||||
|
||||
private
|
||||
# helper for determining reachable blocks
|
||||
def add_next ret
|
||||
|
@ -31,7 +31,7 @@ module Virtual
|
||||
# return the main function (the top level) into which code is compiled
|
||||
# this just create a "main" with create_method , see there
|
||||
def self.main
|
||||
self.create_method( "Object" , "main" , [] )
|
||||
self.create_method( "Kernel" , "main" , [] )
|
||||
end
|
||||
|
||||
# create method does two things
|
||||
|
@ -73,7 +73,6 @@ module Virtual
|
||||
def self.compile_string expression , method
|
||||
value = Virtual.new_word(expression.string)
|
||||
to = Return.new(Reference , value)
|
||||
Machine.instance.space.add_object value
|
||||
method.info.add_code Set.new( to , value )
|
||||
to
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user