From d533402a1663f092cf9835e7bd677ac0d01b38ae Mon Sep 17 00:00:00 2001 From: IsaacShelton Date: Sun, 3 Nov 2024 22:58:03 -0600 Subject: [PATCH] Prepared function head resolving code for ability to resolve generics --- src/resolve/function_body.rs | 1 - src/resolve/function_head.rs | 26 +++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/resolve/function_body.rs b/src/resolve/function_body.rs index 10920beb..f6b11f93 100644 --- a/src/resolve/function_body.rs +++ b/src/resolve/function_body.rs @@ -21,7 +21,6 @@ pub fn resolve_function_bodies( .get_owning_module(physical_file_id) .unwrap_or(physical_file_id); - // NOTE: This module should already have a function haystack let function_haystack = ctx .function_haystacks .get(&module_file_id) diff --git a/src/resolve/function_head.rs b/src/resolve/function_head.rs index 1cbca979..b5afe7cb 100644 --- a/src/resolve/function_head.rs +++ b/src/resolve/function_head.rs @@ -30,6 +30,18 @@ pub fn create_function_heads( *physical_file_id, &ctx.types_in_modules, ); + + let is_generic = function.return_type.contains_polymorph().is_some() + || function + .parameters + .required + .iter() + .any(|param| param.ast_type.contains_polymorph().is_some()); + + if is_generic { + todo!("resolving generic functions is not implemented yet"); + } + let parameters = resolve_parameters(&type_ctx, &function.parameters)?; let return_type = type_ctx.resolve(&function.return_type)?; @@ -49,15 +61,9 @@ pub fn create_function_heads( None } }), - is_generic: false, + is_generic, }); - ctx.jobs.push_back(FuncJob::Regular( - *physical_file_id, - function_i, - function_ref, - )); - if function.privacy.is_public() { let public_of_module = ctx.public_functions.entry(module_file_id).or_default(); @@ -96,6 +102,12 @@ pub fn create_function_heads( .entry(name) .and_modify(|funcs| funcs.push(function_ref)) .or_insert_with(|| vec![function_ref]); + + ctx.jobs.push_back(FuncJob::Regular( + *physical_file_id, + function_i, + function_ref, + )); } }