Ejemplo n.º 1
0
        public async Task BaZicCompile()
        {
            var inputCode =
                @"EXTERN FUNCTION Main(args[])
    VARIABLE var1 = 1
    VARIABLE Var1 = 2
    VARIABLE result = var1 + Var1
    System.Console.WriteLine(result.ToString())
    RETURN result
END FUNCTION";

            using (var interpreter = new BaZicInterpreter(inputCode, false))
            {
                var mscorlib      = AssemblyInfoHelper.GetAssemblyDetailsFromNameOrLocation(typeof(object).Assembly.FullName);
                var baZicCoreTest = AssemblyInfoHelper.GetAssemblyDetailsFromNameOrLocation(typeof(LogMock).Assembly.Location);
                interpreter.SetDependencies(mscorlib, baZicCoreTest);

                var tempFile = Path.Combine(Path.GetTempPath(), "BaZic_Bin", Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + ".exe");
                var errors   = await interpreter.Build(Core.Enums.BaZicCompilerOutputType.ConsoleApp, tempFile);

                Assert.IsNull(errors);
                Assert.IsTrue(File.Exists(tempFile));
                Assert.IsTrue(File.Exists(tempFile.Replace(".exe", ".pdb")));
                Assert.IsTrue(File.Exists(Path.Combine(Path.GetTempPath(), "BaZic_Bin", "BaZic.Core.Tests.dll")));

                File.Delete(tempFile);
                File.Delete(tempFile.Replace(".exe", ".pdb"));
                File.Delete(Path.Combine(Path.GetTempPath(), "BaZic_Bin", "BaZic.Core.Tests.dll"));
                Directory.Delete(Path.Combine(Path.GetTempPath(), @"BaZic_Bin"), true);
            }
        }
Ejemplo n.º 2
0
        internal static async Task RunDebugOptimizedVerbose(List <string> resultReceiver, string inputBaZicCode, string xamlCode, params object[] args)
        {
            using (var interpreter = new BaZicInterpreter(inputBaZicCode, xamlCode, optimize: true))
            {
                interpreter.SetDependencies("PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
                await interpreter.StartDebugAsync(true, args);

                if (interpreter.Error != null)
                {
                    throw interpreter.Error.Exception;
                }

                resultReceiver.Add(interpreter.ProgramResult?.ToString());
            }
        }