コード例 #1
0
        public void Setup()
        {
            var builder = new StringBuilder();
            var writer = new StringWriter(builder);
            var printer = new StreamReportPrinter(writer);
            var settings = new CompilerSettings();
            settings.AssemblyReferences.Add("DbTool.Testing");

            var context = new CompilerContext(settings, printer);
            _evaluator = new Evaluator(context);
        }
コード例 #2
0
ファイル: driver.cs プロジェクト: speier/shake
        public static bool InvokeCompiler(string [] args, TextWriter error)
        {
            try {
                StreamReportPrinter srp = new StreamReportPrinter (error);
                Driver d = Driver.Create (args, true, srp);
                if (d == null)
                    return false;

                return d.Compile () && srp.ErrorsCount == 0;
            } finally {
                Reset ();
            }
        }
コード例 #3
0
ファイル: driver.cs プロジェクト: richardschneider/ILSpy
        public static bool InvokeCompiler(string [] args, TextWriter error)
        {
            try {
                StreamReportPrinter srp = new StreamReportPrinter (error);
                Driver d = Driver.Create (args, true, delegate (string[] a, int i) { System.Console.WriteLine ("Unknown option:" + a[i]); return 0; }, srp);
                if (d == null)
                    return false;

                return d.Compile () && srp.ErrorsCount == 0;
            } finally {
                Reset ();
            }
        }
コード例 #4
0
ファイル: repl.cs プロジェクト: GirlD/mono
		static int Main (string [] args)
		{
			var cmd = new CommandLineParser (Console.Out);
			cmd.UnknownOptionHandler += HandleExtraArguments;

			// Enable unsafe code by default
			var settings = new CompilerSettings () {
				Unsafe = true
			};

			if (!cmd.ParseArguments (settings, args))
				return 1;

			var startup_files = new string [settings.SourceFiles.Count];
			int i = 0;
			foreach (var source in settings.SourceFiles)
				startup_files [i++] = source.FullPathName;
			settings.SourceFiles.Clear ();

			TextWriter agent_stderr = null;
			ReportPrinter printer;
			if (agent != null) {
				agent_stderr = new StringWriter ();
				printer = new StreamReportPrinter (agent_stderr);
			} else {
				printer = new ConsoleReportPrinter ();
			}

			var eval = new Evaluator (new CompilerContext (settings, printer));

			eval.InteractiveBaseClass = typeof (InteractiveBaseShell);
			eval.DescribeTypeExpressions = true;
			eval.WaitOnTask = true;

			CSharpShell shell;
#if !ON_DOTNET
			if (attach.HasValue) {
				shell = new ClientCSharpShell (eval, attach.Value);
			} else if (agent != null) {
				new CSharpAgent (eval, agent, agent_stderr).Run (startup_files);
				return 0;
			} else
#endif
			{
				shell = new CSharpShell (eval);
			}
			return shell.Run (startup_files);
		}
コード例 #5
0
        public void Init()
        {
            var printer = new StreamReportPrinter(_stringWriter);
            var settings = new CompilerSettings();
            settings.AssemblyReferences.AddRange(InitialAssemblies);
            var context = new CompilerContext(settings, printer);
            _evaluator = new Evaluator(context)
                {
                    InteractiveBaseClass = typeof (DbToolInteractive),
                    DescribeTypeExpressions = true,
                };
            ReferenceAssemblies(typeof(Database).Assembly, typeof(DynamicSqlQuery).Assembly);

            Using(InitialUsings);
            DbToolInteractive.Evaluator = _evaluator;
            DbToolInteractive.Output = _stringWriter;
        }
コード例 #6
0
        public MonoCSharpExecutor()
        {
            _reportBuilder = new StringBuilder();
            var writer = new StringWriter(_reportBuilder);
            var printer = new StreamReportPrinter(writer);
            var settings = new CompilerSettings();

            var context = new CompilerContext(settings, printer);
            _evaluator = new Evaluator(context);
            _evaluator.InteractiveBaseClass = typeof (InteractiveStuff);
            _evaluator.ReferenceAssembly(typeof(HttpContext).Assembly);
            _evaluator.ReferenceAssembly(typeof(VisualFarmRepo).Assembly);
            _evaluator.ReferenceAssembly(typeof(BondegardFacade).Assembly);
            _evaluator.ReferenceAssembly(typeof(IVFSConfig).Assembly);
            Execute("using System;");
            Execute("using System.Linq;");
            Execute("using System.Web;");
            Execute("using VisualFarmStudio.Core.Domain;");
            Execute("using VisualFarmStudio.Core.Repository;");
            Execute("using VisualFarmStudio.Lib.Model;");
            Execute("using VisualFarmStudio.Lib.Containers;");
        }
コード例 #7
0
ファイル: settings.cs プロジェクト: OpenFlex/playscript-mono
		public CommandLineParser (TextWriter errorOutput, TextWriter messagesOutput)
		{
			var rp = new StreamReportPrinter (errorOutput);

			parser_settings = new CompilerSettings ();
			report = new Report (new CompilerContext (parser_settings, rp), rp);
			this.output = messagesOutput;
		}
コード例 #8
0
ファイル: eval.cs プロジェクト: speier/shake
        static void Reset()
        {
            CompilerCallableEntryPoint.PartialReset ();
            RootContext.PartialReset ();

            // Workaround for API limitation where full message printer cannot be passed
            ReportPrinter printer;
            if (MessageOutput == Console.Out || MessageOutput == Console.Error){
                var console_reporter = new ConsoleReportPrinter (MessageOutput);
                console_reporter.Fatal = driver.fatal_errors;
                printer = console_reporter;
            } else
                printer = new StreamReportPrinter (MessageOutput);

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

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

            Location.AddFile(null, FileName);
            Location.Initialize ();

            current_debug_name = FileName + (count++) + ".dll";
            if (Environment.GetEnvironmentVariable ("SAVE") != null){
                CodeGen.Init (current_debug_name, current_debug_name, false, ctx);
            } else
                CodeGen.InitDynamic (ctx, current_debug_name);
        }