struct AstDirectiveSolidify {
AstTyped_base;
- AstPolyProc* poly_proc;
+ AstFunction* poly_proc;
bh_arr(AstPolySolution) known_polyvars;
AstNode* resolved_proc;
b32 use_processed : 1;
b32 is_baked : 1;
};
-struct AstFunction {
- AstTyped_base;
-
- Scope *scope;
-
- bh_arr(AstParam) params;
- AstType* return_type;
-
- AstBlock *body;
-
- char* name;
-
- // NOTE: This is NULL, unless this function was generated from a polymorphic
- // procedure call. Then it is set to the token of the call node.
- OnyxToken* generated_from;
- Scope* poly_scope;
-
- // NOTE: This is NULL, unless this function is used in a "#export" directive.
- // It is undefined which name it will have if there are multiple export directives
- // for this particular function.
- OnyxToken* exported_name;
-
- union {
- OnyxToken* intrinsic_name;
-
- // NOTE: Used when the function is declared as foreign
- struct {
- OnyxToken* foreign_module;
- OnyxToken* foreign_name;
- };
- };
-
- struct Entity* entity_header;
- struct Entity* entity_body;
-
- ConstraintContext constraints;
-
- b32 is_exported : 1;
- b32 is_foreign : 1;
- b32 is_intrinsic : 1;
-};
-
typedef struct OverloadOption OverloadOption;
struct OverloadOption {
// This is u64 because padding will make it that anyway.
struct Entity *func_header_entity;
};
-struct AstPolyProc {
- // While the "type" of a polymorphic procedure will never be set, it is necessary
- // for contexts where it used in an expression.
+struct AstFunction {
AstTyped_base;
- Scope *poly_scope;
+ Scope *scope;
+
+ bh_arr(AstParam) params;
+ AstType* return_type;
+
+ AstBlock *body;
+
+ char* name;
+
+ // NOTE: This is NULL, unless this function was generated from a polymorphic
+ // procedure call. Then it is set to the token of the call node.
+ OnyxToken* generated_from;
+ Scope* poly_scope;
+
+ // NOTE: This is NULL, unless this function is used in a "#export" directive.
+ // It is undefined which name it will have if there are multiple export directives
+ // for this particular function.
+ OnyxToken* exported_name;
+
+ union {
+ OnyxToken* intrinsic_name;
+
+ // NOTE: Used when the function is declared as foreign
+ struct {
+ OnyxToken* foreign_module;
+ OnyxToken* foreign_name;
+ };
+ };
+
+ struct Entity* entity_header;
+ struct Entity* entity_body;
+
+ ConstraintContext constraints;
+
+ // Polymorphic procedures use the following fields
+ Scope *parent_scope_of_poly_proc;
bh_arr(AstPolyParam) poly_params;
bh_arr(AstPolySolution) known_slns;
- AstFunction* base_func;
Table(AstSolidifiedFunction) concrete_funcs;
bh_imap active_queries;
+
+ b32 is_exported : 1;
+ b32 is_foreign : 1;
+ b32 is_intrinsic : 1;
};
struct AstPolyQuery {
AstNode_base;
- AstPolyProc *proc;
+ AstFunction *proc;
PolyProcLookupMethod pp_lookup;
ptr given;
OnyxToken *error_loc;
AstEnumType *enum_type;
AstEnumValue *enum_value;
AstMemRes *mem_res;
- AstPolyProc *poly_proc;
+ AstFunction *poly_proc;
AstPolyQuery *poly_query;
AstForeignBlock *foreign_block;
AstMacro *macro;
void insert_poly_sln_into_scope(Scope* scope, AstPolySolution *sln);
TypeMatch find_polymorphic_sln(AstPolySolution *out, AstPolyParam *param, AstFunction *func, PolyProcLookupMethod pp_lookup, ptr actual, char** err_msg);
-AstFunction* polymorphic_proc_lookup(AstPolyProc* pp, PolyProcLookupMethod pp_lookup, ptr actual, OnyxToken* tkn);
-AstFunction* polymorphic_proc_solidify(AstPolyProc* pp, bh_arr(AstPolySolution) slns, OnyxToken* tkn);
-AstNode* polymorphic_proc_try_solidify(AstPolyProc* pp, bh_arr(AstPolySolution) slns, OnyxToken* tkn);
-AstFunction* polymorphic_proc_build_only_header(AstPolyProc* pp, PolyProcLookupMethod pp_lookup, ptr actual);
-AstFunction* polymorphic_proc_build_only_header_with_slns(AstPolyProc* pp, bh_arr(AstPolySolution) slns, b32 error_if_failed);
+AstFunction* polymorphic_proc_lookup(AstFunction* pp, PolyProcLookupMethod pp_lookup, ptr actual, OnyxToken* tkn);
+AstFunction* polymorphic_proc_solidify(AstFunction* pp, bh_arr(AstPolySolution) slns, OnyxToken* tkn);
+AstNode* polymorphic_proc_try_solidify(AstFunction* pp, bh_arr(AstPolySolution) slns, OnyxToken* tkn);
+AstFunction* polymorphic_proc_build_only_header(AstFunction* pp, PolyProcLookupMethod pp_lookup, ptr actual);
+AstFunction* polymorphic_proc_build_only_header_with_slns(AstFunction* pp, bh_arr(AstPolySolution) slns, b32 error_if_failed);
void add_overload_option(bh_arr(OverloadOption)* poverloads, u64 precedence, AstTyped* overload);
AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, Arguments* args);
static inline AstFunction* get_function_from_node(AstNode* node) {
if (node->kind == Ast_Kind_Function) return (AstFunction *) node;
- if (node->kind == Ast_Kind_Polymorphic_Proc) return ((AstPolyProc *) node)->base_func;
+ if (node->kind == Ast_Kind_Polymorphic_Proc) return (AstFunction *) node;
if (node->kind == Ast_Kind_Macro) return get_function_from_node((AstNode*) ((AstMacro *) node)->body);
return NULL;
}
}
if (node->kind == Ast_Kind_Polymorphic_Proc) {
- AstFunction* func = polymorphic_proc_lookup((AstPolyProc *) node, PPLM_By_Function_Type, type, node->token);
+ AstFunction* func = polymorphic_proc_lookup((AstFunction *) node, PPLM_By_Function_Type, type, node->token);
if (func == NULL) return TYPE_MATCH_FAILED;
if (func == (AstFunction *) &node_that_signals_a_yield) return TYPE_MATCH_YIELD;
callee = new_callee;
} else if (callee->kind == Ast_Kind_Polymorphic_Proc) {
- AstTyped* new_callee = (AstTyped *) polymorphic_proc_lookup((AstPolyProc *) callee, PPLM_By_Arguments, &call->args, call->token);
+ AstTyped* new_callee = (AstTyped *) polymorphic_proc_lookup((AstFunction *) callee, PPLM_By_Arguments, &call->args, call->token);
if (new_callee == NULL) return Check_Error;
if (new_callee == (AstTyped *) &node_that_signals_a_yield) {
YIELD(call->token->pos, "Waiting for polymorphic procedure header to pass type-checking.");
CheckStatus check_polyquery(AstPolyQuery *query) {
if (query->function_header->scope == NULL)
- query->function_header->scope = scope_create(context.ast_alloc, query->proc->poly_scope, query->token->pos);
+ query->function_header->scope = scope_create(context.ast_alloc, query->proc->parent_scope_of_poly_proc, query->token->pos);
CheckStatus header_check = check_temp_function_header(query->function_header);
if (header_check == Check_Return_To_Symres) return Check_Return_To_Symres;
case Ast_Kind_Enum_Type:
case Ast_Kind_Enum_Value:
case Ast_Kind_Overloaded_Function:
- case Ast_Kind_Polymorphic_Proc:
case Ast_Kind_Alias:
case Ast_Kind_Code_Block:
case Ast_Kind_Macro:
case Ast_Kind_Binding: return sizeof(AstBinding);
case Ast_Kind_Function: return sizeof(AstFunction);
case Ast_Kind_Overloaded_Function: return sizeof(AstOverloadedFunction);
- case Ast_Kind_Polymorphic_Proc: return sizeof(AstPolyProc);
+ case Ast_Kind_Polymorphic_Proc: return sizeof(AstFunction);
case Ast_Kind_Block: return sizeof(AstBlock);
case Ast_Kind_Local: return sizeof(AstLocal);
case Ast_Kind_Global: return sizeof(AstGlobal);
C(AstBinding, node);
break;
- case Ast_Kind_Function: {
+ case Ast_Kind_Function:
+ case Ast_Kind_Polymorphic_Proc: {
if (clone_depth > 1) {
clone_depth--;
return node;
AstFunction* df = (AstFunction *) nn;
AstFunction* sf = (AstFunction *) node;
+ if (node->kind == Ast_Kind_Polymorphic_Proc) {
+ df->kind = Ast_Kind_Function;
+ df->parent_scope_of_poly_proc = NULL;
+ df->poly_params = NULL;
+ df->known_slns = NULL;
+ df->concrete_funcs = NULL;
+ df->active_queries.hashes = NULL;
+ df->active_queries.entries = NULL;
+ df->poly_scope = NULL;
+ df->entity = NULL;
+ }
+
if (sf->is_foreign) return node;
assert(df->scope == NULL);
AstDirectiveSolidify* dd = (AstDirectiveSolidify *) nn;
AstDirectiveSolidify* sd = (AstDirectiveSolidify *) node;
- dd->poly_proc = (AstPolyProc *) ast_clone(a, (AstNode *) sd->poly_proc);
+ dd->poly_proc = (AstFunction *) ast_clone(a, (AstNode *) sd->poly_proc);
dd->resolved_proc = NULL;
dd->known_polyvars = NULL;
#undef C
AstFunction* clone_function_header(bh_allocator a, AstFunction* func) {
- if (func->kind != Ast_Kind_Function) return NULL;
+ if (func->kind != Ast_Kind_Function && func->kind != Ast_Kind_Polymorphic_Proc) return NULL;
if (func->is_foreign) return func;
memmove(new_func, func, sizeof(AstFunction));
assert(new_func->scope == NULL);
+ if (func->kind == Ast_Kind_Polymorphic_Proc) {
+ new_func->kind = Ast_Kind_Function;
+ new_func->parent_scope_of_poly_proc = NULL;
+ new_func->poly_params = NULL;
+ new_func->known_slns = NULL;
+ new_func->concrete_funcs = NULL;
+ new_func->active_queries.hashes = NULL;
+ new_func->active_queries.entries = NULL;
+ new_func->poly_scope = NULL;
+ new_func->entity = NULL;
+ }
+
+ // new_func->body = NULL;
new_func->return_type = (AstType *) ast_clone(a, func->return_type);
new_func->params = NULL;
// a function from `clone_function_header`.
void clone_function_body(bh_allocator a, AstFunction* dest, AstFunction* source) {
if (dest->kind != Ast_Kind_Function) return;
- if (source->kind != Ast_Kind_Function) return;
+ if (source->kind != Ast_Kind_Polymorphic_Proc && source->kind != Ast_Kind_Function) return;
dest->body = (AstBlock *) ast_clone(a, source->body);
}
case Ast_Kind_Polymorphic_Proc: {
ent.type = Entity_Type_Polymorphic_Proc;
- ent.poly_proc = (AstPolyProc *) node;
+ ent.poly_proc = (AstFunction *) node;
ENTITY_INSERT(ent);
break;
}
// :LinearTokenDependent
solid->token = parser->curr - 1;
- solid->poly_proc = (AstPolyProc *) parse_factor(parser);
+ solid->poly_proc = (AstFunction *) parse_factor(parser);
solid->known_polyvars = NULL;
bh_arr_new(global_heap_allocator, solid->known_polyvars, 2);
function_defined:
if (bh_arr_length(polymorphic_vars) > 0) {
- AstPolyProc* pp = make_node(AstPolyProc, Ast_Kind_Polymorphic_Proc);
- pp->token = func_def->token;
- pp->poly_params = polymorphic_vars;
- pp->base_func = func_def;
-
- return (AstFunction *) pp;
+ func_def->kind = Ast_Kind_Polymorphic_Proc;
+ func_def->poly_params = polymorphic_vars;
} else {
bh_arr_free(polymorphic_vars);
- return func_def;
}
+
+ return func_def;
}
static b32 parse_possible_function_definition_no_consume(OnyxParser* parser) {
bh_arr_push(poly_params, type_node);
}
- AstFunction* func_node = make_node(AstFunction, Ast_Kind_Function);
- AstPolyProc* poly_proc = make_node(AstPolyProc, Ast_Kind_Polymorphic_Proc);
+ AstFunction* poly_proc = make_node(AstFunction, Ast_Kind_Polymorphic_Proc);
- bh_arr_new(global_heap_allocator, func_node->params, bh_arr_length(params));
+ bh_arr_new(global_heap_allocator, poly_proc->params, bh_arr_length(params));
fori (i, 0, bh_arr_length(params)) {
AstLocal* param_local = make_local(parser->allocator, params[i].token, (AstType *) poly_params[i]);
param_local->kind = Ast_Kind_Param;
- bh_arr_push(func_node->params, ((AstParam) {
+ bh_arr_push(poly_proc->params, ((AstParam) {
.local = param_local,
.default_value = NULL,
return_type = (AstType *) return_type_of;
}
- func_node->token = proc_token;
- func_node->body = body_block;
- func_node->return_type = (AstType *) return_type;
+ poly_proc->token = proc_token;
+ poly_proc->body = body_block;
+ poly_proc->return_type = (AstType *) return_type;
poly_proc->token = proc_token;
bh_arr_new(global_heap_allocator, poly_proc->poly_params, bh_arr_length(params));
// This is not handled currently, as you cannot say f :: ($x: $T) yet, which is what this would have to do.
}
}
- poly_proc->base_func = func_node;
*ret = (AstTyped *) poly_proc;
return NULL;
switch (node->kind) {
- case Ast_Kind_Function: {
+ case Ast_Kind_Function:
+ case Ast_Kind_Polymorphic_Proc: {
AstFunction* func = (AstFunction *) node;
if (func->intrinsic_name == NULL) func->intrinsic_name = symbol;
break;
}
- case Ast_Kind_Polymorphic_Proc: {
- AstPolyProc* proc = (AstPolyProc *) node;
-
- if (proc->base_func->intrinsic_name == NULL) proc->base_func->intrinsic_name = symbol;
-
- proc->base_func->name = generate_name_within_scope(parser, symbol);
- break;
- }
-
case Ast_Kind_Macro: {
AstMacro* macro = (AstMacro *) node;
AstFunction* func = (AstFunction *) macro->body;
- if (func->kind == Ast_Kind_Polymorphic_Proc)
- func = (AstFunction *) ((AstPolyProc *) func)->base_func;
-
func->name = generate_name_within_scope(parser, symbol);
break;
}
AstTyped node_that_signals_a_yield = { Ast_Kind_Function, 0 };
AstTyped node_that_signals_failure = { Ast_Kind_Error, 0 };
-static void ensure_polyproc_cache_is_created(AstPolyProc* pp) {
+static void ensure_polyproc_cache_is_created(AstFunction* pp) {
if (pp->concrete_funcs == NULL) sh_new_arena(pp->concrete_funcs);
if (pp->active_queries.hashes == NULL) bh_imap_init(&pp->active_queries, global_heap_allocator, 31);
}
solidified_func->func_header_entity = entity_header;
solidified_func->func->entity_header = entity_header;
solidified_func->func->entity_body = entity_body;
+ solidified_func->func->entity = entity_body;
return 1;
}
// generate the header of the function, which is useful for cases such as checking if a
// set of arguments works for a polymorphic overload option.
static AstSolidifiedFunction generate_solidified_function(
- AstPolyProc* pp,
+ AstFunction* pp,
bh_arr(AstPolySolution) slns,
OnyxToken* tkn,
b32 header_only) {
if (tkn) poly_scope_pos = tkn->pos;
if (header_only) {
- solidified_func.func = (AstFunction *) clone_function_header(context.ast_alloc, pp->base_func);
+ solidified_func.func = (AstFunction *) clone_function_header(context.ast_alloc, pp);
solidified_func.func->flags |= Ast_Flag_Incomplete_Body;
} else {
- solidified_func.func = (AstFunction *) ast_clone(context.ast_alloc, pp->base_func);
+ solidified_func.func = (AstFunction *) ast_clone(context.ast_alloc, pp);
}
- solidified_func.func->poly_scope = scope_create(context.ast_alloc, pp->poly_scope, poly_scope_pos);
+ solidified_func.func->poly_scope = scope_create(context.ast_alloc, pp->parent_scope_of_poly_proc, poly_scope_pos);
insert_poly_slns_into_scope(solidified_func.func->poly_scope, slns);
solidified_func.func->flags |= Ast_Flag_From_Polymorphism;
return solidified_func;
}
-static void ensure_solidified_function_has_body(AstPolyProc* pp, AstSolidifiedFunction *solidified_func) {
+static void ensure_solidified_function_has_body(AstFunction* pp, AstSolidifiedFunction *solidified_func) {
if (solidified_func->func->flags & Ast_Flag_Incomplete_Body) {
- clone_function_body(context.ast_alloc, solidified_func->func, pp->base_func);
+ clone_function_body(context.ast_alloc, solidified_func->func, pp);
// HACK: I'm asserting that this function should return without an error, because
// the only case where it can return an error is if there was a problem with the
return NULL;
}
-static AstTyped* try_lookup_based_on_partial_function_type(AstPolyProc *pp, AstFunctionType *ft) {
+static AstTyped* try_lookup_based_on_partial_function_type(AstFunction *pp, AstFunctionType *ft) {
if (ft->partial_function_type == NULL) {
AstType *old_return_type = ft->return_type;
ft->return_type = (AstType *) &basic_type_void;
}
if (all_types) {
- typed_param = try_lookup_based_on_partial_function_type((AstPolyProc *) potential, ft);
+ typed_param = try_lookup_based_on_partial_function_type((AstFunction *) potential, ft);
}
}
}
// NOTE: The job of this function is to take a polymorphic procedure, as well as a method of
// solving for the polymorphic variables, in order to return an array of the solutions for all
// of the polymorphic variables.
-static bh_arr(AstPolySolution) find_polymorphic_slns(AstPolyProc* pp, PolyProcLookupMethod pp_lookup, ptr actual, OnyxToken *tkn, b32 necessary) {
+static bh_arr(AstPolySolution) find_polymorphic_slns(AstFunction* pp, PolyProcLookupMethod pp_lookup, ptr actual, OnyxToken *tkn, b32 necessary) {
ensure_polyproc_cache_is_created(pp);
if (bh_imap_has(&pp->active_queries, (u64) actual)) {
AstPolyQuery *query = (AstPolyQuery *) bh_imap_get(&pp->active_queries, (u64) actual);
query->given = actual;
query->error_loc = tkn;
query->slns = slns;
- query->function_header = clone_function_header(context.ast_alloc, pp->base_func);
+ query->function_header = clone_function_header(context.ast_alloc, pp);
query->function_header->flags |= Ast_Flag_Header_Check_No_Error;
query->function_header->scope = NULL;
query->error_on_fail = necessary;
// NOTE: The job of this function is to be a wrapper to other functions, providing an error
// message if a solution could not be found. This can't be merged with polymorphic_proc_solidify
// because polymorphic_proc_try_solidify uses the aforementioned function.
-AstFunction* polymorphic_proc_lookup(AstPolyProc* pp, PolyProcLookupMethod pp_lookup, ptr actual, OnyxToken* tkn) {
+AstFunction* polymorphic_proc_lookup(AstFunction* pp, PolyProcLookupMethod pp_lookup, ptr actual, OnyxToken* tkn) {
ensure_polyproc_cache_is_created(pp);
bh_arr(AstPolySolution) slns = find_polymorphic_slns(pp, pp_lookup, actual, tkn, 1);
return result;
}
-AstFunction* polymorphic_proc_solidify(AstPolyProc* pp, bh_arr(AstPolySolution) slns, OnyxToken* tkn) {
+AstFunction* polymorphic_proc_solidify(AstFunction* pp, bh_arr(AstPolySolution) slns, OnyxToken* tkn) {
ensure_polyproc_cache_is_created(pp);
// NOTE: Check if a version of this polyproc has already been created.
return (AstFunction *) &node_that_signals_a_yield;
}
-// NOTE: This can return either a AstFunction or an AstPolyProc, depending if enough parameters were
+// NOTE: This can return either a AstFunction or an AstFunction, depending if enough parameters were
// supplied to remove all the polymorphic variables from the function.
-AstNode* polymorphic_proc_try_solidify(AstPolyProc* pp, bh_arr(AstPolySolution) slns, OnyxToken* tkn) {
+AstNode* polymorphic_proc_try_solidify(AstFunction* pp, bh_arr(AstPolySolution) slns, OnyxToken* tkn) {
i32 valid_argument_count = 0;
bh_arr_each(AstPolySolution, sln, slns) {
// HACK: Some of these initializations assume that the entity for this polyproc has
// made it through the symbol resolution phase.
// - brendanfh 2020/12/25
- AstPolyProc* new_pp = onyx_ast_node_new(context.ast_alloc, sizeof(AstPolyProc), Ast_Kind_Polymorphic_Proc);
+ AstFunction* new_pp = onyx_ast_node_new(context.ast_alloc, sizeof(AstFunction), Ast_Kind_Polymorphic_Proc);
+ memcpy(new_pp, pp, sizeof(AstFunction));
new_pp->token = tkn;
- new_pp->base_func = pp->base_func;
- new_pp->flags = pp->flags;
new_pp->poly_params = bh_arr_copy(context.ast_alloc, pp->poly_params);
ensure_polyproc_cache_is_created(pp);
}
}
-AstFunction* polymorphic_proc_build_only_header(AstPolyProc* pp, PolyProcLookupMethod pp_lookup, ptr actual) {
+AstFunction* polymorphic_proc_build_only_header(AstFunction* pp, PolyProcLookupMethod pp_lookup, ptr actual) {
ensure_polyproc_cache_is_created(pp);
bh_arr(AstPolySolution) slns = find_polymorphic_slns(pp, pp_lookup, actual, NULL, 0);
if (flag_to_yield) {
return polymorphic_proc_build_only_header_with_slns(pp, slns, 0);
}
-AstFunction* polymorphic_proc_build_only_header_with_slns(AstPolyProc* pp, bh_arr(AstPolySolution) slns, b32 error_if_failed) {
+AstFunction* polymorphic_proc_build_only_header_with_slns(AstFunction* pp, bh_arr(AstPolySolution) slns, b32 error_if_failed) {
AstSolidifiedFunction solidified_func;
char* unique_key = build_poly_slns_unique_key(slns);
SYMRES(expression, (AstTyped **) &solid->poly_proc);
if (solid->poly_proc && solid->poly_proc->kind == Ast_Kind_Directive_Solidify) {
- AstPolyProc* potentially_resolved_proc = (AstPolyProc *) ((AstDirectiveSolidify *) solid->poly_proc)->resolved_proc;
+ AstFunction* potentially_resolved_proc = (AstFunction *) ((AstDirectiveSolidify *) solid->poly_proc)->resolved_proc;
if (!potentially_resolved_proc) return Symres_Yield_Micro;
solid->poly_proc = potentially_resolved_proc;
return Symres_Success;
}
-static SymresStatus symres_polyproc(AstPolyProc* pp) {
+static SymresStatus symres_polyproc(AstFunction* pp) {
pp->flags |= Ast_Flag_Comptime;
- pp->poly_scope = curr_scope;
+ pp->parent_scope_of_poly_proc = curr_scope;
return Symres_Success;
}
SYMRES(function_header, (AstFunction *) macro->body);
}
else if (macro->body->kind == Ast_Kind_Polymorphic_Proc) {
- SYMRES(polyproc, (AstPolyProc *) macro->body);
+ SYMRES(polyproc, (AstFunction *) macro->body);
}
macro->flags |= Ast_Flag_Comptime;
query->successful_symres = 0;
if (query->function_header->scope == NULL)
- query->function_header->scope = scope_create(context.ast_alloc, query->proc->poly_scope, query->token->pos);
+ query->function_header->scope = scope_create(context.ast_alloc, query->proc->parent_scope_of_poly_proc, query->token->pos);
scope_enter(query->function_header->scope);
AstFunction* overload = NULL;
switch (node->kind) {
case Ast_Kind_Macro: overload = macro_resolve_header((AstMacro *) node, param_args, NULL, 0); break;
- case Ast_Kind_Polymorphic_Proc: overload = polymorphic_proc_build_only_header((AstPolyProc *) node, PPLM_By_Arguments, param_args); break;
+ case Ast_Kind_Polymorphic_Proc: overload = polymorphic_proc_build_only_header((AstFunction *) node, PPLM_By_Arguments, param_args); break;
case Ast_Kind_Function:
overload = (AstFunction *) node;
arguments_clear_baked_flags(&args);
case Ast_Kind_Function: return (AstFunction *) macro->body;
case Ast_Kind_Polymorphic_Proc: {
- AstPolyProc* pp = (AstPolyProc *) macro->body;
+ AstFunction* pp = (AstFunction *) macro->body;
ensure_polyproc_cache_is_created(pp);
bh_arr(AstPolySolution) slns = find_polymorphic_slns(pp, PPLM_By_Arguments, args, callsite, error_if_failed);
case Ast_Kind_Poly_Call_Type: {
AstPolyCallType* pcall = (AstPolyCallType *) node;
- return find_closest_symbol_in_node(pcall->callee, sym);
+ return find_closest_symbol_in_node((AstNode *) pcall->callee, sym);
}
}