コード例 #1
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);
        }
コード例 #2
0
ファイル: IoMessage.cs プロジェクト: ypyf/io
        IoMessage newParseNextMessageChain(IoState state, IoLexer lexer)
        {
            IoMessage msg = clone(state) as IoMessage;

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                msg.parseName(state, lexer);
            }

            if (lexer.topType() == IoTokenType.OPENPAREN_TOKEN)
            {
                msg.parseArgs(lexer);
            }

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                msg.parseNext(lexer);
            }

            while (lexer.topType() == IoTokenType.TERMINATOR_TOKEN)
            {
                lexer.pop();

                if (lexer.top() != null && lexer.top().isValidMessageName())
                {
                    IoMessage eol = IoMessage.newWithName(state, state.semicolonSymbol);
                    msg.next = eol;
                    eol.parseNext(lexer);
                }
            }

            return(msg);
        }
コード例 #3
0
ファイル: IoNumber.cs プロジェクト: devaspot/io
        public static IoNumber newWithDouble(IoState state, double n)
        {
            IoNumber fab = new IoNumber();
            IoNumber num = state.protoWithInitFunc(fab.name) as IoNumber;
            num = num.clone(state) as IoNumber;
            num.isInteger = false;
            num.doubleValue = n;

            if (Double.Equals(n, 0) ||
                (!Double.IsInfinity(n) && !Double.IsNaN(n) &&
                !n.ToString(CultureInfo.InvariantCulture).Contains(".") &&
                !n.ToString(CultureInfo.InvariantCulture).Contains("E") &&
                !n.ToString(CultureInfo.InvariantCulture).Contains("e")
                )
            )
            {
                try
                {
                    num.longValue = Convert.ToInt32(n);
                    num.isInteger = true;
                }
                catch (OverflowException oe)
                {

                }
            }
            return num;
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
        public static IoNumber newWithDouble(IoState state, double n)
        {
            IoNumber fab = new IoNumber();
            IoNumber num = state.protoWithInitFunc(fab.name) as IoNumber;

            num             = num.clone(state) as IoNumber;
            num.isInteger   = false;
            num.doubleValue = n;

            if (Double.Equals(n, 0) ||
                (!Double.IsInfinity(n) && !Double.IsNaN(n) &&
                 !n.ToString(CultureInfo.InvariantCulture).Contains(".") &&
                 !n.ToString(CultureInfo.InvariantCulture).Contains("E") &&
                 !n.ToString(CultureInfo.InvariantCulture).Contains("e")
                )
                )
            {
                try
                {
                    num.longValue = Convert.ToInt32(n);
                    num.isInteger = true;
                }
                catch (OverflowException oe)
                {
                }
            }
            return(num);
        }
コード例 #7
0
        public static IoObject slotWhile(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;

            if (m.async)
            {
                IoState  state           = target.state;
                IoObject future          = IoObject.createObject(state);
                IEnumerator <IoObject> e = IoObject.slotAsyncWhile(target, locals, message, future);
                state.contextList.Add(e);
                return(future);
            }

            IoObject result = target.state.ioNil;

            while (true)
            {
                bool sasync = m.async;
                m.async = false;
                IoObject cond = m.localsValueArgAt(locals, 0);
                if (cond == target.state.ioFalse || cond == target.state.ioNil)
                {
                    break;
                }
                m.async = sasync;
                result  = m.localsValueArgAt(locals, 1);
                if (target.state.handleStatus() != 0)
                {
                    goto done;
                }
            }
done:
            return(result);
        }
コード例 #8
0
        public void prompt(IoState state)
        {
            IoObject result = null;

            processBootstrap();
            while (true)
            {
                Console.Write("Io> ");
                string s = Console.ReadLine();
                if (s.Equals("quit") || s.Equals("exit"))
                {
                    break;
                }
                result = onDoCStringWithLabel(lobby, s, "prompt:");
                Console.Write("==> ");
                if (result != null)
                {
                    result.print();
                }
                else
                {
                    Console.WriteLine("why null?");
                }
                Console.WriteLine();
            }
        }
コード例 #9
0
ファイル: IoMessage.cs プロジェクト: ypyf/io
        // Message Public Raw Methods

        public static IoMessage newWithName(IoState state, IoSeq ioSymbol)
        {
            IoMessage msg = IoMessage.createObject(state);

            msg.messageName = ioSymbol;
            return(msg);
        }
コード例 #10
0
ファイル: IoSeq.cs プロジェクト: ChadSki/research-io
 public static IoString createObject(IoState state, string symbol)
 {
     IoString str = new IoString();
     str = str.clone(state) as IoString;
     str.value = symbol;
     return str;
 }
コード例 #11
0
ファイル: IoSeq.cs プロジェクト: devaspot/io
 public static IoSeq createObject(IoState state, string symbol)
 {
     IoSeq seq = new IoSeq();
     seq = seq.clone(state) as IoSeq;
     seq.value = symbol;
     return seq;
 }
コード例 #12
0
ファイル: IoCLR.cs プロジェクト: MilkTool/io-clr
        // Public methos

        public IoObject getType(IoState state, string typeName)
        {
            Type t = null;

            foreach (string s in this.usingNamespaces.Keys)
            {
                IoCLRAssembly asm = this.usingNamespaces[s] as IoCLRAssembly;
                t = asm.assembly.GetType(s + "." + typeName);
                if (t != null)
                {
                    IoCLRObject obj = IoCLRObject.createObject(state) as IoCLRObject;
                    obj.clrType     = t;
                    obj.clrInstance = null;
                    return(obj);
                }
            }
            if (t == null)
            {
                foreach (string s in this.loadedAssemblies.Keys)
                {
                    IoCLRAssembly asm = this.loadedAssemblies[s] as IoCLRAssembly;
                    t = asm.assembly.GetType(typeName);
                    if (t != null)
                    {
                        IoCLRObject obj = IoCLRObject.createObject(state) as IoCLRObject;
                        obj.clrType     = t;
                        obj.clrInstance = null;
                        return(obj);
                    }
                }
            }
            return(null);
        }
コード例 #13
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);
        }
