Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        // Published Slots

        public static IoObject slotUsing(IoObject target, IoObject locals, IoObject message)
        {
            IoCLR         self            = target as IoCLR;
            IoMessage     m               = message as IoMessage;
            IoSeq         nameSpace       = m.localsSymbolArgAt(locals, 0);
            bool          validNamespace  = false;
            IoCLRAssembly foundInAssembly = null;

            foreach (IoCLRAssembly asm in self.loadedAssemblies.Values)
            {
                if (asm.assemblyNamespaces[nameSpace.value] != null)
                {
                    validNamespace  = true;
                    foundInAssembly = asm;
                    break;
                }
            }
            if (!validNamespace)
            {
                Console.WriteLine("Namespace '{0}' is not valid.", nameSpace.value);
                return(self);
            }

            if (self.usingNamespaces[nameSpace.value] == null)
            {
                self.usingNamespaces[nameSpace.value] = foundInAssembly;
            }
            return(self);
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
Archivo: IoMessage.cs Proyecto: ypyf/io
        public static IoObject slotRemoveCachedResult(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage self = target as IoMessage;

            self.cachedResult = null;
            return(self);
        }
Ejemplo n.º 5
0
        public static IoObject slotCode(IoObject target, IoObject locals, IoObject m)
        {
            string  s    = "";
            IoBlock self = target as IoBlock;

            if (self.scope != null)
            {
                s += "block(";
            }
            else
            {
                s += "method(";
            }
            int nargs = self.argNames.Count;

            for (int i = 0; i < nargs; i++)
            {
                IoSeq name = self.argNames[i] as IoSeq;
                s += name.value + ", ";
            }

            IoMessage msg = self.containedMessage;
            IoSeq     seq = IoMessage.slotCode(msg, locals, m) as IoSeq;

            s += seq.value + ")";

            return(IoSeq.createObject(target.state, s));
        }
Ejemplo n.º 6
0
        public static IoObject slotSubstract(IoObject self, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoNumber  o = m.localsNumberArgAt(locals, 0);

            return(IoNumber.newWithDouble(self.state, -o.asDouble()));
        }
Ejemplo n.º 7
0
        public IoObject rawGetSlot(IoSeq slot)
        {
            IoObject context = null;
            IoObject v       = rawGetSlotContext(slot, out context);

            return(v);
        }
Ejemplo n.º 8
0
        public static IoObject localsUpdateSlot(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m        = message as IoMessage;
            IoSeq     slotName = m.localsSymbolArgAt(locals, 0);

            if (slotName == null)
            {
                return(target);
            }
            IoObject obj = target.rawGetSlot(slotName);

            if (obj != null)
            {
                IoObject slotValue = m.localsValueArgAt(locals, 1);
                target.slots[slotName.ToString()] = slotValue;
                return(slotValue);
            }
            else
            {
                IoObject theSelf = target.rawGetSlot(target.state.selfMessage.messageName);
                if (theSelf != null)
                {
                    return(theSelf.perform(theSelf, locals, m));
                }
            }
            return(target.state.ioNil);
        }
Ejemplo n.º 9
0
        public static IoObject slotGreaterThan(IoObject self, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoObject  o = m.localsValueArgAt(locals, 0);

            return(self.compare(o) > 0 ? self.state.ioTrue : self.state.ioFalse);
        }
Ejemplo n.º 10
0
Archivo: IoMessage.cs Proyecto: ypyf/io
        // Private Methods

        void localsNumberArgAtErrorForType(IoObject locals, int i, string p)
        {
            IoObject v = localsValueArgAt(locals, i);

            Console.WriteLine("argument {0} to method '{1}' must be a {2}, not a '{3}'",
                              i, this.messageName, p, v.name);
        }
Ejemplo n.º 11
0
        public static IoObject slotCurrentCoroutine(IoObject target, IoObject locals, IoObject message)
        {
            //~//return target.tag.state.currentCoroutine;
            IoCoroutine self = target as IoCoroutine;

            return(self);
        }
Ejemplo n.º 12
0
        public IoObject processBootstrap()
        {
            string[] ios = null;
            try
            {
                ios = Directory.GetFiles("../io/bootstrap");
            }
            catch {
            }
            if (ios == null || ios.Length == 0)
            {
                Console.WriteLine("Bootstrap not found. Processing raw Io.");
                return(null);
            }
            else
            {
                Console.WriteLine("Bootstrap successfully loaded.");
            }
            ArrayList iosa = new ArrayList(ios);

            iosa.Sort();
            IoObject result = null;

            foreach (string s in iosa)
            {
                result = loadFile(s);
            }
            return(result);
        }
Ejemplo n.º 13
0
        // Published Slots

        public static IoObject slotCompare(IoObject self, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoObject  o = m.localsValueArgAt(locals, 0);

            return(IoNumber.newWithDouble(self.state, Convert.ToDouble(self.compare(o))));
        }
Ejemplo n.º 14
0
        public override IoObject activate(IoObject self, IoObject target, IoObject locals, IoMessage m, IoObject slotContext)
        {
            IoCLRFunction method = self as IoCLRFunction;
            IoCLRObject obj = target as IoCLRObject;
            object result = null;

            object[] parameters = new object[method.evaluatedParameters.Count];
            for (int i = 0; i < method.evaluatedParameters.Count; i++)
            {
                IoObject ep = method.evaluatedParameters[i] as IoObject;
                switch (ep.name)
                {
                    case "Object": parameters[i] = ep; break;
                    case "Number":
                        {
                            IoNumber num = ep as IoNumber;
                            if (num.isInteger)
                            {
                                parameters[i] = num.longValue;
                            }
                            else
                            {
                                parameters[i] = num.doubleValue;
                            }

                        }
                        break;
                    case "Sequence": parameters[i] = (ep as IoSeq).value; break;
                    case "CLRObject": parameters[i] = (ep as IoCLRObject).clrInstance; break;
                }

            }

            IoCLRObject clr = IoCLRObject.createObject(self.state);

            try
            {
                if (method.methodInfo is ConstructorInfo)
                {
                    ConstructorInfo ci = method.methodInfo as ConstructorInfo;
                    result = ci.Invoke(parameters);
                }
                else if (method.methodInfo is MethodInfo)
                {
                    MethodInfo mi = method.methodInfo as MethodInfo;
                    result = mi.Invoke(obj.clrInstance, parameters);
                }
                clr.clrType = result != null ? result.GetType() : null;
                clr.clrInstance = result;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                clr.clrType = null;
                clr.clrInstance = null;
            }

            return clr;
        }
Ejemplo n.º 15
0
 public override int compare(IoObject v)
 {
     if (v is IoSeq)
     {
         return(this.value.CompareTo((v as IoSeq).value));
     }
     return(base.compare(v));
 }
Ejemplo n.º 16
0
Archivo: IoMessage.cs Proyecto: ypyf/io
        IoMessage newWithNameReturnsValue(IoState state, IoSeq symbol, IoObject v)
        {
            IoMessage self = clone(state) as IoMessage;

            self.messageName  = symbol;
            self.cachedResult = v;
            return(self);
        }
Ejemplo n.º 17
0
Archivo: IoMessage.cs Proyecto: ypyf/io
        public static IoObject slotSetCachedResult(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage self = target as IoMessage;
            IoMessage msg  = message as IoMessage;

            self.cachedResult = msg.localsValueArgAt(locals, 0);
            return(self);
        }
Ejemplo n.º 18
0
Archivo: IoMessage.cs Proyecto: ypyf/io
        public static IoObject slotCode(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage self = target as IoMessage;
            string    s    = "";

            s = self.descriptionToFollow(true);
            return(IoSeq.createObject(self.state, s));
        }
Ejemplo n.º 19
0
 public static IoObject slotAt(IoObject target, IoObject locals, IoObject message)
 {
     IoMessage m = message as IoMessage;
     IoNumber ind = m.localsNumberArgAt(locals, 0);
     IoList o = target as IoList;
     IoObject v = o.list[ind.asInt()] as IoObject;
     return v == null ? target.state.ioNil : v;
 }
Ejemplo n.º 20
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;
 }
