Rename ParenthesizedExprSynth to StmtSequenceSynth

This commit is contained in:
Tom Hvitved
2021-05-17 13:39:44 +02:00
parent ff06e724b1
commit b434d42d05
3 changed files with 20 additions and 24 deletions

View File

@@ -79,6 +79,12 @@ class StmtSequence extends Expr, TStmtSequence {
override AstNode getAChild(string pred) { pred = "getStmt" and result = this.getStmt(_) }
}
private class StmtSequenceSynth extends StmtSequence, TStmtSequenceSynth {
final override Stmt getStmt(int n) { synthChild(this, n, result) }
final override string toString() { result = "..." }
}
private class Then extends StmtSequence, TThen {
private Generated::Then g;
@@ -206,23 +212,17 @@ class BodyStmt extends StmtSequence, TBodyStmt {
* ```
*/
class ParenthesizedExpr extends StmtSequence, TParenthesizedExpr {
private Generated::ParenthesizedStatements g;
ParenthesizedExpr() { this = TParenthesizedExpr(g) }
final override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) }
final override string getAPrimaryQlClass() { result = "ParenthesizedExpr" }
final override string toString() { result = "( ... )" }
}
private class ParenthesizedExprReal extends ParenthesizedExpr, TParenthesizedExprReal {
private Generated::ParenthesizedStatements g;
ParenthesizedExprReal() { this = TParenthesizedExprReal(g) }
final override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) }
}
private class ParenthesizedExprSynth extends ParenthesizedExpr, TParenthesizedExprSynth {
final override Stmt getStmt(int n) { synthChild(this, n, result) }
}
/**
* A pair expression. For example, in a hash:
* ```rb

View File

@@ -188,10 +188,7 @@ private module Cached {
TNotExpr(Generated::Unary g) { g instanceof @unary_bang or g instanceof @unary_not } or
TOptionalParameter(Generated::OptionalParameter g) or
TPair(Generated::Pair g) or
TParenthesizedExprReal(Generated::ParenthesizedStatements g) or
TParenthesizedExprSynth(AST::AstNode parent, int i) {
mkSynthChild(ParenthesizedExprKind(), parent, i)
} or
TParenthesizedExpr(Generated::ParenthesizedStatements g) or
TRShiftExprReal(Generated::Binary g) { g instanceof @binary_ranglerangle } or
TRShiftExprSynth(AST::AstNode parent, int i) { mkSynthChild(RShiftExprKind(), parent, i) } or
TRangeLiteral(Generated::Range g) or
@@ -231,6 +228,7 @@ private module Cached {
TSpaceshipExpr(Generated::Binary g) { g instanceof @binary_langleequalrangle } or
TSplatArgument(Generated::SplatArgument g) or
TSplatParameter(Generated::SplatParameter g) or
TStmtSequenceSynth(AST::AstNode parent, int i) { mkSynthChild(StmtSequenceKind(), parent, i) } or
TStringArrayLiteral(Generated::StringArray g) or
TStringConcatenation(Generated::ChainedString g) or
TStringEscapeSequenceComponent(Generated::EscapeSequence g) or
@@ -369,7 +367,7 @@ private module Cached {
n = TNotExpr(result) or
n = TOptionalParameter(result) or
n = TPair(result) or
n = TParenthesizedExprReal(result) or
n = TParenthesizedExpr(result) or
n = TRShiftExprReal(result) or
n = TRangeLiteral(result) or
n = TRationalLiteral(result) or
@@ -484,15 +482,15 @@ private module Cached {
kind = MulExprKind() and
result = TMulExprSynth(parent, i)
or
kind = ParenthesizedExprKind() and
result = TParenthesizedExprSynth(parent, i)
or
kind = RShiftExprKind() and
result = TRShiftExprSynth(parent, i)
or
kind = SelfKind() and
result = TSelfSynth(parent, i)
or
kind = StmtSequenceKind() and
result = TStmtSequenceSynth(parent, i)
or
kind = SubExprKind() and
result = TSubExprSynth(parent, i)
)
@@ -560,9 +558,7 @@ class TExpr =
class TStmtSequence =
TBeginBlock or TEndBlock or TThen or TElse or TDo or TEnsure or TStringInterpolationComponent or
TBlock or TBodyStmt or TParenthesizedExpr;
class TParenthesizedExpr = TParenthesizedExprReal or TParenthesizedExprSynth;
TBlock or TBodyStmt or TParenthesizedExpr or TStmtSequenceSynth;
class TBodyStmt = TBeginExpr or TModuleBase or TMethod or TLambda or TDoBlock or TSingletonMethod;

View File

@@ -25,7 +25,7 @@ newtype SynthKind =
LogicalOrExprKind() or
ModuloExprKind() or
MulExprKind() or
ParenthesizedExprKind() or
StmtSequenceKind() or
RShiftExprKind() or
SelfKind() or
SubExprKind()