the further down this goes, the smaller the circles. Soon the point will come. And then back out

This commit is contained in:
Torsten Ruger
2014-06-03 14:49:02 +03:00
parent f60bbfa9ca
commit b7c2089046
7 changed files with 90 additions and 56 deletions

View File

@ -4,15 +4,21 @@ module Ast
class CallSiteExpression < Expression
attr_reader :name, :args , :receiver
def initialize name, args , receiver = Ast::NameExpression.new("self")
def initialize name, args , receiver = Ast::NameExpression.new(:self)
@name , @args , @receiver = name.to_sym , args , receiver
end
def compile context , into
params = args.collect{ |a| a.compile(context, into) }
#TOOD, this needs dynamic resolution
function = context.current_class.get_or_create_function(name)
raise "Forward declaration not implemented (#{name}) #{inspect}" if function == nil
r = context.current_class.name
if !receiver.nil? and receiver.name != :self
r = receiver.name
end
clazz = context.object_space.get_or_create_class r
function = context.current_class.get_function(name)
raise "Forward declaration not implemented for #{clazz.name}:#{name} #{inspect}" if function == nil
call = Vm::CallSite.new( name , params , function)
current_function = context.function
current_function.save_locals(context , into) if current_function