public static void Callcc(Arguments args, VM vm, SourceInfo info) { IValueFunc func = args[0] as IValueFunc; if (func == null) { throw new RheaException( string.Format("function required, but got {0}", args[0]), info ); } ValueCont cont = vm.GetCont(); IList<IValue> newArgs = new List<IValue> { cont }; func.Call(newArgs, vm, info); }
public static void DynamicWind(Arguments args, VM vm, SourceInfo info) { ValueCont cont = vm.GetCont(); var winder = new KeyValuePair<IValue, IValue>(args[0], args[2]); var winders = SList.Cons(winder, vm.Winders); Stack<IInsn> insnStack = new Stack<IInsn>(); insnStack.Push(new InsnCall(0, info)); insnStack.Push(InsnPop.Instance); insnStack.Push(new InsnSetWinders(winders)); insnStack.Push(new InsnPush(args[1])); insnStack.Push(new InsnCall(0, info)); insnStack.Push(new InsnCall(1, info)); vm.Insns = insnStack.ToSList(); vm.Stack = SList.List<IValue>(args[0], cont); }