the further down this goes, the smaller the circles. Soon the point will come. And then back out
This commit is contained in:
@ -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
|
||||
|
@ -31,10 +31,16 @@ module Ast
|
||||
locals[arg] = arg_value
|
||||
args << arg_value
|
||||
end
|
||||
class_name = context.current_class.name
|
||||
function = Vm::Function.new(name , args )
|
||||
# class depends on receiver
|
||||
context.current_class.add_function function
|
||||
if receiver.nil?
|
||||
clazz = context.current_class
|
||||
else
|
||||
c = context.object_space.get_or_create_class receiver.name.to_sym
|
||||
clazz = c.meta_class
|
||||
end
|
||||
|
||||
function = Vm::Function.new(name , args )
|
||||
clazz.add_function function
|
||||
|
||||
parent_locals = context.locals
|
||||
parent_function = context.function
|
||||
|
Reference in New Issue
Block a user