Ejemplo n.º 21
0
 public override IoObject activate(IoObject self, IoObject target, IoObject locals, IoMessage m, IoObject slotContext)
 {
     if (func == null)
     {
         return(self);
     }
     return(func(target, locals, m));
 }
Ejemplo n.º 22
0
        public IoObject onDoCStringWithLabel(IoObject target, string code, string label)
        {
            IoMessage msg = new IoMessage();

            msg = msg.clone(this) as IoMessage;
            msg = msg.newFromTextLabel(this, code, label);
            return(msg.localsPerformOn(target, target));
        }
Ejemplo n.º 23
0
        public static IoObject slotGetSlot(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m        = message as IoMessage;
            IoSeq     slotName = m.localsSymbolArgAt(locals, 0);
            IoObject  slot     = target.rawGetSlot(slotName);

            return(slot == null ? target.state.ioNil : slot);
        }
Ejemplo n.º 24
0
        public static IoObject slotRound(IoObject target, IoObject locals, IoObject message)
        {
            IoNumber self = target as IoNumber;

            return(IoNumber.newWithDouble(target.state,
                                          Math.Round(self.isInteger ? self.longValue : self.doubleValue)
                                          ));
        }
Ejemplo n.º 25
0
 public static IoObject slotGetType(IoObject target, IoObject locals, IoObject message)
 {
     IoCLR self = target as IoCLR;
     IoMessage m = message as IoMessage;
     IoString typeName = m.localsSymbolArgAt(locals, 0);
     IoObject obj = self.getType(target.state, typeName.value);
     return obj == null ? target.state.ioNil : obj;
 }
