/** * This is called on a code path looped. * Then this raises a looped event. * * @param {CodePathSegment} fromSegment - A segment of prev. * @param {CodePathSegment} toSegment - A segment of next. * @returns {void} */ onLooped(fromSegment, toSegment) { if (fromSegment.reachable && toSegment.reachable) { debug.dump(`onCodePathSegmentLoop ${fromSegment.id} -> ${toSegment.id}`); this.emitter.emit( "onCodePathSegmentLoop", fromSegment, toSegment, this.currentNode ); } }
/** * Updates the current segment with empty. * This is called at the last of functions or the program. * * @param {CodePathAnalyzer} analyzer - The instance. * @param {ASTNode} node - The current AST node. * @returns {void} */ function leaveFromCurrentSegment(analyzer, node) { const state = CodePath.getState(analyzer.codePath); const currentSegments = state.currentSegments; for (let i = 0; i < currentSegments.length; ++i) { const currentSegment = currentSegments[i]; debug.dump(`onCodePathSegmentEnd ${currentSegment.id}`); if (currentSegment.reachable) { analyzer.emitter.emit( "onCodePathSegmentEnd", currentSegment, node); } } state.currentSegments = []; }
debug.dump(`onCodePathEnd ${codePath.id}`); analyzer.emitter.emit("onCodePathEnd", codePath, node); debug.dumpDot(codePath);
debug.dump(`onCodePathStart ${codePath.id}`); analyzer.emitter.emit("onCodePathStart", codePath, node); break;