From: Brendan Hansen Date: Mon, 14 Dec 2020 16:45:27 +0000 (-0600) Subject: small bug fixes and repo cleanup X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=e50a9076e45af881721e12cddf64a5257e30ea87;p=onyx.git small bug fixes and repo cleanup --- diff --git a/docs/api_design b/docs/api_design deleted file mode 100644 index 4ce6ebfe..00000000 --- a/docs/api_design +++ /dev/null @@ -1,28 +0,0 @@ - The Onyx Standard Library ---------------------------------------------------------------------------- - -Through Onyx has only one compilation target, WebAssembly 32-bit, there are -fundamentally two different use cases: in a browser, or with WASI. Both of -these use cases are to be treated as equally important. To accommodate for -their very different runtimes, a common standard library must be established -that they can share the functionality. - -The standard high level topics to cover are: - - standard output - - allocation - - standard math functions - - strings - - files - - utility functions - * random - * clock - - arrays - - maps - - common conversions - - - - - - - diff --git a/docs/cli b/docs/cli deleted file mode 100644 index e372cc09..00000000 --- a/docs/cli +++ /dev/null @@ -1,21 +0,0 @@ -Thoughts about the CLI for Onyx -------------------------------- - -Right now, unless a specific argument is recognized, it is treated as a file to add to the compilation. -This has worked well, but as the amount of functionality that is being added to the compiler is increasing, -the need for a better CLI system is imminent. - -Here are all the things the compiler should be able to do: - * Compile a file or a set of files - * Validate a file or set of files - - Everything done in compilations - - No outputting to final WASM file - * Generate documentation for a compilation - - In Human, Tags, or Html format - * Print a help menu - - - - $ onyx compile progs/poly_test.onyx -I other_folder - - $ onyx doc progs/poly_test.onyx --format tag diff --git a/docs/todo b/docs/todo index b30dff4c..236a3fa1 100644 --- a/docs/todo +++ b/docs/todo @@ -87,5 +87,6 @@ Usability: restriction due completely to my laziness and lack of access to a Windows / MacOS computer. + [ ] Make README on GitHub better, and actually describe what to do [ ] Make compiler work on Windows [ ] Make compiler work on MacOS diff --git a/examples/01_hello_world.onyx b/examples/01_hello_world.onyx index 4e1e7e68..c1217e87 100644 --- a/examples/01_hello_world.onyx +++ b/examples/01_hello_world.onyx @@ -22,7 +22,7 @@ package main // prevents a cluttered global namespace. // // In Onyx, there are a couple way to control the 'use package' statement. The example below -// brings in ALL symbols from the 'core' package to the current package scope. This is handy, +// brings in ALL symbols from the 'core' package to the current file scope. This is handy, // but if there are symbols with the same name in multiple packages, there will be conflicts. // To address this, Onyx has two ways of controlling which symbols are included. // @@ -34,10 +34,10 @@ package main // // use package core { some_symbol, some_other_symbol as sos } // -// This next exmaple makes the symbol, 'some_symbol', accessible in the current package scope. +// This next exmaple makes the symbol, 'some_symbol', accessible in the current file scope. // This is useful if there is only one thing you need from a package and you do not want to // worry about conflicting symbol names in the future. This example also makes the symbol, -// 'some_other_symbol', accessible in the current package scope under the name, 'sos'. This +// 'some_other_symbol', accessible in the current file scope under the name, 'sos'. This // is useful if a symbol name is long and you use it a lot in a package. // // As you may expect, you can also combine both of these features into one statement, such as, @@ -49,9 +49,9 @@ use package core // procedure is called when the program starts. There is nothing really special going on here; // you can go look in core/sys/wasi.onyx to see how the actual _start procedure works. At the // end it simply calls main.main, which is this procedure. By convention, main takes a slice -// of cstrings, which were the arguments passed from the command line. We will talk about +// of cstr's, which were the arguments passed from the command line. We will talk about // slices later. -main :: proc (args: [] cstring) { +main :: proc (args: [] cstr) { // This is the actual call to print, which will print the message 'Hello World!\n' onto the screen. // It is not too important to know how this works, but if you are interested you can find the diff --git a/examples/02_variables.onyx b/examples/02_variables.onyx index 253c7fb7..0cb2144a 100644 --- a/examples/02_variables.onyx +++ b/examples/02_variables.onyx @@ -5,7 +5,7 @@ use package core -main :: proc (args: [] cstring) { +main :: proc (args: [] cstr) { // This is the syntax for declaring a local variable in a procedure. foo: i32; diff --git a/examples/03_basics.onyx b/examples/03_basics.onyx index 0ce0ecbd..356f3b65 100644 --- a/examples/03_basics.onyx +++ b/examples/03_basics.onyx @@ -4,7 +4,7 @@ use package core -main :: proc (args: [] cstring) { +main :: proc (args: [] cstr) { // Here is a list of all the builtin types: // void // bool @@ -14,8 +14,8 @@ main :: proc (args: [] cstring) { // i64 u64 // f32 f64 // rawptr - // string - // cstring + // str + // cstr // range // // If you look in core/builtin.onyx, you can see the definition for some @@ -28,7 +28,7 @@ main :: proc (args: [] cstring) { // // Here foo is an i32. The unary prefix ^ operator takes the address of a value. // The type of foo_ptr is ^i32, or a pointer to an i32. Another example of a pointer - // is the cstring builtin. It is ^u8, which is what C would call a char*. + // is the cstr builtin. It is ^u8, which is what C would call a char*. foo := 10; foo_ptr := ^foo; @@ -36,7 +36,7 @@ main :: proc (args: [] cstring) { print(foo); print("\n"); print("foo_ptr is "); - print(foo_ptr); + printf("%p", foo_ptr); print("\n"); @@ -91,13 +91,13 @@ main :: proc (args: [] cstring) { // pointer, a count, and a capacity. The extra capacity field allows implementations // to know how many elements can fit into the space allocated for the array, and not // just how many elements are currently in the array. To facilitate using dynamic - // arrays, there are many array_ procedures in the core package. Take this example. + // arrays, there are many procedures in the core.array package. Take this example. dyn_arr : [..] i32; - array_init(^dyn_arr); - defer array_free(^dyn_arr); + array.init(^dyn_arr); + defer array.free(^dyn_arr); - for i: 0 .. 100 { - array_push(^dyn_arr, i * i * i); + for i: 0 .. 10 { + array.push(^dyn_arr, i * i * i); } print("dyn_arr is "); diff --git a/misc/onyx.sublime-syntax b/misc/onyx.sublime-syntax index ed980ee6..f23f3e51 100644 --- a/misc/onyx.sublime-syntax +++ b/misc/onyx.sublime-syntax @@ -52,7 +52,7 @@ contexts: captures: 1: meta.function-call.onyx - - match: '([a-zA-Z_][a-zA-Z0-9_]+)\s*:' + - match: '([a-zA-Z_][a-zA-Z0-9_]*)\s*:' captures: 1: variable diff --git a/onyx b/onyx index de21dca2..0c0be048 100755 Binary files a/onyx and b/onyx differ diff --git a/src/onyxchecker.c b/src/onyxchecker.c index e8b09118..98133c32 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -1282,7 +1282,8 @@ b32 check_overloaded_function(AstOverloadedFunction* func) { } if ((*node)->kind != Ast_Kind_Function) { - onyx_report_error((*node)->token->pos, "Overload option not function."); + onyx_report_error((*node)->token->pos, "Overload option not function. Got '%s'", + onyx_ast_node_kind_string((*node)->kind)); return 1; } diff --git a/src/onyxsymres.c b/src/onyxsymres.c index f1683e3c..99343dcf 100644 --- a/src/onyxsymres.c +++ b/src/onyxsymres.c @@ -680,9 +680,7 @@ static void symres_global(AstGlobal* global) { static void symres_overloaded_function(AstOverloadedFunction* ofunc) { bh_arr_each(AstTyped *, node, ofunc->overloads) { - if ((*node)->kind == Ast_Kind_Symbol) { - *node = (AstTyped *) symbol_resolve(semstate.curr_scope, (*node)->token); - } + symres_expression(node); } }