@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
166 lines • 4.94 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SyntaxAwareCfgGuidedVisitor = void 0;
const basic_cfg_guided_visitor_1 = require("./basic-cfg-guided-visitor");
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
const assert_1 = require("../util/assert");
/**
* This visitor extends on the {@link BasicCfgGuidedVisitor} by dispatching visitors based on the AST type of the node.
*
* Use {@link BasicCfgGuidedVisitor#start} to start the traversal.
*/
class SyntaxAwareCfgGuidedVisitor extends basic_cfg_guided_visitor_1.BasicCfgGuidedVisitor {
/**
* Get the normalized AST node for the given id or fail if it does not exist.
*/
getNormalizedAst(id) {
return this.config.normalizedAst.idMap.get(id);
}
onStatementNode(node) {
super.onStatementNode(node);
this.onExprOrStmtNode(node);
}
onExpressionNode(node) {
super.onExpressionNode(node);
this.onExprOrStmtNode(node);
}
onExprOrStmtNode(node) {
const astVertex = this.getNormalizedAst(node.id);
if (!astVertex) {
return;
}
const type = astVertex.type;
switch (type) {
case type_1.RType.Access:
return this.visitRAccess(astVertex);
case type_1.RType.Argument:
return this.visitRArgument(astVertex);
case type_1.RType.BinaryOp:
return this.visitRBinaryOp(astVertex);
case type_1.RType.ExpressionList:
return this.visitRExpressionList(astVertex);
case type_1.RType.ForLoop:
return this.visitRForLoop(astVertex);
case type_1.RType.FunctionCall:
return this.visitRFunctionCall(astVertex);
case type_1.RType.FunctionDefinition:
return this.visitRFunctionDefinition(astVertex);
case type_1.RType.IfThenElse:
return this.visitRIfThenElse(astVertex);
case type_1.RType.Parameter:
return this.visitRParameter(astVertex);
case type_1.RType.Pipe:
return this.visitRPipe(astVertex);
case type_1.RType.RepeatLoop:
return this.visitRRepeatLoop(astVertex);
case type_1.RType.UnaryOp:
return this.visitRUnaryOp(astVertex);
case type_1.RType.WhileLoop:
return this.visitRWhileLoop(astVertex);
case type_1.RType.Break:
return this.visitRBreak(astVertex);
case type_1.RType.Comment:
return this.visitRComment(astVertex);
case type_1.RType.LineDirective:
return this.visitRLineDirective(astVertex);
case type_1.RType.Logical:
return this.visitRLogical(astVertex);
case type_1.RType.Next:
return this.visitRNext(astVertex);
case type_1.RType.Number:
return this.visitRNumber(astVertex);
case type_1.RType.String:
return this.visitRString(astVertex);
case type_1.RType.Symbol:
return this.visitRSymbol(astVertex);
default:
(0, assert_1.assertUnreachable)(type);
}
}
/**
* {@link RAccess}
*/
visitRAccess(_node) { }
/**
* {@link RArgument}
*/
visitRArgument(_node) { }
/**
* {@link RBinaryOp}
*/
visitRBinaryOp(_node) { }
/**
* {@link RExpressionList}
*/
visitRExpressionList(_node) { }
/**
* {@link RForLoop}
*/
visitRForLoop(_node) { }
/**
* {@link RFunctionCall}
*/
visitRFunctionCall(_node) { }
/**
* {@link RFunctionDefinition}
*/
visitRFunctionDefinition(_node) { }
/**
* {@link RIfThenElse}
*/
visitRIfThenElse(_node) { }
/**
* {@link RParameter}
*/
visitRParameter(_node) { }
/**
* {@link RPipe}
*/
visitRPipe(_node) { }
/**
* {@link RRepeatLoop}
*/
visitRRepeatLoop(_node) { }
/**
* {@link RUnaryOp}
*/
visitRUnaryOp(_node) { }
/**
* {@link RWhileLoop}
*/
visitRWhileLoop(_node) { }
/**
* {@link RBreak}
*/
visitRBreak(_node) { }
/**
* {@link RComment}
*/
visitRComment(_node) { }
/**
* {@link RLineDirective}
*/
visitRLineDirective(_node) { }
/**
* {@link RLogical}
*/
visitRLogical(_node) { }
/**
* {@link RNext}
*/
visitRNext(_node) { }
/**
* {@link RNumber}
*/
visitRNumber(_node) { }
/**
* {@link RString}
*/
visitRString(_node) { }
/**
* {@link RSymbol}
*/
visitRSymbol(_node) { }
}
exports.SyntaxAwareCfgGuidedVisitor = SyntaxAwareCfgGuidedVisitor;
//# sourceMappingURL=syntax-cfg-guided-visitor.js.map