From bcaf7f25f42b21067a26895e097ada73765ba7d5 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 26 Jan 2022 09:40:50 +0000 Subject: Implement a new "mixed" type which can be either of the three scalar types: int, float, rune. This allows scalar arrays with mixed scalar types --- apl9.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'apl9.h') diff --git a/apl9.h b/apl9.h index b15b7e6..9004636 100644 --- a/apl9.h +++ b/apl9.h @@ -22,6 +22,7 @@ typedef enum AtypeInt, AtypeFloat, AtypeRune, + AtypeMixed, AtypeArray, } arrayDataType; @@ -57,6 +58,7 @@ typedef enum } errorCodes; /* Data types */ +typedef struct Mixed Mixed; typedef struct Array Array; typedef struct Statement Statement; typedef struct Operator Operator; @@ -69,6 +71,16 @@ typedef struct QuadnameDef QuadnameDef; typedef struct ErrorHandler ErrorHandler; typedef struct DfnFrame DfnFrame; +struct Mixed +{ + int type; + union { + vlong i; + double f; + Rune r; + }; +}; + struct Array { arrayDataType type; @@ -82,6 +94,7 @@ struct Array vlong *intdata; double *floatdata; Rune *runedata; + Mixed *mixeddata; Array **arraydata; }; }; @@ -222,6 +235,7 @@ Array *arrayitem(Array *, int); Array *simplifyarray(Array *); int comparearray(Array *, Array *, int); Array *fillelement(Array *); +uvlong arrayspaceused(Array *); /* eval.c */ Datum *eval(Statement *, int); -- cgit v1.2.3