From: Brendan Hansen Date: Mon, 28 Dec 2020 23:21:50 +0000 (-0600) Subject: small bugfix with comments at the start of a file X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=224acc109d602e04f1abafd4552d7512f056e646;p=onyx.git small bugfix with comments at the start of a file --- diff --git a/docs/bugs b/docs/bugs index a308ab82..8ded95c4 100644 --- a/docs/bugs +++ b/docs/bugs @@ -53,6 +53,8 @@ List of known bugs: } ``` +[ ] Polymorphic structs do not recognize default values for members. + [X] `TileData :: [TILE_DATA_WIDTH * TILE_DATA_HEIGHT] bool;` results in a segfault because it is an invalid top level node, but that is not checked before it is tried to be used. diff --git a/onyx b/onyx index 4856420f..1bdc8ffc 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/poly_solidify.onyx b/progs/poly_solidify.onyx index d03475f1..8e16c2c5 100644 --- a/progs/poly_solidify.onyx +++ b/progs/poly_solidify.onyx @@ -20,4 +20,22 @@ main :: proc (args: [] cstr) { 2, proc (a: f32) -> f32 { return ~~(a * 2); }, proc (b: f32) -> f64 { return ~~(b + 6); })); -} \ No newline at end of file + + + arr : [..] i32; + array.init(^arr); + defer array.free(^arr); + + + for i: 0 .. 10 do array.push(^arr, i); + print_array(arr); + + array_map(arr, double); + print_array(arr); +} + +array_map :: proc (arr: [..] $T, f: proc (T) -> T) { + for ^v: arr do *v = f(*v); +} + +double :: proc (v: $V) -> V do return v * 2; \ No newline at end of file diff --git a/src/onyxparser.c b/src/onyxparser.c index 1b034777..dbcc22fb 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -2219,30 +2219,9 @@ void onyx_parser_free(OnyxParser* parser) { } ParseResults onyx_parse(OnyxParser *parser) { - // if (parser->curr->type == Token_Type_Keyword_Package) { - // consume_token(parser); - - // OnyxToken* symbol = expect_token(parser, Token_Type_Symbol); - - // token_toggle_end(symbol); - // Package *package = program_info_package_lookup_or_create( - // parser->program, - // symbol->text, - // parser->program->global_scope, - // parser->allocator); - // token_toggle_end(symbol); - - // parser->package = package; - - // } else { - // Package *package = program_info_package_lookup_or_create( - // parser->program, - // "main", - // parser->program->global_scope, - // parser->allocator); - - // parser->package = package; - // } + // NOTE: Skip comments at the beginning of the file + if (parser->curr->type == Token_Type_Comment) + consume_token(parser); parser->package = parse_package_name(parser)->package; parser->file_scope = scope_create(parser->allocator, parser->package->private_scope, parser->tokenizer->tokens[0].pos);