@@ -1852,6 +1852,11 @@ const FindBreaks = struct {
18521852 }
18531853};
18541854
1855+ pub fn resolveInstanceOfNode (analyser : * Analyser , options : ResolveOptions ) error {OutOfMemory }! ? Type {
1856+ const ty = try analyser .resolveTypeOfNode (options ) orelse return null ;
1857+ return ty .instanceTypeVal (analyser );
1858+ }
1859+
18551860/// Resolves the type of an Ast Node.
18561861/// Returns `null` if the type could not be resolved.
18571862pub fn resolveTypeOfNode (analyser : * Analyser , options : ResolveOptions ) error {OutOfMemory }! ? Type {
@@ -6004,6 +6009,22 @@ pub fn resolveExpressionTypeFromAncestors(
60046009 if (node .toOptional () == var_decl .ast .init_node ) {
60056010 return try analyser .resolveTypeOfNode (.of (ancestors [0 ], handle ));
60066011 }
6012+ if (node .toOptional () == var_decl .ast .addrspace_node ) {
6013+ return analyser .instanceStdBuiltinType ("AddressSpace" );
6014+ }
6015+ if (node .toOptional () == var_decl .ast .section_node ) {
6016+ return .{
6017+ .data = .{
6018+ .pointer = .{
6019+ .size = .slice ,
6020+ .sentinel = .none ,
6021+ .is_const = true ,
6022+ .elem_ty = try analyser .allocType (.fromIP (analyser , .type_type , .u8_type )),
6023+ },
6024+ },
6025+ .is_type_val = false ,
6026+ };
6027+ }
60076028 },
60086029 .if_simple ,
60096030 .@"if" ,
@@ -6108,6 +6129,25 @@ pub fn resolveExpressionTypeFromAncestors(
61086129 return try analyser .resolveTypeOfNode (.of (lhs , handle ));
61096130 }
61106131 },
6132+ .ptr_type_aligned ,
6133+ .ptr_type_sentinel ,
6134+ .ptr_type ,
6135+ .ptr_type_bit_range ,
6136+ = > {
6137+ const ptr = tree .fullPtrType (ancestors [0 ]).? ;
6138+ if (node .toOptional () == ptr .ast .sentinel ) {
6139+ return analyser .resolveInstanceOfNode (.of (ptr .ast .child_type , handle ));
6140+ }
6141+ if (node .toOptional () == ptr .ast .addrspace_node ) {
6142+ return analyser .instanceStdBuiltinType ("AddressSpace" );
6143+ }
6144+ },
6145+ .array_type_sentinel = > {
6146+ const array_type = tree .fullArrayType (ancestors [0 ]).? ;
6147+ if (node .toOptional () == array_type .ast .sentinel ) {
6148+ return analyser .resolveInstanceOfNode (.of (array_type .ast .elem_type , handle ));
6149+ }
6150+ },
61116151
61126152 .equal_equal , .bang_equal = > {
61136153 const lhs , const rhs = tree .nodeData (ancestors [0 ]).node_and_node ;
@@ -6262,6 +6302,41 @@ pub fn resolveExpressionTypeFromAncestors(
62626302
62636303 return null ;
62646304 },
6305+ .fn_proto_simple ,
6306+ .fn_proto_multi ,
6307+ .fn_proto_one ,
6308+ .fn_proto ,
6309+ = > {
6310+ var buf : [1 ]Ast.Node.Index = undefined ;
6311+ const proto = tree .fullFnProto (& buf , ancestors [0 ]).? ;
6312+ if (node .toOptional () == proto .ast .addrspace_expr ) {
6313+ return analyser .instanceStdBuiltinType ("AddressSpace" );
6314+ }
6315+ if (node .toOptional () == proto .ast .callconv_expr ) {
6316+ return analyser .instanceStdBuiltinType ("CallingConvention" );
6317+ }
6318+ if (node .toOptional () == proto .ast .section_expr ) {
6319+ return .{
6320+ .data = .{
6321+ .pointer = .{
6322+ .size = .slice ,
6323+ .sentinel = .none ,
6324+ .is_const = true ,
6325+ .elem_ty = try analyser .allocType (.fromIP (analyser , .type_type , .u8_type )),
6326+ },
6327+ },
6328+ .is_type_val = false ,
6329+ };
6330+ }
6331+ },
6332+ .asm_simple ,
6333+ .@"asm" ,
6334+ = > {
6335+ const full = tree .fullAsm (ancestors [0 ]).? ;
6336+ if (node .toOptional () == full .ast .clobbers ) {
6337+ return analyser .instanceStdBuiltinType ("assembly.Clobbers" );
6338+ }
6339+ },
62656340
62666341 else = > {}, // TODO: Implement more expressions; better safe than sorry
62676342 }
0 commit comments