add also calls on classes and more tests for that
This commit is contained in:
@ -2,10 +2,12 @@ module Ast
|
||||
# assignment, like operators are really function calls
|
||||
|
||||
class CallSiteExpression < Expression
|
||||
attr_reader :name, :args
|
||||
def initialize name, args
|
||||
@name , @args = name.to_sym , args
|
||||
attr_reader :name, :args , :receiver
|
||||
|
||||
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
|
||||
@ -23,13 +25,13 @@ module Ast
|
||||
|
||||
def inspect
|
||||
self.class.name + ".new(" + name.inspect + ", ["+
|
||||
args.collect{|m| m.inspect }.join( ",") +"] )"
|
||||
args.collect{|m| m.inspect }.join( ",") + "] ," + receiver.inspect + ")"
|
||||
end
|
||||
def to_s
|
||||
"#{name}(" + args.join(",") + ")"
|
||||
end
|
||||
def attributes
|
||||
[:name , :args]
|
||||
[:name , :args , :receiver]
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user