mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Fix delayed assert collection
This commit is contained in:
@@ -42,7 +42,7 @@ del *.ilk > NUL 2> NUL
|
|||||||
|
|
||||||
cl %compiler_settings% "src\main.cpp" ^
|
cl %compiler_settings% "src\main.cpp" ^
|
||||||
/link %linker_settings% -OUT:%exe_name% ^
|
/link %linker_settings% -OUT:%exe_name% ^
|
||||||
&& odin run examples/demo/demo.odin
|
&& odin check examples/demo/demo.odin
|
||||||
|
|
||||||
del *.obj > NUL 2> NUL
|
del *.obj > NUL 2> NUL
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package thread
|
package thread
|
||||||
|
|
||||||
#assert(ODIN_OS == "windows");
|
|
||||||
import "core:sys/win32"
|
import "core:sys/win32"
|
||||||
|
|
||||||
Thread_Proc :: #type proc(^Thread) -> int;
|
Thread_Proc :: #type proc(^Thread) -> int;
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
#assert(_BUFFER_SIZE > 0);
|
|
||||||
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:strconv"
|
import "core:strconv"
|
||||||
import "core:mem"
|
import "core:mem"
|
||||||
|
|||||||
+4
-1
@@ -54,7 +54,10 @@ gb_inline void array_init(Array<T> *array, gbAllocator const &a, isize count) {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
gb_inline void array_init(Array<T> *array, gbAllocator const &a, isize count, isize capacity) {
|
gb_inline void array_init(Array<T> *array, gbAllocator const &a, isize count, isize capacity) {
|
||||||
array->allocator = a;
|
array->allocator = a;
|
||||||
array->data = gb_alloc_array(a, T, capacity);
|
array->data = nullptr;
|
||||||
|
if (capacity > 0) {
|
||||||
|
array->data = gb_alloc_array(a, T, capacity);
|
||||||
|
}
|
||||||
array->count = count;
|
array->count = count;
|
||||||
array->capacity = capacity;
|
array->capacity = capacity;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-24
@@ -215,7 +215,7 @@ bool decl_info_has_init(DeclInfo *d) {
|
|||||||
Scope *create_scope(Scope *parent, gbAllocator allocator) {
|
Scope *create_scope(Scope *parent, gbAllocator allocator) {
|
||||||
Scope *s = gb_alloc_item(allocator, Scope);
|
Scope *s = gb_alloc_item(allocator, Scope);
|
||||||
s->parent = parent;
|
s->parent = parent;
|
||||||
map_init(&s->elements, heap_allocator());
|
map_init(&s->elements, heap_allocator());
|
||||||
ptr_set_init(&s->implicit, heap_allocator());
|
ptr_set_init(&s->implicit, heap_allocator());
|
||||||
ptr_set_init(&s->imported, heap_allocator());
|
ptr_set_init(&s->imported, heap_allocator());
|
||||||
ptr_set_init(&s->exported, heap_allocator());
|
ptr_set_init(&s->exported, heap_allocator());
|
||||||
@@ -2119,6 +2119,16 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes) {
|
|||||||
for_array(decl_index, nodes) {
|
for_array(decl_index, nodes) {
|
||||||
AstNode *decl = nodes[decl_index];
|
AstNode *decl = nodes[decl_index];
|
||||||
if (!is_ast_node_decl(decl) && !is_ast_node_when_stmt(decl)) {
|
if (!is_ast_node_decl(decl) && !is_ast_node_when_stmt(decl)) {
|
||||||
|
|
||||||
|
if (c->context.scope->is_file && decl->kind == AstNode_ExprStmt) {
|
||||||
|
AstNode *expr = decl->ExprStmt.expr;
|
||||||
|
if (expr->kind == AstNode_CallExpr &&
|
||||||
|
expr->CallExpr.proc->kind == AstNode_BasicDirective &&
|
||||||
|
expr->CallExpr.proc->BasicDirective.name == "assert") {
|
||||||
|
array_add(&c->context.scope->delayed_asserts, expr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2158,18 +2168,6 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes) {
|
|||||||
check_add_foreign_block_decl(c, decl);
|
check_add_foreign_block_decl(c, decl);
|
||||||
case_end;
|
case_end;
|
||||||
|
|
||||||
|
|
||||||
case_ast_node(ce, CallExpr, decl);
|
|
||||||
if (c->context.scope->is_file &&
|
|
||||||
ce->proc->kind == AstNode_BasicDirective &&
|
|
||||||
ce->proc->BasicDirective.name == "assert") {
|
|
||||||
array_add(&c->context.scope->delayed_asserts, decl);
|
|
||||||
} else {
|
|
||||||
goto error_case;
|
|
||||||
}
|
|
||||||
case_end;
|
|
||||||
|
|
||||||
error_case:
|
|
||||||
default:
|
default:
|
||||||
if (c->context.scope->is_file) {
|
if (c->context.scope->is_file) {
|
||||||
error(decl, "Only declarations are allowed at file scope");
|
error(decl, "Only declarations are allowed at file scope");
|
||||||
@@ -2709,17 +2707,6 @@ void check_import_entities(Checker *c) {
|
|||||||
GB_ASSERT(node->scope->is_package);
|
GB_ASSERT(node->scope->is_package);
|
||||||
AstPackage *p = node->scope->package;
|
AstPackage *p = node->scope->package;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for_array(i, p->files.entries) {
|
|
||||||
AstFile *f = p->files.entries[i].value;
|
|
||||||
|
|
||||||
CheckerContext prev_context = c->context;
|
|
||||||
defer (c->context = prev_context);
|
|
||||||
add_curr_ast_file(c, f);
|
|
||||||
check_collect_entities(c, f->decls);
|
|
||||||
}
|
|
||||||
|
|
||||||
for_array(i, p->files.entries) {
|
for_array(i, p->files.entries) {
|
||||||
AstFile *f = p->files.entries[i].value;
|
AstFile *f = p->files.entries[i].value;
|
||||||
CheckerContext prev_context = c->context;
|
CheckerContext prev_context = c->context;
|
||||||
|
|||||||
Reference in New Issue
Block a user