Fix bug in generic function name replacement
This commit is contained in:
		
							parent
							
								
									107303aa98
								
							
						
					
					
						commit
						384703fbd2
					
				| @ -216,7 +216,6 @@ impl mir::Module { | |||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 TypeDefinitionKind::Generic => panic!("Tried compiling a generic!"), |  | ||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|             if is_ok { |             if is_ok { | ||||||
| @ -241,7 +240,6 @@ impl mir::Module { | |||||||
|                             .collect(), |                             .collect(), | ||||||
|                     ))) |                     ))) | ||||||
|                 } |                 } | ||||||
|                 TypeDefinitionKind::Generic => panic!("Tried compiling a generic!"), |  | ||||||
|             }; |             }; | ||||||
|             types.insert(type_value, typedef.clone()); |             types.insert(type_value, typedef.clone()); | ||||||
|             type_values.insert(type_key.clone(), type_value); |             type_values.insert(type_key.clone(), type_value); | ||||||
|  | |||||||
| @ -96,7 +96,6 @@ impl TypeKind { | |||||||
|             TypeKind::UserPtr(type_kind) => Type::Ptr(Box::new(type_kind.get_type(type_vals))), |             TypeKind::UserPtr(type_kind) => Type::Ptr(Box::new(type_kind.get_type(type_vals))), | ||||||
|             TypeKind::CodegenPtr(type_kind) => Type::Ptr(Box::new(type_kind.get_type(type_vals))), |             TypeKind::CodegenPtr(type_kind) => Type::Ptr(Box::new(type_kind.get_type(type_vals))), | ||||||
|             TypeKind::Borrow(type_kind, _) => Type::Ptr(Box::new(type_kind.get_type(type_vals))), |             TypeKind::Borrow(type_kind, _) => Type::Ptr(Box::new(type_kind.get_type(type_vals))), | ||||||
|             TypeKind::Generic(_) => panic!("Tried to compile a generic type!"), |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -211,7 +210,6 @@ impl TypeKind { | |||||||
|                             }) |                             }) | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     TypeDefinitionKind::Generic => panic!("Tried to generate debug-info for a generic!"), |  | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             _ => DebugTypeData::Basic(DebugBasicType { |             _ => DebugTypeData::Basic(DebugBasicType { | ||||||
|  | |||||||
| @ -140,7 +140,6 @@ impl Display for TypeDefinitionKind { | |||||||
|                 } |                 } | ||||||
|                 f.write_char('}') |                 f.write_char('}') | ||||||
|             } |             } | ||||||
|             TypeDefinitionKind::Generic => write!(f, "generic"), |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -483,7 +482,6 @@ impl Display for TypeKind { | |||||||
|             TypeKind::F128 => write!(f, "f128"), |             TypeKind::F128 => write!(f, "f128"), | ||||||
|             TypeKind::F80 => write!(f, "f80"), |             TypeKind::F80 => write!(f, "f80"), | ||||||
|             TypeKind::F128PPC => write!(f, "f128ppc"), |             TypeKind::F128PPC => write!(f, "f128ppc"), | ||||||
|             TypeKind::Generic(name) => write!(f, "Generic<{}>", name), |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -239,8 +239,10 @@ impl mir::Expression { | |||||||
|                         vec![(function_call.generics.clone(), self.1)], |                         vec![(function_call.generics.clone(), self.1)], | ||||||
|                     ); |                     ); | ||||||
|                 } |                 } | ||||||
|  |                 if function_call.generics.len() > 0 { | ||||||
|                     function_call.name = name_fmt(function_call.name.clone(), function_call.generics.clone()) |                     function_call.name = name_fmt(function_call.name.clone(), function_call.generics.clone()) | ||||||
|                 } |                 } | ||||||
|  |             } | ||||||
|             mir::ExprKind::AssociatedFunctionCall(ty, function_call) => { |             mir::ExprKind::AssociatedFunctionCall(ty, function_call) => { | ||||||
|                 if let Some(calls) = assoc_calls.get_mut(&(ty.clone(), function_call.name.clone())) { |                 if let Some(calls) = assoc_calls.get_mut(&(ty.clone(), function_call.name.clone())) { | ||||||
|                     calls.push((function_call.generics.clone(), self.1)); |                     calls.push((function_call.generics.clone(), self.1)); | ||||||
| @ -250,8 +252,10 @@ impl mir::Expression { | |||||||
|                         vec![(function_call.generics.clone(), self.1)], |                         vec![(function_call.generics.clone(), self.1)], | ||||||
|                     ); |                     ); | ||||||
|                 } |                 } | ||||||
|  |                 if function_call.generics.len() > 0 { | ||||||
|                     function_call.name = name_fmt(function_call.name.clone(), function_call.generics.clone()) |                     function_call.name = name_fmt(function_call.name.clone(), function_call.generics.clone()) | ||||||
|                 } |                 } | ||||||
|  |             } | ||||||
|             mir::ExprKind::If(IfExpression(cond, then_e, else_e)) => { |             mir::ExprKind::If(IfExpression(cond, then_e, else_e)) => { | ||||||
|                 cond.find_calls(calls, assoc_calls); |                 cond.find_calls(calls, assoc_calls); | ||||||
|                 then_e.find_calls(calls, assoc_calls); |                 then_e.find_calls(calls, assoc_calls); | ||||||
|  | |||||||
| @ -54,7 +54,6 @@ impl TypeKind { | |||||||
|             TypeKind::F128 => true, |             TypeKind::F128 => true, | ||||||
|             TypeKind::F80 => true, |             TypeKind::F80 => true, | ||||||
|             TypeKind::F128PPC => true, |             TypeKind::F128PPC => true, | ||||||
|             TypeKind::Generic(_) => false, |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -83,7 +82,6 @@ impl TypeKind { | |||||||
|                         } |                         } | ||||||
|                         size |                         size | ||||||
|                     } |                     } | ||||||
|                     TypeDefinitionKind::Generic => 404, |  | ||||||
|                 }, |                 }, | ||||||
|                 // Easy to recognize default number. Used e.g. when sorting
 |                 // Easy to recognize default number. Used e.g. when sorting
 | ||||||