Ejemplo n.º 26
0
        public static IoObject slotReturn(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoObject  v = m.localsValueArgAt(locals, 0);

            target.state.Return(v);
            return(target);
        }
Ejemplo n.º 27
0
 public static new IoObject slotBlock(IoObject target, IoObject locals, IoObject m)
 {
     IoBlock self = target as IoBlock;
     self = IoBlock.slotMethod(target, locals, m) as IoBlock;
     self.scope = locals;
     self.isActivatable = false;
     return self;
 }
Ejemplo n.º 28
0
        // setSlot("A", 32.45 + (20*(5836 log10)) + (20*(8.5 log10)))
        // !link-budget 22 0 13 126.3606841787141377 8 0

        public static IoObject slotLog2(IoObject target, IoObject locals, IoObject message)
        {
            // IoNumber other = (message as IoMessage).localsNumberArgAt(locals, 0);
            IoNumber self = target as IoNumber;

            return(IoNumber.newWithDouble(target.state,
                                          Math.Log(self.isInteger ? self.longValue : self.doubleValue, 2)));
        }
Ejemplo n.º 29
0
        public IoCLRFunction getMethod(IoMessage message)
        {
            string methodName = message.messageName.value;

            if (clrType == null)
            {
                return(null);
            }
            ConstructorInfo[] searchConstructors = null;
            Type[]            parameters         = null;
            ArrayList         args = null;
            MethodBase        mb   = null;

            args       = new ArrayList();
            parameters = new Type[message.args.Count];

            for (int i = 0; i < message.args.Count; i++)
            {
                IoObject o = message.localsValueArgAt(message, i);
                args.Add(o);
                Type t = null;
                switch (o.name)
                {
                case "Number": t = typeof(double); break;

                case "Object": t = typeof(object); break;

                case "CLRObject": t = (o as IoCLRObject).clrType; break;

                case "Sequence": t = typeof(string); break;
                }
                parameters[i] = t;
            }

            if (methodName.Equals("new"))
            {
                searchConstructors = this.clrType.GetConstructors();
                if (searchConstructors.Length > 0)
                {
                    mb = searchConstructors[0];
                }
            }
            else
            {
                try
                {
                    mb = this.clrType.GetMethod(methodName, parameters);
                }
                catch { }
            }

            IoCLRFunction clrFunction = IoCLRFunction.createObject(this.state);

            clrFunction.methodInfo          = mb;
            clrFunction.parametersTypes     = parameters;
            clrFunction.evaluatedParameters = args;
            return(clrFunction);
        }
Ejemplo n.º 30
0
        public static IoObject slotClone(IoObject target, IoObject locals, IoObject m)
        {
            //IoObject newObject = target.tag.cloneFunc(target.state);
            IoObject newObject = target.clone(target.state);

            //newObject.protos.Clear();
            newObject.protos.Add(target);
            return(target.initClone(target, locals, m as IoMessage, newObject));
        }
