]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani.mdc
oceani: move comment printing from print_exec() to where later
[ocean] / csrc / oceani.mdc
index 496f86a08a1a3a195d284616dc146582924fd89a..c687fddca5ea7a17521fe730c81d8381d61bbb6e 100644 (file)
@@ -534,7 +534,9 @@ and we need `free_binode`.
 
 Printing an `exec` requires that we know the current indent level for
 printing line-oriented components.  As will become clear later, we
-also want to know what sort of bracketing to use.
+also want to know what sort of bracketing to use.  It will also be used
+to sometime print comments after an exec to explain some of the results
+of analysis.
 
 ###### ast functions
 
@@ -564,18 +566,7 @@ also want to know what sort of bracketing to use.
                        print_binode(cast(binode, e), indent, bracket); break;
                ## print exec cases
                }
-               if (e->to_free) {
-                       struct variable *v;
-                       do_indent(indent, "/* FREE");
-                       for (v = e->to_free; v; v = v->next_free) {
-                               printf(" %.*s", v->name->name.len, v->name->name.txt);
-                               printf("[%d,%d]", v->scope_start, v->scope_end);
-                               if (v->frame_pos >= 0)
-                                       printf("(%d+%d)", v->frame_pos,
-                                              v->type ? v->type->size:0);
-                       }
-                       printf(" */\n");
-               }
+               ## print exec extras
        }
 
 ###### forward decls
@@ -1522,7 +1513,9 @@ cannot nest, so a declaration while a name is in-scope is an error.
 
 When a scope closes, the values of the variables might need to be freed.
 This happens in the context of some `struct exec` and each `exec` will
-need to know which variables need to be freed when it completes.
+need to know which variables need to be freed when it completes.  To
+improve visibility, we add a comment when printing any `exec` that
+embodies a scope to list the variables that must be freed when it ends.
 
 ####### exec fields
        struct variable *to_free;
@@ -1540,6 +1533,20 @@ need to know which variables need to be freed when it completes.
                }
        }
 
+###### print exec extras
+       if (e->to_free) {
+               struct variable *v;
+               do_indent(indent, "/* FREE");
+               for (v = e->to_free; v; v = v->next_free) {
+                       printf(" %.*s", v->name->name.len, v->name->name.txt);
+                       printf("[%d,%d]", v->scope_start, v->scope_end);
+                       if (v->frame_pos >= 0)
+                               printf("(%d+%d)", v->frame_pos,
+                                      v->type ? v->type->size:0);
+               }
+               printf(" */\n");
+       }
+
 ###### ast functions
        static void variable_unlink_exec(struct variable *v)
        {