public CallFrame(CallSite callSite, iObject instance, ArgumentBundle arguments = null, CallFrame caller = null) { CallSite = callSite; Instance = instance; Caller = caller ?? Current; Arguments = arguments ?? new ArgumentBundle(); Locals = new LinkedDictionary <Symbol, LocalVariable>(); }
public iObject Call(iObject instance, params iObject[] arguments) { if (arguments.Length != ArgumentKinds.Count) { throw new ArgumentException( $"{MethodName}: Number of arguments ({arguments.Length}) doesn't match expected number ({ArgumentKinds.Count})." ); } var bundle = new ArgumentBundle(ArgumentKinds.Zip(arguments, (kind, arg) => (kind, arg))); CallFrame.Push(this, instance, bundle); try { try { return(CallCache.Call()); } catch (RecompilationRequiredException) { // caught while a method was being undefined. // give a second chance to recover (which will possibly call method_missing). return(CallCache.Call()); } } catch (Exception e) { if (!e.Data.Contains(RB_STACK_KEY)) { e.Data[RB_STACK_KEY] = CallFrame.Current; } throw; } catch (System.Exception e) { if (!e.Data.Contains(RB_STACK_KEY)) { e.Data[RB_STACK_KEY] = CallFrame.Current.CallSite.MethodName.Name; } throw; } finally { CallFrame.Pop(); } }
public static void Pop() => Current = Current?.Caller;
public static void Push(CallFrame other) { other.Caller = Current; Current = other; }
public static CallFrame Push(CallSite callSite, iObject instance, ArgumentBundle arguments = null) => Current = new CallFrame(callSite, instance, arguments);