@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
46 lines • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.processRecall = processRecall;
const known_call_handling_1 = require("../known-call-handling");
const log_1 = require("../../../../../../util/log");
const edge_1 = require("../../../../../graph/edge");
const vertex_1 = require("../../../../../graph/vertex");
const unnamed_call_handling_1 = require("../unnamed-call-handling");
const identifier_1 = require("../../../../../environments/identifier");
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
/**
* Processes a built-in 'Recall' function call, linking
* the recall to the enveloping function closure.
*/
function processRecall(name, args, rootId, data) {
const { information } = (0, known_call_handling_1.processKnownFunctionCall)({
name,
args,
rootId,
data,
origin: built_in_proc_name_1.BuiltInProcName.Recall
});
let cur = data.environment.current;
let closure;
while (cur) {
if (cur.closure) {
closure = cur.closure;
break;
}
cur = cur.parent;
}
if (closure) {
information.graph.addEdge(rootId, closure, edge_1.EdgeType.Calls);
// also kill the name of the recall function
const r = information.graph.getVertex(rootId);
if ((0, vertex_1.isFunctionCallVertex)(r)) {
r.name = unnamed_call_handling_1.UnnamedFunctionCallPrefix + rootId + '-' + identifier_1.Identifier.toString(r.name);
r.environment = information.environment;
}
}
else {
log_1.log.warn('No enclosing function closure found for recall at node', rootId);
}
return information;
}
//# sourceMappingURL=built-in-recall.js.map