Inheritance: IoObject
示例#1
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));
        }
示例#2
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);
        }
示例#3
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();
        }
示例#4
0
        // 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);
        }
示例#5
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));
        }
示例#6
0
        // Published Slots

        public new static 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);
        }
示例#7
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);
        }
示例#8
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"));
        }
示例#9
0
 // Prototypes and Clone
 public static new IoBlock createProto(IoState state)
 {
     IoBlock number = new IoBlock();
     return number.proto(state) as IoBlock;
 }
示例#10
0
 public static new IoBlock createObject(IoState state)
 {
     IoBlock number = new IoBlock();
     return number.clone(state) as IoBlock;
 }
示例#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 static IoObject slotBlock(IoObject target, IoObject locals, IoObject message)
 {
     return(IoBlock.slotBlock(target, locals, message));
 }
示例#13
0
        public new static IoBlock createObject(IoState state)
        {
            IoBlock number = new IoBlock();

            return(number.clone(state) as IoBlock);
        }
示例#14
0
        // Prototypes and Clone

        public new static IoBlock createProto(IoState state)
        {
            IoBlock number = new IoBlock();

            return(number.proto(state) as IoBlock);
        }