private static void LaunchRepl(IodineOptions options, IodineModule module = null) { string interpreterDir = Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location ); if (module != null) { foreach (KeyValuePair <string, IodineObject> kv in module.Attributes) { context.Globals [kv.Key] = kv.Value; } } string iosh = Path.Combine(interpreterDir, "tools", "iosh.id"); if (File.Exists(iosh) && !options.FallBackFlag) { EvalSourceUnit(options, SourceUnit.CreateFromFile(iosh)); } else { ReplShell shell = new ReplShell(context); shell.Run(); } }
/// <summary> /// Executes and loads an Iodine source file /// </summary> /// <returns>Last object evaluated during the execution of the file</returns> /// <param name="file">File path.</param> public dynamic DoFile(string file) { SourceUnit line = SourceUnit.CreateFromFile(file); module = line.Compile(Context); Context.Invoke(module, new IodineObject[] { }); return(null); }
private static void ExecuteOptions(IodineOptions options) { if (options.DebugFlag) { RunDebugServer(); } if (options.WarningFlag) { context.WarningFilter = WarningType.SyntaxWarning; } if (options.SupressWarningFlag) { context.WarningFilter = WarningType.None; } switch (options.InterpreterAction) { case InterpreterAction.Check: CheckIfFileExists(options.FileName); CheckSourceUnit(options, SourceUnit.CreateFromFile(options.FileName)); break; case InterpreterAction.ShowVersion: DisplayInfo(); break; case InterpreterAction.ShowHelp: DisplayUsage(); break; case InterpreterAction.EvaluateFile: CheckIfFileExists(options.FileName); EvalSourceUnit(options, SourceUnit.CreateFromFile(options.FileName)); break; case InterpreterAction.EvaluateArgument: EvalSourceUnit(options, SourceUnit.CreateFromSource(options.FileName)); break; case InterpreterAction.Repl: LaunchRepl(options); break; } }