mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix constant parameter passing
This commit is contained in:
+27
-17
@@ -3168,10 +3168,13 @@ gb_internal lbValue lb_build_call_expr_internal_with_arg_split_args(lbProcedure
|
|||||||
if (e->kind == Entity_TypeName) {
|
if (e->kind == Entity_TypeName) {
|
||||||
array_add(&args, lb_const_nil(p->module, e->type));
|
array_add(&args, lb_const_nil(p->module, e->type));
|
||||||
continue;
|
continue;
|
||||||
} else if (e->kind != Entity_Variable) {
|
} else if (e->kind == Entity_Constant) {
|
||||||
|
array_add(&args, lb_const_value(p->module, e->type, e->Constant.value));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GB_ASSERT(e->kind == Entity_Variable);
|
||||||
|
|
||||||
if (pt->variadic && pt->variadic_index == i) {
|
if (pt->variadic && pt->variadic_index == i) {
|
||||||
lbValue variadic_args = lb_const_nil(p->module, e->type);
|
lbValue variadic_args = lb_const_nil(p->module, e->type);
|
||||||
auto variadic = slice(split_args->positional, pt->variadic_index, split_args->positional.count);
|
auto variadic = slice(split_args->positional, pt->variadic_index, split_args->positional.count);
|
||||||
@@ -3238,23 +3241,30 @@ gb_internal lbValue lb_build_call_expr_internal_with_arg_split_args(lbProcedure
|
|||||||
|
|
||||||
TokenPos pos = ast_token(ce->proc).pos;
|
TokenPos pos = ast_token(ce->proc).pos;
|
||||||
|
|
||||||
for_array(i, args) {
|
|
||||||
Entity *e = pt->params->Tuple.variables[i];
|
if (pt->params != nullptr) {
|
||||||
lbValue arg = args[i];
|
for_array(arg_index, pt->params->Tuple.variables) {
|
||||||
if (arg.value == nullptr) {
|
Entity *e = pt->params->Tuple.variables[arg_index];
|
||||||
switch (e->kind) {
|
|
||||||
case Entity_TypeName:
|
lbValue arg = args[arg_index];
|
||||||
args[i] = lb_const_nil(p->module, e->type);
|
if (arg.value == nullptr) {
|
||||||
break;
|
switch (e->kind) {
|
||||||
case Entity_Variable:
|
case Entity_TypeName:
|
||||||
args[i] = lb_handle_param_value(p, e->type, e->Variable.param_value, pos);
|
args[arg_index] = lb_const_nil(p->module, e->type);
|
||||||
break;
|
break;
|
||||||
case Entity_Constant:
|
case Entity_Variable:
|
||||||
args[i] = lb_handle_param_value(p, e->type, e->Constant.param_value, pos);
|
args[arg_index] = lb_handle_param_value(p, e->type, e->Variable.param_value, pos);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Entity_Constant:
|
||||||
|
args[arg_index] = lb_const_value(p->module, e->type, e->Constant.value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GB_PANIC("Unknown entity kind %.*s\n", LIT(entity_strings[e->kind]));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
args[arg_index] = lb_emit_conv(p, arg, e->type);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
args[i] = lb_emit_conv(p, arg, e->type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user