Skip to content

Commit

Permalink
Prepared function head resolving code for ability to resolve generics
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacShelton committed Nov 4, 2024
1 parent 20b639b commit d533402
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/resolve/function_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 19 additions & 7 deletions src/resolve/function_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Expand All @@ -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();

Expand Down Expand Up @@ -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,
));
}
}

Expand Down

0 comments on commit d533402

Please sign in to comment.