Ejemplo n.º 31
0
        public override void cloneSpecific(IoObject _from, IoObject _to)
        {
            IoBlock to   = _to as IoBlock;
            IoBlock from = _from as IoBlock;

            to.isActivatable    = from.isActivatable;
            to.containedMessage = from.containedMessage;
            to.argNames         = new IoObjectArrayList();
        }
Ejemplo n.º 32
0
        public new static IoObject slotBlock(IoObject target, IoObject locals, IoObject m)
        {
            IoBlock self = target as IoBlock;

            self               = IoBlock.slotMethod(target, locals, m) as IoBlock;
            self.scope         = locals;
            self.isActivatable = false;
            return(self);
        }
Ejemplo n.º 33
0
        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);
        }
Ejemplo n.º 34
0
        public static IoObject slotGetType(IoObject target, IoObject locals, IoObject message)
        {
            IoCLR     self     = target as IoCLR;
            IoMessage m        = message as IoMessage;
            IoSeq     typeName = m.localsSymbolArgAt(locals, 0);
            IoObject  obj      = self.getType(target.state, typeName.value);

            return(obj == null ? target.state.ioNil : obj);
        }
Ejemplo n.º 35
0
        public IoObject loadFile(string fileName)
        {
            StreamReader sr     = new StreamReader(fileName);
            IoObject     result = null;
            string       s      = sr.ReadToEnd();

            result = onDoCStringWithLabel(lobby, s, fileName);
            return(result);
        }
Ejemplo n.º 36
0
 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;
 }
Ejemplo n.º 37
0
 public static IoObject slotAdd(IoObject target, IoObject locals, IoObject message)
 {
     IoNumber other = (message as IoMessage).localsNumberArgAt(locals, 0);
     IoNumber self = target as IoNumber;
     if (other == null) return self;
     return IoNumber.newWithDouble(target.state,
         (self.isInteger ? self.longValue : self.doubleValue) +
         (other.isInteger ? other.longValue : other.doubleValue)
             );
 }
Ejemplo n.º 38
0
 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.state.ioFalse;
     }
     return dict.state.ioTrue;
 }
Ejemplo n.º 39
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.tag.state.ioFalse;
     }
     return dict.tag.state.ioTrue;
 }
Ejemplo n.º 40
0
 // published slots
 public static IoObject slotNamespaces(IoObject target, IoObject locals, IoObject message)
 {
     IoCLRAssembly self = target as IoCLRAssembly;
     IoMessage m = message as IoMessage;
     foreach (string s in self.assemblyNamespaces.Keys)
     {
         Console.Write(s + " ");
     }
     Console.WriteLine();
     return self;
 }
Ejemplo n.º 41
0
 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.state.ioNil : result;
 }
Ejemplo n.º 42
0
 public static IoObject slotMain(IoObject target, IoObject locals, IoObject message)
 {
     IoCoroutine self = target as IoCoroutine;
     //IoObject runTarget = self.rawRunTarget();
     //IoObject runLocals = self.rawRunLocals();
     //IoMessage runMessage = self.rawRunMessage() as IoMessage;
     //if (runLocals != null && runMessage != null && runTarget != null)
     //    runMessage.localsPerformOn(runTarget, runLocals);
     //else
     //    Console.WriteLine("Coroutine 'main' missed needed parameters");
     return self.tag.state.ioNil;
 }
Ejemplo n.º 43
0
        public static IoObject slotAppend(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoList o = target as IoList;

            for (int i = 0; i < m.args.Count; i++)
            {
                IoObject obj = m.localsValueArgAt(locals, i);
                o.list.Add(obj);
            }
            return o;
        }
Ejemplo n.º 44
0
        public static IoObject slotAppendStr(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m = message as IoMessage;
            IoList o = target as IoList;

            for (int i = 0; i < m.args.Count; i++)
            {
                IoList obj = m.localsValueArgAt(locals, i) as IoList;
                for (int j = 0; j < obj.list.Count; j++)
                {
                    IoObject v = obj.list[j] as IoObject;
                    o.list.Add(v);
                }
            }
            return o;
        }