|                 // types by size
 |                 // types by size
 | ||||||
| @ -100,7 +98,6 @@ impl TypeKind { | |||||||
|             TypeKind::F128 => 128, |             TypeKind::F128 => 128, | ||||||
|             TypeKind::F80 => 80, |             TypeKind::F80 => 80, | ||||||
|             TypeKind::F128PPC => 128, |             TypeKind::F128PPC => 128, | ||||||
|             TypeKind::Generic(_) => 0, |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -132,7 +129,6 @@ impl TypeKind { | |||||||
|             TypeKind::F128 => 128, |             TypeKind::F128 => 128, | ||||||
|             TypeKind::F80 => 80, |             TypeKind::F80 => 80, | ||||||
|             TypeKind::F128PPC => 128, |             TypeKind::F128PPC => 128, | ||||||
|             TypeKind::Generic(_) => 0, |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -177,7 +173,6 @@ impl TypeKind { | |||||||
|                 VagueType::TypeRef(_) => TypeCategory::TypeRef, |                 VagueType::TypeRef(_) => TypeCategory::TypeRef, | ||||||
|                 VagueType::Named(_) => TypeCategory::Other, |                 VagueType::Named(_) => TypeCategory::Other, | ||||||
|             }, |             }, | ||||||
|             TypeKind::Generic(_) => TypeCategory::Other, |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -542,7 +542,6 @@ impl<'map> Pass for LinkerPass<'map> { | |||||||
|                             field.1 = field.1.update_imported(foreign_types); |                             field.1 = field.1.update_imported(foreign_types); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     TypeDefinitionKind::Generic => {} |  | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @ -703,7 +702,6 @@ fn resolve_types_recursively( | |||||||
|                         types.extend(resolve_types_recursively(&field.1, modules, seen.clone())?); |                         types.extend(resolve_types_recursively(&field.1, modules, seen.clone())?); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 TypeDefinitionKind::Generic => {} |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         TypeKind::Array(type_kind, _) => types.extend(resolve_types_recursively(&type_kind, modules, seen.clone())?), |         TypeKind::Array(type_kind, _) => types.extend(resolve_types_recursively(&type_kind, modules, seen.clone())?), | ||||||
|  | |||||||
| @ -133,7 +133,6 @@ pub enum TypeKind { | |||||||
|     Borrow(Box<TypeKind>, bool), |     Borrow(Box<TypeKind>, bool), | ||||||
|     UserPtr(Box<TypeKind>), |     UserPtr(Box<TypeKind>), | ||||||
|     CodegenPtr(Box<TypeKind>), |     CodegenPtr(Box<TypeKind>), | ||||||
|     Generic(String), |  | ||||||
|     Vague(VagueType), |     Vague(VagueType), | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -457,7 +456,6 @@ pub struct TypeDefinition { | |||||||
| #[derive(Debug, Clone)] | #[derive(Debug, Clone)] | ||||||
| pub enum TypeDefinitionKind { | pub enum TypeDefinitionKind { | ||||||
|     Struct(StructType), |     Struct(StructType), | ||||||
|     Generic, |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Debug)] | #[derive(Debug)] | ||||||
|  | |||||||
| @ -150,7 +150,6 @@ impl<Data: Clone + Default> Scope<Data> { | |||||||
|         let ty = self.types.get(&key)?; |         let ty = self.types.get(&key)?; | ||||||
|         match &ty.kind { |         match &ty.kind { | ||||||
|             TypeDefinitionKind::Struct(struct_ty) => Some(struct_ty), |             TypeDefinitionKind::Struct(struct_ty) => Some(struct_ty), | ||||||
|             TypeDefinitionKind::Generic => None, |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -48,7 +48,6 @@ impl<'t> Pass for TypeCheck<'t> { | |||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 TypeDefinitionKind::Generic => todo!(), |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if typedef.source_module == module.module_id || typedef.importer == Some(module.module_id) { |             if typedef.source_module == module.module_id || typedef.importer == Some(module.module_id) { | ||||||
| @ -107,7 +106,6 @@ fn check_typedefs_for_recursion<'a, 'b>( | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         TypeDefinitionKind::Generic => {} |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user