@@ -384,6 +384,7 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
384
384
{
385
385
auto &parser = inline_asm_ctx.parser ;
386
386
auto token = parser.peek_current_token ();
387
+ location_t locus = token->get_locus ();
387
388
388
389
if (!inline_asm_ctx.is_global_asm () && check_identifier (parser, " inout" ))
389
390
{
@@ -401,10 +402,8 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
401
402
402
403
// TODO: Is error propogation our top priority, the ? in rust's asm.rs is
403
404
// doing a lot of work.
404
- // TODO: Not sure how to use parse_expr
405
- if (!check_identifier (parser, " " ))
406
- rust_unreachable ();
407
- // auto expr = parse_format_string (inline_asm_ctx);
405
+ std::unique_ptr<AST::Expr> in_expr = parser.parse_expr ();
406
+ rust_assert (in_expr != nullptr );
408
407
409
408
std::unique_ptr<AST::Expr> out_expr;
410
409
@@ -414,11 +413,19 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
414
413
{
415
414
// auto result = parse_format_string (inline_asm_ctx);
416
415
417
- if (!check_identifier (parser, " " ))
418
- rust_unreachable ();
419
- // out_expr = parser.parse_expr();
416
+ out_expr = parser.parse_expr ();
417
+
418
+ AST::InlineAsmOperand::SplitInOut splitinout (
419
+ reg, false , std::move (in_expr), std::move (out_expr));
420
+
421
+ inline_asm_ctx.inline_asm .operands .emplace_back (splitinout,
422
+ locus);
423
+
424
+ return inline_asm_ctx;
420
425
}
421
426
427
+ rust_unreachable ();
428
+
422
429
// TODO: Rembmer to pass in clone_expr() instead of nullptr
423
430
// https://github.com/rust-lang/rust/blob/a3167859f2fd8ff2241295469876a2b687280bdc/compiler/rustc_builtin_macros/src/asm.rs#L135
424
431
// RUST VERSION: ast::InlineAsmOperand::SplitInOut { reg, in_expr:
@@ -432,6 +439,8 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
432
439
}
433
440
else
434
441
{
442
+ AST::InlineAsmOperand::InOut inout (reg, false , std::move (in_expr));
443
+ inline_asm_ctx.inline_asm .operands .emplace_back (inout, locus);
435
444
// https://github.com/rust-lang/rust/blob/a3167859f2fd8ff2241295469876a2b687280bdc/compiler/rustc_builtin_macros/src/asm.rs#L137
436
445
// RUST VERSION: ast::InlineAsmOperand::InOut { reg, expr, late: false
437
446
// }
0 commit comments