introduce constant class and add block to compile signature(wip, work in progress)

This commit is contained in:
Torsten Ruger
2014-05-13 16:24:19 +03:00
parent dd05b30230
commit d7f31e7f39
15 changed files with 145 additions and 140 deletions

View File

@ -13,8 +13,8 @@ module Ast
def to_s
value.to_s
end
def compile context
Vm::Signed.new value
def compile context , into
Vm::Integer.new value
end
def attributes
[:value]
@ -26,10 +26,10 @@ module Ast
def initialize name
@name = name
end
def compile context
variable = Vm::Variable.new(@name)
context.locals[@name] = variable
variable
# compiling a variable resolves it.
# if it wasn't defined, nli is returned
def compile context , into
context.locals[name]
end
def inspect
self.class.name + '.new("' + name + '")'
@ -51,8 +51,8 @@ module Ast
self.class.name + '.new("' + string + '")'
end
def compile context
value = Vm::StringLiteral.new(string)
def compile context , into
value = Vm::StringConstant.new(string)
context.program.add_object value
value
end