Make param mutable based on type
This commit is contained in:
		
							parent
							
								
									60818842a5
								
							
						
					
					
						commit
						b9f6f2ba0f
					
				| @ -367,7 +367,7 @@ impl mir::Module { | |||||||
|                 stack_values.insert( |                 stack_values.insert( | ||||||
|                     p_name.clone(), |                     p_name.clone(), | ||||||
|                     StackValue( |                     StackValue( | ||||||
|                         StackValueKind::Mutable(alloca), |                         StackValueKind::mutable(p_ty.is_mutable(), alloca), | ||||||
|                         TypeKind::Ptr(Box::new(p_ty.clone())), |                         TypeKind::Ptr(Box::new(p_ty.clone())), | ||||||
|                     ), |                     ), | ||||||
|                 ); |                 ); | ||||||
|  | |||||||
| @ -75,8 +75,8 @@ impl TypeKind { | |||||||
| 
 | 
 | ||||||
|     pub fn is_mutable(&self) -> bool { |     pub fn is_mutable(&self) -> bool { | ||||||
|         match self { |         match self { | ||||||
|             TypeKind::Borrow(_, true) => true, |             TypeKind::Borrow(_, false) => false, | ||||||
|             _ => false, |             _ => true, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -161,8 +161,8 @@ impl FunctionDefinition { | |||||||
|                 .set( |                 .set( | ||||||
|                     param.0.clone(), |                     param.0.clone(), | ||||||
|                     ScopeVariable { |                     ScopeVariable { | ||||||
|                         ty: param_t, |                         ty: param_t.clone(), | ||||||
|                         mutable: true, |                         mutable: param_t.is_mutable(), | ||||||
|                     }, |                     }, | ||||||
|                 ) |                 ) | ||||||
|                 .or(Err(ErrorKind::VariableAlreadyDefined(param.0.clone()))); |                 .or(Err(ErrorKind::VariableAlreadyDefined(param.0.clone()))); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user