Permalink
Browse files

Implement [*] style zen slices (fixes #111)

  • Loading branch information...
1 parent 0308871 commit a900903b235b2252cbaa6de55f4ec1061ce15175 @sorear committed May 21, 2012
Showing with 20 additions and 1 deletion.
  1. +15 −0 lib/Kernel.cs
  2. +4 −0 lib/ObjModel.cs
  3. +1 −1 lib/Serialize.cs
View
@@ -3851,6 +3851,8 @@ class KeySlicer : IndexHandler {
P6any ks = key.Fetch();
if (key.islist || !ks.mo.is_any && ks.mo.HasType(Kernel.JunctionMO))
return Slice(obj, key);
+ else if (ks.mo.HasType(Kernel.WhateverMO))
+ return GetAll(obj);
switch (mode) {
case 0: return key;
@@ -3911,6 +3913,8 @@ class IxAnyAtKey : IndexHandler {
P6any ks = key.Fetch();
if (key.islist || !ks.mo.is_any && ks.mo.HasType(Kernel.JunctionMO))
return Slice(obj, key);
+ else if (ks.mo.HasType(Kernel.WhateverMO))
+ return GetAll(obj);
P6any os = obj.Fetch();
if (!os.IsDefined())
@@ -3924,6 +3928,8 @@ class IxAnyAtPos : IndexHandler {
P6any ks = key.Fetch();
if (key.islist || !ks.mo.is_any && ks.mo.HasType(Kernel.JunctionMO))
return Slice(obj, key);
+ else if (ks.mo.HasType(Kernel.WhateverMO))
+ return GetAll(obj);
P6any os = obj.Fetch();
if (!os.IsDefined())
@@ -3947,6 +3953,8 @@ class IxCursorAtKey : IndexHandler {
P6any ks = key.Fetch();
if (key.islist || !ks.mo.is_any && ks.mo.HasType(Kernel.JunctionMO))
return Slice(obj, key);
+ else if (ks.mo.HasType(Kernel.WhateverMO))
+ return GetAll(obj);
P6any o = obj.Fetch();
if (!o.IsDefined())
return Kernel.AnyMO.typeVar;
@@ -3960,6 +3968,8 @@ class IxCursorAtPos : IndexHandler {
P6any ks = key.Fetch();
if (key.islist || !ks.mo.is_any && ks.mo.HasType(Kernel.JunctionMO))
return Slice(obj, key);
+ else if (ks.mo.HasType(Kernel.WhateverMO))
+ return GetAll(obj);
P6any o = obj.Fetch();
if (!o.IsDefined())
@@ -3989,6 +3999,8 @@ class IxHashAtKey : IndexHandler {
P6any ks = key.Fetch();
if (key.islist || !ks.mo.is_any && ks.mo.HasType(Kernel.JunctionMO))
return Slice(obj, key);
+ else if (ks.mo.HasType(Kernel.WhateverMO))
+ return GetAll(obj);
P6any os = obj.Fetch();
if (!os.IsDefined())
@@ -4044,6 +4056,8 @@ class IxListAtPos : IndexHandler {
P6any ks = key.Fetch();
if (key.islist || !ks.mo.is_any && ks.mo.HasType(Kernel.JunctionMO))
return Slice(obj, key);
+ else if (ks.mo.HasType(Kernel.WhateverMO))
+ return GetAll(obj);
P6any os = obj.Fetch();
if (!os.IsDefined())
@@ -4816,6 +4830,7 @@ public class Kernel {
[CORESaved] public static STable AssociativeMO;
[CORESaved] public static STable CallableMO;
[CORESaved] public static STable CodeMO;
+ [CORESaved] public static STable WhateverMO;
[CORESaved] public static STable WhateverCodeMO;
[CORESaved] public static STable RoutineMO;
[CORESaved] public static STable SubMO;
View
@@ -133,6 +133,10 @@ public abstract class IndexHandler : ReflectObj {
return Kernel.NewRWListVar(Kernel.BoxRaw<Variable[]>(
items.ToArray(), Kernel.ParcelMO));
}
+
+ protected Variable GetAll(Variable obj) {
+ return Slice(obj, Builtins.InvokeMethod("keys", obj));
+ }
}
// NOT P6any; these things should only be exposed through a ClassHOW-like
View
@@ -68,7 +68,7 @@ struct ObjRef {
new Dictionary<string,Dictionary<string,MethodInfo>>();
static readonly string signature = "Niecza-Serialized-Module";
- static readonly int version = 24;
+ static readonly int version = 25;
// Routines for use by serialization code
public bool CheckWriteObject(SerUnit into, object o,

0 comments on commit a900903

Please sign in to comment.