Ejemplo n.º 45
0
        public static IoObject slotLoadAssembly(IoObject target, IoObject locals, IoObject message)
        {
            IoCLR self = target as IoCLR;
            IoMessage m = message as IoMessage;
            IoString assemblyName = m.localsSymbolArgAt(locals, 0);
            IoCLRAssembly asm = self.loadedAssemblies[assemblyName.value] as IoCLRAssembly;
            if (asm != null)
            {
                return asm;
            }

            asm = IoCLRAssembly.createObject(target.state);

            asm.assembly = Assembly.LoadWithPartialName(assemblyName.value);
            if (asm.assembly == null) return self;

            self.loadedAssemblies[assemblyName.value] = asm;

            asm.assemblyTypes = asm.assembly.GetTypes();
            asm.assemblyNamespaces = new Hashtable();
            foreach (Type t in asm.assemblyTypes)
            {
                string theNameSpace = t.FullName.LastIndexOf(".") == -1 ? "-" : t.FullName.Substring(0, t.FullName.LastIndexOf("."));
                string theClass = t.FullName.LastIndexOf(".") == -1 ? t.FullName : t.FullName.Substring(t.FullName.LastIndexOf(".") + 1);
                //if (theClass.Equals("Form"))
                //{
                //    int i = 0;
                //}
                if (asm.assemblyNamespaces.ContainsKey(theNameSpace))
                {
                    Hashtable a = asm.assemblyNamespaces[theNameSpace] as Hashtable;
                    a[theClass] = t;
                }

                else
                {
                    Hashtable classes = new Hashtable();
                    classes[theClass] = t;
                    asm.assemblyNamespaces[theNameSpace] = classes;
                }

            }
            return asm;
        }
Ejemplo n.º 46
0
        public static IEnumerator asyncCall(IoContext ctx, IoObject future)
        {
            IoObject target = ctx.target;
            IoObject locals = ctx.locals;
            IoObject result = target;
            IoObject cachedTarget = target;
            IoMessage msg = ctx.message;
            IoObject savedPrevResultAsYieldResult = null;

            do
            {
                if (msg.messageName.Equals(msg.state.semicolonSymbol))
                {
                    target = cachedTarget;
                }
                else
                {
                    result = msg.cachedResult;
                    if (result == null)
                    {
                        if (msg.messageName.value.Equals("yield"))
                        {
                            yield return result;
                        }
                        else
                        {
                            result = target.perform(target, locals, msg);
                        }
                    }
                    if (result == null)
                    {
                        result = savedPrevResultAsYieldResult;
                    }
                    target = result;
                    savedPrevResultAsYieldResult = result;
                }
            } while ((msg = msg.next) != null);
            future.slots["future"] = result;
            yield return null;
            //yield return result;
        }
Ejemplo n.º 47
0
        public static IoObject slotCode(IoObject target, IoObject locals, IoObject m)
        {
            string s = "";
            IoBlock self = target as IoBlock;
            if (self.scope != null)
                s += "block(";
            else
                s += "method(";
            int nargs = self.argNames.Count;
            for (int i = 0; i < nargs; i++)
            {
                IoSeq name = self.argNames[i] as IoSeq;
                s += name.value + ", ";
            }

            IoMessage msg = self.containedMessage;
            IoSeq seq = IoMessage.slotCode(msg, locals, m) as IoSeq;
            s += seq.value + ")";

            return IoSeq.createObject(target.state, s);
        }
Ejemplo n.º 48
0
        // Published Slots
        public static new IoObject slotMethod(IoObject target, IoObject locals, IoObject message)
        {
            IoState state = target.state;
            IoBlock self = IoBlock.createObject(state);
            IoMessage m = message as IoMessage;
            int nargs = m.args.Count;
            IoMessage lastArgAsMessage = (nargs > 0) ? m.rawArgAt(nargs - 1) : state.nilMessage;
            int i;

            self.containedMessage = lastArgAsMessage;
            self.isActivatable = true;

            for (i = 0; i < nargs - 1; i ++)
            {
                IoMessage argMessage = m.rawArgAt(i);
                IoSeq name = argMessage.messageName;
                self.argNames.Add(name);
            }

            return self;
        }
