コード例 #1
0
        public CrossDomainHelper(string[] absoluteFilenames, string assemblyName, string compilerOptions)
        {
            var compileResult = CompilerUtil.Compile(absoluteFilenames, assemblyName, compilerOptions: compilerOptions);

            _assemblyUtility = new AssemblyUtility(compileResult.Assembly);
            _metacomments    = compileResult.Metacomments;
        }
コード例 #2
0
ファイル: DependencyTests.cs プロジェクト: xen2/JSIL
        public void EnumeratesAssemblyDependencies()
        {
            var assembly = CompilerUtil.CompileCS(new[] {
                Path.Combine(
                    ComparisonTest.TestSourceFolder,
                    @"SpecialTestCases\EnumeratesAssemblyDependencies.cs"
                    )
            }, "DependencyTests\\EnumeratesAssemblyDependencies");

            var translator = new AssemblyTranslator(
                new Translator.Configuration {
                IncludeDependencies = false
            }
                );

            var assemblyDefinition = translator.LoadAssembly(assembly.Location);

            translator = new AssemblyTranslator(
                new Translator.Configuration {
                IncludeDependencies = true
            }
                );

            var assemblyPlusDependencies = translator.LoadAssembly(assembly.Location);

            Assert.AreNotEqual(
                (from ad in assemblyDefinition select ad.FullName).ToArray(),
                (from ad in assemblyPlusDependencies select ad.FullName).ToArray()
                );
        }
コード例 #3
0
        public CrossDomainHelper(string[] absoluteFilenames, string assemblyName, string compilerOptions, string currentMetaRevision)
        {
            var compileResult = CompilerUtil.Compile(absoluteFilenames, assemblyName, compilerOptions, currentMetaRevision);

            _assemblyUtility = new AssemblyUtility(compileResult.Assembly);
            _metacomments    = compileResult.Metacomments;
            _wasCached       = compileResult.WasCached;
        }
コード例 #4
0
ファイル: ComparisonTest.cs プロジェクト: thompsonbill/JSIL
        public ComparisonTest(
            EvaluatorPool pool,
            IEnumerable <string> filenames, string outputPath,
            string[] stubbedAssemblies  = null, TypeInfoProvider typeInfo = null,
            AssemblyCache assemblyCache = null, string compilerOptions    = ""
            )
        {
            var started = DateTime.UtcNow.Ticks;

            OutputPath    = outputPath;
            EvaluatorPool = pool;

            var extensions        = (from f in filenames select Path.GetExtension(f).ToLower()).Distinct().ToArray();
            var absoluteFilenames = (from f in filenames select Path.Combine(TestSourceFolder, Portability.NormalizeDirectorySeparators(f)));

            if (extensions.Length != 1)
            {
                throw new InvalidOperationException("Mixture of different source languages provided.");
            }

            var assemblyNamePrefix = Path.GetDirectoryName(outputPath).Split(new char[] { '\\', '/' }).Last();
            var assemblyName       = Path.Combine(
                assemblyNamePrefix,
                Path.GetFileName(outputPath).Replace(".js", "")
                );

            switch (extensions[0])
            {
            case ".exe":
            case ".dll":
                var fns = absoluteFilenames.ToArray();
                if (fns.Length > 1)
                {
                    throw new InvalidOperationException("Multiple binary assemblies provided.");
                }

                Assembly = Assembly.LoadFile(fns[0]);
                break;

            default:
                CompileResult = CompilerUtil.Compile(absoluteFilenames, assemblyName, compilerOptions: compilerOptions);
                Assembly      = CompileResult.Assembly;
                break;
            }

            if (typeInfo != null)
            {
                typeInfo.ClearCaches();
            }

            StubbedAssemblies = stubbedAssemblies;
            TypeInfo          = typeInfo;
            AssemblyCache     = assemblyCache;

            var ended = DateTime.UtcNow.Ticks;

            CompilationElapsed = TimeSpan.FromTicks(ended - started);
        }
コード例 #5
0
        static ComparisonTest()
        {
            var testAssembly = typeof(ComparisonTest).Assembly;
            var assemblyPath = Path.GetDirectoryName(Util.GetPathOfAssembly(testAssembly));

            JSILFolder = Path.GetDirectoryName(Util.GetPathOfAssembly(typeof(JSIL.AssemblyTranslator).Assembly));

            TestSourceFolder = Path.GetFullPath(Path.Combine(assemblyPath, "..", "Tests"));
            if (TestSourceFolder[TestSourceFolder.Length - 1] != Path.DirectorySeparatorChar)
            {
                TestSourceFolder += Path.DirectorySeparatorChar;
            }

            if (IsLinux)
            {
                JSShellPath = "js";
            }
            else
            {
                JSShellPath = Path.GetFullPath(Path.Combine(assemblyPath, "..", "Upstream", "SpiderMonkey", "js.exe"));
            }

            var librarySourceFolder = Path.GetFullPath(Path.Combine(TestSourceFolder, "..", "Libraries"));

            if (librarySourceFolder[librarySourceFolder.Length - 1] != Path.DirectorySeparatorChar)
            {
                librarySourceFolder += Path.DirectorySeparatorChar;
            }

            LoaderJSPath = Path.Combine(librarySourceFolder, @"JSIL.js");

            EvaluatorSetupCode = String.Format(
                @"var jsilConfig = {{
        libraryRoot: {0},
        environment: 'spidermonkey_shell'
    }};",
                Util.EscapeString(librarySourceFolder)
                );

            EvaluatorRunCode = String.Format(
                @"load({0});",
                Util.EscapeString(LoaderJSPath)
                );

            if (CompilerUtil.TryGetMetaVersion(out CurrentMetaRevision))
            {
                Console.WriteLine("Using JSIL.Meta rev {0}", CurrentMetaRevision);
            }
        }