Fix params not being pointers
This commit is contained in:
		
							parent
							
								
									158ddc58c8
								
							
						
					
					
						commit
						848f4118bf
					
				| @ -365,6 +365,7 @@ impl Builder { | |||||||
|                 } |                 } | ||||||
|                 Instr::FunctionCall(fun, params) => { |                 Instr::FunctionCall(fun, params) => { | ||||||
|                     let param_types = self.function_data(&fun).params; |                     let param_types = self.function_data(&fun).params; | ||||||
|  |                     dbg!(¶m_types, ¶ms); | ||||||
|                     if param_types.len() != params.len() { |                     if param_types.len() != params.len() { | ||||||
|                         return Err(()); // TODO error: invalid amount of params
 |                         return Err(()); // TODO error: invalid amount of params
 | ||||||
|                     } |                     } | ||||||
| @ -413,7 +414,6 @@ impl Builder { | |||||||
|                 Instr::ArrayAlloca(_, _) => Ok(()), |                 Instr::ArrayAlloca(_, _) => Ok(()), | ||||||
|                 Instr::GetElemPtr(ptr_val, _) => { |                 Instr::GetElemPtr(ptr_val, _) => { | ||||||
|                     let ptr_ty = ptr_val.get_type(&self)?; |                     let ptr_ty = ptr_val.get_type(&self)?; | ||||||
|                     dbg!(&ptr_ty); |  | ||||||
|                     match ptr_ty { |                     match ptr_ty { | ||||||
|                         Type::Ptr(_) => Ok(()), |                         Type::Ptr(_) => Ok(()), | ||||||
|                         _ => Err(()), |                         _ => Err(()), | ||||||
|  | |||||||
| @ -353,7 +353,10 @@ impl mir::Module { | |||||||
|                 entry.build(Instr::Store(alloca, param)).unwrap(); |                 entry.build(Instr::Store(alloca, param)).unwrap(); | ||||||
|                 stack_values.insert( |                 stack_values.insert( | ||||||
|                     p_name.clone(), |                     p_name.clone(), | ||||||
|                     StackValue(StackValueKind::Immutable(alloca), p_ty.clone()), |                     StackValue( | ||||||
|  |                         StackValueKind::Immutable(alloca), | ||||||
|  |                         TypeKind::Ptr(Box::new(p_ty.clone())), | ||||||
|  |                     ), | ||||||
|                 ); |                 ); | ||||||
| 
 | 
 | ||||||
|                 // Generate debug info
 |                 // Generate debug info
 | ||||||
| @ -585,7 +588,7 @@ impl mir::Expression { | |||||||
|                                 *inner.clone(), |                                 *inner.clone(), | ||||||
|                             ) |                             ) | ||||||
|                         } else { |                         } else { | ||||||
|                             v.clone() |                             panic!("Variable was not a pointer?!?") | ||||||
|                         } |                         } | ||||||
|                     } else { |                     } else { | ||||||
|                         v.clone() |                         v.clone() | ||||||
| @ -636,12 +639,13 @@ impl mir::Expression { | |||||||
|                 let params = call |                 let params = call | ||||||
|                     .parameters |                     .parameters | ||||||
|                     .iter() |                     .iter() | ||||||
|                     .map(|e| e.codegen(scope, state).unwrap().instr()) |                     .map(|e| e.codegen(scope, &mut state.load(true)).unwrap().instr()) | ||||||
|                     .collect(); |                     .collect(); | ||||||
|                 let callee = scope |                 let callee = scope | ||||||
|                     .functions |                     .functions | ||||||
|                     .get(&call.name) |                     .get(&call.name) | ||||||
|                     .expect("function not found!"); |                     .expect("function not found!"); | ||||||
|  |                 dbg!(&self, &callee.ir.value()); | ||||||
|                 Some(StackValue( |                 Some(StackValue( | ||||||
|                     StackValueKind::Immutable( |                     StackValueKind::Immutable( | ||||||
|                         scope |                         scope | ||||||
| @ -1069,11 +1073,7 @@ impl TypeKind { | |||||||
|                 ), |                 ), | ||||||
|                 size_bits: self.size_of(), |                 size_bits: self.size_of(), | ||||||
|             }), |             }), | ||||||
|             TypeKind::Array(type_kind, len) => { |             TypeKind::Array(elem_ty, len) => { | ||||||
|                 let elem_ty = match **type_kind { |  | ||||||
|                     TypeKind::CustomType(_) => TypeKind::Ptr(Box::new(*type_kind.clone())), |  | ||||||
|                     _ => *type_kind.clone(), |  | ||||||
|                 }; |  | ||||||
|                 let elem_ty = elem_ty.clone().get_debug_type_hard( |                 let elem_ty = elem_ty.clone().get_debug_type_hard( | ||||||
|                     scope, |                     scope, | ||||||
|                     debug_info, |                     debug_info, | ||||||
| @ -1097,17 +1097,13 @@ impl TypeKind { | |||||||
|                         let mut fields = Vec::new(); |                         let mut fields = Vec::new(); | ||||||
|                         let mut size_bits = 0; |                         let mut size_bits = 0; | ||||||
|                         for field in &struct_type.0 { |                         for field in &struct_type.0 { | ||||||
|                             let ty = match &field.1 { |  | ||||||
|                                 TypeKind::Array(elem_ty, len) => field.1.clone(), |  | ||||||
|                                 _ => field.1.clone(), |  | ||||||
|                             }; |  | ||||||
|                             fields.push(DebugFieldType { |                             fields.push(DebugFieldType { | ||||||
|                                 name: field.0.clone(), |                                 name: field.0.clone(), | ||||||
|                                 location: field.2.into_debug(tokens).unwrap(), |                                 location: field.2.into_debug(tokens).unwrap(), | ||||||
|                                 size_bits: ty.size_of(), |                                 size_bits: field.1.size_of(), | ||||||
|                                 offset: size_bits, |                                 offset: size_bits, | ||||||
|                                 flags: DwarfFlags, |                                 flags: DwarfFlags, | ||||||
|                                 ty: ty.get_debug_type_hard( |                                 ty: field.1.get_debug_type_hard( | ||||||
|                                     scope, |                                     scope, | ||||||
|                                     debug_info, |                                     debug_info, | ||||||
|                                     debug_types, |                                     debug_types, | ||||||
|  | |||||||
| @ -103,10 +103,10 @@ impl<'map> Pass for LinkerPass<'map> { | |||||||
|             modules.insert(module.name.clone(), Rc::new(RefCell::new((module, tokens)))); |             modules.insert(module.name.clone(), Rc::new(RefCell::new((module, tokens)))); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // modules.insert(
 |         modules.insert( | ||||||
|         //     "std".to_owned(),
 |             "std".to_owned(), | ||||||
|         //     Rc::new(RefCell::new(compile_std(&mut self.module_map)?)),
 |             Rc::new(RefCell::new(compile_std(&mut self.module_map)?)), | ||||||
|         // );
 |         ); | ||||||
| 
 | 
 | ||||||
|         let mut modules_to_process: Vec<Rc<RefCell<(Module, Vec<FullToken>)>>> = |         let mut modules_to_process: Vec<Rc<RefCell<(Module, Vec<FullToken>)>>> = | ||||||
|             modules.values().cloned().collect(); |             modules.values().cloned().collect(); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user