Fix token ranges for for-loops
This commit is contained in:
		
							parent
							
								
									11d93e4adf
								
							
						
					
					
						commit
						a9d5a4d03b
					
				| @ -16,7 +16,7 @@ BINARY="$(echo $1 | cut -d'.' -f1)"".out" | |||||||
| 
 | 
 | ||||||
| echo $1 | echo $1 | ||||||
| 
 | 
 | ||||||
| cargo run --example cli $@ && \ | cargo run --features log_output --example cli $@ && \ | ||||||
| ./$BINARY ; echo "Return value: ""$?" | ./$BINARY ; echo "Return value: ""$?" | ||||||
| 
 | 
 | ||||||
| ## Command from: clang -v hello.o -o test | ## Command from: clang -v hello.o -o test | ||||||
|  | |||||||
| @ -761,6 +761,7 @@ pub fn analyze_block( | |||||||
|                 analyze_expr(context, source_module, expression, scope); |                 analyze_expr(context, source_module, expression, scope); | ||||||
|             } |             } | ||||||
|             mir::StmtKind::While(WhileStatement { condition, block, .. }) => { |             mir::StmtKind::While(WhileStatement { condition, block, .. }) => { | ||||||
|  |                 dbg!(condition); | ||||||
|                 analyze_expr(context, source_module, condition, scope); |                 analyze_expr(context, source_module, condition, scope); | ||||||
|                 analyze_block(context, source_module, block, scope); |                 analyze_block(context, source_module, block, scope); | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -235,7 +235,7 @@ impl ast::Block { | |||||||
|                     ); |                     ); | ||||||
|                     let let_statement = mir::Statement( |                     let let_statement = mir::Statement( | ||||||
|                         StmtKind::Let(counter_var.clone(), true, start.process(module_id)), |                         StmtKind::Let(counter_var.clone(), true, start.process(module_id)), | ||||||
|                         counter_range.as_meta(module_id), |                         start.1.as_meta(module_id), | ||||||
|                     ); |                     ); | ||||||
|                     let statement_range = counter_range.clone() + start.1 + end.1 + block.2; |                     let statement_range = counter_range.clone() + start.1 + end.1 + block.2; | ||||||
| 
 | 
 | ||||||
| @ -243,25 +243,25 @@ impl ast::Block { | |||||||
|                         StmtKind::Set( |                         StmtKind::Set( | ||||||
|                             mir::Expression( |                             mir::Expression( | ||||||
|                                 mir::ExprKind::Variable(counter_var.clone()), |                                 mir::ExprKind::Variable(counter_var.clone()), | ||||||
|                                 (start.1 + end.1).as_meta(module_id), |                                 counter_range.as_meta(module_id), | ||||||
|                             ), |                             ), | ||||||
|                             mir::Expression( |                             mir::Expression( | ||||||
|                                 mir::ExprKind::BinOp( |                                 mir::ExprKind::BinOp( | ||||||
|                                     mir::BinaryOperator::Add, |                                     mir::BinaryOperator::Add, | ||||||
|                                     Box::new(mir::Expression( |                                     Box::new(mir::Expression( | ||||||
|                                         mir::ExprKind::Variable(counter_var.clone()), |                                         mir::ExprKind::Variable(counter_var.clone()), | ||||||
|                                         (start.1 + end.1).as_meta(module_id), |                                         counter_range.as_meta(module_id), | ||||||
|                                     )), |                                     )), | ||||||
|                                     Box::new(mir::Expression( |                                     Box::new(mir::Expression( | ||||||
|                                         mir::ExprKind::Literal(mir::Literal::Vague(mir::VagueLiteral::Number(1))), |                                         mir::ExprKind::Literal(mir::Literal::Vague(mir::VagueLiteral::Number(1))), | ||||||
|                                         (start.1 + end.1).as_meta(module_id), |                                         counter_range.as_meta(module_id), | ||||||
|                                     )), |                                     )), | ||||||
|                                     mir::TypeKind::Vague(mir::VagueType::Unknown), |                                     mir::TypeKind::Vague(mir::VagueType::Unknown), | ||||||
|                                 ), |                                 ), | ||||||
|                                 (start.1 + end.1).as_meta(module_id), |                                 counter_range.as_meta(module_id), | ||||||
|                             ), |                             ), | ||||||
|                         ), |                         ), | ||||||
|                         (start.1 + end.1).as_meta(module_id), |                         counter_range.as_meta(module_id), | ||||||
|                     ); |                     ); | ||||||
|                     let mut mir_block = block.into_mir(module_id); |                     let mut mir_block = block.into_mir(module_id); | ||||||
|                     mir_block.statements.push(set_new); |                     mir_block.statements.push(set_new); | ||||||
| @ -272,17 +272,17 @@ impl ast::Block { | |||||||
|                                     mir::BinaryOperator::Cmp(mir::CmpOperator::LT), |                                     mir::BinaryOperator::Cmp(mir::CmpOperator::LT), | ||||||
|                                     Box::new(mir::Expression( |                                     Box::new(mir::Expression( | ||||||
|                                         mir::ExprKind::Variable(counter_var), |                                         mir::ExprKind::Variable(counter_var), | ||||||
|                                         (start.1 + end.1).as_meta(module_id), |                                         counter_range.as_meta(module_id), | ||||||
|                                     )), |                                     )), | ||||||
|                                     Box::new(end.process(module_id)), |                                     Box::new(end.process(module_id)), | ||||||
|                                     mir::TypeKind::Vague(mir::VagueType::Unknown), |                                     mir::TypeKind::Vague(mir::VagueType::Unknown), | ||||||
|                                 ), |                                 ), | ||||||
|                                 (start.1 + end.1).as_meta(module_id), |                                 end.1.as_meta(module_id), | ||||||
|                             ), |                             ), | ||||||
|                             block: mir_block.clone(), |                             block: mir_block.clone(), | ||||||
|                             meta: (start.1 + end.1 + block.2).as_meta(module_id), |                             meta: (*counter_range + end.1 + block.2).as_meta(module_id), | ||||||
|                         }), |                         }), | ||||||
|                         (start.1 + end.1 + block.2).as_meta(module_id), |                         (*counter_range + end.1 + block.2).as_meta(module_id), | ||||||
|                     ); |                     ); | ||||||
| 
 | 
 | ||||||
|                     let inner_scope = StmtKind::Expression(mir::Expression( |                     let inner_scope = StmtKind::Expression(mir::Expression( | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user