summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/array.c b/array.c
index 3643ee6..71c35f6 100644
--- a/array.c
+++ b/array.c
@@ -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);