| ... | ... | @@ -4811,6 +4811,15 @@ fn transCreateNodeIdentifier(c: *Context, name: []const u8) !*ast.Node { |
| 4811 | 4811 | return &identifier.base; |
| 4812 | 4812 | } |
| 4813 | 4813 | |
| 4814 | fn transCreateNodeTypeIdentifier(c: *Context, name: []const u8) !*ast.Node { |
| 4815 | const token_index = try appendTokenFmt(c, .Identifier, "{}", .{name}); |
| 4816 | const identifier = try c.a().create(ast.Node.Identifier); |
| 4817 | identifier.* = .{ |
| 4818 | .token = token_index, |
| 4819 | }; |
| 4820 | return &identifier.base; |
| 4821 | } |
| 4822 | |
| 4814 | 4823 | pub fn freeErrors(errors: []ClangErrMsg) void { |
| 4815 | 4824 | ZigClangErrorMsg_delete(errors.ptr, errors.len); |
| 4816 | 4825 | } |
| ... | ... | @@ -5314,14 +5323,15 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5314 | 5323 | return parseCNumLit(c, tok, source, source_loc); |
| 5315 | 5324 | }, |
| 5316 | 5325 | // eventually this will be replaced by std.c.parse which will handle these correctly |
| 5317 | | .Keyword_void, |
| 5318 | | .Keyword_bool, |
| 5319 | | .Keyword_double, |
| 5320 | | .Keyword_long, |
| 5321 | | .Keyword_int, |
| 5322 | | .Keyword_float, |
| 5323 | | .Keyword_short, |
| 5324 | | .Keyword_char, |
| 5326 | .Keyword_void => return transCreateNodeTypeIdentifier(c, "c_void"), |
| 5327 | .Keyword_bool => return transCreateNodeTypeIdentifier(c, "bool"), |
| 5328 | .Keyword_double => return transCreateNodeTypeIdentifier(c, "f64"), |
| 5329 | .Keyword_long => return transCreateNodeTypeIdentifier(c, "c_long"), |
| 5330 | .Keyword_int => return transCreateNodeTypeIdentifier(c, "c_int"), |
| 5331 | .Keyword_float => return transCreateNodeTypeIdentifier(c, "f32"), |
| 5332 | .Keyword_short => return transCreateNodeTypeIdentifier(c, "c_short"), |
| 5333 | .Keyword_char => return transCreateNodeTypeIdentifier(c, "c_char"), |
| 5334 | .Keyword_unsigned => return transCreateNodeTypeIdentifier(c, "c_uint"), |
| 5325 | 5335 | .Identifier => { |
| 5326 | 5336 | const mangled_name = scope.getAlias(source[tok.start..tok.end]); |
| 5327 | 5337 | return transCreateNodeIdentifier(c, mangled_name); |
| ... | ... | @@ -5483,7 +5493,17 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5483 | 5493 | // hack to get zig fmt to render a comma in builtin calls |
| 5484 | 5494 | _ = try appendToken(c, .Comma, ","); |
| 5485 | 5495 | |
| 5486 | | const ptr = try transCreateNodePtrType(c, false, false, .Identifier); |
| 5496 | const ptr_kind = blk:{ |
| 5497 | // * token |
| 5498 | _ = it.prev(); |
| 5499 | // last token of `node` |
| 5500 | const prev_id = it.prev().?.id; |
| 5501 | _ = it.next(); |
| 5502 | _ = it.next(); |
| 5503 | break :blk if (prev_id == .Keyword_void) .Asterisk else Token.Id.Identifier; |
| 5504 | }; |
| 5505 | |
| 5506 | const ptr = try transCreateNodePtrType(c, false, false, ptr_kind); |
| 5487 | 5507 | ptr.rhs = node; |
| 5488 | 5508 | return &ptr.base; |
| 5489 | 5509 | } else { |