typedef struct Entity {
EntityType type;
EntityState state;
- u32 attempts;
+
+ // TODO: Document this!
+ u16 macro_attempts;
+ u16 micro_attempts;
b32 entered_in_queue : 1;
compose :: proc (a: $A, f: proc (A) -> $B, g: proc (B) -> $C) -> C do return g(f(a));
-specific_compose_1 :: #solidify specific_compose_0 { A = f32 };
specific_compose_0 :: #solidify compose { B = f32 };
+specific_compose_1 :: #solidify specific_compose_0 { A = f32 };
specific_compose_2 :: #solidify specific_compose_1 { C = f64 };
main :: proc (args: [] cstr) {
static b32 process_entity(Entity* ent) {
if (context.options->verbose_output == 3) {
if (ent->expr && ent->expr->token)
- printf("%s | %s (%d) | %s:%i:%i\n",
+ printf("%s | %s (%d, %d) | %s:%i:%i\n",
entity_state_strings[ent->state],
entity_type_strings[ent->type],
- (u32) ent->attempts,
+ (u32) ent->macro_attempts,
+ (u32) ent->micro_attempts,
ent->expr->token->pos.filename,
ent->expr->token->pos.line,
ent->expr->token->pos.column);
else if (ent->expr)
- printf("%s | %s (%d) \n",
+ printf("%s | %s (%d, %d) \n",
entity_state_strings[ent->state],
entity_type_strings[ent->type],
- (u32) ent->attempts);
+ (u32) ent->macro_attempts,
+ (u32) ent->micro_attempts);
}
// CLEANUP: There should be a nicer way to track if the builtins have
const char* entity_type_strings[Entity_Type_Count] = {
"Unknown",
+ "Error",
"Add to Load Path",
"Load File",
"Binding (Declaration)",
if (phase1 != phase2 || phase1 != 2) {
if (e1->state != e2->state)
return (i32) e1->state - (i32) e2->state;
- else
+ else if (e1->type != e2->type)
return (i32) e1->type - (i32) e2->type;
+ else
+ return (i32) (e1->micro_attempts - e2->micro_attempts);
} else {
- return (i32) e1->attempts - (i32) e2->attempts;
+ return (i32) e1->macro_attempts - (i32) e2->macro_attempts;
}
}
bh_allocator alloc = bh_arena_allocator(&entities->entity_arena);
Entity* entity = bh_alloc_item(alloc, Entity);
*entity = e;
- entity->attempts = 0;
+ entity->macro_attempts = 0;
+ entity->micro_attempts = 0;
entity->entered_in_queue = 0;
return entity;
if (ss > Symres_Errors_Start) return ss; \
} while (0)
+#define SYMRES_IF_SYMBOL(node_ptr) do { \
+ if ((*(node_ptr))->kind == Ast_Kind_Symbol) SYMRES(expression, node_ptr); \
+ } while (0);
+
typedef enum SymresStatus {
Symres_Success,
Symres_Complete,
Symres_Errors_Start,
- Symres_Yield,
+ Symres_Yield_Macro,
+ Symres_Yield_Micro,
Symres_Error,
} SymresStatus;
return Symres_Error;
} else {
- return Symres_Yield;
+ return Symres_Yield_Macro;
}
} else {
static SymresStatus symres_directive_solidify(AstDirectiveSolidify** psolid) {
AstDirectiveSolidify* solid = *psolid;
- if (solid->resolved_proc != NULL)
+ 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) {
- solid->poly_proc = (AstPolyProc *) ((AstDirectiveSolidify *) solid->poly_proc)->resolved_proc;
+ AstPolyProc* potentially_resolved_proc = (AstPolyProc *) ((AstDirectiveSolidify *) solid->poly_proc)->resolved_proc;
+ if (!potentially_resolved_proc) return Symres_Yield_Micro;
+
+ solid->poly_proc = potentially_resolved_proc;
}
if (!solid->poly_proc || solid->poly_proc->kind != Ast_Kind_Polymorphic_Proc) {
onyx_report_error(package->package_name->pos, "package not found in included source files");
return Symres_Error;
} else {
- return Symres_Yield;
+ return Symres_Yield_Macro;
}
}
onyx_report_error((*alias)->token->pos, "This symbol was not found in this package.");
return Symres_Error;
} else {
- return Symres_Yield;
+ return Symres_Yield_Macro;
}
}
default: break;
}
- if (ss == Symres_Success) ent->state = next_state;
- if (ss == Symres_Yield) ent->attempts++;
+ if (ss == Symres_Success) ent->state = next_state;
+ if (ss == Symres_Yield_Macro) ent->macro_attempts++;
+ if (ss == Symres_Yield_Micro) ent->micro_attempts++;
if (ent->scope) curr_scope = old_scope;
curr_package = NULL;