Exemplo n.º 1
0
 public ScopeManager(CompileRequest compileRequest, Wax.WaxHub waxHub)
 {
     this.wax                    = waxHub;
     this.localDeps              = compileRequest.LocalDeps;
     this.projectDirectory       = compileRequest.ProjectDirectory;
     this.ImportedAssemblyScopes = new List <CompilationScope>();
 }
Exemplo n.º 2
0
        internal static U3Window CreateWindow(int id, Wax.WaxHub waxHub)
        {
#if WINDOWS
            return(new U3WindowWindows()
            {
                ID = id
            });
#elif MAC
            return(new U3WindowMac(waxHub)
            {
                ID = id
            });
#elif LINUX
            throw new System.NotImplementedException();
#else
            throw new System.NotImplementedException();
#endif
        }
Exemplo n.º 3
0
        public ParserContext(CompileRequest compileRequest, Wax.WaxHub waxHub)
        {
            this.ClassIdAlloc   = 1;
            this.ScopeIdAlloc   = 1;
            this.CompileRequest = compileRequest;
            this.ProjectId      = compileRequest.ProjectId;
            this.DelegateMainTo = compileRequest.DelegateMainTo;
            this.TypeContext    = new TypeContext();
            Locale rootLocale = compileRequest.CompilerLocale;

            ExternalAssemblyMetadata userDefinedAssembly = CreateRootAssembly(compileRequest.CompilerLocale);
            CompilationScope         userDefinedScope    = new CompilationScope(this, userDefinedAssembly, rootLocale, compileRequest.RootProgrammingLanguage);

            this.PushScope(userDefinedScope);
            this.ScopeManager = new ScopeManager(compileRequest, waxHub);
            this.NamespacePrefixLookupForCurrentFile = new List <string>();
            this.ConstantAndEnumResolutionState      = new Dictionary <TopLevelEntity, ConstantResolutionState>();
            this.LiteralLookup = new LiteralLookup();
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        internal U3WindowMac(Wax.WaxHub waxHub)
        {
            string u3Path;
            string srcRoot = waxHub.SourceRoot;

            if (srcRoot != null)
            {
                u3Path = System.IO.Path.Combine(waxHub.SourceRoot, "Compiler", "U3", "webview", "u3mac");
            }
            else
            {
                u3Path = System.IO.Path.Combine(GetExecutableDirectory(), "u3", "u3mac");
            }
            if (!System.IO.File.Exists(u3Path))
            {
                throw new Exception("Coudl not find U3 executable: " + u3Path);
            }
            this.u3Path   = u3Path;
            this.token    = GetGibberishToken();
            this.filePath = System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("TMPDIR"), "u3_" + this.token);
        }
Exemplo n.º 6
0
        public static void WaxSend(object eventLoopObj, object waxHubObj, bool isListener, string serviceId, string payloadJson, Value callback)
        {
            Wax.WaxHub waxHub    = (Wax.WaxHub)waxHubObj;
            EventLoop  eventLoop = (EventLoop)eventLoopObj;
            Dictionary <string, object> payload = new Dictionary <string, object>(new Wax.Util.JsonParser(payloadJson).ParseAsDictionary());

            if (waxHub.GetService(serviceId) == null)
            {
                eventLoop.ExecuteFunctionPointerNativeArgs(callback, new object[] { "The service '" + serviceId + "' does not exist.", null });
            }
            else if (isListener)
            {
                waxHub.RegisterListener(serviceId, payload, (data) =>
                {
                    object[] callbackArgs = new object[] { null, null };
                    callbackArgs[1]       = Wax.Util.JsonUtil.SerializeJson(data);
                    eventLoop.ExecuteFunctionPointerNativeArgs(callback, callbackArgs);
                    return(true);
                });
            }
            else
            {
                waxHub.SendRequest(serviceId, payload).ContinueWith(responseTask =>
                {
                    object[] callbackArgs = new object[] { null, null };
                    if (responseTask.IsFaulted)
                    {
                        callbackArgs[0] = responseTask.Exception.Message;
                    }
                    else
                    {
                        callbackArgs[1] = Wax.Util.JsonUtil.SerializeJson(responseTask.Result);
                    }
                    eventLoop.ExecuteFunctionPointerNativeArgs(callback, callbackArgs);
                });
            }
        }
Exemplo n.º 7
0
        private static string GetValidatedCanonicalBuildFilePathImpl(string originalBuildFilePath, Wax.WaxHub waxHub)
        {
            string buildFilePath = originalBuildFilePath;

            buildFilePath = FileUtil.FinalizeTilde(buildFilePath);
            if (!buildFilePath.StartsWith("/") &&
                !(buildFilePath.Length > 1 && buildFilePath[1] == ':'))
            {
                // Build file will always be absolute. So make it absolute if it isn't already.
                buildFilePath = FileUtil.GetAbsolutePathFromRelativeOrAbsolutePath(buildFilePath);
            }

            if (!FileUtil.FileExists(buildFilePath))
            {
                return(null);
            }

            return(buildFilePath);
        }
Exemplo n.º 8
0
        public static string GetValidatedCanonicalBuildFilePath(string originalBuildFilePath, Wax.WaxHub waxHub)
        {
            string validatedPath = GetValidatedCanonicalBuildFilePathImpl(originalBuildFilePath, waxHub);

            if (validatedPath == null)
            {
                throw new InvalidOperationException("Build file does not exist: " + originalBuildFilePath);
            }
            return(validatedPath);
        }