#define DIR_SEPARATOR '\\'
#endif
+ fori (i, 0, 128) if (fn[i] == '/') fn[i] = DIR_SEPARATOR;
+
bh_arr_each(const char *, folder, cs->options->included_folders) {
if ((*folder)[strlen(*folder) - 1] != DIR_SEPARATOR)
bh_snprintf(path, 256, "%s%c%s", *folder, DIR_SEPARATOR, fn);
if (switchnode->assignment != NULL) CHECK(statement, (AstNode *) switchnode->assignment);
CHECK(expression, &switchnode->expr);
+ resolve_expression_type(switchnode->expr);
if (!type_is_integer(switchnode->expr->type) && switchnode->expr->type->kind != Type_Kind_Enum) {
onyx_report_error(switchnode->expr->token->pos, "expected integer or enum type for switch expression");
return Check_Error;
// NOTE: Build callee's type
fill_in_type((AstTyped *) callee);
+ if (callee->type == NULL) {
+ onyx_report_error(call->token->pos, "There was an error with looking up the type of this function.");
+ return Check_Error;
+ }
if (callee->type->kind != Type_Kind_Function) {
onyx_report_error(call->token->pos,
static const u8 wants[Jump_Type_Count] = { 1, 2, 3 };
- i32 labelidx = 0;
+ u64 labelidx = 0;
u8 wanted = wants[jump->jump];
b32 success = 0;
labelidx++;
}
+ 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) {
+ emit_statement(mod, &code, mod->deferred_stmts[i].stmt);
+ i--;
+ }
+ }
+
if (success) {
// NOTE: If the previous instruction was a non conditional jump,
// don't emit another jump since it will never be reached.
--- /dev/null
+Doing something with Index is 0
+Doing something with Index is 1
+Doing something with Index is 2
+Skipping 3!!
+Index is 3
+Doing something with Index is 4
+Doing something with Index is 5
+Doing something with Index is 6
+Doing something with Index is 7
+Doing something with Index is 8
+Doing something with Index is 9
+i is 10
+
+
+===================================
+Doing something with Index is 0
+Doing something with Index is 1
+Doing something with Index is 2
+Skipping 3!!
+Index is 3
+i is 4
+
+
+===================================
+In block deferred!
+Deferred!
+Default!
+At the end!
--- /dev/null
+#load "core/std/js"
+
+use package core
+
+main :: proc (args: [] cstr) {
+ defer println("At the end!");
+ i := 0;
+ while i < 10 {
+ defer i += 1;
+ defer printf("Index is %i\n", i);
+
+ if i == 3 {
+ printf("Skipping %i!!\n", i);
+ continue;
+ }
+
+ printf("Doing something with ");
+ }
+ printf("i is %i\n", i);
+
+ println("\n\n===================================");
+ i = 0;
+ while i < 10 {
+ defer i += 1;
+ defer printf("Index is %i\n", i);
+
+ if i == 3 {
+ printf("Skipping %i!!\n", i);
+ break;
+ }
+
+ printf("Doing something with ");
+ }
+ printf("i is %i\n", i);
+
+ println("\n\n===================================");
+ switch i {
+ case 4 {
+ defer println("Deferred!");
+ {
+ defer println("In block deferred!");
+ fallthrough;
+ }
+ println("Case 4!");
+ }
+
+ case #default {
+ println("Default!");
+ }
+ }
+}