@@ -46,13 +46,11 @@ using namespace swift::syntax;
46
46
// SILParserState implementation
47
47
// ===----------------------------------------------------------------------===//
48
48
49
- namespace swift {
50
- // This has to be in the 'swift' namespace because it's forward-declared for
51
- // SILParserState.
52
- class SILParserTUState : public SILParserTUStateBase {
49
+ namespace {
50
+ class SILParserState : public SILParserStateBase {
53
51
public:
54
- explicit SILParserTUState (SILModule &M) : M(M) {}
55
- ~SILParserTUState ();
52
+ explicit SILParserState (SILModule &M) : M(M) {}
53
+ ~SILParserState ();
56
54
57
55
SILModule &M;
58
56
@@ -80,9 +78,9 @@ class SILParserTUState : public SILParserTUStateBase {
80
78
bool parseSILProperty (Parser &P) override ;
81
79
bool parseSILScope (Parser &P) override ;
82
80
};
83
- } // end namespace swift
81
+ } // end anonymous namespace
84
82
85
- SILParserTUState ::~SILParserTUState () {
83
+ SILParserState ::~SILParserState () {
86
84
if (!ForwardRefFns.empty ()) {
87
85
for (auto Entry : ForwardRefFns) {
88
86
if (Entry.second .Loc .isValid ()) {
@@ -101,11 +99,6 @@ SILParserTUState::~SILParserTUState() {
101
99
}
102
100
}
103
101
104
- SILParserState::SILParserState (SILModule *M)
105
- : Impl(M ? std::make_unique<SILParserTUState>(*M) : nullptr) {}
106
-
107
- SILParserState::~SILParserState () = default ;
108
-
109
102
std::unique_ptr<SILModule>
110
103
ParseSILModuleRequest::evaluate (Evaluator &evaluator,
111
104
SILGenDescriptor desc) const {
@@ -117,8 +110,8 @@ ParseSILModuleRequest::evaluate(Evaluator &evaluator,
117
110
118
111
auto silMod = SILModule::createEmptyModule (desc.context , desc.conv ,
119
112
desc.opts );
120
- SILParserState parserState (silMod.get ());
121
- Parser parser (*bufferID, *SF, parserState. Impl . get () );
113
+ SILParserState parserState (* silMod.get ());
114
+ Parser parser (*bufferID, *SF, & parserState);
122
115
PrettyStackTraceParser StackTrace (parser);
123
116
124
117
auto hadError = parser.parseTopLevelSIL ();
@@ -157,11 +150,11 @@ namespace {
157
150
};
158
151
159
152
class SILParser {
160
- friend SILParserTUState ;
153
+ friend SILParserState ;
161
154
public:
162
155
Parser &P;
163
156
SILModule &SILMod;
164
- SILParserTUState &TUState;
157
+ SILParserState &TUState;
165
158
SILFunction *F = nullptr ;
166
159
GenericEnvironment *ContextGenericEnv = nullptr ;
167
160
@@ -193,8 +186,8 @@ namespace {
193
186
194
187
public:
195
188
SILParser (Parser &P)
196
- : P(P), SILMod(static_cast <SILParserTUState *>(P.SIL)->M),
197
- TUState (*static_cast <SILParserTUState *>(P.SIL)),
189
+ : P(P), SILMod(static_cast <SILParserState *>(P.SIL)->M),
190
+ TUState (*static_cast <SILParserState *>(P.SIL)),
198
191
ParsedTypeCallback([](Type ty) {}) {}
199
192
200
193
// / diagnoseProblems - After a function is fully parse, emit any diagnostics
@@ -5638,7 +5631,7 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
5638
5631
// / 'sil' sil-linkage '@' identifier ':' sil-type decl-sil-body?
5639
5632
// / decl-sil-body:
5640
5633
// / '{' sil-basic-block+ '}'
5641
- bool SILParserTUState ::parseDeclSIL (Parser &P) {
5634
+ bool SILParserState ::parseDeclSIL (Parser &P) {
5642
5635
// Inform the lexer that we're lexing the body of the SIL declaration. Do
5643
5636
// this before we consume the 'sil' token so that all later tokens are
5644
5637
// properly handled.
@@ -5806,7 +5799,7 @@ bool SILParserTUState::parseDeclSIL(Parser &P) {
5806
5799
5807
5800
// / decl-sil-stage: [[only in SIL mode]]
5808
5801
// / 'sil_stage' ('raw' | 'canonical')
5809
- bool SILParserTUState ::parseDeclSILStage (Parser &P) {
5802
+ bool SILParserState ::parseDeclSILStage (Parser &P) {
5810
5803
SourceLoc stageLoc = P.consumeToken (tok::kw_sil_stage);
5811
5804
if (!P.Tok .is (tok::identifier)) {
5812
5805
P.diagnose (P.Tok , diag::expected_sil_stage_name);
@@ -5887,7 +5880,7 @@ static Optional<VarDecl *> lookupGlobalDecl(Identifier GlobalName,
5887
5880
5888
5881
// / decl-sil-global: [[only in SIL mode]]
5889
5882
// / 'sil_global' sil-linkage @name : sil-type [external]
5890
- bool SILParserTUState ::parseSILGlobal (Parser &P) {
5883
+ bool SILParserState ::parseSILGlobal (Parser &P) {
5891
5884
// Inform the lexer that we're lexing the body of the SIL declaration.
5892
5885
Lexer::SILBodyRAII Tmp (*P.L );
5893
5886
@@ -5944,7 +5937,7 @@ bool SILParserTUState::parseSILGlobal(Parser &P) {
5944
5937
// / decl-sil-property: [[only in SIL mode]]
5945
5938
// / 'sil_property' sil-decl-ref '(' sil-key-path-pattern-component ')'
5946
5939
5947
- bool SILParserTUState ::parseSILProperty (Parser &P) {
5940
+ bool SILParserState ::parseSILProperty (Parser &P) {
5948
5941
Lexer::SILBodyRAII Tmp (*P.L );
5949
5942
5950
5943
auto loc = P.consumeToken (tok::kw_sil_property);
@@ -6017,7 +6010,7 @@ bool SILParserTUState::parseSILProperty(Parser &P) {
6017
6010
// / '{' sil-vtable-entry* '}'
6018
6011
// / sil-vtable-entry:
6019
6012
// / SILDeclRef ':' SILFunctionName
6020
- bool SILParserTUState ::parseSILVTable (Parser &P) {
6013
+ bool SILParserState ::parseSILVTable (Parser &P) {
6021
6014
P.consumeToken (tok::kw_sil_vtable);
6022
6015
SILParser VTableState (P);
6023
6016
@@ -6545,7 +6538,7 @@ static bool parseSILVTableEntry(
6545
6538
// / associated_type_protocol (AssocName: ProtocolName):
6546
6539
// / protocol-conformance|dependent
6547
6540
// / base_protocol ProtocolName: protocol-conformance
6548
- bool SILParserTUState ::parseSILWitnessTable (Parser &P) {
6541
+ bool SILParserState ::parseSILWitnessTable (Parser &P) {
6549
6542
P.consumeToken (tok::kw_sil_witness_table);
6550
6543
SILParser WitnessState (P);
6551
6544
@@ -6648,7 +6641,7 @@ bool SILParserTUState::parseSILWitnessTable(Parser &P) {
6648
6641
// / sil-default-witness-entry:
6649
6642
// / sil-witness-entry
6650
6643
// / 'no_default'
6651
- bool SILParserTUState ::parseSILDefaultWitnessTable (Parser &P) {
6644
+ bool SILParserState ::parseSILDefaultWitnessTable (Parser &P) {
6652
6645
P.consumeToken (tok::kw_sil_default_witness_table);
6653
6646
SILParser WitnessState (P);
6654
6647
@@ -6715,7 +6708,7 @@ bool SILParserTUState::parseSILDefaultWitnessTable(Parser &P) {
6715
6708
// /
6716
6709
// / index-subset ::=
6717
6710
// / [0-9]+ (' ' [0-9]+)*
6718
- bool SILParserTUState ::parseSILDifferentiabilityWitness (Parser &P) {
6711
+ bool SILParserState ::parseSILDifferentiabilityWitness (Parser &P) {
6719
6712
auto loc = P.consumeToken (tok::kw_sil_differentiability_witness);
6720
6713
auto silLoc = RegularLocation (loc);
6721
6714
SILParser State (P);
@@ -6865,7 +6858,7 @@ llvm::Optional<llvm::coverage::Counter> SILParser::parseSILCoverageExpr(
6865
6858
// / StartLine ':' StartCol '->' EndLine ':' EndCol
6866
6859
// / sil-coverage-expr:
6867
6860
// / ...
6868
- bool SILParserTUState ::parseSILCoverageMap (Parser &P) {
6861
+ bool SILParserState ::parseSILCoverageMap (Parser &P) {
6869
6862
P.consumeToken (tok::kw_sil_coverage_map);
6870
6863
SILParser State (P);
6871
6864
@@ -6956,7 +6949,7 @@ bool SILParserTUState::parseSILCoverageMap(Parser &P) {
6956
6949
// / scope-parent ::= sil-function-name ':' sil-type
6957
6950
// / scope-parent ::= sil-scope-ref
6958
6951
// / debug-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+
6959
- bool SILParserTUState ::parseSILScope (Parser &P) {
6952
+ bool SILParserState ::parseSILScope (Parser &P) {
6960
6953
P.consumeToken (tok::kw_sil_scope);
6961
6954
SILParser ScopeState (P);
6962
6955
0 commit comments