2014-05-03 15:13:44 +03:00
|
|
|
module Vm
|
|
|
|
|
|
|
|
# name and args , return
|
|
|
|
|
2014-05-13 21:15:02 +03:00
|
|
|
class CallSite < Value
|
2014-05-03 15:13:44 +03:00
|
|
|
|
2014-05-13 21:06:12 +03:00
|
|
|
def initialize(name , args , function )
|
2014-05-13 16:24:19 +03:00
|
|
|
@name = name
|
2014-05-05 10:13:49 +03:00
|
|
|
@args = args
|
2014-05-13 21:06:12 +03:00
|
|
|
@function = function
|
2014-05-03 15:13:44 +03:00
|
|
|
end
|
2014-05-13 16:24:19 +03:00
|
|
|
attr_reader :function , :args , :name
|
2014-05-03 15:13:44 +03:00
|
|
|
|
2014-05-13 16:24:19 +03:00
|
|
|
def load_args into
|
2014-05-05 09:35:40 +03:00
|
|
|
args.each_with_index do |arg , index|
|
2014-05-14 11:33:23 +03:00
|
|
|
if arg.is_a? IntegerConstant
|
|
|
|
Vm::Integer.new(index).load into , arg
|
|
|
|
else
|
2014-05-14 22:04:03 +03:00
|
|
|
Vm::Integer.new(index).move( into, arg ) if arg.register != index
|
2014-05-14 11:33:23 +03:00
|
|
|
end
|
2014-05-05 09:35:40 +03:00
|
|
|
end
|
2014-05-03 15:13:44 +03:00
|
|
|
end
|
2014-05-06 21:36:28 +03:00
|
|
|
|
2014-05-13 16:24:19 +03:00
|
|
|
def do_call into
|
2014-05-14 11:33:23 +03:00
|
|
|
CMachine.instance.function_call into , self
|
2014-05-03 15:13:44 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|