@@ -193,7 +193,6 @@ parse_reg_operand (InlineAsmContext inline_asm_ctx)
193
193
// None
194
194
// };
195
195
auto &parser = inline_asm_ctx.parser ;
196
- AST::InlineAsmOperand reg_operand;
197
196
auto token = parser.peek_current_token ();
198
197
auto iden_token = parser.peek_current_token ();
199
198
@@ -243,12 +242,13 @@ parse_reg_operand (InlineAsmContext inline_asm_ctx)
243
242
inline_asm_ctx = *result;
244
243
break ;
245
244
}
246
- else if (result.error () == COMMITTED
247
- && parse_func != parse_reg_operand_unexpected)
248
- return result;
249
- else if (result.error () == COMMITTED
250
- && parse_func == parse_reg_operand_unexpected)
251
- return inline_asm_ctx;
245
+ else if (result.error () == COMMITTED)
246
+ {
247
+ if (parse_func == parse_reg_operand_unexpected)
248
+ return inline_asm_ctx;
249
+ else
250
+ return result;
251
+ }
252
252
}
253
253
254
254
auto &inline_asm = inline_asm_ctx.inline_asm ;
@@ -297,7 +297,6 @@ parse_reg_operand_in (InlineAsmContext inline_asm_ctx)
297
297
{
298
298
// For the keyword IN, currently we count it as a seperate keyword called
299
299
// Rust::IN search for #define RS_TOKEN_LIST in code base.
300
- AST::InlineAsmOperand reg_operand;
301
300
auto &parser = inline_asm_ctx.parser ;
302
301
if (!inline_asm_ctx.is_global_asm () && parser.skip_token (IN))
303
302
{
@@ -316,8 +315,7 @@ parse_reg_operand_in (InlineAsmContext inline_asm_ctx)
316
315
// TODO: When we've succesfully parse an expr, remember to clone_expr()
317
316
// instead of nullptr
318
317
// struct AST::InlineAsmOperand::In in (reg, nullptr);
319
- // reg_operand.set_in (in);
320
- // inline_asm_ctx.inline_asm.operands.push_back (reg_operand);
318
+ // inline_asm_ctx.inline_asm.operands.push_back (in);
321
319
return inline_asm_ctx;
322
320
}
323
321
return tl::unexpected<InlineAsmParseError> (NONCOMMITED);
@@ -327,7 +325,6 @@ tl::expected<InlineAsmContext, InlineAsmParseError>
327
325
parse_reg_operand_out (InlineAsmContext inline_asm_ctx)
328
326
{
329
327
auto &parser = inline_asm_ctx.parser ;
330
- AST::InlineAsmOperand reg_operand;
331
328
if (!inline_asm_ctx.is_global_asm () && check_identifier (parser, " out" ))
332
329
{
333
330
auto reg = parse_reg (inline_asm_ctx);
@@ -342,8 +339,7 @@ parse_reg_operand_out (InlineAsmContext inline_asm_ctx)
342
339
// instead of nullptr
343
340
struct AST ::InlineAsmOperand::Out out (reg, false , std::move (expr));
344
341
345
- reg_operand.set_out (out);
346
- inline_asm_ctx.inline_asm .operands .push_back (reg_operand);
342
+ inline_asm_ctx.inline_asm.operands.push_back (out);
347
343
348
344
return inline_asm_ctx;
349
345
}
@@ -373,7 +369,6 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
373
369
auto &parser = inline_asm_ctx.parser ;
374
370
auto token = parser.peek_current_token ();
375
371
376
- AST::InlineAsmOperand reg_operand;
377
372
if (!inline_asm_ctx.is_global_asm () && check_identifier (parser, " inout" ))
378
373
{
379
374
auto reg = parse_reg (inline_asm_ctx);
@@ -391,8 +386,7 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
391
386
// TODO: Is error propogation our top priority, the ? in rust's asm.rs is
392
387
// doing a lot of work.
393
388
// TODO: Not sure how to use parse_expr
394
- auto exist_ident1 = check_identifier (parser, " " );
395
- if (!exist_ident1)
389
+ if (!check_identifier (parser, " " ))
396
390
rust_unreachable ();
397
391
// auto expr = parse_format_string (inline_asm_ctx);
398
392
@@ -402,10 +396,9 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
402
396
{
403
397
if (!parser.skip_token (UNDERSCORE))
404
398
{
405
- auto exist_ident2 = check_identifier (parser, " " );
406
399
// auto result = parse_format_string (inline_asm_ctx);
407
400
408
- if (!exist_ident2 )
401
+ if (!check_identifier (parser, " " ) )
409
402
rust_unreachable ();
410
403
// out_expr = parser.parse_expr();
411
404
}
@@ -416,8 +409,8 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
416
409
// expr, out_expr, late: false }
417
410
// struct AST::InlineAsmOperand::SplitInOut split_in_out (reg,
418
411
// false, nullptr,
419
- // nullptr); reg_operand.set_split_in_out (split_in_out);
420
- // inline_asm_ctx.inline_asm.operands.push_back (reg_operand );
412
+ // nullptr);
413
+ // inline_asm_ctx.inline_asm.operands.push_back (split_in_out );
421
414
422
415
return inline_asm_ctx;
423
416
}
@@ -427,8 +420,8 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
427
420
// RUST VERSION: ast::InlineAsmOperand::InOut { reg, expr, late: false
428
421
// }
429
422
// struct AST::InlineAsmOperand::InOut inout (reg, false,
430
- // nullptr); reg_operand.set_in_out (inout);
431
- // inline_asm_ctx.inline_asm.operands.push_back (reg_operand );
423
+ // nullptr);
424
+ // inline_asm_ctx.inline_asm.operands.push_back (inout );
432
425
return inline_asm_ctx;
433
426
}
434
427
}
@@ -440,12 +433,10 @@ tl::expected<InlineAsmContext, InlineAsmParseError>
440
433
parse_reg_operand_const (InlineAsmContext inline_asm_ctx)
441
434
{
442
435
auto &parser = inline_asm_ctx.parser ;
443
- AST::InlineAsmOperand reg_operand;
444
436
if (parser.peek_current_token ()->get_id () == CONST)
445
437
{
446
438
// TODO: Please handle const with parse_expr instead.
447
439
auto anon_const = parse_format_string (inline_asm_ctx);
448
- reg_operand.set_cnst (tl::nullopt);
449
440
rust_unreachable ();
450
441
return tl::unexpected<InlineAsmParseError> (COMMITTED);
451
442
}
0 commit comments