Преглед изворни кода

2003-07-08 Gonzalo Paniagua Javier <[email protected]>

	* BaseCompiler.cs: first look for cached items, then generate the tree.
	This should speed things up.

	* CachingCompiler.cs: when compiling web services, use the full path of
	the .asmx file as key when caching.

	* WebServiceCompiler.cs: first look for cached items, then generate
	the source file.

svn path=/trunk/mcs/; revision=16045
Gonzalo Paniagua Javier пре 22 година
родитељ
комит
df3cd55444

+ 9 - 7
mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs

@@ -66,12 +66,6 @@ namespace System.Web.Compilation
 			CreateConstructor (null, null);
 		}
 
-		void BuildTree ()
-		{
-			Init ();
-			CreateMethods ();
-		}
-
 		protected virtual void CreateStaticFields ()
 		{
 			CodeMemberField fld = new CodeMemberField (typeof (bool), "__intialized");
@@ -148,11 +142,19 @@ namespace System.Web.Compilation
 
 		public virtual Type GetCompiledType () 
 		{
+			Init ();
+			CompilationCacheItem item = CachingCompiler.GetCached (parser.InputFile);
+			if (item != null) {
+				Assembly a = item.Result.CompiledAssembly;
+				if (a != null)
+					return a.GetType (mainClassExpr.Type.BaseType, true);
+			}
+
 			//TODO: get the compiler and default options from system.web/compileroptions
 			provider = new CSharpCodeProvider ();
 			compiler = provider.CreateCompiler ();
 
-			BuildTree ();
+			CreateMethods ();
 			compilerParameters.IncludeDebugInformation = parser.Debug;
 			CompilerResults results = CachingCompiler.Compile (this);
 			CheckCompilerErrors (results);

+ 4 - 4
mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs

@@ -129,22 +129,22 @@ namespace System.Web.Compilation
 			return results;
 		}
 
-		public static CompilerResults Compile (WebServiceCompiler compiler, string file)
+		public static CompilerResults Compile (string key, string file, WebServiceCompiler compiler)
 		{
-			CompilationCacheItem item = GetCached (file);
+			CompilationCacheItem item = GetCached (key);
 			if (item != null)
 				return item.Result;
 			
 			CompilerResults results = null;
 			lock (compilationLock) {
-				item = GetCached (file);
+				item = GetCached (key);
 				if (item != null)
 					return item.Result;
 
 				CompilerParameters options = GetOptions (compiler.Parser.Assemblies);
 				options.IncludeDebugInformation = compiler.Parser.Debug;
 				results = compiler.Compiler.CompileAssemblyFromFile (options, file);
-				cache [file] = new CompilationCacheItem (results, compiler.Parser.Dependencies);
+				cache [key] = new CompilationCacheItem (results, compiler.Parser.Dependencies);
 			}
 
 			return results;

+ 11 - 0
mcs/class/System.Web/System.Web.Compilation/ChangeLog

@@ -1,3 +1,14 @@
+2003-07-08  Gonzalo Paniagua Javier <[email protected]>
+
+	* BaseCompiler.cs: first look for cached items, then generate the tree.
+	This should speed things up.
+
+	* CachingCompiler.cs: when compiling web services, use the full path of
+	the .asmx file as key when caching.
+
+	* WebServiceCompiler.cs: first look for cached items, then generate
+	the source file.
+
 2003-07-04  Gonzalo Paniagua Javier <[email protected]>
 
 	* AspParser.cs: more useful error information,

+ 10 - 2
mcs/class/System.Web/System.Web.Compilation/WebServiceCompiler.cs

@@ -7,9 +7,10 @@
 // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
 //
 using System;
+using System.CodeDom.Compiler;
 using System.IO;
 using System.Web.UI;
-using System.CodeDom.Compiler;
+using System.Reflection;
 //temp:
 using Microsoft.CSharp;
 
@@ -37,6 +38,13 @@ namespace System.Web.Compilation
 			if (wService.Program.Trim () == "")
 				return wService.GetTypeFromBin (wService.ClassName);
 
+			CompilationCacheItem item = CachingCompiler.GetCached (wService.PhysicalPath);
+			if (item != null) {
+				Assembly a = item.Result.CompiledAssembly;
+				if (a != null)
+					return a.GetType (wService.ClassName, true);
+			}
+
 			//FIXME: update when we support other languages
 			string fname = Path.ChangeExtension (Path.GetTempFileName (), ".cs");
 			StreamWriter sw = new StreamWriter (File.OpenWrite (fname));
@@ -44,7 +52,7 @@ namespace System.Web.Compilation
 			sw.Close ();
 
 			//TODO: get the compiler and default options from system.web/compileroptions
-			CompilerResults results = CachingCompiler.Compile (this, fname);
+			CompilerResults results = CachingCompiler.Compile (wService.PhysicalPath, fname, this);
 			CheckCompilerErrors (results);
 
 			return results.CompiledAssembly.GetType (wService.ClassName, true);