[ ] Why are character literals signed????
+[X] `fallthrough` in a for loop does not emit deferred statments correctly.
+
List of things to change:
[X] Currently, there is no way to use the initialized members of a structure without using a struct literal.
There should be a initialize intrinsic procedure that takes a pointer to anything and initializes it.
// NOTE: This should not be called until immediately before using the return value.
// This function can return a static variable which will change if this is called
// another time. -brendanfh 2020/10/09
-static char* lookup_included_file(char* filename) {
+static char* lookup_included_file(char* filename, char* relative_to) {
static char path[256];
fori (i, 0, 256) path[i] = 0;
AstInclude* include = ent->include;
if (include->kind == Ast_Kind_Load_File) {
- char* filename = lookup_included_file(include->name);
+ char* filename = lookup_included_file(include->name, NULL);
char* formatted_name = bh_strdup(global_heap_allocator, filename);
process_source_file(formatted_name, include->token->pos);
if (type_node->kind == Ast_Kind_Array_Type) {
if (((AstArrayType *) type_node)->count_expr) {
+ // CLEANUP: The return value is not checked on this call.
check_expression(&((AstArrayType *) type_node)->count_expr);
+
resolve_expression_type(((AstArrayType *) type_node)->count_expr);
}
}
bh_arr_each(AstNode *, param, pctype->params) {
if (!node_is_type(*param)) {
+ // CLEANUP: The return value is not checked on this call.
check_expression((AstTyped **) param);
+
resolve_expression_type((AstTyped *) *param);
fill_in_type((AstTyped *) *param);
}
EMIT_FUNC(structured_jump, AstJump* jump) {
bh_arr(WasmInstruction) code = *pcode;
+ // :CLEANUP These numbers should become constants because they are shared with
+ // enter_structured_block's definitions.
static const u8 wants[Jump_Type_Count] = { 1, 2, 3 };
u64 labelidx = 0;
if (bh_arr_length(mod->deferred_stmts) != 0) {
i32 i = bh_arr_length(mod->deferred_stmts) - 1;
- while (i >= 0 && mod->deferred_stmts[i].depth >= labelidx) {
+ i32 d = bh_arr_length(mod->structured_jump_target) - (labelidx + 1);
+
+ while (i >= 0 && mod->deferred_stmts[i].depth > d) {
emit_deferred_stmt(mod, &code, mod->deferred_stmts[i]);
i--;
}
--- /dev/null
+1234
+World
+1234
+World
+1234
+World
+1234
+World
+1234
+World
+Closing the iterator
+Default case
--- /dev/null
+#load "core/std"
+
+use package core
+
+custom_iterator :: () -> Iterator(i32) {
+
+ next :: (data: rawptr) -> (i32, bool) {
+ return 1234, true;
+ }
+
+ close :: (data: rawptr) {
+ println("Closing the iterator");
+ }
+
+ return .{
+ data = null,
+ next = next,
+ close = close,
+ };
+}
+
+main :: (args: [] cstr) {
+
+ switch 10 {
+ case 5 do println("Never");
+
+ case 10 {
+ count := 5;
+ for i: custom_iterator() {
+ println(i);
+ defer println("World");
+
+ count -= 1;
+
+ // :FIXEDBUG This was were it was breaking; the iterator close didn't run here.
+ if count == 0 do fallthrough;
+ }
+ }
+
+ case #default {
+ println("Default case");
+ }
+ }
+}
\ No newline at end of file