comments and cosmetics

This commit is contained in:
Torsten Ruger 2014-07-24 21:56:31 +03:00
parent e427bcef43
commit 13a05e7b72
3 changed files with 13 additions and 10 deletions

View File

@ -8,7 +8,7 @@ module Ast
end end
r = receiver ? receiver.compile(method,frame) : Virtual::SelfReference.new r = receiver ? receiver.compile(method,frame) : Virtual::SelfReference.new
method = Virtual::MethodDefinition.new(name , args , r ) method = Virtual::MethodDefinition.new(name , args , r )
frame = frame.new_frame #frame = frame.new_frame
return_type = nil return_type = nil
body.each do |ex| body.each do |ex|
return_type = ex.compile(method,frame ) return_type = ex.compile(method,frame )

View File

@ -8,14 +8,16 @@ module Virtual
# #
# In a dynamic language the method is dynamically resolved, and so the size of the frame is not know to the caller # In a dynamic language the method is dynamically resolved, and so the size of the frame is not know to the caller
# Also exceptions (with the possibility of retry) and the idea of being able to take and store bindings # Also exceptions (with the possibility of retry) and the idea of being able to take and store bindings
# make it to say the very least unsensibly tricky to store them on the stack. So we don't. # make it, to say the very least, unsensibly tricky to store them on the stack. So we don't.
# Also at runtime Messages and frames remain completely "normal" objects # Also at runtime Messages and Frames remain completely "normal" objects. Ie have layouts and so on. Which resolves the
# dichotomy of objects on the stack or heap. Sama sama.
class Frame class Frame
def initialize variables def initialize locals , temps
@variables = variables @locals = locals
@tmps = tmps
end end
attr_accessor :variables attr_accessor :locals , :tmps
end end
end end

View File

@ -1,5 +1,5 @@
module Virtual module Virtual
# So when an object calls a method, or sends a message, this is what a sends: a Message # So when an object calls a method, or sends a message, this is what it sends: a Message
# A message contains the sender, return and exceptional return addresses,the arguments, and a slot for the frame. # A message contains the sender, return and exceptional return addresses,the arguments, and a slot for the frame.
@ -24,14 +24,15 @@ module Virtual
@me = me @me = me
@next_normal = normal @next_normal = normal
@next_exception = exceptional @next_exception = exceptional
@arguments = arguments
# a frame represents the local and temporary variables at a point in the program. # a frame represents the local and temporary variables at a point in the program.
@frame = [] @frame = nil
end end
attr_reader :me, :next_normal, :next_exception, :frame attr_reader :me, :next_normal, :next_exception, :arguments , :frame
# dummy for the eventual # dummy for the eventual
def new_frame def new_frame
self raise self.inspect
end end
# #
def compile_get method , name def compile_get method , name