Splitting NameExpression into three, Known,Local,Argument

The decision which to use can be made higher up, in ruby, and so it
should.
This commit is contained in:
Torsten Ruger
2017-01-16 09:33:49 +02:00
parent 96f19d18c0
commit 5f7ea08a43
6 changed files with 47 additions and 21 deletions

View File

@ -36,6 +36,7 @@ module Vm
@value = value
end
end
class NameExpression < Expression
include ValuePrinter
attr_accessor :value
@ -44,6 +45,16 @@ module Vm
@value = value
end
end
class LocalName < NameExpression
end
class ArgumentName < NameExpression
end
class InstanceName < NameExpression
end
class KnownName < NameExpression
end
class ClassExpression < Expression
include ValuePrinter
attr_accessor :value

View File

@ -85,9 +85,9 @@ module Vm
end
def on_call statement
name_s , arguments , receiver = *statement
name , arguments , receiver = *statement
w = Tree::CallSite.new()
w.name = name_s.children.first
w.name = name
w.arguments = process_all(arguments)
w.receiver = process(receiver)
w
@ -109,8 +109,17 @@ module Vm
Tree::NilExpression.new
end
def on_name statement
Tree::NameExpression.new(statement.children.first)
def on_arg statement
Tree::ArgumentName.new(statement.children.first)
end
def on_local statement
Tree::LocalName.new(statement.children.first)
end
def on_ivar statement
Tree::InstanceName.new(statement.children.first)
end
def on_known statement
Tree::KnownName.new(statement.children.first)
end
def on_string expression