Example #1
0
		public static void Run()
		{
			Parse ();

			var pcw = new LegacyParseCacheView (new[]{ srcDir });
			var ctxt = new ResolutionContext (pcw, new ConditionalCompilationFlags(versions,0, true));

			var mod = pcw.LookupModuleName (null, "botan.pubkey.algo.dsa").First();
			var scope = ResolutionTests.N<DMethod> (mod, "DSAVerificationOperation.verify");
			var scopedStmt = ResolutionTests.S (scope, 9);

			ctxt.Push (scope, scopedStmt.Location);

			ITypeDeclaration td = new IdentifierDeclaration ("q"){ Location = scopedStmt.Location };
			AbstractType t;

			var sw = new Stopwatch ();
			Console.WriteLine ("Begin resolving...");
			sw.Restart ();
			t = TypeDeclarationResolver.ResolveSingle(td, ctxt);

			sw.Stop ();

			Console.WriteLine ("Finished resolution. {0} ms.", sw.ElapsedMilliseconds);

			sw.Restart ();
			t = TypeDeclarationResolver.ResolveSingle(td, ctxt);

			sw.Stop ();

			Console.WriteLine ("Finished resolution. {0} ms.", sw.ElapsedMilliseconds);
		}
Example #2
0
		public static void Main (string[] args)
		{
			var rt = new ResolutionTests ();
			rt.SetupEnvironment ();

			Trace.Listeners.Clear ();
			Trace.AutoFlush = false;
			Trace.UseGlobalLock = false;
			if(File.Exists(traceFile))
				File.Delete (traceFile);
			Trace.Listeners.Add (new TextWriterTraceListener (traceFile));

			/*
			var sw2 = new Stopwatch();
			var code = File.ReadAllText(@"B:\Programs\D\dmd2\src\phobos\std\datetime.d");
			sw2.Start();
			var ast = DParser.ParseString(code, true);
			sw2.Stop();
			Console.WriteLine (sw2.ElapsedMilliseconds);
			return;*/
			//DParser.ParseString (@"");
			//(new ResolutionTests ()).BasicResolution0 ();
			//(new IndentationTests ()).TestIssue576 ();		
			//(new IndentationTests ()).SwitchIndentation ();

			//BotanProfil.Run ();
			rt.LooseResolution2();

			Trace.Flush ();
			return;

			// Indent testing
			/*var code = @"
";
			var line = 4;
			var ind = D_Parser.Formatting.Indent.IndentEngineWrapper.CalculateIndent(code, line, false, 4);
			var o = DocumentHelper.LocationToOffset(code, line,1);
			
			var o2 = o;
			while(o2 < code.Length && code[o2] == ' ' || code[o2] == '\t')
				o2++;
			
			code = code.Substring(0,o) + ind + code.Substring(o2);
			Console.Write(code+"|");
			
			Console.ReadKey(true);
			return;*/

			
			// Phobos & Druntime parsing

			Console.WriteLine ("Begin parsing...");

			var dirs = Environment.OSVersion.Platform == PlatformID.Unix ? new[] { @"/usr/include/dlang" } : new[] { @"B:\Programs\D\dmd2\src\phobos", @"B:\Programs\D\dmd2\src\druntime\import" };
			var skipFunctionBodies = false;


			var dirsLeft = dirs.Length;
			var ev=new System.Threading.AutoResetEvent(false);

			if (skipFunctionBodies)	Console.WriteLine ("Skipping method bodies!");
			GlobalParseCache.BeginAddOrUpdatePaths(dirs, skipFunctionBodies, (pc) =>
			{
				Console.WriteLine("{0}/{1}ms", pc.Duration, pc.ParseDuration);
				ev.Set();
			});

			ev.WaitOne();

			Console.WriteLine("done.");
			Console.WriteLine();
			var pcw = new LegacyParseCacheView(dirs);
			var ccf = new ConditionalCompilationFlags(new[]{ Environment.OSVersion.Platform == PlatformID.Unix ?"Posix":"Windows", "D2" }, 1, true, null, 0);

			Console.WriteLine ("Dump parse errors:");
			int modCount = 0;
			foreach (var dir in dirs)
				foreach (var mod in GlobalParseCache.EnumModulesRecursively(dir)) {
					modCount++;
					if (mod.ParseErrors.Count > 0) {
						Console.WriteLine (" "+mod.FileName);
						Console.WriteLine ("  ("+mod.ModuleName+")");

						foreach (var err in mod.ParseErrors) {
							Console.WriteLine ("({0}):", err.Location.ToString ());
							Console.WriteLine ("\t"+err.Message);
						}
					}
				}

			Console.WriteLine("{0} modules parsed.", modCount);

			Console.WriteLine();
			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}