return distributor(as_iterator(it));
}
-#match distributor (it: Iterator($T)) -> Iterator(T) {
+#match distributor (it: Iterator) -> Iterator(it.Iter_Type) {
Context :: struct (T: type_expr) {
mutex: sync.Mutex;
iterator: Iterator(T);
cfree(c);
}
- c := new(Context(T));
+ c := new(Context(it.Iter_Type));
sync.mutex_init(^c.mutex);
c.iterator = it;
- return .{c, #solidify next {T=T}, #solidify close {T=T}};
+ return .{c, #solidify next {T=it.Iter_Type}, #solidify close {T=it.Iter_Type}};
}
parallel_for :: #match {}
["--tests"]
test_folder := "./tests";
+
+ ["--compile-only"]
+ compile_only := false;
}
args_parse :: (c_args: [] cstr, output: ^Settings) -> bool {
// The executable to use when compiling
onyx_cmd: str;
at_least_one_test_failed := false;
+ compile_only := false; @Bug // why is this necessary? why is settings.compile_only false when in the thread code?
}
exec_context := init(Execution_Context);
+ exec_context.compile_only = settings.compile_only;
switch runtime.compiler_os {
case .Linux {
iter.parallel_for(cases, settings.threads, ^exec_context) {
// Weird macros mean I have to forward external names
use package core
- print_color :: print_color
-
- printf("[{}] Running test {}...\n", context.thread_id, it.source_file);
+ print_color :: print_color;
+
+ args: [] str;
+ if thread_data.compile_only {
+ printf("[{}] Compiling test {}...\n", context.thread_id, it.source_file);
+ args = .[it.source_file];
+ } else {
+ printf("[{}] Running test {}...\n", context.thread_id, it.source_file);
+ args = .["run", it.source_file];
+ }
- proc := os.process_spawn(thread_data.onyx_cmd, .["run", it.source_file]);
+ proc := os.process_spawn(thread_data.onyx_cmd, args);
defer os.process_destroy(^proc);
proc_reader := io.reader_make(^proc);
continue;
}
+ if thread_data.compile_only do continue;
+
for expected_file: os.with_file(it.expected_file) {
expected_reader := io.reader_make(expected_file);
expected_output := io.read_all(^expected_reader);
CheckStatus check_memres(AstMemRes* memres);
CheckStatus check_type(AstType** ptype);
CheckStatus check_insert_directive(AstDirectiveInsert** pinsert);
+CheckStatus check_directive_solidify(AstDirectiveSolidify** psolid);
CheckStatus check_do_block(AstDoBlock** pdoblock);
CheckStatus check_constraint(AstConstraint *constraint);
CheckStatus check_constraint_context(ConstraintContext *cc, Scope *scope, OnyxFilePos pos);
static CheckStatus check_resolve_callee(AstCall* call, AstTyped** effective_callee) {
if (call->kind == Ast_Kind_Intrinsic_Call) return Check_Success;
- call->callee = (AstTyped *) strip_aliases((AstNode *) call->callee);
-
- AstTyped* callee = call->callee;
+ AstTyped* callee = (AstTyped *) strip_aliases((AstNode *) call->callee);
b32 calling_a_macro = 0;
if (callee->kind == Ast_Kind_Overloaded_Function) {
break;
case Ast_Kind_Directive_Solidify:
- *pexpr = (AstTyped *) ((AstDirectiveSolidify *) expr)->resolved_proc;
+ CHECK(directive_solidify, (AstDirectiveSolidify **) pexpr);
break;
case Ast_Kind_Directive_Defined:
return Check_Return_To_Symres;
}
+CheckStatus check_directive_solidify(AstDirectiveSolidify** psolid) {
+ AstDirectiveSolidify* solid = *psolid;
+
+ bh_arr_each(AstPolySolution, sln, solid->known_polyvars) {
+ CHECK(expression, &sln->value);
+
+ if (node_is_type((AstNode *) sln->value)) {
+ sln->type = type_build_from_ast(context.ast_alloc, sln->ast_type);
+ sln->kind = PSK_Type;
+ } else {
+ sln->kind = PSK_Value;
+ }
+ }
+
+ solid->resolved_proc = polymorphic_proc_try_solidify(solid->poly_proc, solid->known_polyvars, solid->token);
+ if (solid->resolved_proc == (AstNode *) &node_that_signals_a_yield) {
+ solid->resolved_proc = NULL;
+ YIELD(solid->token->pos, "Waiting for partially solidified procedure.");
+ }
+
+ // NOTE: Not a DirectiveSolidify.
+ *psolid = (AstDirectiveSolidify *) solid->resolved_proc;
+
+ return Check_Success;
+}
+
CheckStatus check_statement(AstNode** pstmt) {
AstNode* stmt = *pstmt;
if (found_match) {
valid_argument_count++;
} else {
- onyx_report_error(tkn->pos, Error_Critical, "'%b' is not a type variable of '%b'.",
- sln->poly_sym->token->text, sln->poly_sym->token->length,
- pp->token->text, pp->token->length);
+ if (pp->name) {
+ onyx_report_error(tkn->pos, Error_Critical, "'%b' is not a type variable of '%s'.",
+ sln->poly_sym->token->text, sln->poly_sym->token->length, pp->name);
+ } else {
+ onyx_report_error(tkn->pos, Error_Critical, "'%b' is not a type variable of '%b'.",
+ sln->poly_sym->token->text, sln->poly_sym->token->length,
+ pp->token->text, pp->token->length);
+ }
return (AstNode *) pp;
}
}
}
static SymresStatus symres_directive_solidify(AstDirectiveSolidify** psolid) {
- // @Cleanup: A lot of this code should move to the checker?
-
AstDirectiveSolidify* solid = *psolid;
- if (solid->resolved_proc != NULL) {
- *psolid = (AstDirectiveSolidify *) solid->resolved_proc;
- return Symres_Success;
- }
SYMRES(expression, (AstTyped **) &solid->poly_proc);
if (solid->poly_proc && solid->poly_proc->kind == Ast_Kind_Directive_Solidify) {
onyx_report_error(solid->token->pos, Error_Critical, "Expected polymorphic procedure in #solidify directive.");
return Symres_Error;
}
-
+
bh_arr_each(AstPolySolution, sln, solid->known_polyvars) {
// HACK: This assumes that 'ast_type' and 'value' are at the same offset.
SYMRES(expression, &sln->value);
-
- if (node_is_type((AstNode *) sln->value)) {
- sln->type = type_build_from_ast(context.ast_alloc, sln->ast_type);
- sln->kind = PSK_Type;
- } else {
- sln->kind = PSK_Value;
- }
- }
-
- solid->resolved_proc = polymorphic_proc_try_solidify(solid->poly_proc, solid->known_polyvars, solid->token);
- if (solid->resolved_proc == (AstNode *) &node_that_signals_a_yield) {
- solid->resolved_proc = NULL;
- return Symres_Yield_Macro;
}
- // NOTE: Not a DirectiveSolidify.
- *psolid = (AstDirectiveSolidify *) solid->resolved_proc;
return Symres_Success;
}