@@ -193,7 +193,6 @@ parse_reg_operand (InlineAsmContext inline_asm_ctx)
193193 // None
194194 // };
195195 auto &parser = inline_asm_ctx.parser ;
196- AST ::InlineAsmOperand reg_operand;
197196 auto token = parser.peek_current_token ();
198197 auto iden_token = parser.peek_current_token ();
199198
@@ -243,12 +242,13 @@ parse_reg_operand (InlineAsmContext inline_asm_ctx)
243242 inline_asm_ctx = *result;
244243 break ;
245244 }
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+ }
252252 }
253253
254254 auto &inline_asm = inline_asm_ctx.inline_asm ;
@@ -297,7 +297,6 @@ parse_reg_operand_in (InlineAsmContext inline_asm_ctx)
297297{
298298 // For the keyword IN, currently we count it as a seperate keyword called
299299 // Rust::IN search for #define RS_TOKEN_LIST in code base.
300- AST ::InlineAsmOperand reg_operand;
301300 auto &parser = inline_asm_ctx.parser ;
302301 if (!inline_asm_ctx.is_global_asm () && parser.skip_token (IN ))
303302 {
@@ -316,8 +315,7 @@ parse_reg_operand_in (InlineAsmContext inline_asm_ctx)
316315 // TODO: When we've succesfully parse an expr, remember to clone_expr()
317316 // instead of nullptr
318317 // 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);
321319 return inline_asm_ctx;
322320 }
323321 return tl::unexpected<InlineAsmParseError> (NONCOMMITED );
@@ -327,7 +325,6 @@ tl::expected<InlineAsmContext, InlineAsmParseError>
327325parse_reg_operand_out (InlineAsmContext inline_asm_ctx)
328326{
329327 auto &parser = inline_asm_ctx.parser ;
330- AST ::InlineAsmOperand reg_operand;
331328 if (!inline_asm_ctx.is_global_asm () && check_identifier (parser, " out" ))
332329 {
333330 auto reg = parse_reg (inline_asm_ctx);
@@ -342,8 +339,7 @@ parse_reg_operand_out (InlineAsmContext inline_asm_ctx)
342339 // instead of nullptr
343340 struct AST ::InlineAsmOperand::Out out (reg, false , std::move (expr));
344341
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);
347343
348344 return inline_asm_ctx;
349345 }
@@ -373,7 +369,6 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
373369 auto &parser = inline_asm_ctx.parser ;
374370 auto token = parser.peek_current_token ();
375371
376- AST ::InlineAsmOperand reg_operand;
377372 if (!inline_asm_ctx.is_global_asm () && check_identifier (parser, " inout" ))
378373 {
379374 auto reg = parse_reg (inline_asm_ctx);
@@ -391,8 +386,7 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
391386 // TODO: Is error propogation our top priority, the ? in rust's asm.rs is
392387 // doing a lot of work.
393388 // TODO: Not sure how to use parse_expr
394- auto exist_ident1 = check_identifier (parser, " " );
395- if (!exist_ident1)
389+ if (!check_identifier (parser, " " ))
396390 rust_unreachable ();
397391 // auto expr = parse_format_string (inline_asm_ctx);
398392
@@ -402,10 +396,9 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
402396 {
403397 if (!parser.skip_token (UNDERSCORE ))
404398 {
405- auto exist_ident2 = check_identifier (parser, " " );
406399 // auto result = parse_format_string (inline_asm_ctx);
407400
408- if (!exist_ident2 )
401+ if (!check_identifier (parser, " " ) )
409402 rust_unreachable ();
410403 // out_expr = parser.parse_expr();
411404 }
@@ -416,8 +409,8 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
416409 // expr, out_expr, late: false }
417410 // struct AST::InlineAsmOperand::SplitInOut split_in_out (reg,
418411 // 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 );
421414
422415 return inline_asm_ctx;
423416 }
@@ -427,8 +420,8 @@ parse_reg_operand_inout (InlineAsmContext inline_asm_ctx)
427420 // RUST VERSION: ast::InlineAsmOperand::InOut { reg, expr, late: false
428421 // }
429422 // 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 );
432425 return inline_asm_ctx;
433426 }
434427 }
@@ -440,12 +433,10 @@ tl::expected<InlineAsmContext, InlineAsmParseError>
440433parse_reg_operand_const (InlineAsmContext inline_asm_ctx)
441434{
442435 auto &parser = inline_asm_ctx.parser ;
443- AST ::InlineAsmOperand reg_operand;
444436 if (parser.peek_current_token ()->get_id () == CONST )
445437 {
446438 // TODO: Please handle const with parse_expr instead.
447439 auto anon_const = parse_format_string (inline_asm_ctx);
448- reg_operand.set_cnst (tl::nullopt );
449440 rust_unreachable ();
450441 return tl::unexpected<InlineAsmParseError> (COMMITTED );
451442 }
0 commit comments