coming together, more and more each day

This commit is contained in:
Torsten Ruger
2014-05-13 21:06:12 +03:00
parent f6711ea49c
commit 04af367bc0
8 changed files with 45 additions and 28 deletions

View File

@ -27,12 +27,13 @@ module Ast
args << arg_value
end
function = Vm::Function.new(name , args )
context.program.add_function function
parent_locals = context.locals
parent_function = context.function
context.locals = locals
context.function = function
context.program.add_function function
into = function.entry
block.each do |b|
compiled = b.compile(context , into)

View File

@ -5,14 +5,16 @@ module Ast
class FuncallExpression < Expression
attr_reader :name, :args
def initialize name, args
@name , @args = name , args
@name , @args = name.to_sym , args
end
def compile context , into
params = args.collect{ |a| a.compile(context, into) }
fun = Vm::FunctionCall.new( name , params )
fun.load_args into
fun.do_call into
fun
function = context.program.get_or_create_function(name)
raise "Forward declaration not implemented (#{name}) #{inspect}" if function == nil
call = Vm::FunctionCall.new( name , params , function)
call.load_args into
call.do_call into
call
end
def inspect