add the idea of a frame

This commit is contained in:
Torsten Ruger
2014-06-29 19:05:35 +03:00
parent 16ceb2a60d
commit 18faeeb042
5 changed files with 44 additions and 14 deletions

View File

@ -4,7 +4,7 @@ module Ast
class IntegerExpression < Expression
# attr_reader :value
def compile binding
def compile frame
Virtual::IntegerConstant.new value
end
end
@ -13,9 +13,10 @@ module Ast
# attr_reader :name
# compiling a variable resolves it. if it wasn't defined, raise an exception
def compile context
raise "Undefined variable #{name}, defined locals #{context.locals.keys.join('-')}" unless context.locals.has_key?(name)
context.locals[name]
def compile frame
# either a variable or needs to be called.
frame.get(name)
# frame.send name
end
end