상속: 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
 public static new IoMap createProto(IoState state)
 {
     IoMap m = new IoMap();
     return m.proto(state) as IoMap;
 }
예제 #12
0
        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
 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;
 }