/* * PCN System Compiler: VT transformations * Author: Robert Olson * Argonne National Laboratory * * Please see the DISCLAIMER file in the top level directory of the * distribution regarding the provisions under which this software * is distributed. * * vtco_reloc1.ptn - Collapse relocated call arguments into single arg * * */ -proc_metacalls(xform_calls, vtco_reloc1:xform_call) xform_calls(id, defn, newdefn) {; map:map_transform_to_calls(vtco_reloc1:xform_call(id), id, defn, newdefn) } xform_call(id, call, newcall) {? call ?= call(call_id, call_args, anno), anno != [], call_id ?= {":", call_mod, call_name}, id ?= {":", pgm_mod, _} -> {|| sys:list_length(call_args, nargs), make_formal_arg_list(nargs, formal_arg_list), sys:list_to_tuple(formal_arg_list, formal_arg_tuple), sys:list_to_tuple(call_args, arg_tuple), unique_var(arg), vtco_remap:call_is_metacall(call_mod, call_name, is_metacall), {? is_metacall == "true" -> {|| unique_var(aux_mod), unique_var(aux_proc), guard = [{"?=", arg, {aux_mod, aux_proc, formal_arg_tuple}}], body = call({":", aux_mod, aux_proc}, formal_arg_list, []), defn = program([arg], [], block("?", [{"->", guard, body}])), vtco_utils:insert_with_dot(pgm_mod, "_port_reloc1_metacall", defn, newname), newcall = call(newname, [{call_mod, call_name, arg_tuple}], anno) }, default -> {|| guard = [{"?=", arg, formal_arg_tuple}], body = call(call_id, formal_arg_list, []), defn = program([arg], [], block("?", [{"->", guard, body}])), vtco_utils:insert_with_dot(pgm_mod, call_name, defn, newname), newcall = call(newname, [arg_tuple], anno) } }, vtco_exports:add_exports([newname]) }, default -> {|| newcall = call } } make_formal_arg_list(nargs, formal_arg_list) {? nargs == 0 -> {|| formal_arg_list = [] }, nargs > 0 -> {; unique_var(v), formal_arg_list = [v | formal_arg_list1], make_formal_arg_list(nargs - 1, formal_arg_list1) } }