This commit is contained in:
Torsten Ruger 2015-05-24 20:00:11 +03:00
parent 5670f07eac
commit 4d0773ebae
4 changed files with 17 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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