Inheritance: IoObject
Beispiel #1
0
Datei: IoList.cs Projekt: ypyf/io
        public override IoObject proto(IoState state)
        {
            IoList pro = new IoList();

            pro.state = state;
            //   pro.tag.cloneFunc = new IoTagCloneFunc(pro.clone);
            pro.createSlots();
            pro.createProtos();
            pro.list = new IoObjectArrayList();
            state.registerProtoWithFunc(pro.name, new IoStateProto(pro.name, pro, new IoStateProtoFunc(pro.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("indexOf", new IoMethodFunc(IoList.slotIndexOf)),
                new IoCFunction("capacity", new IoMethodFunc(IoList.slotSize)),
                new IoCFunction("size", new IoMethodFunc(IoList.slotSize)),
                new IoCFunction("removeAll", new IoMethodFunc(IoList.slotRemoveAll)),
                new IoCFunction("append", new IoMethodFunc(IoList.slotAppend)),
                new IoCFunction("appendSeq", new IoMethodFunc(IoList.slotAppendSeq)),
                new IoCFunction("with", new IoMethodFunc(IoList.slotWith)),
                new IoCFunction("prepend", new IoMethodFunc(IoList.slotPrepend)),
                new IoCFunction("push", new IoMethodFunc(IoList.slotAppend)),
                new IoCFunction("at", new IoMethodFunc(IoList.slotAt)),
                new IoCFunction("last", new IoMethodFunc(IoList.slotLast)),
                new IoCFunction("pop", new IoMethodFunc(IoList.slotPop)),
                new IoCFunction("removeAt", new IoMethodFunc(IoList.slotRemoveAt)),
                new IoCFunction("reverseForeach", new IoMethodFunc(IoList.slotReverseForeach)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
Beispiel #2
0
Datei: IoList.cs Projekt: ypyf/io
        public static IoObject slotAt(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m   = message as IoMessage;
            IoNumber  ind = m.localsNumberArgAt(locals, 0);
            IoList    o   = target as IoList;
            IoObject  v   = o.list[ind.asInt()] as IoObject;

            return(v == null ? target.state.ioNil : v);
        }
Beispiel #3
0
Datei: IoList.cs Projekt: ypyf/io
        public static IoObject slotRemoveAll(IoObject target, IoObject locals, IoObject m)
        {
            IoList o = target as IoList;

            if (o.list != null)
            {
                o.list.Clear();
            }
            return(target);
        }
Beispiel #4
0
        public static IoObject slotArguments(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage self = target as IoMessage;
            IoList    list = IoList.createObject(target.state);

            foreach (IoObject o in self.args)
            {
                list.append(o);
            }
            return(list);
        }
Beispiel #5
0
Datei: IoList.cs Projekt: ypyf/io
        public static IoObject slotLast(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoList    o = target as IoList;

            if (o.list.Count > 0)
            {
                IoObject e = o.list[o.list.Count - 1] as IoObject;
                return(e);
            }
            return(target.state.ioNil);
        }
Beispiel #6
0
Datei: IoList.cs Projekt: ypyf/io
        public static IoObject slotWith(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoList    o = IoList.createObject(target.state) as IoList;

            for (int i = 0; i < m.args.Count; i++)
            {
                IoObject obj = m.localsValueArgAt(locals, i);
                o.list.Add(obj);
            }
            return(o);
        }
Beispiel #7
0
Datei: IoList.cs Projekt: ypyf/io
        public override IoObject clone(IoState state)
        {
            IoObject proto  = state.protoWithInitFunc(name);
            IoList   result = new IoList();

            uniqueIdCounter++;
            result.uniqueId = uniqueIdCounter;
            result.list     = new IoObjectArrayList();
            result.state    = state;
            result.createProtos();
            result.createSlots();
            result.protos.Add(proto);
            return(result);
        }
Beispiel #8
0
Datei: IoList.cs Projekt: ypyf/io
        // Published Slots

        public static IoObject slotIndexOf(IoObject target, IoObject locals, IoObject m)
        {
            IoList   o     = target as IoList;
            IoObject value = (m as IoMessage).localsValueArgAt(locals, 1);

            try
            {
                return(IoNumber.newWithDouble(target.state, o.list.IndexOf(value)));
            }
            catch (ArgumentOutOfRangeException aoore)
            {
                object ex = aoore;
                return(target.state.ioNil);
            }
        }
Beispiel #9
0
Datei: IoList.cs Projekt: ypyf/io
        public static IoObject slotPop(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoList    o = target as IoList;

            if (o.list.Count > 0)
            {
                IoObject e = o.list[o.list.Count - 1] as IoObject;
                o.list.RemoveAt(o.list.Count - 1);
                return(e);
            }
            else
            {
                return(target.state.ioNil);
            }
        }
Beispiel #10
0
Datei: IoList.cs Projekt: ypyf/io
        public static IoObject slotAppendSeq(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoList    o = target as IoList;

            for (int i = 0; i < m.args.Count; i++)
            {
                IoList obj = m.localsValueArgAt(locals, i) as IoList;
                for (int j = 0; j < obj.list.Count; j++)
                {
                    IoObject v = obj.list[j] as IoObject;
                    o.list.Add(v);
                }
            }
            return(o);
        }
Beispiel #11
0
Datei: IoList.cs Projekt: ypyf/io
        public static IoObject slotRemoveAt(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m   = message as IoMessage;
            IoNumber  ind = m.localsNumberArgAt(locals, 0);
            IoList    o   = target as IoList;

            try
            {
                o.list.RemoveAt(ind.asInt());
                return(target);
            }
            catch (ArgumentOutOfRangeException aoore)
            {
                object ex = aoore;
                return(target.state.ioNil);
            }
        }
Beispiel #12
0
 public static new IoList createProto(IoState state)
 {
     IoList m = new IoList();
     return m.proto(state) as IoList;
 }
Beispiel #13
0
 public static new IoList createObject(IoState state)
 {
     IoList m = new IoList();
     return m.clone(state) as IoList;
 }
Beispiel #14
0
        public override IoObject proto(IoState state)
        {
            IoList pro = new IoList();
            pro.state = state;
             //   pro.tag.cloneFunc = new IoTagCloneFunc(pro.clone);
            pro.createSlots();
            pro.createProtos();
            pro.list = new IoObjectList();
            state.registerProtoWithFunc(pro.name, new IoStateProto(pro.name, pro, new IoStateProtoFunc(pro.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("indexOf", new IoMethodFunc(IoList.slotIndexOf)),
                new IoCFunction("capacity", new IoMethodFunc(IoList.slotSize)),
                new IoCFunction("size", new IoMethodFunc(IoList.slotSize)),
                new IoCFunction("removeAll", new IoMethodFunc(IoList.slotRemoveAll)),
                new IoCFunction("append", new IoMethodFunc(IoList.slotAppend)),
                new IoCFunction("appendStr", new IoMethodFunc(IoList.slotAppendStr)),
                new IoCFunction("with", new IoMethodFunc(IoList.slotWith)),
                new IoCFunction("prepend", new IoMethodFunc(IoList.slotPrepend)),
                new IoCFunction("push", new IoMethodFunc(IoList.slotAppend)),
                new IoCFunction("at", new IoMethodFunc(IoList.slotAt)),
                new IoCFunction("last", new IoMethodFunc(IoList.slotLast)),
                new IoCFunction("pop", new IoMethodFunc(IoList.slotPop)),
                new IoCFunction("removeAt", new IoMethodFunc(IoList.slotRemoveAt)),
                new IoCFunction("reverseForeach", new IoMethodFunc(IoList.slotReverseForeach)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
Beispiel #15
0
 public override IoObject clone(IoState state)
 {
     IoObject proto = state.protoWithInitFunc(name);
     IoList result = new IoList();
     uniqueIdCounter++;
     result.uniqueId = uniqueIdCounter;
     result.list = new IoObjectList();
     result.state = state;
     result.createProtos();
     result.createSlots();
     result.protos.Add(proto);
     return result;
 }
Beispiel #16
0
Datei: IoList.cs Projekt: ypyf/io
        public new static IoList createObject(IoState state)
        {
            IoList m = new IoList();

            return(m.clone(state) as IoList);
        }
Beispiel #17
0
Datei: IoList.cs Projekt: ypyf/io
        public new static IoList createProto(IoState state)
        {
            IoList m = new IoList();

            return(m.proto(state) as IoList);
        }
Beispiel #18
0
        public IoState()
        {
            objectProto = IoObject.createProto(this);
            core        = objectProto.clone(this);
            lobby       = objectProto.clone(this);

            IoSeq seqProto = IoSeq.createProto(this);

            setupSingletons();
            setupSymbols();

            objectProto.protoFinish(this);

            IoMessage messageProto = IoMessage.createProto(this);

            nilMessage = IoMessage.createObject(this) as IoMessage;
            nilMessage.cachedResult = ioNil;
            nilMessage.messageName  = IOSYMBOL("nil");

            IoMap       mapProto   = IoMap.createProto(this);
            IoNumber    numProto   = IoNumber.createProto(this);
            IoCFunction cfProto    = IoCFunction.createProto(this);
            IoBlock     blockProto = IoBlock.createProto(this);
            //IoCoroutine coroProto = IoCoroutine.createProto(this);
            //mainCoroutine = coroProto;
            //currentCoroutine = coroProto;
            IoCall callProto = IoCall.createProto(this);
            IoList listProto = IoList.createProto(this);

            clrProto = IoCLR.createProto(this);
            IoCLRAssembly asmProto    = IoCLRAssembly.createProto(this);
            IoCLRObject   clrObjProto = IoCLRObject.createProto(this);

            IoObject protos = objectProto.clone(this);

            protos.slots["Core"]   = core;
            protos.slots["Addons"] = null;

            lobby.slots["Lobby"]  = lobby;
            lobby.slots["Protos"] = protos;

            core.slots["Object"] = objectProto;
            core.slots["Map"]    = mapProto;
            // core.slots["Coroutine"] = coroProto;
            core.slots["Message"]     = messageProto;
            core.slots["CFunction"]   = cfProto;
            core.slots["Number"]      = numProto;
            core.slots["Block"]       = blockProto;
            core.slots["Call"]        = callProto;
            core.slots["Locals"]      = localsProto = objectProto.localsProto(this);
            core.slots["List"]        = listProto;
            core.slots["Sequence"]    = seqProto;
            core.slots["CLR"]         = clrProto;
            core.slots["CLRAssembly"] = asmProto;
            core.slots["CLRObject"]   = clrObjProto;

            objectProto.protos.Add(lobby);
            lobby.protos.Add(protos);
            protos.protos.Add(core);

            localsUpdateSlotCFunc = new IoCFunction(this, "localsUpdate", IoObject.localsUpdateSlot);

            initMessage      = IoMessage.newWithName(this, IOSYMBOL("init"));
            forwardMessage   = IoMessage.newWithName(this, IOSYMBOL("forward"));
            activateMessage  = IoMessage.newWithName(this, IOSYMBOL("activate"));
            selfMessage      = IoMessage.newWithName(this, IOSYMBOL("self"));
            opShuffleMessage = IoMessage.newWithName(this, IOSYMBOL("opShuffle"));
            mainMessage      = IoMessage.newWithName(this, IOSYMBOL("main"));
            typeMessage      = IoMessage.newWithName(this, IOSYMBOL("type"));
        }
Beispiel #19
0
Datei: IoList.cs Projekt: ypyf/io
        public static IoObject slotSize(IoObject target, IoObject locals, IoObject m)
        {
            IoList o = target as IoList;

            return(IoNumber.newWithDouble(target.state, o.list.Count));
        }