adds self reference and improve methods a little
This commit is contained in:
@ -23,6 +23,10 @@ module Virtual
|
||||
end
|
||||
attr_reader :next_normal, :next_exception, :me, :binding
|
||||
|
||||
# dummy for the eventual
|
||||
def new_frame
|
||||
self
|
||||
end
|
||||
#
|
||||
def compile_get method , name
|
||||
method.add FrameGet.new(name)
|
||||
|
@ -1,3 +1,5 @@
|
||||
require_relative "object"
|
||||
|
||||
module Virtual
|
||||
|
||||
# Instruction is an abstract for all the code of the object-machine. Derived classe make up the actual functionality
|
||||
@ -8,11 +10,10 @@ module Virtual
|
||||
# defining a minimal set of instructions needed to implement oo.
|
||||
|
||||
# This is partly because jumping over this layer and doing in straight in assember was too big a step
|
||||
class Instruction
|
||||
class Instruction < Virtual::Object
|
||||
attr_accessor :next
|
||||
|
||||
def inspect
|
||||
self.class.name + ".new()"
|
||||
def attributes
|
||||
[:next]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -15,7 +15,7 @@ module Virtual
|
||||
Method.new(:main , [] , Virtual::SelfReference )
|
||||
end
|
||||
def attributes
|
||||
[:name , :args , :receiver]
|
||||
[:name , :args , :receiver , :start , :return_type]
|
||||
end
|
||||
def initialize name , args , receiver = Virtual::SelfReference.new , return_type = Virtual::Reference
|
||||
@name = name.to_sym
|
||||
@ -26,7 +26,8 @@ module Virtual
|
||||
@start = MethodEnter.new
|
||||
@current = @start
|
||||
end
|
||||
attr_reader :name , :args , :receiver
|
||||
attr_reader :name , :args , :receiver , :start
|
||||
attr_accessor :return_type
|
||||
|
||||
def add instruction
|
||||
@current.next = instruction
|
||||
|
Reference in New Issue
Block a user