コード例 #14
0
 public static IoSeq createSymbolInMachine(IoState state, string symbol)
 {
     if (state.symbols[symbol] == null)
     {
         state.symbols[symbol] = IoSeq.createObject(state, symbol);
     }
     return(state.symbols[symbol] as IoSeq);
 }
コード例 #15
0
        public static IoSeq createObject(IoState state, string symbol)
        {
            IoSeq seq = new IoSeq();

            seq       = seq.clone(state) as IoSeq;
            seq.value = symbol;
            return(seq);
        }
コード例 #16
0
ファイル: IoMessage.cs プロジェクト: ypyf/io
        IoMessage newWithNameReturnsValue(IoState state, IoSeq symbol, IoObject v)
        {
            IoMessage self = clone(state) as IoMessage;

            self.messageName  = symbol;
            self.cachedResult = v;
            return(self);
        }
コード例 #17
0
ファイル: IoCLR.cs プロジェクト: ChadSki/research-io
 public IoCLR(IoState state, string name)
 {
     isActivatable = true;
     this.state = state;
     createSlots();
     createProtos();
     uniqueId = 0;
 }
コード例 #18
0
ファイル: IoCLR.cs プロジェクト: MilkTool/io-clr
 public IoCLR(IoState state, string name)
 {
     isActivatable = true;
     this.state    = state;
     createSlots();
     createProtos();
     uniqueId = 0;
 }
コード例 #19
0
 public static IoSeq createSymbolInMachine(IoState state, string symbol)
 {
     if (!state.symbols.ContainsKey(symbol))
     {
         state.symbols[symbol] = IoSeq.createObject(state, symbol);
     }
     return(state.symbols[symbol]);
 }
コード例 #20
0
ファイル: IoMessage.cs プロジェクト: ypyf/io
        void parseName(IoState state, IoLexer lexer)
        {
            IoToken token = lexer.pop();

            messageName = IoSeq.createSymbolInMachine(state, token.name);
            ifPossibleCacheToken(token);
            //rawSetLineNumber(token.lineNumber);
            //rawSetCharNumber(token.charNumber);
        }
コード例 #21
0
ファイル: IoCFunction.cs プロジェクト: devaspot/io
 public IoCFunction(IoState state, string name, IoMethodFunc func)
 {
     isActivatable = true;
     this.state = state;
     createSlots();
     createProtos();
     uniqueId = 0;
     funcName = name;
     this.func = func;
 }
コード例 #22
0
ファイル: IoCFunction.cs プロジェクト: ypyf/io
 public IoCFunction(IoState state, string name, IoMethodFunc func)
 {
     isActivatable = true;
     this.state    = state;
     createSlots();
     createProtos();
     uniqueId  = 0;
     funcName  = name;
     this.func = func;
 }
