public localsValueArgAt ( |
||
locals | ||
i | int | |
Результат |
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); }
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); }
public static IoObject slotAtIfAbsentPut(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; if (dict.lookupMap(key) == null) { dict.map[key.ToString()] = value; } return(target); }
public static IoObject slotIf(IoObject target, IoObject locals, IoObject message) { IoMessage m = message as IoMessage; IoObject r = m.localsValueArgAt(locals, 0); bool condition = r != target.state.ioNil && r != target.state.ioFalse; int index = condition ? 1 : 2; if (index < m.args.Count) { return(m.localsValueArgAt(locals, index)); } return(condition ? target.state.ioTrue : target.state.ioFalse); }
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.tag.state.ioNil : result); }
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); }
// 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)))); }
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); }
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); }
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); }
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); }
public static IoObject slotDoMessage(IoObject self, IoObject locals, IoObject m) { IoMessage msg = m as IoMessage; IoMessage aMessage = msg.localsMessageArgAt(locals, 0) as IoMessage; IoObject context = self; if (msg.args.Count >= 2) { context = msg.localsValueArgAt(locals, 1); } return(aMessage.localsPerformOn(context, self)); }
public static IoObject slotWith(IoObject target, IoObject locals, IoObject message) { IoMessage m = message as IoMessage; IoList o = IoList.createObject(target.state) as IoList; for (int i = 0; i < m.args.Count; i++) { IoObject obj = m.localsValueArgAt(locals, i); o.list.Add(obj); } return(o); }
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.tag.state.ioFalse); } return(dict.tag.state.ioTrue); }
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.state.ioFalse); } return(dict.state.ioTrue); }
public static IoObject slotSetSlot(IoObject target, IoObject locals, IoObject message) { IoMessage m = message as IoMessage; IoSeq slotName = m.localsSymbolArgAt(locals, 0); IoObject slotValue = m.localsValueArgAt(locals, 1); if (slotName == null) { return(target); } target.slots[slotName.ToString()] = slotValue; return(slotValue); }
public static IoObject slotSetSlotWithType(IoObject target, IoObject locals, IoObject message) { IoMessage m = message as IoMessage; IoSeq slotName = m.localsSymbolArgAt(locals, 0); IoObject slotValue = m.localsValueArgAt(locals, 1); target.slots[slotName] = slotValue; if (slotValue.slots[target.state.typeSymbol] == null) { slotValue.slots[target.state.typeSymbol] = slotName; } return(slotValue); }
public static IoObject slotSetSlotWithType(IoObject target, IoObject locals, IoObject message) { IoMessage m = message as IoMessage; IoSeq slotName = m.localsSymbolArgAt(locals, 0); IoObject slotValue = m.localsValueArgAt(locals, 1); target.slots[slotName.ToString()] = slotValue; if (!slotValue.slots.ContainsKey(target.state.typeSymbol)) { slotValue.slots[target.state.typeSymbol.ToString()] = slotName; } return(slotValue); }
// 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); }
public static IoObject slotAppendSeq(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); }
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)); }
public static IoObject slotUpdateSlot(IoObject target, IoObject locals, IoObject message) { IoMessage m = message as IoMessage; IoSeq slotName = m.localsSymbolArgAt(locals, 0); IoObject slotValue = m.localsValueArgAt(locals, 1); if (slotName == null) { return(target); } if (target.rawGetSlot(slotName) != null) { target.slots[slotName.ToString()] = slotValue; } else { Console.WriteLine("Slot {0} not found. Must define slot using := operator before updating.", slotName.value); } return(slotValue); }
public static IoObject slotEevalArg(IoObject target, IoObject locals, IoObject message) { IoMessage m = message as IoMessage; return(m.localsValueArgAt(locals, 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; }
// 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; }
public static IEnumerator <IoObject> slotAsyncWhile(IoObject target, IoObject locals, IoObject message, IoObject future) { IoMessage m = message as IoMessage; IoObject result = target.state.ioNil; IoObject cond = null; while (true) { cond = m.localsValueArgAt(locals, 0); //evaluateArgs(m, new EvaluateArgsEventArgs(0), out cond); if (cond == target.state.ioFalse || cond == target.state.ioNil) { break; } //result = m.localsValueArgAt(locals, 1); //evaluateArgs(m, new EvaluateArgsEventArgs(1), out result); IoMessage msg = 1 < m.args.Count ? m.args[1] as IoMessage : null; if (msg != null) { if (msg.cachedResult != null && msg.next == null) { result = msg.cachedResult; yield return(result); } //result = localMessage.localsPerformOn(locals, locals); result = target; IoObject cachedTarget = target; 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) { target = cachedTarget; //result = savedPrevResultAsYieldResult; } else { target = result; } savedPrevResultAsYieldResult = result; } } while ((msg = msg.next) != null); future.slots["future"] = result; yield return(null); } result = m.state.ioNil; if (target.state.handleStatus() != 0) { goto done; } } done: yield return(null); }