"\n"
"Usage:\n"
"\tonyx compile [-o <target file>] [--verbose] <input files>\n"
+ "\tonyx check [--verbose] <input files>\n"
#ifdef ENABLE_RUN_WITH_WASMER
"\tonyx run <input files> -- <args>\n"
#endif
options.action = ONYX_COMPILE_ACTION_COMPILE;
arg_parse_start = 2;
}
+ if (!strcmp(argv[1], "check")) {
+ options.action = ONYX_COMPILE_ACTION_CHECK;
+ arg_parse_start = 2;
+ }
#ifdef ENABLE_RUN_WITH_WASMER
else if (!strcmp(argv[1], "run")) {
options.action = ONYX_COMPILE_ACTION_RUN;
case Entity_State_Resolve_Symbols: symres_entity(ent); break;
case Entity_State_Check_Types: check_entity(ent); break;
- case Entity_State_Code_Gen: emit_entity(ent); break;
+
+ case Entity_State_Code_Gen: {
+ if (context.options->action == ONYX_COMPILE_ACTION_CHECK) {
+ ent->state = Entity_State_Finalized;
+ break;
+ }
+
+ emit_entity(ent);
+ break;
+ }
}
b32 changed = ent->state != before_state;
switch (compile_opts.action) {
case ONYX_COMPILE_ACTION_PRINT_HELP: bh_printf(docstring); return 1;
+ case ONYX_COMPILE_ACTION_CHECK:
+ compiler_progress = onyx_compile();
+ break;
+
case ONYX_COMPILE_ACTION_COMPILE:
compiler_progress = onyx_compile();
if (compiler_progress == ONYX_COMPILER_PROGRESS_SUCCESS) {
case debug_type_kind_structure:
return t->structure.member_count;
- // TEMPORARY this will be the array elements
- case debug_type_kind_array: return 0;
+ case debug_type_kind_array: return t->array.count;
}
}
return;
}
+ if (type->kind == debug_type_kind_array) {
+ builder->base_type = type->array.type;
+ builder->max_index = get_subvalues_for_type(builder, builder->base_type);
+
+ debug_type_info_t *sub_type = &builder->info->types[builder->base_type];
+
+ // Double buffering here so if there are multiple
+ // pointer descentions, the names don't get mangled.
+ static char name_buffer[2048];
+ static char tmp_buffer[2048];
+ snprintf(tmp_buffer, 2048, "[%d]", index);
+ strncpy(name_buffer, tmp_buffer, 2048);
+ builder->it_name = name_buffer;
+
+ if (builder->base_loc_kind == debug_sym_loc_register) {
+ ovm_value_t value;
+ if (!lookup_register_in_frame(builder->ovm_state, builder->ovm_frame, builder->base_loc, &value)) {
+ goto bad_case;
+ }
+
+ builder->base_loc_kind = debug_sym_loc_global;
+ builder->base_loc = value.u32 + sub_type->size * index;
+ }
+
+ else if (builder->base_loc_kind == debug_sym_loc_stack || builder->base_loc_kind == debug_sym_loc_global) {
+ builder->base_loc += sub_type->size * index;
+ }
+
+ return;
+ }
+
bad_case:
builder->base_loc_kind = debug_sym_loc_unknown;
return;
if (builder->it_index >= builder->max_index) return false;
debug_type_info_t *type = &builder->info->types[builder->base_type];
+ static char name_buffer[2048];
+ static char tmp_buffer[2048];
if (type->kind == debug_type_kind_modifier && type->modifier.modifier_kind == debug_type_modifier_kind_pointer) {
// Double buffering here so if there are multiple
// pointer descentions, the names don't get mangled.
- static char name_buffer[2048];
- static char tmp_buffer[2048];
snprintf(tmp_buffer, 2048, "*%s", builder->it_name);
strncpy(name_buffer, tmp_buffer, 2048);
}
}
+ if (type->kind == debug_type_kind_array) {
+ snprintf(tmp_buffer, 2048, "[%d]", builder->it_index);
+ strncpy(name_buffer, tmp_buffer, 2048);
+ builder->it_name = name_buffer;
+ builder->it_type = type->array.type;
+ builder->it_has_children = get_subvalues_for_type(builder, builder->it_type) > 0;
+
+ debug_type_info_t *sub_type = &builder->info->types[builder->it_type];
+
+ if (builder->base_loc_kind == debug_sym_loc_register) {
+ ovm_value_t value;
+ if (lookup_register_in_frame(builder->ovm_state, builder->ovm_frame, builder->base_loc, &value)) {
+ builder->base_loc_kind = debug_sym_loc_global;
+ builder->base_loc = value.u32 + sub_type->size * builder->it_index;
+ }
+ }
+
+ if (builder->base_loc_kind == debug_sym_loc_stack) {
+ builder->it_loc_kind = debug_sym_loc_stack;
+ builder->it_loc = builder->base_loc + sub_type->size * builder->it_index;
+ }
+
+ if (builder->base_loc_kind == debug_sym_loc_global) {
+ builder->it_loc_kind = debug_sym_loc_global;
+ builder->it_loc = builder->base_loc + sub_type->size * builder->it_index;
+ }
+ }
+
builder->it_index++;
return true;