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

CFG: Reintroduce `toString()`s
This commit is contained in:
Tom Hvitved
2021-02-11 18:46:26 +01:00
committed by GitHub
4 changed files with 29 additions and 18 deletions

View File

@@ -213,7 +213,7 @@ class Module extends ModuleBase, ConstantWriteAccess, @module {
* global scope, as in this example:
*
* ```rb
* class ::Foo
* module ::Foo
* end
* ```
*/

View File

@@ -53,9 +53,10 @@ module Call {
final override Generated::Call generated;
final override Expr getReceiver() {
if exists(generated.getReceiver())
then result = generated.getReceiver()
else result = generated.getMethod().(Generated::ScopeResolution).getScope()
result = generated.getReceiver()
or
not exists(generated.getReceiver()) and
result = generated.getMethod().(Generated::ScopeResolution).getScope()
}
final override string getMethodName() {

View File

@@ -85,6 +85,16 @@ class AstCfgNode extends CfgNode, TAstNode {
or
n = any(Generated::For f).getValue() and
s = "In"
or
// TODO: Remove these nodes from the CFG
n = any(Generated::Class c).getName() and
s = n.toString()
or
n = any(Generated::Module m).getName() and
s = n.toString()
or
n = any(Generated::ScopeResolution sc).getName() and
s = n.toString()
|
result = "[" + this.getSplitsString() + "] " + s
or

View File

@@ -894,9 +894,9 @@ cfg.rb:
#-----| -> character
# 58| Silly
#-----| -> (no string representation)
#-----| -> Silly
# 58| (no string representation)
# 58| Silly
#-----| -> Object
# 58| Superclass
@@ -1375,9 +1375,9 @@ cfg.rb:
#-----| -> ... > ...
# 115| C
#-----| -> (no string representation)
#-----| -> C
# 115| (no string representation)
# 115| C
#-----| -> 42
# 116| ... = ...
@@ -1426,9 +1426,9 @@ cfg.rb:
#-----| -> Array
# 122| M
#-----| -> (no string representation)
#-----| -> M
# 122| (no string representation)
# 122| M
#-----| -> nil
# 123| ... = ...
@@ -1592,16 +1592,16 @@ cfg.rb:
#-----| -> M
# 137| M
#-----| -> (no string representation)
#-----| -> Constant
# 137| (no string representation)
# 137| Constant
#-----| -> Constant
# 138| Constant
#-----| -> class << ...
# 138| call to itself
#-----| -> (no string representation)
#-----| -> Constant
# 138| M
#-----| -> itself
@@ -1609,7 +1609,7 @@ cfg.rb:
# 138| itself
#-----| -> call to itself
# 138| (no string representation)
# 138| Constant
#-----| -> Constant
# 140| class << ...
@@ -2721,9 +2721,9 @@ loops.rb:
raise.rb:
# 1| ExceptionA
#-----| -> (no string representation)
#-----| -> ExceptionA
# 1| (no string representation)
# 1| ExceptionA
#-----| -> Exception
# 1| Superclass
@@ -2733,9 +2733,9 @@ raise.rb:
#-----| -> Superclass
# 4| ExceptionB
#-----| -> (no string representation)
#-----| -> ExceptionB
# 4| (no string representation)
# 4| ExceptionB
#-----| -> Exception
# 4| Superclass