adds variable, something compliles , but...

This commit is contained in:
Torsten Ruger
2014-05-10 17:55:02 +03:00
parent 5b002c0ff6
commit e600911fe8
6 changed files with 33 additions and 9 deletions

View File

@ -23,6 +23,11 @@ module Ast
def initialize name
@name = name
end
def compile context
variable = Vm::Variable.new(@name)
context.locals[@name] = variable
variable
end
def inspect
self.class.name + ".new(" + name + ")"
end

View File

@ -14,11 +14,15 @@ module Ast
end
def compile context
args = params.collect{|p| Vm::Value.type p.name }
function = Vm::Function.new(name ,args )
context.program.add_function function
parent_locals = context.locals
context.locals = {}
args = []
params.each do |param|
args << param.compile(context) # making the argument a local
end
# args = params.collect{|p| Vm::Value.type p.name }
function = Vm::Function.new(name ,args )
context.program.add_function function
block.each do |b|
compiled = b.compile context
if compiled.is_a? Vm::Block

View File

@ -35,8 +35,10 @@ module Ast
end
def compile context
var = @assigned.compile(context)
context.locals[@assignee] = var
value = @assigned.compile(context)
variable = Vm::Variable.new @assignee , :r0 , value
context.locals[@assignee] = variable
variable
end
def attributes