public static Frame MEMap_for_each(Frame th, P6any lst, Func<Variable,Variable> fcn) { VarDeque iter = new VarDeque(Kernel.NewRWListVar(lst)); Frame fr = th.MakeChild(null, Kernel.CommonMEMap_I, Kernel.AnyP); fr.lexi0 = 0; fr.lex0 = new BatchSource(1, iter); fr.lex1 = new VarDeque(); fr.lex2 = fcn; return fr; }
public static Frame MEZip(Frame th, bool with, Variable[] pcl) { Frame fr = th.MakeChild(null, Kernel.CommonMEMap_I, Kernel.AnyP); Kernel.SetTopFrame(fr); fr.lexi0 = 0; fr.lex2 = ExtractWith(with, ref pcl); fr.lex0 = new ZipSource(pcl); fr.lex1 = new VarDeque(); return fr; }
public static Frame MEGrep(Frame th, Variable[] lst) { VarDeque iter = new VarDeque(lst); Variable fcn = iter.Shift(); iter = Kernel.IterFlatten(iter); Frame fr = th.MakeChild(null, Kernel.CommonGrep_I, Kernel.AnyP); fr.lexi0 = 0; fr.lex0 = iter; fr.lex1 = new VarDeque(); fr.lex2 = fcn; return fr; }
public static Frame MEMap(Frame th, Variable[] lst) { VarDeque iter = new VarDeque(lst); Variable fcn = iter.Shift(); P6any fcni = fcn.Fetch(); int arity = get_count(fcni); Frame fr = th.MakeChild(null, Kernel.CommonMEMap_I, Kernel.AnyP); fr.lexi0 = 0; fr.lex0 = new BatchSource(arity, iter); fr.lex1 = new VarDeque(); fr.lex2 = fcni; return fr; }
public Frame proto_dispatch(Frame th, Variable unused) { Frame nth = th.MakeChild(null, Lexer.StandardProtoSI, Kernel.AnyP); nth.pos = new Variable[] { MakeCursorV() }; return nth; }
public Frame list_common(bool eval, Frame th, Variable var) { VarDeque iter = Builtins.start_iter(var); List<object> toks = new List<object>(); List<LAD> lads = new List<LAD>(); NFA pad = new NFA(); pad.cursor_class = st.ns.klass; while (Kernel.IterHasFlat(iter, true)) { Variable svar = iter.Shift(); P6any sobj = svar.Fetch(); retry: if (sobj.Isa(Kernel.RegexMO)) { toks.Add(sobj); pad.outer_stack.Add(Kernel.GetOuter(sobj)); pad.info_stack.Add(Kernel.GetInfo(sobj)); lads.Add(pad.info_stack[0].ltm.Reify(pad)); pad.outer_stack.Clear(); pad.info_stack.Clear(); } else if (eval) { sobj = Builtins.compile_bind_regex(th, sobj.mo.mro_raw_Str.Get(svar)); svar = Kernel.NewROScalar(sobj); goto retry; } else { string str = sobj.mo.mro_raw_Str.Get(svar); toks.Add(str); lads.Add(new LADStr(str)); } } int[] cases = (new Lexer(pad, "array_var", lads.ToArray())). Run(global.orig_s, st.pos); Frame nth = th.MakeChild(null, ArrayHelperSI, Kernel.AnyP); nth.lex0 = MakeCursor(); nth.lex1 = toks; nth.lex2 = cases; return nth; }
public static Frame MECross(Frame th, bool with, Variable[] pcl) { var setting = th.info.setting; Frame fr = th.MakeChild(null, setting.CommonMEMap_I, setting.AnyP); Kernel.SetTopFrame(fr); fr.lexi0 = 0; fr.lex2 = ExtractWith(with, ref pcl); fr.lex0 = new CrossSource(pcl); fr.lex1 = new VarDeque(); return fr; }
public static Frame simple_eval(Frame th, Variable str) { if (up_domain == null) return Kernel.Die(th, "Cannot eval; no compiler available"); CrossDomainReceiver r = (CrossDomainReceiver) up_domain.CreateInstanceAndUnwrap("Kernel", "Niecza.UpCallee"); SubInfo outer = th.caller.info; string[] msg = r.Call(AppDomain.CurrentDomain, new string[] { "eval", str.Fetch().mo.mro_raw_Str.Get(str), (outer.unit == null ? "" : outer.unit.name), outer.xref_no.ToString() }); if (msg[0] != "") return Kernel.Die(th, msg[0]); return th.MakeChild(null, new SubInfo("boot-" + eval_result.Method.DeclaringType, eval_result), Kernel.AnyP); }
public Frame proto_dispatch(Frame th, Variable unused) { Frame nth = th.MakeChild(null, th.info.setting.StandardLexerSI, global.setting.AnyP); nth.pos = new Variable[] { MakeCursorV() }; return nth; }