| ... | @@ -324,6 +324,7 @@ fn transStmt( | ... | @@ -324,6 +324,7 @@ fn transStmt( |
| 324 | switch (sc) { | 324 | switch (sc) { |
| 325 | .CompoundStmtClass => return transCompoundStmt(rp, scope, @ptrCast(*const ZigClangCompoundStmt, stmt)), | 325 | .CompoundStmtClass => return transCompoundStmt(rp, scope, @ptrCast(*const ZigClangCompoundStmt, stmt)), |
| 326 | .DeclStmtClass => return transDeclStmt(rp, scope, @ptrCast(*const ZigClangDeclStmt, stmt)), | 326 | .DeclStmtClass => return transDeclStmt(rp, scope, @ptrCast(*const ZigClangDeclStmt, stmt)), |
| | 327 | .ImplicitCastExprClass => return transImplicitCastExpr(rp, scope, @ptrCast(*const ZigClangImplicitCastExpr, stmt)), |
| 327 | else => { | 328 | else => { |
| 328 | return revertAndWarn( | 329 | return revertAndWarn( |
| 329 | rp, | 330 | rp, |
| ... | @@ -409,7 +410,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe | ... | @@ -409,7 +410,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe |
| 409 | | 410 | |
| 410 | const eq_token = try appendToken(c, .Equal, "="); | 411 | const eq_token = try appendToken(c, .Equal, "="); |
| 411 | const init_node = if (ZigClangVarDecl_getInit(var_decl)) |expr| | 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 | else | 414 | else |
| 414 | null; | 415 | null; |
| 415 | const semicolon_token = try appendToken(c, .Semicolon, ";"); | 416 | const semicolon_token = try appendToken(c, .Semicolon, ";"); |
| ... | @@ -423,7 +424,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe | ... | @@ -423,7 +424,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe |
| 423 | .name_token = name_token, | 424 | .name_token = name_token, |
| 424 | .eq_token = eq_token, | 425 | .eq_token = eq_token, |
| 425 | .mut_token = mut_token, | 426 | .mut_token = mut_token, |
| 426 | .comptime_token = null, // TODO IsConstexpr ? | 427 | .comptime_token = null, |
| 427 | .extern_export_token = null, // TODO ?TokenIndex, | 428 | .extern_export_token = null, // TODO ?TokenIndex, |
| 428 | .lib_name = null, // TODO ?*Node, | 429 | .lib_name = null, // TODO ?*Node, |
| 429 | .type_node = null, // TODO ?*Node, | 430 | .type_node = null, // TODO ?*Node, |
| ... | @@ -452,13 +453,30 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe | ... | @@ -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 | fn transImplicitCastExpr( |
| 456 | return revertAndWarn( | 457 | rp: RestorePoint, |
| 457 | rp, | 458 | scope: *Scope, |
| 458 | error.UnsupportedTranslation, | 459 | expr: *const ZigClangImplicitCastExpr, |
| 459 | ZigClangExpr_getBeginLoc(expr), | 460 | ) !TransResult { |
| 460 | "TODO implement translation of Expr", | 461 | switch (ZigClangImplicitCastExpr_getCastKind(@ptrCast(*const ZigClangImplicitCastExpr, expr))) { |
| 461 | ); | 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 | fn findBlockScope(inner: *Scope) *Scope.Block { | 482 | fn findBlockScope(inner: *Scope) *Scope.Block { |