UNPKG

@syntest/cfg

Version:
71 lines 2.83 kB
"use strict"; /* * Copyright 2020-2023 Delft University of Technology and SynTest contributors * * This file is part of SynTest Framework - SynTest Core. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ContractedControlFlowGraph = void 0; const diagnostics_1 = require("../diagnostics"); const ControlFlowGraph_1 = require("./ControlFlowGraph"); /** * A contracted control flow graph. * This class contains the (original) full graph and a mapping between the nodes in the contracted graph and the nodes in the full graph. */ class ContractedControlFlowGraph extends ControlFlowGraph_1.ControlFlowGraph { constructor(entry, successExit, errorExit, nodes, edges, fullGraph, nodeMapping) { super(entry, successExit, errorExit, nodes, edges); this._fullGraph = fullGraph; this._nodeMapping = nodeMapping; this._reverseNodeMapping = new Map(); for (const [key, value] of this._nodeMapping) { for (const node of value) { if (this._reverseNodeMapping.has(node)) throw new Error((0, diagnostics_1.duplicateNodeInMappping)()); this._reverseNodeMapping.set(node, key); } } for (const nodeId of nodes.keys()) { if (!this._nodeMapping.has(nodeId)) { this._nodeMapping.set(nodeId, [nodeId]); } if (!this._reverseNodeMapping.has(nodeId)) this._reverseNodeMapping.set(nodeId, nodeId); } } get fullGraph() { return this._fullGraph; } get nodeMapping() { return this._nodeMapping; } get reverseNodeMapping() { return this._reverseNodeMapping; } getParentNode(node) { if (!this._reverseNodeMapping.has(node)) { throw new Error((0, diagnostics_1.nodeNotFoundInMapping)(node)); } return this._reverseNodeMapping.get(node); } getChildNodes(node) { if (!this._nodeMapping.has(node)) { throw new Error((0, diagnostics_1.nodeNotFoundInMapping)(node)); } return this._nodeMapping.get(node); } } exports.ContractedControlFlowGraph = ContractedControlFlowGraph; //# sourceMappingURL=ContractedControlFlowGraph.js.map