small cleanup and better CLI documentation
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 16 Feb 2021 19:47:07 +0000 (13:47 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 16 Feb 2021 19:47:07 +0000 (13:47 -0600)
bin/onyx
src/onyx.c
src/onyxsymres.c
src/onyxwasm.c

index 4dff50bcd68592b0800847dc0956677c3abcfe3f..5e1cdfbdabef1ba7329d30c99de57b87c8a7a6f5 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 8b26168f2689489249abab1b08d461a7474f080f..c0969323bd172ec58fb98a73d92308879111edf1 100644 (file)
@@ -38,8 +38,17 @@ static const char* docstring = "Onyx compiler version " VERSION "\n"
     "Flags:\n"
     "\t<input files>           List of initial files\n"
     "\t-o <target_file>        Specify the target file (default: out.wasm)\n"
-    "\t-r <runtime>            Specifies a runtime. Can be: wasi, js, custom.\n"
-    "\t--verbose               Verbose output\n";
+    "\t--runtime, -r <runtime> Specifies a runtime. Can be: wasi, js, custom.\n"
+    "\t--verbose, -V           Verbose output\n"
+    "\t           -VV          Very verbose output\n"
+    "\t           -VVV         Very very verbose output (to be used by compiler developers)\n"
+    "\t--use-post-mvp-features Enables post MVP WASM features such as memory.copy and memory.fill\n"
+    "\n"
+    "Developer flags:\n"
+    "\t--print-function-mappings Prints a mapping from WASM function index to source location.\n"
+    "\t--print-static-if-results Prints the conditional result of each #if statement. Useful for debugging.\n"
+    "\n";
+
 
 static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *argv[]) {
     CompileOptions options = {
@@ -98,7 +107,7 @@ static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *arg
             else if (!strcmp(argv[i], "-I")) {
                 bh_arr_push(options.included_folders, argv[++i]);
             }
-            else if (!strcmp(argv[i], "-r")) {
+            else if (!strcmp(argv[i], "-r") || !strcmp(argv[i], "--runtime")) {
                 i += 1;
                 if      (!strcmp(argv[i], "wasi"))   options.runtime = Runtime_Wasi;
                 else if (!strcmp(argv[i], "js"))     options.runtime = Runtime_Js;
index 8c707304f74c85cd70a784cd80e6d76e046c9187..5fc8e609785e2cb3cb85c80ae72cc42f350b361e 100644 (file)
@@ -580,6 +580,12 @@ static SymresStatus symres_switch(AstSwitch* switchnode) {
 static SymresStatus symres_use(AstUse* use) {
     SYMRES(expression, &use->expr);
 
+    if (use->expr->kind == Ast_Kind_Package) {
+        AstPackage* package = (AstPackage *) use->expr;
+        scope_include(curr_scope, package->package->scope, use->token->pos);
+        return Symres_Success;
+    }
+
     if (use->expr->kind == Ast_Kind_Enum_Type) {
         AstEnumType* et = (AstEnumType *) use->expr;
 
index d62d44e751d87761a56d70bf55adc18de9b568df..a9742e80f4a66d6756e57b785207d1570cea62b9 100644 (file)
@@ -955,7 +955,7 @@ EMIT_FUNC(switch, AstSwitch* switch_node) {
         WID(WI_I32_CONST, switch_node->min_case);
         WI(WI_I32_SUB);
     }
-    WIL(WI_JUMP_TABLE, (u64) bt);
+    WIP(WI_JUMP_TABLE, bt);
     WI(WI_BLOCK_END);
 
     bh_arr_each(AstSwitchCase, sc, switch_node->cases) {