public static object ActivateWithCallAndData(IokeObject receiver, IokeObject context, IokeObject message, object obj, object c, IDictionary <string, object> d1) { switch (receiver.data.type) { case IokeData.TYPE_DEFAULT_METHOD: return(DefaultMethod.ActivateWithCallAndDataFixed(receiver, context, message, obj, c, d1)); case IokeData.TYPE_DEFAULT_MACRO: return(DefaultMacro.ActivateWithCallAndDataFixed(receiver, context, message, obj, c, d1)); case IokeData.TYPE_DEFAULT_SYNTAX: return(DefaultSyntax.ActivateWithCallAndDataFixed(receiver, context, message, obj, c, d1)); case IokeData.TYPE_LEXICAL_MACRO: return(LexicalMacro.ActivateWithCallAndDataFixed(receiver, context, message, obj, c, d1)); case IokeData.TYPE_NATIVE_METHOD: return(NativeMethod.ActivateFixed(receiver, context, message, obj)); case IokeData.TYPE_METHOD_PROTOTYPE: return(Method.ActivateFixed(receiver, context, message, obj)); case IokeData.TYPE_LEXICAL_BLOCK: return(LexicalBlock.ActivateWithCallAndDataFixed(receiver, context, message, obj, c, d1)); case IokeData.TYPE_ALIAS_METHOD: return(AliasMethod.ActivateFixed(receiver, context, message, obj)); case IokeData.TYPE_NONE: default: return(IokeData.ActivateFixed(receiver, context, message, obj)); } }
public static object ActivateWithDataFixed(IokeObject self, IokeObject context, IokeObject message, object on, IDictionary <string, object> data) { DefaultMethod dm = (DefaultMethod)self.data; if (dm.code == null) { IokeObject condition = IokeObject.As(IokeObject.GetCellChain(context.runtime.Condition, message, context, "Error", "Invocation", "NotActivatable"), context).Mimic(message, context); condition.SetCell("message", message); condition.SetCell("context", context); condition.SetCell("receiver", on); condition.SetCell("method", self); condition.SetCell("report", context.runtime.NewText("You tried to activate a method without any code - did you by any chance activate the DefaultMethod kind by referring to it without wrapping it inside a call to cell?")); context.runtime.ErrorCondition(condition); return(null); } IokeObject c = context.runtime.Locals.Mimic(message, context); c.SetCell("self", on); c.SetCell("@", on); c.RegisterMethod(c.runtime.NewNativeMethod("will return the currently executing method receiver", new NativeMethod.WithNoArguments("@@", (method, _context, _message, _on, outer) => { outer.ArgumentsDefinition.GetEvaluatedArguments(_context, _message, _on, new SaneArrayList(), new SaneDictionary <string, object>()); return(self); }))); c.SetCell("currentMessage", message); c.SetCell("surroundingContext", context); foreach (var d in data) { string s = d.Key; c.SetCell(s.Substring(0, s.Length - 1), d.Value); } c.SetCell("super", CreateSuperCallFor(self, context, message, on, dm.name)); dm.arguments.AssignArgumentValues(c, context, message, on); try { return(context.runtime.interpreter.Evaluate(dm.code, c, on, c)); } catch (ControlFlow.Return e) { if (e.context == c) { return(e.Value); } else { throw e; } } }