Ejemplo n.º 49
0
 public static IoObject localsUpdateSlot(IoObject target, IoObject locals, IoObject message)
 {
     IoMessage m = message as IoMessage;
     IoSeq slotName = m.localsSymbolArgAt(locals, 0);
     if (slotName == null) return target;
     IoObject obj = target.rawGetSlot(slotName);
     if (obj != null)
     {
         IoObject slotValue = m.localsValueArgAt(locals, 1);
         target.slots[slotName] = slotValue;
         return slotValue;
     }
     else
     {
         IoObject theSelf = target.rawGetSlot(target.state.selfMessage.messageName);
         if (theSelf != null)
         {
             return theSelf.perform(theSelf, locals, m);
         }
     }
     return target.state.ioNil;
 }
Ejemplo n.º 50
0
        //public object Yield()
        //{
        //    yield return null;
        //}
        public static IoObject slotResume(IoObject target, IoObject locals, IoObject message)
        {
            IoCoroutine self = target as IoCoroutine;
            //object ret = null;

            //if (self.fiber != null)
            //{
            //    IoCoroutine current = target.tag.state.currentCoroutine;
            //    target.tag.state.currentCoroutine = self;
            //    ret = self.fiber.Resume();
            //    //if (ret == null)
            //    //{
            //    //    Console.WriteLine("Fiber Exceeds on " + self.fiber.uniqueId);
            //    //    throw new Exception("Can't resume Fiber");
            //    //}
            //}
            //else
            //{
            //    IoCoroutine.slotRun(self, null, null);
            //}

            return self;
        }
Ejemplo n.º 51
0
 public static IoObject slotEmpty(IoObject target, IoObject locals, IoObject m)
 {
     IoMap dict = target as IoMap;
     if (dict.map != null) dict.map.Clear();
     return target;
 }
Ejemplo n.º 52
0
        public void setupSingletons()
        {
            ioNil = objectProto.clone(this);
            ioNil.slots["type"] = IOSYMBOL("nil");
            core.slots["nil"] = ioNil;

            ioTrue = IoObject.createObject(this);
            ioTrue.slots["type"] = IOSYMBOL("true");
            core.slots["true"] = ioTrue;

            ioFalse = IoObject.createObject(this);
            ioFalse.slots["type"] = IOSYMBOL("false");
            core.slots["false"] = ioFalse;
        }
Ejemplo n.º 53
0
 public void Return(IoObject v)
 {
     stopStatus = IoStopStatus.MESSAGE_STOP_STATUS_RETURN;
     returnValue = v;
 }
Ejemplo n.º 54
0
 public IoObject onDoCStringWithLabel(IoObject target, string code, string label)
 {
     IoMessage msg = new IoMessage();
     msg = msg.clone(this) as IoMessage;
     msg = msg.newFromTextLabel(this, code, label);
     return msg.localsPerformOn(target, target);
 }
Ejemplo n.º 55
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"));
        }
Ejemplo n.º 56
0
 public override void cloneSpecific(IoObject from, IoObject to)
 {
     to.isActivatable = true;
 }
Ejemplo n.º 57
0
 public override IoObject activate(IoObject self, IoObject target, IoObject locals, IoMessage m, IoObject slotContext)
 {
     return self;
 }
Ejemplo n.º 58
0
        // Published Slots
        public static IoObject slotUsing(IoObject target, IoObject locals, IoObject message)
        {
            IoCLR self = target as IoCLR;
            IoMessage m = message as IoMessage;
            IoString nameSpace = m.localsSymbolArgAt(locals, 0);
            bool validNamespace = false;
            IoCLRAssembly foundInAssembly = null;
            foreach (IoCLRAssembly asm in self.loadedAssemblies.Values)
            {
                if (asm.assemblyNamespaces[nameSpace.value] != null)
                {
                    validNamespace = true;
                    foundInAssembly = asm;
                    break;
                }
            }
            if (!validNamespace)
            {
                Console.WriteLine("Namespace '{0}' is not valid.", nameSpace.value);
                return self;
            }

            if (self.usingNamespaces[nameSpace.value] == null)
                self.usingNamespaces[nameSpace.value] = foundInAssembly;
            return self;
        }
Ejemplo n.º 59
0
 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;
 }
Ejemplo n.º 60
0
 public override void cloneSpecific(IoObject from, IoObject to)
 {
     (to as IoMap).map = (from as IoMap).map.Clone() as Hashtable;
 }