// Many of these functions will be improved when
// multiple return values are implemented.
-use package builtin
+
use package core
use package wasi
package gl
// To be used with the corresponding gl.js
-use package builtin
+
// ClearBufferMask
DEPTH_BUFFER_BIT :: 0x00000100
key : rawptr;
value : rawptr;
- next : i32;
+ next : i32;
}
ptrmap_init :: proc (use pmap: ^PtrMap, hash_count: i32 = 16) {
ptrmap_lookup :: proc (use pmap: ^PtrMap, key: rawptr) -> PtrMapLookupResult {
lr := PtrMapLookupResult.{};
- hash := cast(u32) 0xcbf29ce4 ^ cast(u32) key;
+ hash := cast(u32) 0xcbf29ce7 ^ cast(u32) key;
lr.hash_index = hash % hashes.count;
lr.entry_index = hashes[lr.hash_index];
package core
-use package builtin
+
#include_file "core/alloc"
#include_file "core/array"
package core
-use package builtin
+
#include_file "core/alloc"
#include_file "core/array"
package system
-use package builtin
+
use package core
use package main as main
#include_file "core/wasi"
-use package builtin
+
use package wasi
use package core
use package main as main
package wasi
-use package builtin
+
use package core {
memory_init,
stdio_init,
[X] #file and #line directives
- string and u32 respectively that represent the current file and line number where the directive is
- [ ] ** Put type info in data section so it is runtime accessible
+ [ ] data structure based iteration
+
+ [ ] Put type info in data section so it is runtime accessible
- type name
- size
- alignment
struct Package {
char *name;
+ bh_arr(Package *) unqualified_uses;
+
Scope *scope;
Scope *include_scope;
Scope *private_scope;
extern AstBasicType basic_type_f64;
extern AstBasicType basic_type_rawptr;
+extern AstNode builtin_package_node;
extern AstNumLit builtin_heap_start;
extern AstGlobal builtin_stack_top;
extern AstType *builtin_string_type;
#include_file "core/std/wasi"
-use package builtin
use package core
print_arr_details :: proc (arr: ^[..] $T) {
print_arr_details(^s.b);
for i: 0, 100 {
- array_push(^s.a, 5 * i);
+ array_push(^s.a, (5 * i) % 21);
array_push(^s.b, 3l * cast(i64) i);
}
print("\n\n");
map : PtrMap;
- ptrmap_init(^map);
+ ptrmap_init(^map, 50);
defer ptrmap_free(^map);
for i: 0, 100 do ptrmap_put(^map, ^s.a[i], ^s.b[i]);
#include_file "string"
#include_file "file"
-use package builtin
+
// NOTE: Didn't realize this would work so easily
use package core { string_builder_append as sba }
AstBasicType basic_type_f64 = { Ast_Kind_Basic_Type, 0, NULL, "f64" , &basic_types[Basic_Kind_F64] };
AstBasicType basic_type_rawptr = { Ast_Kind_Basic_Type, 0, NULL, "rawptr", &basic_types[Basic_Kind_Rawptr] };
+static OnyxToken builtin_package_token = { Token_Type_Symbol, 7, "builtin ", { 0 } };
+AstNode builtin_package_node = { Ast_Kind_Symbol, Ast_Flag_No_Clone, &builtin_package_token, NULL };
+
static OnyxToken builtin_heap_start_token = { Token_Type_Symbol, 12, "__heap_start ", { 0 } };
static OnyxToken builtin_stack_top_token = { Token_Type_Symbol, 11, "__stack_top ", { 0 } };
AstNumLit builtin_heap_start = { Ast_Kind_NumLit, Ast_Flag_Const, &builtin_heap_start_token, NULL, (AstType *) &basic_type_rawptr, NULL, 0 };
};
void initialize_builtins(bh_allocator a, ProgramInfo* prog) {
+ // HACK
+ builtin_package_token.text = bh_strdup(global_heap_allocator, builtin_package_token.text);
+
BuiltinSymbol* bsym = (BuiltinSymbol *) &builtin_symbols[0];
while (bsym->sym != NULL) {
if (bsym->package == NULL)
parser->package = package;
}
+ AstUsePackage* implicit_use_builtin = make_node(AstUsePackage, Ast_Kind_Use_Package);
+ implicit_use_builtin->package = (AstPackage *) &builtin_package_node;
+ add_node_to_process(parser, (AstNode *) implicit_use_builtin);
+
while (parser->curr->type != Token_Type_End_Stream) {
if (parser->hit_unexpected_token) return parser->results;
param->local->type = param->default_value->type;
}
- if (param->local->type == NULL) break;
+ if (param->local->type == NULL) {
+ onyx_report_error(param->local->token->pos,
+ "Unable to resolve type for parameter, '%b'.\n",
+ param->local->token->text,
+ param->local->token->length);
+ return;
+ }
symbol_introduce(semstate.curr_scope, param->local->token, (AstNode *) param->local);
}
}
- if (package->alias == NULL && package->only == NULL)
+ if (package->alias == NULL && package->only == NULL) {
+ b32 already_included = 0;
+ bh_arr_each(Package *, included_package, semstate.curr_package->unqualified_uses) {
+ if (*included_package == p) {
+ already_included = 1;
+ break;
+ }
+ }
+
+ if (already_included) return;
+
scope_include(semstate.curr_package->include_scope, p->scope);
+
+ bh_arr_push(semstate.curr_package->unqualified_uses, p);
+ }
}
static void symres_enum(AstEnumType* enum_node) {
package->include_scope = scope_create(alloc, parent_scope);
package->scope = scope_create(alloc, package->include_scope);
package->private_scope = scope_create(alloc, package->scope);
+ package->unqualified_uses = NULL;
+ bh_arr_new(global_heap_allocator, package->unqualified_uses, 4);
bh_table_put(Package *, prog->packages, pac_name, package);