PartialReset() public static method

public static PartialReset ( ) : void
return void
Beispiel #1
0
        void Reset()
        {
            CompilerCallableEntryPoint.PartialReset();

            Location.Reset();
            Location.Initialize(ctx.SourceFiles);
        }
Beispiel #2
0
        static void Reset()
        {
            CompilerCallableEntryPoint.PartialReset();

            //
            // PartialReset should not reset the core types, this is very redundant.
            //
            if (!TypeManager.InitCoreTypes())
            {
                throw new Exception("Failed to InitCoreTypes");
            }
            TypeManager.InitOptionalCoreTypes();

            Location.AddFile("{interactive}");
            Location.Initialize();

            current_debug_name = "interactive" + (count++) + ".dll";
            if (Environment.GetEnvironmentVariable("SAVE") != null)
            {
                CodeGen.Init(current_debug_name, current_debug_name, false);
            }
            else
            {
                CodeGen.InitDynamic(current_debug_name);
            }
        }
Beispiel #3
0
        static void Reset()
        {
            CompilerCallableEntryPoint.PartialReset();

            // Workaround for API limitation where full message printer cannot be passed
            ReportPrinter printer = MessageOutput == Console.Out || MessageOutput == Console.Error ?
                                    new ConsoleReportPrinter(MessageOutput) :
                                    new StreamReportPrinter(MessageOutput);

            ctx = new CompilerContext(new Report(printer));
            RootContext.ToplevelTypes = new ModuleContainer(ctx, true);

            //
            // PartialReset should not reset the core types, this is very redundant.
            //
            if (!TypeManager.InitCoreTypes(ctx))
            {
                throw new Exception("Failed to InitCoreTypes");
            }
            TypeManager.InitOptionalCoreTypes(ctx);

            Location.AddFile(null, "{interactive}");
            Location.Initialize();

            current_debug_name = "interactive" + (count++) + ".dll";
            if (Environment.GetEnvironmentVariable("SAVE") != null)
            {
                CodeGen.Init(current_debug_name, current_debug_name, false, ctx);
            }
            else
            {
                CodeGen.InitDynamic(ctx, current_debug_name);
            }
        }
Beispiel #4
0
        static void Reset()
        {
            CompilerCallableEntryPoint.PartialReset();

            Location.AddFile(null, "{interactive}");
            Location.Initialize();
        }
        static void Reset()
        {
            CompilerCallableEntryPoint.PartialReset();

            Location.AddFile(null, "{interactive}");
            Location.Initialize();

            current_debug_name = "interactive" + (count++) + ".dll";
        }
        /// <summary>
        ///   Optional initialization for the Evaluator.
        /// </summary>
        /// <remarks>
        ///  Initializes the Evaluator with the command line
        ///  options that would be processed by the command
        ///  line compiler.  Only the first call to
        ///  InitAndGetStartupFiles or Init will work, any future
        ///  invocations are ignored.
        ///
        ///  You can safely avoid calling this method if your application
        ///  does not need any of the features exposed by the command line
        ///  interface.
        ///
        ///  This method return an array of strings that contains any
        ///  files that were specified in `args'.
        ///
        ///  If the unknownOptionParser is not null, this function is invoked
        ///  with the current args array and the index of the option that is not
        ///  known.  A value of true means that the value was processed, otherwise
        ///  it will be reported as an error
        /// </remarks>
        public static string [] InitAndGetStartupFiles(string [] args, Func <string [], int, int> unknownOptionParser)
        {
            lock (evaluator_lock)
            {
                if (inited)
                {
                    return(new string [0]);
                }

                CompilerCallableEntryPoint.Reset();
                var crp = new ConsoleReportPrinter();
                driver = Driver.Create(args, false, unknownOptionParser, crp);
                if (driver == null)
                {
                    throw new Exception("Failed to create compiler driver with the given arguments");
                }

                crp.Fatal = driver.fatal_errors;
                ctx       = driver.ctx;

                RootContext.ToplevelTypes = new ModuleContainer(ctx);

                var startup_files = new List <string> ();
                foreach (CompilationUnit file in Location.SourceFiles)
                {
                    startup_files.Add(file.Path);
                }

                CompilerCallableEntryPoint.PartialReset();

                var importer = new ReflectionImporter(ctx.BuildinTypes);
                loader = new DynamicLoader(importer, ctx);

                RootContext.ToplevelTypes.SetDeclaringAssembly(new AssemblyDefinitionDynamic(RootContext.ToplevelTypes, "temp"));

                loader.LoadReferences(RootContext.ToplevelTypes);
                ctx.BuildinTypes.CheckDefinitions(RootContext.ToplevelTypes);
                RootContext.ToplevelTypes.InitializePredefinedTypes();

                RootContext.EvalMode = true;
                inited = true;

                return(startup_files.ToArray());
            }
        }