package core.random
-#private_file seed : i64 = 867530932187
+#private_file seed : i64 = 8675309
#private_file RANDOM_MULTIPLIER :: 25214903917
#private_file RANDOM_INCREMENT :: cast(i64) 11
void arguments_remove_baked(Arguments* args);
b32 check_arguments_against_type(Arguments* args, TypeFunction* func_type, VarArgKind* va_kind,
OnyxToken* location, char* func_name, struct OnyxError* error);
-i32 function_get_minimum_argument_count(TypeFunction* type, Arguments* args);
+i32 get_argument_buffer_size(TypeFunction* type, Arguments* args);
// GROSS: Using void* to avoid having to cast everything.
const char* node_get_type_name(void* node);
AstFunction* callee=NULL;
CHECK(resolve_callee, call, (AstTyped **) &callee);
- i32 arg_count = function_get_minimum_argument_count(&callee->type->Function, &call->args);
+ i32 arg_count = get_argument_buffer_size(&callee->type->Function, &call->args);
arguments_ensure_length(&call->args, arg_count);
char* err_msg = NULL;
CheckStatus check_memres(AstMemRes* memres) {
if (memres->initial_value != NULL) {
CHECK(expression, &memres->initial_value);
- resolve_expression_type(memres->initial_value);
if ((memres->initial_value->flags & Ast_Flag_Comptime) == 0) {
ERROR(memres->initial_value->token->pos, "Top level expressions must be compile time known.");
}
} else {
+ resolve_expression_type(memres->initial_value);
if (memres->initial_value->type == NULL && memres->initial_value->entity != NULL && memres->initial_value->entity->state <= Entity_State_Check_Types) {
YIELD(memres->token->pos, "Waiting for global type to be constructed.");
}
assert(overload->type->kind == Type_Kind_Function);
arguments_remove_baked(&args);
- arguments_ensure_length(&args, function_get_minimum_argument_count(&overload->type->Function, &args));
+ arguments_ensure_length(&args, get_argument_buffer_size(&overload->type->Function, &args));
// NOTE: If the arguments cannot be placed successfully in the parameters list
if (!fill_in_arguments(&args, (AstNode *) overload, NULL)) continue;
return count;
}
-i32 function_get_minimum_argument_count(TypeFunction* type, Arguments* args) {
+i32 get_argument_buffer_size(TypeFunction* type, Arguments* args) {
i32 non_vararg_param_count = (i32) type->param_count;
- if (non_vararg_param_count > 0 && type->params[type->param_count - 1] == builtin_vararg_type_type)
- non_vararg_param_count--;
+ if (non_vararg_param_count > 0) {
+ if (type->params[type->param_count - 1] == builtin_vararg_type_type) non_vararg_param_count--;
+ if (type->params[type->param_count - 1]->kind == Type_Kind_VarArgs) non_vararg_param_count--;
+ }
return bh_max(non_vararg_param_count, non_baked_argument_count(args));
}
if (func_name == NULL) func_name = "UNKNOWN FUNCTION";
bh_arr(AstArgument *) arg_arr = (bh_arr(AstArgument *)) args->values;
- i32 arg_count = function_get_minimum_argument_count(func_type, args);
+ i32 arg_count = get_argument_buffer_size(func_type, args);
Type **formal_params = func_type->params;
Type* variadic_type = NULL;