reduce method return type to type and introduce a single instruction for instance get

This commit is contained in:
Torsten Ruger
2014-07-14 21:28:21 +03:00
parent b1893482ff
commit b59a9da34e
11 changed files with 51 additions and 19 deletions

View File

@ -19,6 +19,9 @@ module Virtual
def inspect
self.class.name + ".new(#{@integer})"
end
def type
Virtual::Integer
end
end
# The name really says it all.

View File

@ -35,5 +35,9 @@ module Virtual
def compile_send method , name , with = []
method.add FrameSend.new(name , with )
end
def compile_set method , name , val
method.add FrameSet.new(name , val )
end
end
end

View File

@ -39,6 +39,10 @@ module Virtual
def initialize name
@name = name
end
attr_reader :name
def attributes
[:name]
end
end
class FrameSend < Instruction
@ -48,13 +52,29 @@ module Virtual
@args = args
end
attr_reader :name , :args
def == other
self.class == other.class && self.name == other.name
def attributes
[:name , :args]
end
def inspect
self.class.name + ".new(:#{@name} , [ " + args.collect{|a| a.inspect}.join(",")+ "])"
end
class FrameSet < Instruction
def initialize name , val
@name = name.to_sym
@value = val
end
attr_reader :name , :value
def attributes
[:name , :value]
end
end
class ObjectGet < Instruction
def initialize name
@name = name
end
attr_reader :name
def attributes
[:name]
end
end
end