diff options
| author | gingerBill <bill@gingerbill.org> | 2019-11-02 16:36:46 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-11-02 16:36:46 +0000 |
| commit | e3d3a81617dd78a9b193bbc07f2a29315774ff57 (patch) | |
| tree | d285fd38b6daae5ac62a8adb10269d31b8f97135 /src/check_stmt.cpp | |
| parent | dbdbbcd60f1273e246d11696476ac4772f91c258 (diff) | |
multivalued procedure calls allows in `for in` to allow a pseudo-iterator; `@thread_local` for variables in procedure
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 2bf82facd..63cb4da8b 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1487,7 +1487,8 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { val1 = t_int; } else { Operand operand = {Addressing_Invalid}; - check_expr_or_type(ctx, &operand, rs->expr); + check_expr_base(ctx, &operand, expr, nullptr); + error_operand_no_value(&operand); if (operand.mode == Addressing_Type) { if (!is_type_enum(operand.type)) { @@ -1532,6 +1533,45 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { val0 = t->Map.key; val1 = t->Map.value; break; + + case Type_Tuple: + if (false) { + check_not_tuple(ctx, &operand); + } else { + isize count = t->Tuple.variables.count; + if (count < 1 || count > 3) { + check_not_tuple(ctx, &operand); + error_line("\tMultiple return valued parameters in a range statement are limited to a maximum of 2 usable values with a trailing boolean for the conditional\n"); + break; + } + Type *cond_type = t->Tuple.variables[count-1]->type; + if (!is_type_boolean(cond_type)) { + gbString s = type_to_string(cond_type); + error(operand.expr, "The final type of %td-valued tuple must be a boolean, got %s", count, s); + gb_string_free(s); + break; + } + + if (count > 1) val0 = t->Tuple.variables[0]->type; + if (count > 2) val1 = t->Tuple.variables[1]->type; + + if (rs->val1 != nullptr && count < 3) { + gbString s = type_to_string(t); + error(operand.expr, "Expected a 3-value tuple on the rhs, got (%s)", s); + gb_string_free(s); + break; + } + + if (rs->val0 != nullptr && count < 2) { + gbString s = type_to_string(t); + error(operand.expr, "Expected at least a 2-values tuple on the rhs, got (%s)", s); + gb_string_free(s); + break; + } + + } + break; + } } @@ -1849,6 +1889,19 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { e->flags |= EntityFlag_Static; } } + if (ac.thread_local_model != "") { + String name = e->token.string; + if (name == "_") { + error(e->token, "The 'thread_local' attribute is not allowed to be applied to '_'"); + } else { + e->flags |= EntityFlag_Static; + } + e->Variable.thread_local_model = ac.thread_local_model; + } + + if (ac.is_static && ac.thread_local_model != "") { + error(e->token, "The 'static' attribute is not needed if 'thread_local' is applied"); + } } check_arity_match(ctx, vd); |