Ver Fonte

Show actual version of compiler in console output

Bepsi há 6 anos atrás
pai
commit
e5133fa35a
2 ficheiros alterados com 11 adições e 7 exclusões
  1. 7 4
      NTERA.Compiler/Compiler.cs
  2. 4 3
      NTERA.Compiler/Program.cs

+ 7 - 4
NTERA.Compiler/Compiler.cs

@@ -19,9 +19,12 @@ namespace NTERA.Compiler
 
 		public Dictionary<FunctionDefinition, string> DeclaredFunctions = new Dictionary<FunctionDefinition, string>();
 
-		public Compiler(string inputDirectory)
+		public int Threads { get; set; }
+
+		public Compiler(string inputDirectory, int threads)
 		{
 			InputDirectory = inputDirectory;
+			Threads = threads;
 		}
 
 		protected static string[] DefaultGlobalNumberVariables =
@@ -283,7 +286,7 @@ namespace NTERA.Compiler
 #else
 			Parallel.ForEach(Directory.EnumerateFiles(erbPath, "*.erh", SearchOption.AllDirectories), new ParallelOptions
 			{
-				MaxDegreeOfParallelism = 8
+				MaxDegreeOfParallelism = Threads
 			}, file =>
 #endif
 			{
@@ -312,7 +315,7 @@ namespace NTERA.Compiler
 #else
 			Parallel.ForEach(Directory.EnumerateFiles(erbPath, "*.erb", SearchOption.AllDirectories), new ParallelOptions
 			{
-				MaxDegreeOfParallelism = 8
+				MaxDegreeOfParallelism = Threads
 			}, file =>
 #endif
 			{
@@ -345,7 +348,7 @@ namespace NTERA.Compiler
 #else
 			Parallel.ForEach(DeclaredFunctions, new ParallelOptions
 			{
-				MaxDegreeOfParallelism = 8
+				MaxDegreeOfParallelism = Threads
 			}, kv =>
 #endif
 			{

+ 4 - 3
NTERA.Compiler/Program.cs

@@ -12,18 +12,19 @@ namespace NTERA.Compiler
 				: Environment.CurrentDirectory;
 
 			string outputPath = Path.Combine(path, "output");
+			int threads = 8;
 
 			if (!Directory.Exists(outputPath))
 				Directory.CreateDirectory(outputPath);
 
-			Console.WriteLine("NTERA 0.X");
+			Console.WriteLine($"NTERA {typeof(Program).Assembly.GetName().Version}");
 			Console.WriteLine("-------------------------");
 			Console.WriteLine($"Compiling '{path}' to '{outputPath}'");
-			Console.WriteLine("Using 8 threads");
+			Console.WriteLine($"Using {threads} threads");
 			
 
 
-			Compiler compiler = new Compiler(path);
+			Compiler compiler = new Compiler(path, threads);
 			compiler.Compile(outputPath);
 
 			Console.WriteLine();