]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani.mdc
oceani: discard AssignRef and DeclareRef
[ocean] / csrc / oceani.mdc
index 2f3c9731e9ed703ad095a954855bd85cd43c20e7..543ca75a300a6ae740b19ccb15b9ff1d24a92a2a 100644 (file)
@@ -1157,7 +1157,7 @@ A separate function encoding these cases will simplify some code later.
        {
                int cmp;
                if (tl != tr)
-                       return tl - tr; // NOTEST
+                       return tl - tr;
                switch (tl->vtype) {
                case Vlabel: cmp = left->label == right->label ? 0 : 1; break;
                case Vnum: cmp = mpq_cmp(left->num, right->num); break;
@@ -2398,16 +2398,16 @@ with a const size by whether they are prepared at parse time or not.
                struct value *vsize;
                mpz_t q;
                if (type->array.static_size)
-                       return 1;       // UNTESTED
+                       return 1;       // NOTEST - guard against reentry
                if (type->array.unspec && parse_time)
-                       return 1;       // UNTESTED
+                       return 1;       // NOTEST - unspec is still incomplete
                if (parse_time && type->array.vsize && !type->array.vsize->global)
-                       return 1;       // UNTESTED
+                       return 1;       // NOTEST - should be impossible
 
                if (type->array.vsize) {
                        vsize = var_value(c, type->array.vsize);
                        if (!vsize)
-                               return 1;       // UNTESTED
+                               return 1;       // NOTEST - should be impossible
                        mpz_init(q);
                        mpz_tdiv_q(q, mpq_numref(vsize->num), mpq_denref(vsize->num));
                        type->array.size = mpz_get_si(q);
@@ -2416,7 +2416,7 @@ with a const size by whether they are prepared at parse time or not.
                if (!parse_time)
                        return 1;
                if (type->array.member->size <= 0)
-                       return 0;       // UNTESTED
+                       return 0;       // NOTEST - error caught before here
 
                type->array.static_size = 1;
                type->size = type->array.size * type->array.member->size;
@@ -3387,7 +3387,7 @@ anything in the heap or on the stack.  A reference can be assigned
        case AddressOf:
                /* left must be lval, we create reference to it */
                if (!type || type->free != reference_free)
-                       t = propagate_types(b->left, c, perr, type, 0); // UNTESTED
+                       t = propagate_types(b->left, c, perr, type, 0); // NOTEST impossible
                else
                        t = propagate_types(b->left, c, perr,
                                            type->reference.referent, 0);
@@ -4553,7 +4553,8 @@ the common header for all reductions to use.
        Block -> { IN OptNL Statementlist OUT OptNL } ${ $0 = $<Sl; }$
        |        { SimpleStatements } ${ $0 = reorder_bilist($<SS); }$
        |        SimpleStatements ; ${ $0 = reorder_bilist($<SS); }$
-       |        SimpleStatements EOL ${ $0 = reorder_bilist($<SS); }$
+       |        SimpleStatements EOL ${ $0 = reorder_bilist($<SS); 
+               }$
        |        IN OptNL Statementlist OUT ${ $0 = $<Sl; }$
 
        OpenBlock -> OpenScope { IN OptNL Statementlist OUT OptNL } ${ $0 = $<Sl; }$
@@ -4562,7 +4563,7 @@ the common header for all reductions to use.
        |        OpenScope SimpleStatements EOL ${ $0 = reorder_bilist($<SS); }$
        |        IN OpenScope OptNL Statementlist OUT ${ $0 = $<Sl; }$
 
-       UseBlock -> { OpenScope IN OptNL Statementlist OUT OptNL } ${ $0 = $<Sl; }$
+       UseBlock -> { IN OpenScope OptNL Statementlist OUT OptNL } ${ $0 = $<Sl; }$
        |        { OpenScope SimpleStatements } ${ $0 = reorder_bilist($<SS); }$
        |        IN OpenScope OptNL Statementlist OUT ${ $0 = $<Sl; }$
 
@@ -4576,7 +4577,7 @@ the common header for all reductions to use.
 
        ComplexStatements -> ComplexStatements ComplexStatement ${
                if ($2 == NULL) {
-                       $0 = $<1;
+                       $0 = $<1;       // NOTEST - impossible
                } else {
                        $0 = new(binode);
                        $0->op = Block;
@@ -4586,7 +4587,7 @@ the common header for all reductions to use.
        }$
        | ComplexStatement ${
                if ($1 == NULL) {
-                       $0 = NULL;
+                       $0 = NULL;      // NOTEST - impossible
                } else {
                        $0 = new(binode);
                        $0->op = Block;
@@ -4773,8 +4774,8 @@ it is declared, it is assumed to be a global constant which are allowed to
 be declared at any time.
 
 ###### Binode types
-       Assign, AssignRef,
-       Declare, DeclareRef,
+       Assign,
+       Declare,
 
 ###### declare terminals
        $TERM =
@@ -4810,7 +4811,6 @@ be declared at any time.
 ###### print binode cases
 
        case Assign:
-       case AssignRef:
                do_indent(indent, "");
                print_exec(b->left, -1, bracket);
                printf(" = ");
@@ -4820,7 +4820,6 @@ be declared at any time.
                break;
 
        case Declare:
-       case DeclareRef:
                {
                struct variable *v = cast(var, b->left)->var;
                do_indent(indent, "");
@@ -4850,9 +4849,7 @@ be declared at any time.
 ###### propagate binode cases
 
        case Assign:
-       case AssignRef:
        case Declare:
-       case DeclareRef:
                /* Both must match, or left may be ref and right an lval
                 * Type must support 'dup',
                 * For Assign, left must not be constant.
@@ -4870,12 +4867,8 @@ be declared at any time.
                                ; // No more effort needed
                        else if (t->free == reference_free &&
                                 t->reference.referent == t2 &&
-                                !(*perr_local & Erval)) {
-                               if (b->op == Assign)
-                                       b->op = AssignRef;
-                               if (b->op == Declare)
-                                       b->op = DeclareRef;
-                       }
+                                !(*perr_local & Erval))
+                               b->right = take_addr(b->right);
                        else if (t->free == reference_free &&
                                 t->reference.referent == t2 &&
                                 (*perr_local & Erval))
@@ -4889,7 +4882,7 @@ be declared at any time.
                if (*perr & Erval)
                        type_err(c, "error: cannot assign to an rval", b,
                                 NULL, 0, NULL);
-               else if ((b->op == Assign || b->op == AssignRef) && (*perr & Econst)) {
+               else if (b->op == Assign && (*perr & Econst)) {
                        type_err(c, "error: Cannot assign to a constant: %v",
                                 b->left, NULL, 0, NULL);
                        if (b->left->type == Xvar) {
@@ -4911,21 +4904,13 @@ be declared at any time.
 ###### interp binode cases
 
        case Assign:
-       case AssignRef:
                lleft = linterp_exec(c, b->left, &ltype);
-               if (!lleft)
-                       // FIXME lleft==NULL probably means illegal array ref
-                       // should that cause a runtime error
-                       ;
-               else if (b->op == AssignRef)
-                       lleft->ref = linterp_exec(c, b->right, &rtype);
-               else
+               if (lleft)
                        dinterp_exec(c, b->right, lleft, ltype, 1);
                ltype = Tnone;
                break;
 
        case Declare:
-       case DeclareRef:
        {
                struct variable *v = cast(var, b->left)->var;
                struct value *val;
@@ -4935,8 +4920,6 @@ be declared at any time.
                        v->type->prepare_type(c, v->type, 0);
                if (!b->right)
                        val_init(v->type, val);
-               else if (b->op == DeclareRef)
-                       val->ref = linterp_exec(c, b->right, &rtype);
                else
                        dinterp_exec(c, b->right, val, v->type, 0);
                break;