diff options
author | glenda <glenda@9front> | 2022-10-22 19:03:56 +0000 |
---|---|---|
committer | glenda <glenda@9front> | 2022-10-22 19:03:56 +0000 |
commit | 79ab1a4223d53bbdbffc55ae7f9740d953c57945 (patch) | |
tree | 65104abcf220f4774ab2b84a0d772c891a9dff17 /array.c | |
parent | 6a0d0638cdf510a9033fcd1e1a66daf636197a6f (diff) |
Prepare for a namespace implementation at some point
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -12,7 +12,8 @@ int datasizes[] = { [AtypeFloat] = sizeof(double), [AtypeRune] = sizeof(Rune), [AtypeMixed] = sizeof(Mixed), - [AtypeArray] = sizeof(Array *) + [AtypeArray] = sizeof(Array *), + [AtypeNamespace] = sizeof(Namespace *), }; Array * @@ -50,6 +51,14 @@ mkrunearray(Rune *str) } Array * +mkscalarns(Namespace *ns) +{ + Array *a = allocarray(AtypeNamespace, 0, 1); + a->nsdata[0] = ns; + return a; +} + +Array * duparray(Array *a) { Array *b = duparrayshape(a, GetType(a)); @@ -198,6 +207,9 @@ arrayitem(Array *a, int index) res = a->arraydata[index]; incref(res); break; + case AtypeNamespace: + res = mkscalarns(a->nsdata[index]); + break; default: throwerror(L"Unhandled case in arrayitem 2", ENotImplemented); } @@ -321,6 +333,9 @@ comparearray(Array *a, Array *b, int checkshapes) case AtypeArray: sub = comparearray(a->arraydata[i], b->arraydata[i], checkshapes); break; + case AtypeNamespace: + sub = a->nsdata[i] > b->nsdata[i] ? 1 : a->nsdata[i] == b->nsdata[i] ? 0 : -1; + break; default: print("Missing comparison code for type %d\n", GetType(a)); exits(nil); |