Esempio n. 1
0
        public override async Task <Dictionary <string, object> > HandleRequest(Dictionary <string, object> request)
        {
            Wax.ToolchainCommand command = new Wax.ToolchainCommand(request);

            // Always show library stack traces when running from source.
            if (this.Hub.SourceRoot != null)
            {
                command.ToolchainArgs = command.ToolchainArgs.Append(new Wax.ToolchainArg()
                {
                    Name = "showLibStack", Value = "1"
                }).ToArray();
            }

            if (this.Hub.ErrorsAsExceptions)
            {
                return(await this.HandleRequestImpl(command));
            }
            else
            {
                try
                {
                    return(await this.HandleRequestImpl(command));
                }
                catch (InvalidOperationException ioe)
                {
                    return(new Dictionary <string, object>()
                    {
                        { "errors", new Wax.Error[] { new Wax.Error {
                                                          Message = ioe.Message
                                                      } } }
                    });
                }
            }
        }
Esempio n. 2
0
        private async Task <Dictionary <string, object> > HandleRequestImpl(Wax.ToolchainCommand command)
        {
            Wax.Error[] errors = await MainPipeline.Run(command, this.Hub) ?? new Wax.Error[0];

            return(new Dictionary <string, object>()
            {
                { "errors", errors }
            });
        }
Esempio n. 3
0
        private static async Task MainTask(string[] args)
        {
            Wax.WaxHub waxHub = new Wax.WaxHub();

            waxHub.SourceRoot         = SourceDirectoryFinder.CrayonSourceDirectory;
            waxHub.ErrorsAsExceptions = !IS_RELEASE;

            waxHub.RegisterService(new Router.RouterService());
            waxHub.RegisterService(new AssemblyResolver.AssemblyService());
            waxHub.RegisterService(new Runtime.RuntimeService());
            waxHub.RegisterService(new Builder.BuilderService());
            waxHub.RegisterService(new U3.U3Service());

            Wax.ToolchainCommand command = FlagParser.Parse(args);

            if (command.UseOutputPrefixes)
            {
                Wax.ConsoleWriter.EnablePrefixes();
            }

            foreach (string directory in GetExtensionDirectories())
            {
                waxHub.RegisterExtensionDirectory(directory);
            }

            waxHub.RegisterLibraryDirectory(GetLibraryDirectory());

            Dictionary <string, object> result = await waxHub.SendRequest("router", command);

            Wax.Error[] errors = Wax.Error.GetErrorsFromResult(result);

            if (command.UseJsonOutput)
            {
                string jsonErrors = "{\"errors\":[" +
                                    string.Join(',', errors.Select(err => err.ToJson())) +
                                    "]}";
                Wax.ConsoleWriter.Print(Wax.ConsoleMessageType.COMPILER_INFORMATION, jsonErrors);
            }
            else if (errors.Length > 0)
            {
                ErrorPrinter.ShowErrors(errors, waxHub.ErrorsAsExceptions);
            }
        }