| ... | @@ -357,7 +357,7 @@ fn transCompoundStmtInline( | ... | @@ -357,7 +357,7 @@ fn transCompoundStmtInline( |
| 357 | const end_it = ZigClangCompoundStmt_body_end(stmt); | 357 | const end_it = ZigClangCompoundStmt_body_end(stmt); |
| 358 | var scope = parent_scope; | 358 | var scope = parent_scope; |
| 359 | while (it != end_it) : (it += 1) { | 359 | while (it != end_it) : (it += 1) { |
| 360 | const result = try transStmt(rp, scope, it.*, .unused, .r_value); | 360 | const result = try transStmt(rp, parent_scope, it.*, .unused, .r_value); |
| 361 | scope = result.child_scope; | 361 | scope = result.child_scope; |
| 362 | try block_node.statements.push(result.node); | 362 | try block_node.statements.push(result.node); |
| 363 | } | 363 | } |
| ... | @@ -438,11 +438,22 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe | ... | @@ -438,11 +438,22 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe |
| 438 | }; | 438 | }; |
| 439 | scope = &var_scope.base; | 439 | scope = &var_scope.base; |
| 440 | | 440 | |
| | 441 | const colon_token = try appendToken(c, .Colon, ":"); |
| | 442 | const loc = ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, stmt)); |
| | 443 | const type_node = try transQualType(rp, qual_type, loc); |
| | 444 | |
| 441 | const eq_token = try appendToken(c, .Equal, "="); | 445 | const eq_token = try appendToken(c, .Equal, "="); |
| 442 | const init_node = if (ZigClangVarDecl_getInit(var_decl)) |expr| | 446 | const init_node = if (ZigClangVarDecl_getInit(var_decl)) |expr| |
| 443 | (try transExpr(rp, scope, expr, .used, .r_value)).node | 447 | (try transExpr(rp, scope, expr, .used, .r_value)).node |
| 444 | else | 448 | else blk: { |
| 445 | null; | 449 | const undefined_token = try appendToken(c, .Keyword_undefined, "undefined"); |
| | 450 | const undefined_node = try rp.c.a().create(ast.Node.UndefinedLiteral); |
| | 451 | undefined_node.* = ast.Node.UndefinedLiteral{ |
| | 452 | .base = ast.Node{ .id = .UndefinedLiteral }, |
| | 453 | .token = undefined_token, |
| | 454 | }; |
| | 455 | break :blk &undefined_node.base; |
| | 456 | }; |
| 446 | const semicolon_token = try appendToken(c, .Semicolon, ";"); | 457 | const semicolon_token = try appendToken(c, .Semicolon, ";"); |
| 447 | | 458 | |
| 448 | const node = try c.a().create(ast.Node.VarDecl); | 459 | const node = try c.a().create(ast.Node.VarDecl); |
| ... | @@ -457,7 +468,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe | ... | @@ -457,7 +468,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe |
| 457 | .comptime_token = null, | 468 | .comptime_token = null, |
| 458 | .extern_export_token = null, // TODO ?TokenIndex, | 469 | .extern_export_token = null, // TODO ?TokenIndex, |
| 459 | .lib_name = null, // TODO ?*Node, | 470 | .lib_name = null, // TODO ?*Node, |
| 460 | .type_node = null, // TODO ?*Node, | 471 | .type_node = type_node, |
| 461 | .align_node = null, // TODO ?*Node, | 472 | .align_node = null, // TODO ?*Node, |
| 462 | .section_node = null, // TODO ?*Node, | 473 | .section_node = null, // TODO ?*Node, |
| 463 | .init_node = init_node, | 474 | .init_node = init_node, |