Пример #1
0
Файл: IoList.cs Проект: 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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public override IoObject proto(IoState state)
        {
            IoNumber pro = new IoNumber();

            pro.state = state;
            pro.createSlots();
            pro.createProtos();
            pro.doubleValue = 0;
            pro.longValue   = 0;
            pro.isInteger   = true;
            state.registerProtoWithFunc(name, new IoStateProto(pro.name, pro, new IoStateProtoFunc(pro.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("asNumber", new IoMethodFunc(IoNumber.slotAsNumber)),
                new IoCFunction("+", new IoMethodFunc(IoNumber.slotAdd)),
                new IoCFunction("-", new IoMethodFunc(IoNumber.slotSubstract)),
                new IoCFunction("*", new IoMethodFunc(IoNumber.slotMultiply)),
                new IoCFunction("/", new IoMethodFunc(IoNumber.slotDivide)),
                new IoCFunction("log10", new IoMethodFunc(IoNumber.slotLog10)),
                new IoCFunction("log2", new IoMethodFunc(IoNumber.slotLog2)),
                new IoCFunction("log", new IoMethodFunc(IoNumber.slotLog)),
                new IoCFunction("pow", new IoMethodFunc(IoNumber.slotPow)),
                new IoCFunction("pi", new IoMethodFunc(IoNumber.slotPi)),
                new IoCFunction("e", new IoMethodFunc(IoNumber.slotE)),
                new IoCFunction("minPositive", new IoMethodFunc(IoNumber.slotMinPositive)),
                new IoCFunction("exp", new IoMethodFunc(IoNumber.slotExp)),
                new IoCFunction("round", new IoMethodFunc(IoNumber.slotRound)),
//                new IoCFunction("asString", new IoMethodFunc(this.asString))
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
Пример #4
0
        public override IoObject proto(IoState state)
        {
            IoCoroutine pro = new IoCoroutine();

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

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("run", new IoMethodFunc(IoCoroutine.slotRun)),
                new IoCFunction("main", new IoMethodFunc(IoCoroutine.slotMain)),
                new IoCFunction("resume", new IoMethodFunc(IoCoroutine.slotResume)),
                new IoCFunction("isCurrent", new IoMethodFunc(IoCoroutine.slotIsCurrent)),
                new IoCFunction("currentCoroutine", new IoMethodFunc(IoCoroutine.slotCurrentCoroutine)),
                new IoCFunction("implementation", new IoMethodFunc(IoCoroutine.slotImplementation)),
                new IoCFunction("setMessageDebugging", new IoMethodFunc(IoCoroutine.slotSetMessageDebugging)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
Пример #5
0
        public override void cloneSpecific(IoObject _from, IoObject _to)
        {
            IoCFunction from = _from as IoCFunction;
            IoCFunction to   = _to as IoCFunction;

            to.isActivatable = true;
            to.funcName      = from.funcName;
            to.func          = from.func;
        }
Пример #6
0
        // proto finish must be called only before first Sequence proto created

        public IoObject protoFinish(IoState state)
        {
            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("compare", new IoMethodFunc(IoObject.slotCompare)),
                new IoCFunction("==", new IoMethodFunc(IoObject.slotEquals)),
                new IoCFunction("!=", new IoMethodFunc(IoObject.slotNotEquals)),
                new IoCFunction(">=", new IoMethodFunc(IoObject.slotGreaterThanOrEqual)),
                new IoCFunction("<=", new IoMethodFunc(IoObject.slotLessThanOrEqual)),
                new IoCFunction(">", new IoMethodFunc(IoObject.slotGreaterThan)),
                new IoCFunction("<", new IoMethodFunc(IoObject.slotLessThan)),
                new IoCFunction("-", new IoMethodFunc(IoObject.slotSubstract)),
                new IoCFunction("", new IoMethodFunc(IoObject.slotEevalArg)),
                new IoCFunction("self", new IoMethodFunc(IoObject.slotSelf)),
                new IoCFunction("clone", new IoMethodFunc(IoObject.slotClone)),
                new IoCFunction("return", new IoMethodFunc(IoObject.slotReturn)),
                new IoCFunction("cloneWithoutInit", new IoMethodFunc(IoObject.slotCloneWithoutInit)),
                new IoCFunction("doMessage", new IoMethodFunc(IoObject.slotDoMessage)),
                new IoCFunction("print", new IoMethodFunc(IoObject.slotPrint)),
                new IoCFunction("println", new IoMethodFunc(IoObject.slotPrintln)),
                new IoCFunction("slotNames", new IoMethodFunc(IoObject.slotSlotNames)),
                new IoCFunction("type", new IoMethodFunc(IoObject.slotType)),
                new IoCFunction("evalArg", new IoMethodFunc(IoObject.slotEevalArg)),
                new IoCFunction("evalArgAndReturnSelf", new IoMethodFunc(IoObject.slotEevalArgAndReturnSelf)),
                new IoCFunction("do", new IoMethodFunc(IoObject.slotDo)),
                new IoCFunction("getSlot", new IoMethodFunc(IoObject.slotGetSlot)),
                new IoCFunction("updateSlot", new IoMethodFunc(IoObject.slotUpdateSlot)),
                new IoCFunction("setSlot", new IoMethodFunc(IoObject.slotSetSlot)),
                new IoCFunction("setSlotWithType", new IoMethodFunc(IoObject.slotSetSlotWithType)),
                new IoCFunction("message", new IoMethodFunc(IoObject.slotMessage)),
                new IoCFunction("method", new IoMethodFunc(IoObject.slotMethod)),
                new IoCFunction("block", new IoMethodFunc(IoObject.slotBlock)),
                new IoCFunction("init", new IoMethodFunc(IoObject.slotSelf)),
                new IoCFunction("thisContext", new IoMethodFunc(IoObject.slotSelf)),
                new IoCFunction("thisMessage", new IoMethodFunc(IoObject.slotThisMessage)),
                new IoCFunction("thisLocals", new IoMethodFunc(IoObject.slotThisLocals)),
                new IoCFunction("init", new IoMethodFunc(IoObject.slotSelf)),
                new IoCFunction("if", new IoMethodFunc(IoObject.slotIf)),
                new IoCFunction("yield", new IoMethodFunc(IoObject.slotYield)),
                new IoCFunction("@@", new IoMethodFunc(IoObject.slotAsyncCall)),
                new IoCFunction("yieldingCoros", new IoMethodFunc(IoObject.slotYieldingCoros)),
                new IoCFunction("while", new IoMethodFunc(IoObject.slotWhile))
            };
            IoObject o = state.protoWithInitFunc(name);

            o.addTaglessMethodTable(state, methodTable);
            return(o);
        }
Пример #7
0
        public override IoObject proto(IoState state)
        {
            IoCLRFunction pro = new IoCLRFunction();

            pro.state    = state;
            pro.uniqueId = 0;
            pro.createSlots();
            pro.createProtos();
            pro.isActivatable = true;
            state.registerProtoWithFunc(pro.name, new IoStateProto(pro.name, pro, new IoStateProtoFunc(pro.proto)));
            //pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
Пример #8
0
        public static IoObject slotAsyncCall(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage msg      = message as IoMessage;
            IoMessage aMessage = msg.rawArgAt(0);
            IoObject  context  = target;

            if (msg.args.Count >= 2)
            {
                context = msg.localsValueArgAt(locals, 1);
            }

            IoBlock o = target.rawGetSlot(aMessage.messageName) as IoBlock;

            if (o != null)
            {
                IoMessage mmm = o.containedMessage;
                mmm.async = true;


                IoContext ctx = new IoContext();
                ctx.target  = context;
                ctx.locals  = target;
                ctx.message = mmm;
                mmm.async   = true;
                IoState  state           = target.state;
                IoObject future          = IoObject.createObject(state);
                IEnumerator <IoObject> e = IoMessage.asyncCall(ctx, future);
                state.contextList.Add(e);
                return(future);
            }
            else
            {
                IoCFunction cf = target.rawGetSlot(aMessage.messageName) as IoCFunction;
                if (cf != null)
                {
                    cf.async = true;
                    return(cf.activate(target, locals, aMessage, null));
                }
            }
            return(aMessage.localsPerformOn(target, locals));
        }
Пример #9
0
        public override IoObject proto(IoState state)
        {
            IoSeq pro = new IoSeq();

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

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("appendSeq", new IoMethodFunc(IoSeq.slotAppendSeq)),
                new IoCFunction("at", new IoMethodFunc(IoSeq.slotAt)),
                new IoCFunction("reverse", new IoMethodFunc(IoSeq.slotReverse)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
Пример #10
0
        public override IoObject proto(IoState state)
        {
            IoCLR pro = new IoCLR();

            pro.state    = state;
            pro.uniqueId = 0;
            pro.createSlots();
            pro.createProtos();
            pro.isActivatable = true;
            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("loadAssembly", new IoMethodFunc(IoCLR.slotLoadAssembly)),
                new IoCFunction("using", new IoMethodFunc(IoCLR.slotUsing)),
                new IoCFunction("getType", new IoMethodFunc(IoCLR.slotGetType)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
Пример #11
0
        public override IoObject proto(IoState state)
        {
            IoBlock pro = new IoBlock();

            pro.state = state;
            pro.createSlots();
            pro.createProtos();
            pro.containedMessage = state.nilMessage;
            pro.argNames         = new IoObjectArrayList();
            state.registerProtoWithFunc(name, new IoStateProto(name, pro, new IoStateProtoFunc(this.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("call", new IoMethodFunc(IoBlock.slotCall)),
                new IoCFunction("code", new IoMethodFunc(IoBlock.slotCode)),
                new IoCFunction("block", new IoMethodFunc(IoBlock.slotBlock)),
                new IoCFunction("method", new IoMethodFunc(IoBlock.slotMethod)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
Пример #12
0
        public override IoObject proto(IoState state)
        {
            IoMessage pro = new IoMessage();

            pro.state = state;
            //  pro.tag.cloneFunc = new IoTagCloneFunc(this.clone);
            //pro.tag.activateFunc = new IoTagActivateFunc(this.activate);
            pro.createSlots();
            pro.createProtos();
            pro.uniqueId    = 0;
            pro.messageName = IoSeq.createSymbolInMachine(state, "anonymous");
            pro.label       = IoSeq.createSymbolInMachine(state, "unlabeled");
            pro.args        = new List <IoMessage>();
            state.registerProtoWithFunc(name, new IoStateProto(name, pro, new IoStateProtoFunc(this.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("name", new IoMethodFunc(IoMessage.slotName)),
                new IoCFunction("setName", new IoMethodFunc(IoMessage.slotSetName)),
                new IoCFunction("next", new IoMethodFunc(IoMessage.slotNext)),
                new IoCFunction("setNext", new IoMethodFunc(IoMessage.slotSetNext)),
                new IoCFunction("code", new IoMethodFunc(IoMessage.slotCode)),
                new IoCFunction("arguments", new IoMethodFunc(IoMessage.slotArguments)),
                new IoCFunction("appendArg", new IoMethodFunc(IoMessage.slotAppendArg)),
                new IoCFunction("argAt", new IoMethodFunc(IoMessage.slotArgAt)),
                new IoCFunction("argCount", new IoMethodFunc(IoMessage.slotArgCount)),
                new IoCFunction("asString", new IoMethodFunc(IoMessage.slotCode)),
                new IoCFunction("cachedResult", new IoMethodFunc(IoMessage.slotCachedResult)),
                new IoCFunction("setCachedResult", new IoMethodFunc(IoMessage.slotSetCachedResult)),
                new IoCFunction("removeCachedResult", new IoMethodFunc(IoMessage.slotRemoveCachedResult)),
                new IoCFunction("hasCachedResult", new IoMethodFunc(IoMessage.slotHasCachedResult)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
Пример #13
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;
        }
Пример #14
0
        public override IoObject proto(IoState state)
        {
            IoNumber pro = new IoNumber();
            pro.state = state;
            pro.createSlots();
            pro.createProtos();
            pro.doubleValue = 0;
            pro.longValue = 0;
            pro.isInteger = true;
            state.registerProtoWithFunc(name, new IoStateProto(pro.name, pro, new IoStateProtoFunc(pro.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("asNumber", new IoMethodFunc(IoNumber.slotAsNumber)),
                new IoCFunction("+", new IoMethodFunc(IoNumber.slotAdd)),
                new IoCFunction("-", new IoMethodFunc(IoNumber.slotSubstract)),
                new IoCFunction("*", new IoMethodFunc(IoNumber.slotMultiply)),
                new IoCFunction("/", new IoMethodFunc(IoNumber.slotDivide)),
                new IoCFunction("log10", new IoMethodFunc(IoNumber.slotLog10)),
                new IoCFunction("log2", new IoMethodFunc(IoNumber.slotLog2)),
                new IoCFunction("log", new IoMethodFunc(IoNumber.slotLog)),
                new IoCFunction("pow", new IoMethodFunc(IoNumber.slotPow)),
                new IoCFunction("pi", new IoMethodFunc(IoNumber.slotPi)),
                new IoCFunction("e", new IoMethodFunc(IoNumber.slotE)),
                new IoCFunction("minPositive", new IoMethodFunc(IoNumber.slotMinPositive)),
                new IoCFunction("exp", new IoMethodFunc(IoNumber.slotExp)),
                new IoCFunction("round", new IoMethodFunc(IoNumber.slotRound)),
            //                new IoCFunction("asString", new IoMethodFunc(this.asString))
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
Пример #15
0
 public static new IoCFunction createObject(IoState state)
 {
     IoCFunction cf = new IoCFunction();
     return cf.proto(state).clone(state) as IoCFunction;
 }
Пример #16
0
        public override IoObject proto(IoState state)
        {
            IoCLRObject pro = new IoCLRObject();
            pro.state = state;
            pro.uniqueId = 0;
            pro.createSlots();
            pro.createProtos();
            pro.isActivatable = true;
            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("type", new IoMethodFunc(IoObject.slotType))
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
Пример #17
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"));
        }
Пример #18
0
        public override IoObject proto(IoState state)
        {
            IoString pro = new IoString();
            pro.state = state;
            //    pro.tag.cloneFunc = new IoTagCloneFunc(this.clone);
            //    pro.tag.compareFunc = new IoTagCompareFunc(this.compare);
            pro.createSlots();
            pro.createProtos();
            state.registerProtoWithFunc(name, new IoStateProto(name, pro, new IoStateProtoFunc(this.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("appendStr", new IoMethodFunc(IoString.slotAppendStr)),
                new IoCFunction("at", new IoMethodFunc(IoString.slotAt)),
                new IoCFunction("reverse", new IoMethodFunc(IoString.slotReverse)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
Пример #19
0
 public static new IoCFunction createProto(IoState state)
 {
     IoCFunction cf = new IoCFunction();
     return cf.proto(state) as IoCFunction;
 }
Пример #20
0
        public override IoObject proto(IoState state)
        {
            IoBlock pro = new IoBlock();
            pro.state = state;
            pro.createSlots();
            pro.createProtos();
            pro.containedMessage = state.nilMessage;
            pro.argNames = new IoObjectArrayList();
            state.registerProtoWithFunc(name, new IoStateProto(name, pro, new IoStateProtoFunc(this.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("call", new IoMethodFunc(IoBlock.slotCall)),
                new IoCFunction("code", new IoMethodFunc(IoBlock.slotCode)),
                new IoCFunction("block", new IoMethodFunc(IoBlock.slotBlock)),
                new IoCFunction("method", new IoMethodFunc(IoBlock.slotMethod)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
Пример #21
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;
        }
Пример #22
0
 // proto finish must be called only before first Sequence proto created
 public IoObject protoFinish(IoState state)
 {
     IoCFunction[] methodTable = new IoCFunction[] {
         new IoCFunction("compare", new IoMethodFunc(IoObject.slotCompare)),
         new IoCFunction("==", new IoMethodFunc(IoObject.slotEquals)),
         new IoCFunction("!=", new IoMethodFunc(IoObject.slotNotEquals)),
         new IoCFunction(">=", new IoMethodFunc(IoObject.slotGreaterThanOrEqual)),
         new IoCFunction("<=", new IoMethodFunc(IoObject.slotLessThanOrEqual)),
         new IoCFunction(">", new IoMethodFunc(IoObject.slotGreaterThan)),
         new IoCFunction("<", new IoMethodFunc(IoObject.slotLessThan)),
         new IoCFunction("-", new IoMethodFunc(IoObject.slotSubstract)),
         new IoCFunction("", new IoMethodFunc(IoObject.slotEevalArg)),
         new IoCFunction("self", new IoMethodFunc(IoObject.slotSelf)),
         new IoCFunction("clone", new IoMethodFunc(IoObject.slotClone)),
         new IoCFunction("return", new IoMethodFunc(IoObject.slotReturn)),
         new IoCFunction("cloneWithoutInit", new IoMethodFunc(IoObject.slotCloneWithoutInit)),
         new IoCFunction("doMessage", new IoMethodFunc(IoObject.slotDoMessage)),
         new IoCFunction("print", new IoMethodFunc(IoObject.slotPrint)),
         new IoCFunction("println", new IoMethodFunc(IoObject.slotPrintln)),
         new IoCFunction("slotNames", new IoMethodFunc(IoObject.slotSlotNames)),
         new IoCFunction("type", new IoMethodFunc(IoObject.slotType)),
         new IoCFunction("evalArg", new IoMethodFunc(IoObject.slotEevalArg)),
         new IoCFunction("evalArgAndReturnSelf", new IoMethodFunc(IoObject.slotEevalArgAndReturnSelf)),
         new IoCFunction("do", new IoMethodFunc(IoObject.slotDo)),
         new IoCFunction("getSlot", new IoMethodFunc(IoObject.slotGetSlot)),
         new IoCFunction("updateSlot", new IoMethodFunc(IoObject.slotUpdateSlot)),
         new IoCFunction("setSlot", new IoMethodFunc(IoObject.slotSetSlot)),
         new IoCFunction("setSlotWithType", new IoMethodFunc(IoObject.slotSetSlotWithType)),
         new IoCFunction("message", new IoMethodFunc(IoObject.slotMessage)),
         new IoCFunction("method", new IoMethodFunc(IoObject.slotMethod)),
         new IoCFunction("block", new IoMethodFunc(IoObject.slotBlock)),
         new IoCFunction("init", new IoMethodFunc(IoObject.slotSelf)),
         new IoCFunction("thisContext", new IoMethodFunc(IoObject.slotSelf)),
         new IoCFunction("thisMessage", new IoMethodFunc(IoObject.slotThisMessage)),
         new IoCFunction("thisLocals", new IoMethodFunc(IoObject.slotThisLocals)),
         new IoCFunction("init", new IoMethodFunc(IoObject.slotSelf)),
         new IoCFunction("if", new IoMethodFunc(IoObject.slotIf)),
         new IoCFunction("yield", new IoMethodFunc(IoObject.slotYield)),
         new IoCFunction("@@", new IoMethodFunc(IoObject.slotAsyncCall)),
         new IoCFunction("yieldingCoros", new IoMethodFunc(IoObject.slotYieldingCoros)),
         new IoCFunction("while", new IoMethodFunc(IoObject.slotWhile))
     };
     IoObject o = state.protoWithInitFunc(name);
     o.addTaglessMethodTable(state, methodTable);
     return o;
 }
Пример #23
0
        public new static IoCFunction createObject(IoState state)
        {
            IoCFunction cf = new IoCFunction();

            return(cf.proto(state).clone(state) as IoCFunction);
        }
Пример #24
0
        public override IoObject proto(IoState state)
        {
            IoCLR pro = new IoCLR();
            pro.state = state;
            pro.uniqueId = 0;
            pro.createSlots();
            pro.createProtos();
            pro.isActivatable = true;
            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("loadAssembly", new IoMethodFunc(IoCLR.slotLoadAssembly)),
                new IoCFunction("using", new IoMethodFunc(IoCLR.slotUsing)),
                new IoCFunction("getType", new IoMethodFunc(IoCLR.slotGetType)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
Пример #25
0
        public override IoObject proto(IoState state)
        {
            IoCoroutine pro = new IoCoroutine();
            pro.tag.state = state;
              //  pro.tag.cloneFunc = new IoTagCloneFunc(this.clone);
            pro.createSlots();
            pro.createProtos();
            state.registerProtoWithFunc(name, new IoStateProto(name, pro, new IoStateProtoFunc(this.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("run", new IoMethodFunc(IoCoroutine.slotRun)),
                new IoCFunction("main", new IoMethodFunc(IoCoroutine.slotMain)),
                new IoCFunction("resume", new IoMethodFunc(IoCoroutine.slotResume)),
                new IoCFunction("isCurrent", new IoMethodFunc(IoCoroutine.slotIsCurrent)),
                new IoCFunction("currentCoroutine", new IoMethodFunc(IoCoroutine.slotCurrentCoroutine)),
                new IoCFunction("implementation", new IoMethodFunc(IoCoroutine.slotImplementation)),
                new IoCFunction("setMessageDebugging", new IoMethodFunc(IoCoroutine.slotSetMessageDebugging)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
Пример #26
0
        public override IoObject proto(IoState state)
        {
            IoMessage pro = new IoMessage();
            pro.state = state;
              //  pro.tag.cloneFunc = new IoTagCloneFunc(this.clone);
            //pro.tag.activateFunc = new IoTagActivateFunc(this.activate);
            pro.createSlots();
            pro.createProtos();
            pro.uniqueId = 0;
            pro.messageName = IoSeq.createSymbolInMachine(state, "anonymous");
            pro.label = IoSeq.createSymbolInMachine(state, "unlabeled");
            pro.args = new IoObjectArrayList();
            state.registerProtoWithFunc(name, new IoStateProto(name, pro, new IoStateProtoFunc(this.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("name", new IoMethodFunc(IoMessage.slotName)),
                new IoCFunction("setName", new IoMethodFunc(IoMessage.slotSetName)),
                new IoCFunction("next", new IoMethodFunc(IoMessage.slotNext)),
                new IoCFunction("setNext", new IoMethodFunc(IoMessage.slotSetNext)),
                new IoCFunction("code", new IoMethodFunc(IoMessage.slotCode)),
                new IoCFunction("arguments", new IoMethodFunc(IoMessage.slotArguments)),
                new IoCFunction("appendArg", new IoMethodFunc(IoMessage.slotAppendArg)),
                new IoCFunction("argAt", new IoMethodFunc(IoMessage.slotArgAt)),
                new IoCFunction("argCount", new IoMethodFunc(IoMessage.slotArgCount)),
                new IoCFunction("asString", new IoMethodFunc(IoMessage.slotCode)),
                new IoCFunction("cachedResult", new IoMethodFunc(IoMessage.slotCachedResult)),
                new IoCFunction("setCachedResult", new IoMethodFunc(IoMessage.slotSetCachedResult)),
                new IoCFunction("removeCachedResult", new IoMethodFunc(IoMessage.slotRemoveCachedResult)),
                new IoCFunction("hasCachedResult", new IoMethodFunc(IoMessage.slotHasCachedResult)),

            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
Пример #27
0
 public void addTaglessMethodTable(IoState state, IoCFunction[] table)
 {
     //foreach (IoMethodTableEntry entry in table)
     //    slots[entry.name] = new IoCFunction(state, entry.name, entry.func);
     foreach (IoCFunction entry in table)
     {
         entry.state = state;
         slots[entry.funcName] = entry;
     }
 }
Пример #28
0
        public new static IoCFunction createProto(IoState state)
        {
            IoCFunction cf = new IoCFunction();

            return(cf.proto(state) as IoCFunction);
        }