public override IP5Any Clone(Runtime runtime, int depth) { P5Array clone = new P5Array(runtime, array.Count); if (depth > 0) { foreach (var i in array) { var enumerable = i as IP5Enumerable; if (enumerable != null) clone.PushFlatten(runtime, i); else clone.Push(runtime, i.Clone(runtime, depth - 1)); } } else foreach (var i in array) clone.PushFlatten(runtime, i); return clone; }
public void Run(Runtime runtime, string[] args) { P5Array argv = new P5Array(parser_runtime); foreach (var arg in args) argv.Push(parser_runtime, new P5Scalar(parser_runtime, arg)); P5Array arglist_new = new P5Array(parser_runtime, new P5Scalar(parser_runtime, "Language::P"), new P5Scalar(parser_runtime, argv), GetInit(runtime)); try { var p = arglist_new.CallMethod(parser_runtime, Opcode.ContextValues.SCALAR, "new_from_argv"); P5Array arglist_run = new P5Array(parser_runtime, p); arglist_run.CallMethod(parser_runtime, Opcode.ContextValues.VOID, "run"); } catch (System.Reflection.TargetInvocationException te) { var e = te.InnerException as P5Exception; if (e == null) throw te; else throw FixupException(e); } catch (P5Exception e) { throw FixupException(e); } }