From: NeilBrown Date: Wed, 1 May 2019 08:22:38 +0000 (+1000) Subject: oceani: prepare for adding new types with new syntax. X-Git-Tag: JamisonCreek-3~29 X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=db00441dcdc7b27285d32b0be2e178a59bdb07af oceani: prepare for adding new types with new syntax. 1/ 'Variable' now returns an 'exec', so other things returning and 'exec' can be the LHS of an assignment. 2/ provide forward-decls of generic functions so that new type functions can use them to work with components of the types. Signed-off-by: NeilBrown --- diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 68e5b60..9ab456a 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -580,6 +580,17 @@ which are often passed around by value. return rv; } +###### forward decls + + static void free_value(struct value v); + static int type_compat(struct type *require, struct type *have, int rules); + static void type_print(struct type *type, FILE *f); + static struct value val_init(struct type *type); + static struct value dup_value(struct value v); + static int value_cmp(struct value left, struct value right); + static void print_value(struct value v); + static struct value parse_value(struct type *type, char *arg); + ###### free context types while (context.typelist) { @@ -1732,6 +1743,7 @@ link to find the primary instance. } } }$ + $*exec Variable -> IDENTIFIER ${ { struct variable *v = var_ref(config2context(config), $1.txt); $0 = new_pos(var, $1); @@ -1744,7 +1756,7 @@ link to find the primary instance. v->where_set = $0; } } - $0->var = v; + cast(var, $0)->var = v; } }$ $*type