コード例 #23
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;
     }
 }
コード例 #24
0
        public virtual IoObject proto(IoState state)
        {
            IoObject pro = new IoObject();

            pro.state = state;
            pro.createSlots();
            pro.createProtos();
            pro.uniqueId = 0;
            state.registerProtoWithFunc(name, new IoStateProto(pro.name, pro, new IoStateProtoFunc(pro.proto)));
            return(pro);
        }
コード例 #25
0
        public override IoObject clone(IoState state)
        {
            IoSeq proto  = state.protoWithInitFunc(name) as IoSeq;
            IoSeq result = new IoSeq();

            result.state = state;
            result.value = proto.value;
            result.createProtos();
            result.createSlots();
            result.protos.Add(proto);
            return(result);
        }
コード例 #26
0
ファイル: IoCLRObject.cs プロジェクト: devaspot/io
 public override IoObject clone(IoState state)
 {
     IoCLRObject proto = state.protoWithInitFunc(name) as IoCLRObject;
     IoCLRObject result = new IoCLRObject();
     result.isActivatable = true;
     uniqueIdCounter++;
     result.uniqueId = uniqueIdCounter;
     result.state = state;
     result.createProtos();
     result.createSlots();
     result.protos.Add(proto);
     return result;
 }
コード例 #27
0
ファイル: IoCLRObject.cs プロジェクト: ypyf/io
 public override IoObject clone(IoState state)
 {
     IoCLRObject proto = state.protoWithInitFunc(name) as IoCLRObject;
     IoCLRObject result = new IoCLRObject();
     result.isActivatable = true;
     uniqueIdCounter++;
     result.uniqueId = uniqueIdCounter;
     result.state = state;
     result.createProtos();
     result.createSlots();
     result.protos.Add(proto);
     return result;
 }
コード例 #28
0
ファイル: IoMessage.cs プロジェクト: ypyf/io
        IoMessage newFromTextLabelSymbol(IoState state, string code, IoSeq labelSymbol)
        {
            IoLexer   lexer = new IoLexer();
            IoMessage msg   = new IoMessage();

            msg     = msg.clone(state) as IoMessage;
            lexer.s = code;
            lexer.lex();
            msg = this.newParse(state, lexer);
            msg.opShuffle();
            msg.label = labelSymbol;
            return(msg);
        }
コード例 #29
0
ファイル: IoCoroutine.cs プロジェクト: redchew-fork/io
        public override IoObject clone(IoState state)
        {
            IoCoroutine proto  = state.protoWithInitFunc(name) as IoCoroutine;
            IoCoroutine result = new IoCoroutine();

            uniqueIdCounter++;
            result.uniqueId = uniqueIdCounter;
            result.tag      = proto.tag;
            result.createProtos();
            result.createSlots();
            result.protos.Add(proto);
            return(result);
        }
コード例 #30
0
        public virtual IoObject clone(IoState state)
        {
            IoObject proto = state.protoWithInitFunc(name);
            IoObject o     = Activator.CreateInstance(this.GetType()) as IoObject;

            uniqueIdCounter++;
            o.uniqueId = uniqueIdCounter;
            o.state    = proto.state;
            o.createSlots();
            o.createProtos();
            o.protos.Add(proto);
            cloneSpecific(this, o);
            return(o);
        }
コード例 #31
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);
        }
コード例 #32
0
ファイル: IoBlock.cs プロジェクト: MilkTool/io-clr
        // Call Public Raw Methods

        public override IoObject activate(IoObject sender, IoObject target, IoObject locals, IoMessage m, IoObject slotContext)
        {
            IoState state = sender.state;
            IoBlock self  = sender as IoBlock;

            IoObjectArrayList argNames = self.argNames;
            IoObject          scope    = self.scope;

            IoObject blockLocals = state.localsProto.clone(state);
            IoObject result      = null;
            IoObject callObject  = null;

            blockLocals.isLocals = true;

            if (scope == null)
            {
                scope = target;
            }

            blockLocals.createSlots();

            callObject = IoCall.with(state, locals, target, m, slotContext, self, null /*state.currentCoroutine*/);

            IoSeqObjectHashtable bslots = blockLocals.slots;

            bslots["call"]       = callObject;
            bslots["self"]       = scope;
            bslots["updateSlot"] = state.localsUpdateSlotCFunc;

            if (argNames != null)
            {
                for (int i = 0; i < argNames.Count; i++)
                {
                    IoSeq    name = argNames[i] as IoSeq;
                    IoObject arg  = m.localsValueArgAt(locals, i);
                    blockLocals.slots[name] = arg;
                }
            }

            if (self.containedMessage != null)
            {
                result = self.containedMessage.localsPerformOn(blockLocals, blockLocals);
            }

            if (self.passStops == IoCallStatus.MESSAGE_STOP_STATUS_NORMAL)
            {
            }

            return(result);
        }
