aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstrap/outstmt.c11
-rw-r--r--compiler/TheCommand.slul6
2 files changed, 11 insertions, 6 deletions
diff --git a/bootstrap/outstmt.c b/bootstrap/outstmt.c
index 847ff67..d02121b 100644
--- a/bootstrap/outstmt.c
+++ b/bootstrap/outstmt.c
@@ -26,12 +26,18 @@ enum AlwaysValue {
ALWAYS_TRUE
};
-static enum AlwaysValue always_value(const struct Expr *expr)
+static const struct Expr *outermost_expr(const struct Expr *expr)
{
assert(expr != NULL);
while (expr->rpnnext) {
expr = expr->rpnnext;
}
+ return expr;
+}
+
+static enum AlwaysValue always_value(const struct Expr *expr)
+{
+ expr = outermost_expr(expr);
if (!is_expr_const(expr)) return CAN_VARY;
if (expr->kind == E_FALSE) return EXPLICIT_FALSE;
if (expr->kind == E_TRUE) return EXPLICIT_TRUE;
@@ -290,7 +296,8 @@ static void emit_single_statement(struct Stmt *stmt)
if (!var->is_modifiable) {
/* Non-modifiable variables are limited to
the range of their initial value. */
- struct TypeRef *expr_tr = var->initval->typeref;
+ const struct TypeRef *expr_tr =
+ outermost_expr(var->initval)->typeref;
if (var->typeref != expr_tr) {
unsigned quals = var->typeref->quals;
*var->typeref = *expr_tr;
diff --git a/compiler/TheCommand.slul b/compiler/TheCommand.slul
index af5cc84..e8fb7f8 100644
--- a/compiler/TheCommand.slul
+++ b/compiler/TheCommand.slul
@@ -102,10 +102,8 @@ main
test_switch
- # FIXME these two lines give "Bootstrap compiler does not support method
- # calls on elementary types"
- #SomeClass! sc = new_with_n 123
- #sc.set_b true
+ SomeClass! sc1 = new_with_n 123
+ sc1.set_b true
SomeClass! sc = new
sc.count
sc.set_b true