상속: IoObject
예제 #1
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);
        }
예제 #2
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;
 }
예제 #3
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;
 }
예제 #4
0
파일: IoCLR.cs 프로젝트: MilkTool/io-clr
        public IoCLRObject getType(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 = new IoCLRObject();
                    obj.clrType     = t;
                    obj.clrInstance = null;
                }
            }
            return(null);
        }
예제 #5
0
파일: IoCLRObject.cs 프로젝트: ypyf/io
        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;
        }
예제 #6
0
 public IoCLRObject getType(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 = new IoCLRObject();
             obj.clrType = t;
             obj.clrInstance = null;
         }
     }
     return null;
 }
예제 #7
0
파일: IoCLRObject.cs 프로젝트: devaspot/io
 public static new IoCLRObject createProto(IoState state)
 {
     IoCLRObject cf = new IoCLRObject();
     return cf.proto(state) as IoCLRObject;
 }
예제 #8
0
파일: IoCLRObject.cs 프로젝트: devaspot/io
        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;
        }
예제 #9
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"));
        }
예제 #10
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);
        }
예제 #11
0
파일: IoCLRObject.cs 프로젝트: ypyf/io
 public new static IoCLRObject createObject(IoState state)
 {
     IoCLRObject cf = new IoCLRObject();
     return cf.proto(state).clone(state) as IoCLRObject;
 }
예제 #12
0
        public new static IoCLRObject createProto(IoState state)
        {
            IoCLRObject cf = new IoCLRObject();

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