Skip to content

Commit 8f93988

Browse files
committed
misc bugfixes
1 parent 2a08ca0 commit 8f93988

File tree

7 files changed

+38
-27
lines changed

7 files changed

+38
-27
lines changed

compiler/cli/main.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,6 @@ int main(int argc, char *argv[]) {
938938
case ONYX_EVENT_ALL_TYPES_CHECKED:
939939
break;
940940

941-
case ONYX_EVENT_PHASE_START:
942-
break;
943-
944941
case ONYX_EVENT_SYMBOL_DEFINED:
945942
// bh_printf("DEFINED SYMBOL AT %s:%d,%d\n",
946943
// onyx_event_field_str(ctx, i, "filename"),

compiler/include/astnodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,6 +2429,7 @@ void compiler_events_clear(Context *context);
24292429
CompilerEvent *compiler_event_add(Context *context, u32 event_type);
24302430
void compiler_event_add_field_str(Context *context, CompilerEvent *event, char *field, char *value);
24312431
void compiler_event_add_field_int(Context *context, CompilerEvent *event, char *field, i32 value);
2432+
void compiler_event_log(Context *context, char *fmt, ...);
24322433

24332434

24342435
// NOTE: Useful inlined functions

compiler/src/extensions.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,10 @@ b32 compiler_extension_negotiate_capabilities(Context *context, CompilerExtensio
263263
}
264264

265265
{
266-
CompilerEvent *e = compiler_event_add(context, 1);
267-
compiler_event_add_field_str(context, e, "message",
268-
bh_aprintf(context->scratch_alloc, "Extension '%s' spawned with protocol version %d.",
269-
ext->name, extension_protocol_version
270-
)
266+
compiler_event_log(
267+
context,
268+
"Extension '%s' spawned with protocol version %d.",
269+
ext->name, extension_protocol_version
271270
);
272271
}
273272

compiler/src/library_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ onyx_pump_t onyx_pump(onyx_context_t *ctx) {
548548
} else if (context->cycle_almost_detected == 3) {
549549
send_stalled_hooks(context);
550550
} else if (context->cycle_almost_detected == 2) {
551-
compiler_event_add(context, 4);
551+
compiler_event_add(context, ONYX_EVENT_ALL_TYPES_CHECKED);
552552
}
553553

554554
context->cycle_almost_detected += 1;

compiler/src/utils.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "astnodes.h"
77
#include "errors.h"
88
#include "doc.h"
9+
#include "onyx.h"
910

1011
//
1112
// Program info and packages
@@ -1815,3 +1816,15 @@ void compiler_event_add_field_int(Context *context, CompilerEvent *event, char *
18151816
event->first_field = new_field;
18161817
}
18171818

1819+
void compiler_event_log(Context *context, char *fmt, ...) {
1820+
va_list va;
1821+
va_start(va, fmt);
1822+
1823+
char buf[1024] = {0};
1824+
bh_snprintf_va(buf, 1023, (const char *) fmt, va);
1825+
1826+
CompilerEvent *e = compiler_event_add(context, ONYX_EVENT_LOG);
1827+
compiler_event_add_field_str(context, e, "message", buf);
1828+
1829+
va_end(va);
1830+
}

compiler/src/wasm_emit.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5355,23 +5355,24 @@ void onyx_wasm_module_link(Context *context, OnyxWasmModule *module, OnyxWasmLin
53555355
}
53565356

53575357

5358-
// if (context->options->print_function_mappings) {
5359-
// bh_arr_each(AstFunction *, pfunc, module->all_procedures) {
5360-
// AstFunction *func = *pfunc;
5361-
5362-
// u64 func_idx = (u64) bh_imap_get(&module->index_map, (u64) func);
5363-
5364-
// if (!func->is_foreign) {
5365-
// func_idx += module->next_foreign_func_idx;
5366-
// }
5367-
5368-
// bh_printf("%d -> %s:%d:%d\n",
5369-
// func_idx,
5370-
// func->token->pos.filename,
5371-
// func->token->pos.line,
5372-
// func->token->pos.column);
5373-
// }
5374-
// }
5358+
if (0) {
5359+
bh_arr_each(AstFunction *, pfunc, module->all_procedures) {
5360+
AstFunction *func = *pfunc;
5361+
5362+
u64 func_idx = (u64) bh_imap_get(&module->index_map, (u64) func);
5363+
5364+
if (!func->is_foreign) {
5365+
func_idx += module->next_foreign_func_idx;
5366+
}
5367+
5368+
compiler_event_log(context,
5369+
"%d -> %s:%d:%d\n",
5370+
func_idx,
5371+
func->token->pos.filename,
5372+
func->token->pos.line,
5373+
func->token->pos.column);
5374+
}
5375+
}
53755376
}
53765377

53775378
void onyx_wasm_module_free(OnyxWasmModule* module) {

core/net/net.onyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ make_ipv4_address :: (out: &SocketAddress, addr: str, port: u16) {
138138
make_unix_address :: (out: &SocketAddress, path: str) {
139139
*out = .{ Unix = .{} };
140140

141-
out_path := cast([&] u8) out + alignof out.tag_enum;
141+
out_path := cast([&] u8) out + alignof typeof *out;
142142
offset := 0;
143143
while offset < math.min(path.count, UNIX_SOCKET_PATH_LEN - 1) {
144144
defer offset += 1;

0 commit comments

Comments
 (0)