Skip to content

Commit 46ff10c

Browse files
committed
Update the reflection syntax according to the latest draft
1 parent cf9426d commit 46ff10c

File tree

17 files changed

+70
-64
lines changed

17 files changed

+70
-64
lines changed

packages/cxx-frontend/src/AST.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7012,9 +7012,9 @@ export class GlobalScopeReflectExpressionAST extends ExpressionAST {
70127012
}
70137013

70147014
/**
7015-
* Returns the location of the caret token in this node
7015+
* Returns the location of the caretCaret token in this node
70167016
*/
7017-
getCaretToken(): Token | undefined {
7017+
getCaretCaretToken(): Token | undefined {
70187018
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
70197019
}
70207020

@@ -7044,9 +7044,9 @@ export class NamespaceReflectExpressionAST extends ExpressionAST {
70447044
}
70457045

70467046
/**
7047-
* Returns the location of the caret token in this node
7047+
* Returns the location of the caretCaret token in this node
70487048
*/
7049-
getCaretToken(): Token | undefined {
7049+
getCaretCaretToken(): Token | undefined {
70507050
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
70517051
}
70527052

@@ -7084,9 +7084,9 @@ export class TypeIdReflectExpressionAST extends ExpressionAST {
70847084
}
70857085

70867086
/**
7087-
* Returns the location of the caret token in this node
7087+
* Returns the location of the caretCaret token in this node
70887088
*/
7089-
getCaretToken(): Token | undefined {
7089+
getCaretCaretToken(): Token | undefined {
70907090
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
70917091
}
70927092

@@ -7119,9 +7119,9 @@ export class ReflectExpressionAST extends ExpressionAST {
71197119
}
71207120

71217121
/**
7122-
* Returns the location of the caret token in this node
7122+
* Returns the location of the caretCaret token in this node
71237123
*/
7124-
getCaretToken(): Token | undefined {
7124+
getCaretCaretToken(): Token | undefined {
71257125
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
71267126
}
71277127

packages/cxx-frontend/src/ASTSlot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export enum ASTSlot {
4848
captureDefault = 25,
4949
captureDefaultLoc = 26,
5050
captureList = 27,
51-
caretLoc = 28,
51+
caretCaretLoc = 28,
5252
caseLoc = 29,
5353
castLoc = 30,
5454
catchLoc = 31,

packages/cxx-frontend/src/TokenKind.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export enum TokenKind {
4141
BAR_BAR,
4242
BAR_EQUAL,
4343
BAR,
44+
CARET_CARET,
4445
CARET_EQUAL,
4546
CARET,
4647
COLON_COLON,

packages/cxx-gen-ast/src/tokens.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const OPERATORS: Array<[kind: string, spelling: string]> = [
4343
["BAR_BAR", "||"],
4444
["BAR_EQUAL", "|="],
4545
["BAR", "|"],
46+
["CARET_CARET", "^^"],
4647
["CARET_EQUAL", "^="],
4748
["CARET", "^"],
4849
["COLON_COLON", "::"],

src/parser/cxx/ast.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,50 +1770,50 @@ auto SpliceExpressionAST::lastSourceLocation() -> SourceLocation {
17701770
}
17711771

17721772
auto GlobalScopeReflectExpressionAST::firstSourceLocation() -> SourceLocation {
1773-
if (auto loc = cxx::firstSourceLocation(caretLoc)) return loc;
1773+
if (auto loc = cxx::firstSourceLocation(caretCaretLoc)) return loc;
17741774
if (auto loc = cxx::firstSourceLocation(scopeLoc)) return loc;
17751775
return {};
17761776
}
17771777

17781778
auto GlobalScopeReflectExpressionAST::lastSourceLocation() -> SourceLocation {
17791779
if (auto loc = cxx::lastSourceLocation(scopeLoc)) return loc;
1780-
if (auto loc = cxx::lastSourceLocation(caretLoc)) return loc;
1780+
if (auto loc = cxx::lastSourceLocation(caretCaretLoc)) return loc;
17811781
return {};
17821782
}
17831783

17841784
auto NamespaceReflectExpressionAST::firstSourceLocation() -> SourceLocation {
1785-
if (auto loc = cxx::firstSourceLocation(caretLoc)) return loc;
1785+
if (auto loc = cxx::firstSourceLocation(caretCaretLoc)) return loc;
17861786
if (auto loc = cxx::firstSourceLocation(identifierLoc)) return loc;
17871787
return {};
17881788
}
17891789

17901790
auto NamespaceReflectExpressionAST::lastSourceLocation() -> SourceLocation {
17911791
if (auto loc = cxx::lastSourceLocation(identifierLoc)) return loc;
1792-
if (auto loc = cxx::lastSourceLocation(caretLoc)) return loc;
1792+
if (auto loc = cxx::lastSourceLocation(caretCaretLoc)) return loc;
17931793
return {};
17941794
}
17951795

17961796
auto TypeIdReflectExpressionAST::firstSourceLocation() -> SourceLocation {
1797-
if (auto loc = cxx::firstSourceLocation(caretLoc)) return loc;
1797+
if (auto loc = cxx::firstSourceLocation(caretCaretLoc)) return loc;
17981798
if (auto loc = cxx::firstSourceLocation(typeId)) return loc;
17991799
return {};
18001800
}
18011801

18021802
auto TypeIdReflectExpressionAST::lastSourceLocation() -> SourceLocation {
18031803
if (auto loc = cxx::lastSourceLocation(typeId)) return loc;
1804-
if (auto loc = cxx::lastSourceLocation(caretLoc)) return loc;
1804+
if (auto loc = cxx::lastSourceLocation(caretCaretLoc)) return loc;
18051805
return {};
18061806
}
18071807

18081808
auto ReflectExpressionAST::firstSourceLocation() -> SourceLocation {
1809-
if (auto loc = cxx::firstSourceLocation(caretLoc)) return loc;
1809+
if (auto loc = cxx::firstSourceLocation(caretCaretLoc)) return loc;
18101810
if (auto loc = cxx::firstSourceLocation(expression)) return loc;
18111811
return {};
18121812
}
18131813

18141814
auto ReflectExpressionAST::lastSourceLocation() -> SourceLocation {
18151815
if (auto loc = cxx::lastSourceLocation(expression)) return loc;
1816-
if (auto loc = cxx::lastSourceLocation(caretLoc)) return loc;
1816+
if (auto loc = cxx::lastSourceLocation(caretCaretLoc)) return loc;
18171817
return {};
18181818
}
18191819

src/parser/cxx/ast.fbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,24 +1114,24 @@ table SpliceExpression /* ExpressionAST */ {
11141114
}
11151115

11161116
table GlobalScopeReflectExpression /* ExpressionAST */ {
1117-
caret_loc: uint32;
1117+
caret_caret_loc: uint32;
11181118
scope_loc: uint32;
11191119
}
11201120

11211121
table NamespaceReflectExpression /* ExpressionAST */ {
11221122
identifier: string;
1123-
caret_loc: uint32;
1123+
caret_caret_loc: uint32;
11241124
identifier_loc: uint32;
11251125
}
11261126

11271127
table TypeIdReflectExpression /* ExpressionAST */ {
11281128
type_id: TypeId;
1129-
caret_loc: uint32;
1129+
caret_caret_loc: uint32;
11301130
}
11311131

11321132
table ReflectExpression /* ExpressionAST */ {
11331133
expression: Expression;
1134-
caret_loc: uint32;
1134+
caret_caret_loc: uint32;
11351135
}
11361136

11371137
table LabelAddressExpression /* ExpressionAST */ {

src/parser/cxx/ast.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,7 @@ class GlobalScopeReflectExpressionAST final : public ExpressionAST {
22022202

22032203
GlobalScopeReflectExpressionAST() : ExpressionAST(Kind) {}
22042204

2205-
SourceLocation caretLoc;
2205+
SourceLocation caretCaretLoc;
22062206
SourceLocation scopeLoc;
22072207

22082208
void accept(ASTVisitor* visitor) override { visitor->visit(this); }
@@ -2217,7 +2217,7 @@ class NamespaceReflectExpressionAST final : public ExpressionAST {
22172217

22182218
NamespaceReflectExpressionAST() : ExpressionAST(Kind) {}
22192219

2220-
SourceLocation caretLoc;
2220+
SourceLocation caretCaretLoc;
22212221
SourceLocation identifierLoc;
22222222
const Identifier* identifier = nullptr;
22232223
NamespaceSymbol* symbol = nullptr;
@@ -2234,7 +2234,7 @@ class TypeIdReflectExpressionAST final : public ExpressionAST {
22342234

22352235
TypeIdReflectExpressionAST() : ExpressionAST(Kind) {}
22362236

2237-
SourceLocation caretLoc;
2237+
SourceLocation caretCaretLoc;
22382238
TypeIdAST* typeId = nullptr;
22392239

22402240
void accept(ASTVisitor* visitor) override { visitor->visit(this); }
@@ -2249,7 +2249,7 @@ class ReflectExpressionAST final : public ExpressionAST {
22492249

22502250
ReflectExpressionAST() : ExpressionAST(Kind) {}
22512251

2252-
SourceLocation caretLoc;
2252+
SourceLocation caretCaretLoc;
22532253
ExpressionAST* expression = nullptr;
22542254

22552255
void accept(ASTVisitor* visitor) override { visitor->visit(this); }

src/parser/cxx/ast_pretty_printer.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,8 +2804,8 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()(SpliceExpressionAST* ast) {
28042804

28052805
void ASTPrettyPrinter::ExpressionVisitor::operator()(
28062806
GlobalScopeReflectExpressionAST* ast) {
2807-
if (ast->caretLoc) {
2808-
accept.writeToken(ast->caretLoc);
2807+
if (ast->caretCaretLoc) {
2808+
accept.writeToken(ast->caretCaretLoc);
28092809
}
28102810
if (ast->scopeLoc) {
28112811
nospace();
@@ -2816,8 +2816,8 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()(
28162816

28172817
void ASTPrettyPrinter::ExpressionVisitor::operator()(
28182818
NamespaceReflectExpressionAST* ast) {
2819-
if (ast->caretLoc) {
2820-
accept.writeToken(ast->caretLoc);
2819+
if (ast->caretCaretLoc) {
2820+
accept.writeToken(ast->caretCaretLoc);
28212821
}
28222822
if (ast->identifierLoc) {
28232823
accept.writeToken(ast->identifierLoc);
@@ -2826,16 +2826,16 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()(
28262826

28272827
void ASTPrettyPrinter::ExpressionVisitor::operator()(
28282828
TypeIdReflectExpressionAST* ast) {
2829-
if (ast->caretLoc) {
2830-
accept.writeToken(ast->caretLoc);
2829+
if (ast->caretCaretLoc) {
2830+
accept.writeToken(ast->caretCaretLoc);
28312831
}
28322832
accept(ast->typeId);
28332833
}
28342834

28352835
void ASTPrettyPrinter::ExpressionVisitor::operator()(
28362836
ReflectExpressionAST* ast) {
2837-
if (ast->caretLoc) {
2838-
accept.writeToken(ast->caretLoc);
2837+
if (ast->caretCaretLoc) {
2838+
accept.writeToken(ast->caretCaretLoc);
28392839
}
28402840
accept(ast->expression);
28412841
}

src/parser/cxx/ast_rewriter_expressions.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ auto ASTRewriter::ExpressionVisitor::operator()(
973973

974974
copy->valueCategory = ast->valueCategory;
975975
copy->type = ast->type;
976-
copy->caretLoc = ast->caretLoc;
976+
copy->caretCaretLoc = ast->caretCaretLoc;
977977
copy->scopeLoc = ast->scopeLoc;
978978

979979
return copy;
@@ -985,7 +985,7 @@ auto ASTRewriter::ExpressionVisitor::operator()(
985985

986986
copy->valueCategory = ast->valueCategory;
987987
copy->type = ast->type;
988-
copy->caretLoc = ast->caretLoc;
988+
copy->caretCaretLoc = ast->caretCaretLoc;
989989
copy->identifierLoc = ast->identifierLoc;
990990
copy->identifier = ast->identifier;
991991
copy->symbol = ast->symbol;
@@ -999,7 +999,7 @@ auto ASTRewriter::ExpressionVisitor::operator()(TypeIdReflectExpressionAST* ast)
999999

10001000
copy->valueCategory = ast->valueCategory;
10011001
copy->type = ast->type;
1002-
copy->caretLoc = ast->caretLoc;
1002+
copy->caretCaretLoc = ast->caretCaretLoc;
10031003
copy->typeId = rewrite.typeId(ast->typeId);
10041004

10051005
return copy;
@@ -1011,7 +1011,7 @@ auto ASTRewriter::ExpressionVisitor::operator()(ReflectExpressionAST* ast)
10111011

10121012
copy->valueCategory = ast->valueCategory;
10131013
copy->type = ast->type;
1014-
copy->caretLoc = ast->caretLoc;
1014+
copy->caretCaretLoc = ast->caretCaretLoc;
10151015
copy->expression = rewrite.expression(ast->expression);
10161016

10171017
return copy;

src/parser/cxx/ast_slot.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ std::string_view kMemberSlotNames[] = {
7878
"captureDefault",
7979
"captureDefaultLoc",
8080
"captureList",
81-
"caretLoc",
81+
"caretCaretLoc",
8282
"caseLoc",
8383
"castLoc",
8484
"catchLoc",
@@ -3504,8 +3504,8 @@ void ASTSlot::visit(SpliceExpressionAST* ast) {
35043504

35053505
void ASTSlot::visit(GlobalScopeReflectExpressionAST* ast) {
35063506
switch (slot_) {
3507-
case 0: // caretLoc
3508-
value_ = ast->caretLoc.index();
3507+
case 0: // caretCaretLoc
3508+
value_ = ast->caretCaretLoc.index();
35093509
slotKind_ = ASTSlotKind::kToken;
35103510
slotNameIndex_ = SlotNameIndex{28};
35113511
break;
@@ -3521,8 +3521,8 @@ void ASTSlot::visit(GlobalScopeReflectExpressionAST* ast) {
35213521

35223522
void ASTSlot::visit(NamespaceReflectExpressionAST* ast) {
35233523
switch (slot_) {
3524-
case 0: // caretLoc
3525-
value_ = ast->caretLoc.index();
3524+
case 0: // caretCaretLoc
3525+
value_ = ast->caretCaretLoc.index();
35263526
slotKind_ = ASTSlotKind::kToken;
35273527
slotNameIndex_ = SlotNameIndex{28};
35283528
break;
@@ -3543,8 +3543,8 @@ void ASTSlot::visit(NamespaceReflectExpressionAST* ast) {
35433543

35443544
void ASTSlot::visit(TypeIdReflectExpressionAST* ast) {
35453545
switch (slot_) {
3546-
case 0: // caretLoc
3547-
value_ = ast->caretLoc.index();
3546+
case 0: // caretCaretLoc
3547+
value_ = ast->caretCaretLoc.index();
35483548
slotKind_ = ASTSlotKind::kToken;
35493549
slotNameIndex_ = SlotNameIndex{28};
35503550
break;
@@ -3560,8 +3560,8 @@ void ASTSlot::visit(TypeIdReflectExpressionAST* ast) {
35603560

35613561
void ASTSlot::visit(ReflectExpressionAST* ast) {
35623562
switch (slot_) {
3563-
case 0: // caretLoc
3564-
value_ = ast->caretLoc.index();
3563+
case 0: // caretCaretLoc
3564+
value_ = ast->caretCaretLoc.index();
35653565
slotKind_ = ASTSlotKind::kToken;
35663566
slotNameIndex_ = SlotNameIndex{28};
35673567
break;

0 commit comments

Comments
 (0)