X-Git-Url: https://ocean-lang.org/code/?a=blobdiff_plain;f=csrc%2Foceani.mdc;h=beb4fc9830f41e25f4fbe65e54bb4195a3abde18;hb=bc126aadf03e4e64710f2ad7d76d1247090219d5;hp=fabfe188c07ebd5bc9abdca9dd492aad34041de2;hpb=6a7ef05f3986dd8127b8c3bfaeeceb514a8beaa4;p=ocean diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index fabfe18..beb4fc9 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -691,7 +691,7 @@ A separate function encoding these cases will simplify some code later. } } - static void _dup_value(struct type *type, + static void _dup_value(struct type *type, struct value *vold, struct value *vnew) { switch (type->vtype) { @@ -1031,7 +1031,7 @@ list of in_scope names. The storage of the value of a variable will be described later. For now we just need to know that when a variable goes out of scope, it might -need to be freed. For this we need to be able to find it, so assume that +need to be freed. For this we need to be able to find it, so assume that `var_value()` will provide that. ###### variable fields @@ -1575,7 +1575,7 @@ propagation is needed. ###### ast - enum val_rules {Rnolabel = 1<<0, Rboolok = 1<<1, Rnoconstant = 2<<1}; + enum val_rules {Rnolabel = 1<<0, Rboolok = 1<<1, Rnoconstant = 1<<2}; ###### format cases case 'r': @@ -2061,7 +2061,7 @@ function will be needed. struct value *v; v = (void*) val->ptr + type->structure.fields[i].offset; if (type->structure.fields[i].init) - dup_value(type->structure.fields[i].type, + dup_value(type->structure.fields[i].type, type->structure.fields[i].init, v); else @@ -2480,7 +2480,6 @@ further detailed when Expression Lists are introduced. } } }$ - $*binode Args -> ArgsLine NEWLINE ${ $0 = $right)) { t = propagate_types(e->left, c, ok, NULL, rules); - if ((rules & Rboolok) && t == Tbool) + if ((rules & Rboolok) && (t == Tbool || t == Tnone)) + t = NULL; + if (t == Tnone && e->right) + /* Only the final statement *must* return a value + * when not Rboolok + */ t = NULL; - if (t && t != Tnone && t != Tbool) { + if (t) { if (!type) type = t; else if (t != type) @@ -4008,7 +4012,7 @@ function. Use, ###### expr precedence - $TERM use + $TERM use ###### SimpleStatement Grammar | use Expression ${ @@ -4708,7 +4712,6 @@ The code in an Ocean program is all stored in function declarations. One of the functions must be named `main` and it must accept an array of strings as a parameter - the command line arguments. - As this is the top level, several things are handled a bit differently. The function is not interpreted by `interp_exec` as that isn't @@ -4877,7 +4880,6 @@ analysis is a bit more interesting at this level. array_init(v->var->type, vl); for (i = 0; i < argc; i++) { struct value *vl2 = vl->array + i * v->var->type->array.member->size; - arg.str.txt = argv[i]; arg.str.len = strlen(argv[i]);