public object ConvertToThis(object on, bool signalCondition, IokeObject message, IokeObject context) { if (on is IokeObject) { if (IokeObject.dataOf(on).GetType().Equals(data.GetType())) { return(on); } else { return(IokeObject.ConvertTo(this, on, signalCondition, IokeObject.dataOf(on).ConvertMethod, message, context)); } } else { if (signalCondition) { throw new System.Exception("oh no. -(: " + message.Name); } else { return(context.runtime.nul); } } }
public object ConvertTo(IokeObject self, object mimic, bool signalCondition, string conversionMethod, IokeObject message, IokeObject context) { if (IokeObject.IsMimic(self, IokeObject.As(mimic, context), context)) { return(self); } if (signalCondition) { IokeObject condition = IokeObject.As(IokeObject.GetCellChain(context.runtime.Condition, message, context, "Error", "Type", "IncorrectType"), context).Mimic(message, context); condition.SetCell("message", message); condition.SetCell("context", context); condition.SetCell("receiver", self); condition.SetCell("expectedType", mimic); object[] newCell = new object[] { self }; context.runtime.WithRestartReturningArguments(() => { context.runtime.ErrorCondition(condition); }, context, new IokeObject.UseValue("object", newCell)); return(IokeObject.ConvertTo(mimic, newCell[0], signalCondition, conversionMethod, message, context)); } return(null); }