Inheritance: IoObject
コード例 #1
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public override IoObject proto(IoState state)
        {
            IoMap pro = new IoMap();

            pro.tag.state        = state;
            pro.tag.cloneFunc    = new IoTagCloneFunc(pro.clone);
            pro.tag.activateFunc = new IoTagActivateFunc(pro.activate);
            pro.createSlots();
            pro.createProtos();
            pro.map = new Hashtable();
            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("at", new IoMethodFunc(IoMap.slotAt)),
                new IoCFunction("atPut", new IoMethodFunc(IoMap.slotAtPut)),
                new IoCFunction("atIfAbsentPut", new IoMethodFunc(IoMap.slotAtIfAbsentPut)),
                new IoCFunction("empty", new IoMethodFunc(IoMap.slotEmpty)),
                new IoCFunction("size", new IoMethodFunc(IoMap.slotSize)),
                new IoCFunction("removeAt", new IoMethodFunc(IoMap.slotRemoveAt)),
                new IoCFunction("hasKey", new IoMethodFunc(IoMap.slotHasKey)),
                new IoCFunction("hasValue", new IoMethodFunc(IoMap.slotHasValue)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
コード例 #2
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public static IoObject slotRemoveAt(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m    = message as IoMessage;
            IoObject  key  = m.localsSymbolArgAt(locals, 0);
            IoMap     dict = target as IoMap;

            dict.map[key.ToString()] = null;
            return(target);
        }
コード例 #3
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public static IoObject slotSize(IoObject target, IoObject locals, IoObject m)
        {
            IoMap dict = target as IoMap;

            if (dict.map != null)
            {
                return(IoNumber.newWithDouble(dict.tag.state, dict.map.Count));
            }
            return(dict.tag.state.ioNil);
        }
コード例 #4
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public static IoObject slotEmpty(IoObject target, IoObject locals, IoObject m)
        {
            IoMap dict = target as IoMap;

            if (dict.map != null)
            {
                dict.map.Clear();
            }
            return(target);
        }
コード例 #5
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public static IoObject slotAtPut(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m     = message as IoMessage;
            IoObject  key   = m.localsValueArgAt(locals, 0);
            IoObject  value = m.localsValueArgAt(locals, 1);
            IoMap     dict  = target as IoMap;

            dict.map[key.ToString()] = value;
            return(target);
        }
コード例 #6
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public static IoObject slotHasValue(IoObject target, IoObject locals, IoObject message)
        {
            IoMap     dict = target as IoMap;
            IoMessage m    = message as IoMessage;
            IoObject  val  = m.localsValueArgAt(locals, 0);

            if (dict.lookupMapValues(val) == null)
            {
                return(dict.tag.state.ioFalse);
            }
            return(dict.tag.state.ioTrue);
        }
コード例 #7
0
        public static IoObject slotHasKey(IoObject target, IoObject locals, IoObject message)
        {
            IoMap     dict = target as IoMap;
            IoMessage m    = message as IoMessage;
            IoObject  key  = m.localsValueArgAt(locals, 0);

            if (dict.lookupMap(key) == null)
            {
                return(dict.state.ioFalse);
            }
            return(dict.state.ioTrue);
        }
コード例 #8
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public static IoObject slotAtIfAbsentPut(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m     = message as IoMessage;
            IoObject  key   = m.localsValueArgAt(locals, 0);
            IoObject  value = m.localsValueArgAt(locals, 1);
            IoMap     dict  = target as IoMap;

            if (dict.lookupMap(key) == null)
            {
                dict.map[key.ToString()] = value;
            }
            return(target);
        }
コード例 #9
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public override IoObject clone(IoState state)
        {
            IoObject proto  = state.protoWithInitFunc(name);
            IoMap    result = new IoMap();

            uniqueIdCounter++;
            result.uniqueId = uniqueIdCounter;
            result.map      = new Hashtable();
            result.tag      = proto.tag;
            result.createProtos();
            result.createSlots();
            result.protos.Add(proto);
            return(result);
        }
コード例 #10
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public static IoObject slotAt(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m      = message as IoMessage;
            IoObject  result = null;
            IoObject  symbol = m.localsValueArgAt(locals, 0);
            IoMap     dict   = target as IoMap;

            result = dict.lookupMap(symbol) as IoObject;
            if (result == null && m.args.Count > 1)
            {
                result = m.localsValueArgAt(locals, 1);
            }
            return(result == null ? dict.tag.state.ioNil : result);
        }
コード例 #11
0
ファイル: IoMap.cs プロジェクト: ChadSki/research-io
 public static new IoMap createProto(IoState state)
 {
     IoMap m = new IoMap();
     return m.proto(state) as IoMap;
 }
コード例 #12
0
ファイル: IoMap.cs プロジェクト: ChadSki/research-io
        public override IoObject proto(IoState state)
        {
            IoMap pro = new IoMap();
            pro.state = state;
            pro.createSlots();
            pro.createProtos();
            pro.map = new Hashtable();
            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("at", new IoMethodFunc(IoMap.slotAt)),
                new IoCFunction("atPut", new IoMethodFunc(IoMap.slotAtPut)),
                new IoCFunction("atIfAbsentPut", new IoMethodFunc(IoMap.slotAtIfAbsentPut)),
                new IoCFunction("empty", new IoMethodFunc(IoMap.slotEmpty)),
                new IoCFunction("size", new IoMethodFunc(IoMap.slotSize)),
                new IoCFunction("removeAt", new IoMethodFunc(IoMap.slotRemoveAt)),
                new IoCFunction("hasKey", new IoMethodFunc(IoMap.slotHasKey)),
                new IoCFunction("hasValue", new IoMethodFunc(IoMap.slotHasValue)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
コード例 #13
0
ファイル: IoBDB.cs プロジェクト: MilkTool/io-clr
        public new static IoMap createProto(IoState state)
        {
            IoMap m = new IoMap();

            return(m.proto(state) as IoMap);
        }
コード例 #14
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"));
        }
コード例 #15
0
ファイル: IoBDB.cs プロジェクト: stangelandcl/io-clr
 public override IoObject clone(IoState state)
 {
     IoObject proto = state.protoWithInitFunc(name);
     IoMap result = new IoMap();
     uniqueIdCounter++;
     result.uniqueId = uniqueIdCounter;
     result.map = new Hashtable();
     result.tag = proto.tag;
     result.createProtos();
     result.createSlots();
     result.protos.Add(proto);
     return result;
 }