コード例 #33
0
ファイル: IoList.cs プロジェクト: 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);
        }
コード例 #34
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);
        }
コード例 #35
0
        public IoObject localsProto(IoState state)
        {
            IoObject obj        = IoObject.createObject(state);
            IoObject firstProto = obj.protos[0] as IoObject;

            foreach (var key in firstProto.slots.Keys)
            {
                obj.slots[key] = firstProto.slots[key];
            }
            firstProto.protos.Clear();
            obj.slots["setSlot"]          = new IoCFunction(state, "setSlot", new IoMethodFunc(IoObject.slotSetSlot));
            obj.slots["setSlotWithType"]  = new IoCFunction(state, "setSlotWithType", new IoMethodFunc(IoObject.slotSetSlotWithType));
            obj.slots["updateSlot"]       = new IoCFunction(state, "updateSlot", new IoMethodFunc(IoObject.localsUpdateSlot));
            obj.slots["thisLocalContext"] = new IoCFunction(state, "thisLocalContext", new IoMethodFunc(IoObject.slotThisLocals));
            obj.slots["forward"]          = new IoCFunction(state, "forward", new IoMethodFunc(IoObject.slotLocalsForward));
            return(obj);
        }
コード例 #36
0
ファイル: IoCLRFunction.cs プロジェクト: redchew-fork/io
        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);
        }
コード例 #37
0
ファイル: IoCLRAssembly.cs プロジェクト: stangelandcl/io-clr
        public override IoObject proto(IoState state)
        {
            IoCLRAssembly pro = new IoCLRAssembly();
            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("namespaces", new IoMethodFunc(IoCLRAssembly.slotNamespaces)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
コード例 #38
0
ファイル: IoMap.cs プロジェクト: ChadSki/research-io
 public static new IoMap createProto(IoState state)
 {
     IoMap m = new IoMap();
     return m.proto(state) as IoMap;
 }
コード例 #39
0
ファイル: IoCLR.cs プロジェクト: ChadSki/research-io
 // Public methos
 public IoObject getType(IoState state, string typeName)
 {
     Type t = null;
     foreach (string s in this.usingNamespaces.Keys)
     {
         IoCLRAssembly asm = this.usingNamespaces[s] as IoCLRAssembly;
         t = asm.assembly.GetType(s + "." + typeName);
         if (t != null)
         {
             IoCLRObject obj = IoCLRObject.createObject(state) as IoCLRObject;
             obj.clrType = t;
             obj.clrInstance = null;
             return obj;
         }
     }
     if (t == null)
     {
         foreach (string s in this.loadedAssemblies.Keys)
         {
             IoCLRAssembly asm = this.loadedAssemblies[s] as IoCLRAssembly;
             t = asm.assembly.GetType(typeName);
             if (t != null)
             {
                 IoCLRObject obj = IoCLRObject.createObject(state) as IoCLRObject;
                 obj.clrType = t;
                 obj.clrInstance = null;
                 return obj;
             }
         }
     }
     return null;
 }
コード例 #40
0
ファイル: IoBlock.cs プロジェクト: stangelandcl/io-clr
 // Prototypes and Clone
 public static new IoBlock createProto(IoState state)
 {
     IoBlock number = new IoBlock();
     return number.proto(state) as IoBlock;
 }
コード例 #41
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;
        }
コード例 #42
0
ファイル: IoBlock.cs プロジェクト: stangelandcl/io-clr
        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;
        }
コード例 #43
0
ファイル: IoCLRAssembly.cs プロジェクト: stangelandcl/io-clr
 public static new IoCLRAssembly createObject(IoState state)
 {
     IoCLRAssembly cf = new IoCLRAssembly();
     return cf.proto(state).clone(state) as IoCLRAssembly;
 }
