public static object Execute(LogoContext context, ICollection runlist, params object[] template_args) { string[] runlist_strs = new string[runlist.Count]; int i = 0; foreach (object o in runlist) { if (o is ICollection) { runlist_strs[i] = Funcs.ListToString((ICollection)o, 0, true); } else { runlist_strs[i] = o.ToString(); } i++; } Interpreter interp = new Interpreter((Interpreter)context.CallingEngine, context); interp.template_args = template_args; Parser parser = new Parser(interp.stores, null); parser.AllowQuestionMark = true; InstructionList tree = parser.Parse(runlist_strs); return(interp.Execute(tree)); }
public void Invoke(LogoContext context, ICollection arguments, ref object result) { // Debug (arguments); LogoContext cc = new LogoContext(context); Hashtable dict = cc.Dict; object[] arguments_list = new object[arguments.Count]; arguments.CopyTo(arguments_list, 0); int i = 0; foreach (ArgumentInfo info in args) { if (i < arguments_list.Length) { dict[info.name] = arguments_list[i]; } else if (info.val != null) { dict[info.name] = info.val; } i++; } // Collect remaining arguments if (args.Length > 0 && args[args.Length - 1].collect) { int col_len = arguments_list.Length - args.Length; if (col_len < 0) { col_len = 0; } object[] collector = new object[col_len]; if (col_len > 0) { Array.Copy(arguments_list, args.Length, collector, 0, col_len); } dict[args[args.Length - 1].name] = collector; } Interpreter interp = new Interpreter((Interpreter)context.CallingEngine, cc); result = interp.Execute(tree); }
public static object Execute (LogoContext context, ICollection runlist, params object[] template_args) { string[] runlist_strs = new string[runlist.Count]; int i = 0; foreach (object o in runlist) { if (o is ICollection) runlist_strs[i] = Funcs.ListToString ((ICollection) o, 0, true); else runlist_strs[i] = o.ToString (); i++; } Interpreter interp = new Interpreter ((Interpreter) context.CallingEngine, context); interp.template_args = template_args; Parser parser = new Parser (interp.stores, null); parser.AllowQuestionMark = true; InstructionList tree = parser.Parse (runlist_strs); return interp.Execute (tree); }
public void Invoke (LogoContext context, ICollection arguments, ref object result) { // Debug (arguments); LogoContext cc = new LogoContext (context); Hashtable dict = cc.Dict; object[] arguments_list = new object[arguments.Count]; arguments.CopyTo (arguments_list, 0); int i = 0; foreach (ArgumentInfo info in args) { if (i < arguments_list.Length) dict[info.name] = arguments_list[i]; else if (info.val != null) dict[info.name] = info.val; i++; } // Collect remaining arguments if (args.Length > 0 && args[args.Length - 1].collect) { int col_len = arguments_list.Length - args.Length; if (col_len < 0) col_len = 0; object[] collector = new object[col_len]; if (col_len > 0) Array.Copy (arguments_list, args.Length, collector, 0, col_len); dict[args[args.Length - 1].name] = collector; } Interpreter interp = new Interpreter ((Interpreter) context.CallingEngine, cc); result = interp.Execute (tree); }
private void Interpret (InstructionList tree) { Interpreter interp = new Interpreter (funcs); interp.Execute (tree); }
public static int Main (string[] args) { if (args.Length != 1) { Console.WriteLine ("Usage: test-interp.exe filename"); return 1; } IMessageStoreCollection stores = new IMessageStoreCollection (); stores.Add (new CTSMessageTarget (typeof (Funcs))); Parser parser = new Parser (stores, new LogoMessageTarget ()); FileStream stream = new FileStream (args[0], FileMode.Open); InstructionList tree = parser.Parse (new StreamReader (stream)); Interpreter interp = new Interpreter (stores); interp.Execute (tree); return 0; }
private void Interpret(InstructionList tree) { Interpreter interp = new Interpreter(funcs); interp.Execute(tree); }