]> ocean-lang.org Git - ocean/commitdiff
oceani: improve reporting of variables being freed at end of block.
authorNeilBrown <neil@brown.name>
Tue, 9 Nov 2021 04:58:50 +0000 (15:58 +1100)
committerNeilBrown <neil@brown.name>
Tue, 9 Nov 2021 05:08:19 +0000 (16:08 +1100)
1/ if frame_pos hasn't been set, possibly because type propagation hit
   an error, don't report the offset.
2/ Don't report G or L for global/local, and this will always be a a
   local variable.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani.mdc

index 6c5b4466a229ec73a63ac565e5e5300cbd43b740..76c8c9b4efd96414511685e620c4d7b7e849acbd 100644 (file)
@@ -1153,6 +1153,7 @@ all pending-scope variables become conditionally scoped.
                v->scope = InScope;
                v->in_scope = c->in_scope;
                c->in_scope = v;
                v->scope = InScope;
                v->in_scope = c->in_scope;
                c->in_scope = v;
+               ## variable init
                return v;
        }
 
                return v;
        }
 
@@ -1299,9 +1300,15 @@ the frame needs to be reallocated as it grows so it can store those
 values.  The local frame doesn't get values until the interpreted phase
 is started, so there is no need to allocate until the size is known.
 
 values.  The local frame doesn't get values until the interpreted phase
 is started, so there is no need to allocate until the size is known.
 
+We initialize the `frame_pos` to an impossible value, so that we can
+tell if it was set or not later.
+
 ###### variable fields
 ###### variable fields
-               short frame_pos;
-               short global;
+       short frame_pos;
+       short global;
+
+###### variable init
+       v->frame_pos = -1;
 
 ###### parse context
 
 
 ###### parse context
 
@@ -1538,10 +1545,12 @@ also want to know what sort of bracketing to use.
                if (e->to_free) {
                        struct variable *v;
                        do_indent(indent, "/* FREE");
                if (e->to_free) {
                        struct variable *v;
                        do_indent(indent, "/* FREE");
-                       for (v = e->to_free; v; v = v->next_free)
-                               printf(" %.*s(%c%d+%d)", v->name->name.len, v->name->name.txt,
-                                      v->global ? 'G':'L',
-                                      v->frame_pos, v->type ? v->type->size:0);
+                       for (v = e->to_free; v; v = v->next_free) {
+                               printf(" %.*s", v->name->name.len, v->name->name.txt);
+                               if (v->frame_pos >= 0)
+                                       printf("(%d+%d)", v->frame_pos,
+                                              v->type ? v->type->size:0);
+                       }
                        printf(" */\n");
                }
        }
                        printf(" */\n");
                }
        }