コード例 #44
0
ファイル: IoSeq.cs プロジェクト: ChadSki/research-io
 public static new IoString createObject(IoState state)
 {
     IoString s = new IoString();
     return s.clone(state) as IoString;
 }
コード例 #45
0
ファイル: IoCLR.cs プロジェクト: ChadSki/research-io
 public static new IoCLR createObject(IoState state)
 {
     IoCLR cf = new IoCLR();
     return cf.proto(state).clone(state) as IoCLR;
 }
コード例 #46
0
ファイル: Program.cs プロジェクト: stangelandcl/io-clr
 static void Main()
 {
     IoState state = new IoState();
     state.prompt(state);
 }
コード例 #47
0
ファイル: IoCLRObject.cs プロジェクト: devaspot/io
 public static new IoCLRObject createProto(IoState state)
 {
     IoCLRObject cf = new IoCLRObject();
     return cf.proto(state) as IoCLRObject;
 }
コード例 #48
0
ファイル: IoObject.cs プロジェクト: devaspot/io
 public IoSeqObjectHashtable(IoState s)
 {
     state = s;
 }
コード例 #49
0
ファイル: IoSeq.cs プロジェクト: ChadSki/research-io
 public static new IoString createProto(IoState state)
 {
     IoString s = new IoString();
     return s.proto(state) as IoString;
 }
コード例 #50
0
ファイル: IoCLRAssembly.cs プロジェクト: stangelandcl/io-clr
 public static new IoCLRAssembly createProto(IoState state)
 {
     IoCLRAssembly cf = new IoCLRAssembly();
     return cf.proto(state) as IoCLRAssembly;
 }
コード例 #51
0
ファイル: IoCLR.cs プロジェクト: ChadSki/research-io
        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;
        }
コード例 #52
0
ファイル: IoSeq.cs プロジェクト: ChadSki/research-io
        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;
        }
コード例 #53
0
ファイル: IoBlock.cs プロジェクト: stangelandcl/io-clr
 public static new IoBlock createObject(IoState state)
 {
     IoBlock number = new IoBlock();
     return number.clone(state) as IoBlock;
 }
コード例 #54
0
ファイル: IoSeq.cs プロジェクト: ChadSki/research-io
 public override IoObject clone(IoState state)
 {
     IoString proto = state.protoWithInitFunc(name) as IoString;
     IoString result = new IoString();
     result.state = state;
     result.value = proto.value;
     result.createProtos();
     result.createSlots();
     result.protos.Add(proto);
     return result;
 }
コード例 #55
0
ファイル: IoCLR.cs プロジェクト: ChadSki/research-io
 public static new IoCLR createProto(IoState state)
 {
     IoCLR cf = new IoCLR();
     return cf.proto(state) as IoCLR;
 }
コード例 #56
0
ファイル: IoCLRFunction.cs プロジェクト: devaspot/io
 public static new IoCLRFunction createProto(IoState state)
 {
     IoCLRFunction cf = new IoCLRFunction();
     return cf.proto(state) as IoCLRFunction;
 }
コード例 #57
0
ファイル: IoState.cs プロジェクト: stangelandcl/io-clr
        public void prompt(IoState state)
        {
            IoObject result = null;
            processBootstrap();
            while (true)
            {
                Console.Write("Io> ");
                string s = Console.ReadLine();
                if (s.Equals("quit") || s.Equals("exit")) break;
                result = onDoCStringWithLabel(lobby, s, "prompt:");
                Console.Write("==> ");
                if (result != null)
                    result.print();
                else Console.WriteLine("why null?");
                Console.WriteLine();

            }
        }
コード例 #58
0
ファイル: IoSeq.cs プロジェクト: ChadSki/research-io
 public static IoString createSymbolInMachine(IoState state, string symbol)
 {
     if (!state.symbols.ContainsKey(symbol))
         state.symbols[symbol] = IoString.createObject(state, symbol);
     return state.symbols[symbol];
 }
コード例 #59
0
ファイル: IoCLRFunction.cs プロジェクト: devaspot/io
 public static new IoCLRFunction createObject(IoState state)
 {
     IoCLRFunction cf = new IoCLRFunction();
     return cf.proto(state).clone(state) as IoCLRFunction;
 }
コード例 #60
0
ファイル: IoObject.cs プロジェクト: devaspot/io
 // 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;
 }