Merge pull request #99 from github/hvitved/cfg/to-string

CFG: Use manual `toString()`s for `AstCfgNode` when available
This commit is contained in:
Tom Hvitved
2021-01-21 14:10:16 +01:00
committed by GitHub
3 changed files with 539 additions and 528 deletions

View File

@@ -12,6 +12,7 @@ private import ast.internal.TreeSitter
* A node in the abstract syntax tree. This class is the base class for all Ruby
* program elements.
*/
// TODO: Replace base class with an abstract range class once we have full coverage
class AstNode extends @ast_node {
Generated::AstNode generated;

View File

@@ -1,6 +1,7 @@
/** Provides classes representing the control flow graph. */
private import codeql.Locations
private import codeql_ruby.AST as AST
private import codeql_ruby.ast.internal.TreeSitter::Generated
private import codeql_ruby.controlflow.BasicBlocks
private import SuccessorTypes
@@ -133,9 +134,18 @@ module CfgNodes {
final override AstNode getNode() { result = n }
final override string toString() {
result = "[" + this.getSplitsString() + "] " + n.toString()
or
not exists(this.getSplitsString()) and result = n.toString()
exists(string s |
// TODO: Remove once the SSA implementation is based on the AST layer
s = n.(AST::AstNode).toString() and
s != "AstNode"
or
n.(AST::AstNode).toString() = "AstNode" and
s = n.toString()
|
result = "[" + this.getSplitsString() + "] " + s
or
not exists(this.getSplitsString()) and result = s
)
}
/** Gets a comma-separated list of strings for each split in this node, if any. */

File diff suppressed because it is too large Load Diff