@@ -262,6 +262,9 @@ pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void {
262
262
token_tags [parse_error .token ].symbol (),
263
263
});
264
264
},
265
+ .extra_addrspace_qualifier = > {
266
+ return stream .writeAll ("extra addrspace qualifier" );
267
+ },
265
268
.extra_align_qualifier = > {
266
269
return stream .writeAll ("extra align qualifier" );
267
270
},
@@ -1021,7 +1024,7 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
1021
1024
},
1022
1025
.fn_proto_one = > {
1023
1026
const extra = tree .extraData (datas [n ].lhs , Node .FnProtoOne );
1024
- // linksection, callconv, align can appear in any order, so we
1027
+ // addrspace, linksection, callconv, align can appear in any order, so we
1025
1028
// find the last one here.
1026
1029
var max_node : Node.Index = datas [n ].rhs ;
1027
1030
var max_start = token_starts [main_tokens [max_node ]];
@@ -1034,6 +1037,14 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
1034
1037
max_offset = 1 ; // for the rparen
1035
1038
}
1036
1039
}
1040
+ if (extra .addrspace_expr != 0 ) {
1041
+ const start = token_starts [main_tokens [extra .addrspace_expr ]];
1042
+ if (start > max_start ) {
1043
+ max_node = extra .addrspace_expr ;
1044
+ max_start = start ;
1045
+ max_offset = 1 ; // for the rparen
1046
+ }
1047
+ }
1037
1048
if (extra .section_expr != 0 ) {
1038
1049
const start = token_starts [main_tokens [extra .section_expr ]];
1039
1050
if (start > max_start ) {
@@ -1055,7 +1066,7 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
1055
1066
},
1056
1067
.fn_proto = > {
1057
1068
const extra = tree .extraData (datas [n ].lhs , Node .FnProto );
1058
- // linksection, callconv, align can appear in any order, so we
1069
+ // addrspace, linksection, callconv, align can appear in any order, so we
1059
1070
// find the last one here.
1060
1071
var max_node : Node.Index = datas [n ].rhs ;
1061
1072
var max_start = token_starts [main_tokens [max_node ]];
@@ -1068,6 +1079,14 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
1068
1079
max_offset = 1 ; // for the rparen
1069
1080
}
1070
1081
}
1082
+ if (extra .addrspace_expr != 0 ) {
1083
+ const start = token_starts [main_tokens [extra .addrspace_expr ]];
1084
+ if (start > max_start ) {
1085
+ max_node = extra .addrspace_expr ;
1086
+ max_start = start ;
1087
+ max_offset = 1 ; // for the rparen
1088
+ }
1089
+ }
1071
1090
if (extra .section_expr != 0 ) {
1072
1091
const start = token_starts [main_tokens [extra .section_expr ]];
1073
1092
if (start > max_start ) {
@@ -1138,6 +1157,7 @@ pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
1138
1157
return tree .fullVarDecl (.{
1139
1158
.type_node = extra .type_node ,
1140
1159
.align_node = extra .align_node ,
1160
+ .addrspace_node = extra .addrspace_node ,
1141
1161
.section_node = extra .section_node ,
1142
1162
.init_node = data .rhs ,
1143
1163
.mut_token = tree .nodes .items (.main_token )[node ],
@@ -1151,6 +1171,7 @@ pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
1151
1171
return tree .fullVarDecl (.{
1152
1172
.type_node = extra .type_node ,
1153
1173
.align_node = extra .align_node ,
1174
+ .addrspace_node = 0 ,
1154
1175
.section_node = 0 ,
1155
1176
.init_node = data .rhs ,
1156
1177
.mut_token = tree .nodes .items (.main_token )[node ],
@@ -1163,6 +1184,7 @@ pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
1163
1184
return tree .fullVarDecl (.{
1164
1185
.type_node = data .lhs ,
1165
1186
.align_node = 0 ,
1187
+ .addrspace_node = 0 ,
1166
1188
.section_node = 0 ,
1167
1189
.init_node = data .rhs ,
1168
1190
.mut_token = tree .nodes .items (.main_token )[node ],
@@ -1175,6 +1197,7 @@ pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
1175
1197
return tree .fullVarDecl (.{
1176
1198
.type_node = 0 ,
1177
1199
.align_node = data .lhs ,
1200
+ .addrspace_node = 0 ,
1178
1201
.section_node = 0 ,
1179
1202
.init_node = data .rhs ,
1180
1203
.mut_token = tree .nodes .items (.main_token )[node ],
@@ -1249,6 +1272,7 @@ pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.
1249
1272
.return_type = data .rhs ,
1250
1273
.params = params ,
1251
1274
.align_expr = 0 ,
1275
+ .addrspace_expr = 0 ,
1252
1276
.section_expr = 0 ,
1253
1277
.callconv_expr = 0 ,
1254
1278
});
@@ -1265,6 +1289,7 @@ pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto {
1265
1289
.return_type = data .rhs ,
1266
1290
.params = params ,
1267
1291
.align_expr = 0 ,
1292
+ .addrspace_expr = 0 ,
1268
1293
.section_expr = 0 ,
1269
1294
.callconv_expr = 0 ,
1270
1295
});
@@ -1282,6 +1307,7 @@ pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnP
1282
1307
.return_type = data .rhs ,
1283
1308
.params = params ,
1284
1309
.align_expr = extra .align_expr ,
1310
+ .addrspace_expr = extra .addrspace_expr ,
1285
1311
.section_expr = extra .section_expr ,
1286
1312
.callconv_expr = extra .callconv_expr ,
1287
1313
});
@@ -1298,6 +1324,7 @@ pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto {
1298
1324
.return_type = data .rhs ,
1299
1325
.params = params ,
1300
1326
.align_expr = extra .align_expr ,
1327
+ .addrspace_expr = extra .addrspace_expr ,
1301
1328
.section_expr = extra .section_expr ,
1302
1329
.callconv_expr = extra .callconv_expr ,
1303
1330
});
@@ -1453,6 +1480,7 @@ pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType {
1453
1480
return tree .fullPtrType (.{
1454
1481
.main_token = tree .nodes .items (.main_token )[node ],
1455
1482
.align_node = data .lhs ,
1483
+ .addrspace_node = 0 ,
1456
1484
.sentinel = 0 ,
1457
1485
.bit_range_start = 0 ,
1458
1486
.bit_range_end = 0 ,
@@ -1466,6 +1494,7 @@ pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType {
1466
1494
return tree .fullPtrType (.{
1467
1495
.main_token = tree .nodes .items (.main_token )[node ],
1468
1496
.align_node = 0 ,
1497
+ .addrspace_node = 0 ,
1469
1498
.sentinel = data .lhs ,
1470
1499
.bit_range_start = 0 ,
1471
1500
.bit_range_end = 0 ,
@@ -1480,6 +1509,7 @@ pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType {
1480
1509
return tree .fullPtrType (.{
1481
1510
.main_token = tree .nodes .items (.main_token )[node ],
1482
1511
.align_node = extra .align_node ,
1512
+ .addrspace_node = extra .addrspace_node ,
1483
1513
.sentinel = extra .sentinel ,
1484
1514
.bit_range_start = 0 ,
1485
1515
.bit_range_end = 0 ,
@@ -1494,6 +1524,7 @@ pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType {
1494
1524
return tree .fullPtrType (.{
1495
1525
.main_token = tree .nodes .items (.main_token )[node ],
1496
1526
.align_node = extra .align_node ,
1527
+ .addrspace_node = extra .addrspace_node ,
1497
1528
.sentinel = extra .sentinel ,
1498
1529
.bit_range_start = extra .bit_range_start ,
1499
1530
.bit_range_end = extra .bit_range_end ,
@@ -2063,6 +2094,7 @@ pub const full = struct {
2063
2094
mut_token : TokenIndex ,
2064
2095
type_node : Node.Index ,
2065
2096
align_node : Node.Index ,
2097
+ addrspace_node : Node.Index ,
2066
2098
section_node : Node.Index ,
2067
2099
init_node : Node.Index ,
2068
2100
};
@@ -2130,6 +2162,7 @@ pub const full = struct {
2130
2162
return_type : Node.Index ,
2131
2163
params : []const Node.Index ,
2132
2164
align_expr : Node.Index ,
2165
+ addrspace_expr : Node.Index ,
2133
2166
section_expr : Node.Index ,
2134
2167
callconv_expr : Node.Index ,
2135
2168
};
@@ -2288,6 +2321,7 @@ pub const full = struct {
2288
2321
pub const Components = struct {
2289
2322
main_token : TokenIndex ,
2290
2323
align_node : Node.Index ,
2324
+ addrspace_node : Node.Index ,
2291
2325
sentinel : Node.Index ,
2292
2326
bit_range_start : Node.Index ,
2293
2327
bit_range_end : Node.Index ,
@@ -2397,6 +2431,7 @@ pub const Error = struct {
2397
2431
expected_var_decl_or_fn ,
2398
2432
expected_loop_payload ,
2399
2433
expected_container ,
2434
+ extra_addrspace_qualifier ,
2400
2435
extra_align_qualifier ,
2401
2436
extra_allowzero_qualifier ,
2402
2437
extra_const_qualifier ,
@@ -2723,13 +2758,13 @@ pub const Node = struct {
2723
2758
/// main_token is the `fn` keyword.
2724
2759
/// extern function declarations use this tag.
2725
2760
fn_proto_multi ,
2726
- /// `fn(a: b) rhs linksection (e) callconv(f )`. `FnProtoOne[lhs]`.
2761
+ /// `fn(a: b) rhs addrspace (e) linksection(f) callconv(g )`. `FnProtoOne[lhs]`.
2727
2762
/// zero or one parameters.
2728
2763
/// anytype and ... parameters are omitted from the AST tree.
2729
2764
/// main_token is the `fn` keyword.
2730
2765
/// extern function declarations use this tag.
2731
2766
fn_proto_one ,
2732
- /// `fn(a: b, c: d) rhs linksection (e) callconv(f )`. `FnProto[lhs]`.
2767
+ /// `fn(a: b, c: d) rhs addrspace (e) linksection(f) callconv(g )`. `FnProto[lhs]`.
2733
2768
/// anytype and ... parameters are omitted from the AST tree.
2734
2769
/// main_token is the `fn` keyword.
2735
2770
/// extern function declarations use this tag.
@@ -2893,11 +2928,13 @@ pub const Node = struct {
2893
2928
pub const PtrType = struct {
2894
2929
sentinel : Index ,
2895
2930
align_node : Index ,
2931
+ addrspace_node : Index ,
2896
2932
};
2897
2933
2898
2934
pub const PtrTypeBitRange = struct {
2899
2935
sentinel : Index ,
2900
2936
align_node : Index ,
2937
+ addrspace_node : Index ,
2901
2938
bit_range_start : Index ,
2902
2939
bit_range_end : Index ,
2903
2940
};
@@ -2920,8 +2957,13 @@ pub const Node = struct {
2920
2957
};
2921
2958
2922
2959
pub const GlobalVarDecl = struct {
2960
+ /// Populated if there is an explicit type ascription.
2923
2961
type_node : Index ,
2962
+ /// Populated if align(A) is present.
2924
2963
align_node : Index ,
2964
+ /// Populated if addrspace(A) is present.
2965
+ addrspace_node : Index ,
2966
+ /// Populated if linksection(A) is present.
2925
2967
section_node : Index ,
2926
2968
};
2927
2969
@@ -2953,6 +2995,8 @@ pub const Node = struct {
2953
2995
param : Index ,
2954
2996
/// Populated if align(A) is present.
2955
2997
align_expr : Index ,
2998
+ /// Populated if addrspace(A) is present.
2999
+ addrspace_expr : Index ,
2956
3000
/// Populated if linksection(A) is present.
2957
3001
section_expr : Index ,
2958
3002
/// Populated if callconv(A) is present.
@@ -2964,6 +3008,8 @@ pub const Node = struct {
2964
3008
params_end : Index ,
2965
3009
/// Populated if align(A) is present.
2966
3010
align_expr : Index ,
3011
+ /// Populated if addrspace(A) is present.
3012
+ addrspace_expr : Index ,
2967
3013
/// Populated if linksection(A) is present.
2968
3014
section_expr : Index ,
2969
3015
/// Populated if callconv(A) is present.
0 commit comments