rename function_call to call_site in all levels to avoid confusion

This commit is contained in:
Torsten Ruger
2014-05-13 21:15:02 +03:00
parent 04af367bc0
commit 46ea1df51e
17 changed files with 73 additions and 70 deletions

View File

@ -0,0 +1,31 @@
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
end
def compile context , into
params = args.collect{ |a| a.compile(context, into) }
function = context.program.get_or_create_function(name)
raise "Forward declaration not implemented (#{name}) #{inspect}" if function == nil
call = Vm::CallSite.new( name , params , function)
call.load_args into
call.do_call into
call
end
def inspect
self.class.name + ".new(" + name.inspect + ", ["+
args.collect{|m| m.inspect }.join( ",") +"] )"
end
def to_s
"#{name}(" + args.join(",") + ")"
end
def attributes
[:name , :args]
end
end
end

View File

@ -38,3 +38,4 @@ require_relative "conditional_expression"
require_relative "while_expression"
require_relative "function_expression"
require_relative "operator_expressions"
require_relative "call_site_expression"

View File

@ -1,34 +1,5 @@
module Ast
# assignment, like operators are really function calls
class FuncallExpression < Expression
attr_reader :name, :args
def initialize name, args
@name , @args = name.to_sym , args
end
def compile context , into
params = args.collect{ |a| a.compile(context, into) }
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
self.class.name + ".new(" + name.inspect + ", ["+
args.collect{|m| m.inspect }.join( ",") +"] )"
end
def to_s
"#{name}(" + args.join(",") + ")"
end
def attributes
[:name , :args]
end
end
class OperatorExpression < Expression
attr_reader :operator, :left, :right