AST: make Expr extend Stmt

This commit is contained in:
Arthur Baars
2021-02-11 15:25:54 +01:00
parent f02d4a977d
commit fd6aeba9f5
3 changed files with 7 additions and 20 deletions

View File

@@ -1,30 +1,15 @@
private import codeql_ruby.AST
private import codeql_ruby.CFG
private import internal.Expr
private import internal.Variable
private import codeql_ruby.controlflow.internal.ControlFlowGraphImpl
/**
* An expression.
*
* This is the root QL class for all expressions.
*/
class Expr extends AstNode {
class Expr extends Stmt {
override Expr::Range range;
Expr() { this = range }
/** Gets a control-flow node for this expression, if any. */
CfgNodes::AstCfgNode getAControlFlowNode() { result.getNode() = this }
/** Gets the control-flow scope of this expression, if any. */
CfgScope getCfgScope() { result = getCfgScope(this) }
/** Gets the variable scope that this expression belongs to. */
VariableScope getVariableScope() { result = enclosingScope(this) }
/** Gets the enclosing callable, if any. */
Callable getEnclosingCallable() { result = this.getCfgScope() }
}
/**

View File

@@ -1,6 +1,7 @@
private import codeql_ruby.AST
private import codeql_ruby.CFG
private import internal.Statement
private import internal.Variable
private import codeql_ruby.controlflow.internal.ControlFlowGraphImpl
/**
@@ -17,6 +18,9 @@ class Stmt extends AstNode {
/** Gets the control-flow scope of this statement, if any. */
CfgScope getCfgScope() { result = getCfgScope(this) }
/** Gets the variable scope that this statement belongs to. */
VariableScope getVariableScope() { result = enclosingScope(this) }
/** Gets the enclosing callable, if any. */
Callable getEnclosingCallable() { result = this.getCfgScope() }
}

View File

@@ -1,11 +1,9 @@
private import codeql_ruby.AST
private import codeql_ruby.ast.internal.AST
private import codeql_ruby.ast.internal.Pattern
private import codeql_ruby.ast.internal.Statement
private import codeql_ruby.ast.internal.TreeSitter
private import codeql_ruby.ast.internal.Variable
module Expr {
abstract class Range extends AstNode::Range { }
abstract class Range extends Stmt::Range { }
}
module Literal {