Beispiel #1
0
 public void SetScriptFilename([PexAssumeUnderTest] AphidInterpreter target, string filename)
 {
     target.SetScriptFilename(filename);
     // TODO: add assertions to method AphidInterpreterTest.SetScriptFilename(AphidInterpreter, String)
 }
Beispiel #2
0
        private static void RunScript(string[] args)
        {
            if (!File.Exists(args[0]))
            {
                Console.WriteLine("Could not find {0}", args[0]);
                Environment.Exit(1);
            }

            var ext            = Path.GetExtension(args[0]).ToLower();
            var isTextDocument = ext == ".alxt";
            var file           = Path.GetFullPath(args[0]);
            var interpreter    = new AphidInterpreter();

            interpreter.SetScriptFilename(file);
            EnvironmentLibrary.SetEnvArgs(true);
            var result = true;

#if !APHID_DEBUGGING_ENABLED
            if (AphidConfig.Current.ScriptCaching)
            {
                var cache = new AphidByteCodeCache(interpreter.Loader.SearchPaths.ToArray())
                {
                    DisableConstantFolding = false,
                    InlineScripts          = true,
                };

                if (AphidErrorHandling.HandleErrors)
                {
                    result = AphidCli.TryAction(
                        interpreter,
                        () => AphidScript.Read(file),
                        () => interpreter.Interpret(cache.Read(file)),
                        allowErrorReporting: true);
                }
                else
                {
                    interpreter.Interpret(cache.Read(file));
                }
            }
            else
            {
#endif
            var code = AphidScript.Read(file);

            if (AphidErrorHandling.HandleErrors)
            {
                result = AphidCli.TryAction(
                    interpreter,
                    code,
                    () => interpreter.Interpret(code, file, isTextDocument),
                    allowErrorReporting: true);
            }
            else
            {
                interpreter.Interpret(code, file, isTextDocument);
            }

            if (interpreter.CurrentScope.ResolveBool(AphidName.OpenRepl))
            {
                new AphidRepl {
                    Interpreter = interpreter
                }.Run();
            }
#if !APHID_DEBUGGING_ENABLED
        }
#endif
            if (!result)
            {
                Environment.Exit(0xbad5230);
            }
        }