| ... | ... | @@ -324,6 +324,7 @@ fn transStmt( |
| 324 | 324 | switch (sc) { |
| 325 | 325 | .CompoundStmtClass => return transCompoundStmt(rp, scope, @ptrCast(*const ZigClangCompoundStmt, stmt)), |
| 326 | 326 | .DeclStmtClass => return transDeclStmt(rp, scope, @ptrCast(*const ZigClangDeclStmt, stmt)), |
| 327 | .ImplicitCastExprClass => return transImplicitCastExpr(rp, scope, @ptrCast(*const ZigClangImplicitCastExpr, stmt)), |
| 327 | 328 | else => { |
| 328 | 329 | return revertAndWarn( |
| 329 | 330 | rp, |
| ... | ... | @@ -409,7 +410,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe |
| 409 | 410 | |
| 410 | 411 | const eq_token = try appendToken(c, .Equal, "="); |
| 411 | 412 | const init_node = if (ZigClangVarDecl_getInit(var_decl)) |expr| |
| 412 | | (try transExpr(rp, scope, expr)).node |
| 413 | (try transExpr(rp, scope, expr, .used, .r_value)).node |
| 413 | 414 | else |
| 414 | 415 | null; |
| 415 | 416 | const semicolon_token = try appendToken(c, .Semicolon, ";"); |
| ... | ... | @@ -423,7 +424,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe |
| 423 | 424 | .name_token = name_token, |
| 424 | 425 | .eq_token = eq_token, |
| 425 | 426 | .mut_token = mut_token, |
| 426 | | .comptime_token = null, // TODO IsConstexpr ? |
| 427 | .comptime_token = null, |
| 427 | 428 | .extern_export_token = null, // TODO ?TokenIndex, |
| 428 | 429 | .lib_name = null, // TODO ?*Node, |
| 429 | 430 | .type_node = null, // TODO ?*Node, |
| ... | ... | @@ -452,13 +453,30 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe |
| 452 | 453 | }; |
| 453 | 454 | } |
| 454 | 455 | |
| 455 | | fn transExpr(rp: RestorePoint, scope: *Scope, expr: *const ZigClangExpr) !TransResult { |
| 456 | | return revertAndWarn( |
| 457 | | rp, |
| 458 | | error.UnsupportedTranslation, |
| 459 | | ZigClangExpr_getBeginLoc(expr), |
| 460 | | "TODO implement translation of Expr", |
| 461 | | ); |
| 456 | fn transImplicitCastExpr( |
| 457 | rp: RestorePoint, |
| 458 | scope: *Scope, |
| 459 | expr: *const ZigClangImplicitCastExpr, |
| 460 | ) !TransResult { |
| 461 | switch (ZigClangImplicitCastExpr_getCastKind(@ptrCast(*const ZigClangImplicitCastExpr, expr))) { |
| 462 | else => |kind| return revertAndWarn( |
| 463 | rp, |
| 464 | error.UnsupportedTranslation, |
| 465 | ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, expr)), |
| 466 | "TODO implement translation of CastKind {}", |
| 467 | @tagName(kind), |
| 468 | ), |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | fn transExpr( |
| 473 | rp: RestorePoint, |
| 474 | scope: *Scope, |
| 475 | expr: *const ZigClangExpr, |
| 476 | used: ResultUsed, |
| 477 | lrvalue: LRValue, |
| 478 | ) TransError!TransResult { |
| 479 | return transStmt(rp, scope, @ptrCast(*const ZigClangStmt, expr), used, lrvalue); |
| 462 | 480 | } |
| 463 | 481 | |
| 464 | 482 | fn findBlockScope(inner: *Scope) *Scope.Block { |