Author: martin
Date: 2005-04-15 12:04:22 -0400 (Fri, 15 Apr 2005)
New Revision: 43057
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/attribute.cs
trunk/mcs/gmcs/class.cs
trunk/mcs/gmcs/codegen.cs
trunk/mcs/gmcs/cs-tokenizer.cs
trunk/mcs/gmcs/driver.cs
trunk/mcs/gmcs/ecore.cs
trunk/mcs/gmcs/location.cs
trunk/mcs/gmcs/namespace.cs
trunk/mcs/gmcs/report.cs
trunk/mcs/gmcs/rootcontext.cs
trunk/mcs/gmcs/typemanager.cs
Log:
**** Merged r41638 from MCS ****
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/ChangeLog 2005-04-15 16:04:22 UTC (rev 43057)
@@ -1,3 +1,40 @@
+2005-03-10 Marek Safar <[EMAIL PROTECTED]>
+
+ * attributes.cs (Attributes.Emit): Continue after CheckTargets.
+ It caused exception in namespace resolving (again!).
+
+ * class.cs (Class.ctor): Removed exit.
+ (PropertyMethod.ctor): ditto.
+
+ * codegen.cs (Codegen.Reset): Reset static data.
+ (Codegen.ResolveTopBlock): Forward error status from ResolveMeta.
+
+ * cs-tokenizer.cs (Cleanup): Removed.
+
+ * driver.cs (GetSystemDir): Rewrote to one line command.
+ It caused problem with unloaded dynamic modules.
+ (UnixParseOption): Removed Exit.
+ (CompilerCallableEntryPoint.InvokeCompiler): Make static.
+ (CompilerCallableEntryPoint.Reset): Reset suitable static data.
+ Now can be mcs used as library.
+
+ * ecore.cs (Expression.ResolveBoolean): Use Location.Null for
+ empty location.
+
+ * location.cs (Reset): Reset static data.
+
+ * namespace.cs (Reset): Reset static data.
+
+ * report.cs (Report.Reset): Reset static data.
+
+ * rootcontext.cs (RootContext.Reset): Reset static data.
+
+ * tree.cs (RootTypes.ctor): Use Location.Null
+
+ * typemanager.cs (TypeManager.Reset): Reset static data.
+ (CoreLookupType): Removed Exit.
+ (TypeHandle.Reset): Reset static data.
+
2005-03-10 Raja R Harinath <[EMAIL PROTECTED]>
Fix #73516.
Modified: trunk/mcs/gmcs/attribute.cs
===================================================================
--- trunk/mcs/gmcs/attribute.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/attribute.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -1297,8 +1297,7 @@
public void Emit (EmitContext ec, Attributable ias)
{
- if (!CheckTargets (ias))
- return;
+ CheckTargets (ias);
ListDictionary ld = new ListDictionary ();
Modified: trunk/mcs/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/class.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -2923,7 +2923,6 @@
{
if (RootContext.Version == LanguageVersion.ISO_1) {
Report.FeatureIsNotStandardized (l, "static
classes");
- Environment.Exit (1);
}
}
@@ -6415,7 +6414,6 @@
if (accessor.ModFlags != 0 &&
RootContext.Version == LanguageVersion.ISO_1) {
Report.FeatureIsNotStandardized
(Location, "accessor modifiers");
- Environment.Exit (1);
}
}
Modified: trunk/mcs/gmcs/codegen.cs
===================================================================
--- trunk/mcs/gmcs/codegen.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/codegen.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -35,6 +35,11 @@
static CodeGen ()
{
+ Reset ();
+ }
+
+ public static void Reset ()
+ {
Assembly = new AssemblyClass ();
Module = new ModuleClass (RootContext.Unsafe);
}
@@ -96,10 +101,12 @@
//
// Initializes the code generator variables
//
- static public void Init (string name, string output, bool
want_debugging_support)
+ static public bool Init (string name, string output, bool
want_debugging_support)
{
FileName = output;
AssemblyName an = Assembly.GetAssemblyName (name,
output);
+ if (an == null)
+ return false;
if (an.KeyPair != null) {
// If we are going to strong name our assembly
make
@@ -130,14 +137,14 @@
RootContext.StrongNameKeyContainer + "'.");
Environment.Exit (1);
}
- throw;
+ return false;
}
catch (CryptographicException) {
if ((RootContext.StrongNameKeyContainer !=
null) || (RootContext.StrongNameKeyFile != null)) {
Report.Error (1548, "Could not use the
specified key to strongname the assembly.");
Environment.Exit (1);
}
- throw;
+ return false;
}
//
@@ -153,6 +160,8 @@
if (want_debugging_support)
InitializeSymbolWriter (output);
+
+ return true;
}
static public void Save (string name)
@@ -680,36 +689,35 @@
int errors = Report.Errors;
block.ResolveMeta (block, this, ip);
+ if (Report.Errors != errors)
+ return false;
+ bool old_do_flow_analysis = DoFlowAnalysis;
+ DoFlowAnalysis = true;
- if (Report.Errors == errors){
- bool old_do_flow_analysis =
DoFlowAnalysis;
- DoFlowAnalysis = true;
-
- if (anonymous_method_host != null)
- current_flow_branching =
FlowBranching.CreateBranching (
+ if (anonymous_method_host != null)
+ current_flow_branching =
FlowBranching.CreateBranching (
anonymous_method_host.CurrentBranching, FlowBranching.BranchingType.Block,
block, loc);
- else
+ else
current_flow_branching =
FlowBranching.CreateBranching (
null,
FlowBranching.BranchingType.Block, block, loc);
- if (!block.Resolve (this)) {
- current_flow_branching = null;
- DoFlowAnalysis =
old_do_flow_analysis;
- return false;
- }
-
- FlowBranching.Reachability reachability
= current_flow_branching.MergeTopBlock ();
+ if (!block.Resolve (this)) {
current_flow_branching = null;
-
DoFlowAnalysis = old_do_flow_analysis;
+ return false;
+ }
- if (reachability.AlwaysReturns ||
- reachability.AlwaysThrows ||
- reachability.IsUnreachable)
- unreachable = true;
- }
+ FlowBranching.Reachability reachability =
current_flow_branching.MergeTopBlock ();
+ current_flow_branching = null;
+
+ DoFlowAnalysis = old_do_flow_analysis;
+
+ if (reachability.AlwaysReturns ||
+ reachability.AlwaysThrows ||
+ reachability.IsUnreachable)
+ unreachable = true;
#if PRODUCTION
} catch (Exception e) {
Console.WriteLine ("Exception caught by
the compiler while compiling:");
@@ -1259,7 +1267,7 @@
RootContext.StrongNameKeyFile +
"'
doesn't have a private key.");
}
- Environment.Exit (1);
+ return null;
}
}
}
@@ -1267,7 +1275,7 @@
else {
Report.Error (1548, "Could not strongname the
assembly. File `" +
RootContext.StrongNameKeyFile + "' not
found.");
- Environment.Exit (1);
+ return null;
}
return an;
}
Modified: trunk/mcs/gmcs/cs-tokenizer.cs
===================================================================
--- trunk/mcs/gmcs/cs-tokenizer.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/cs-tokenizer.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -420,10 +420,6 @@
Mono.CSharp.Location.Push (file);
}
- public static void Cleanup () {
- identifiers = null;
- }
-
static bool is_identifier_start_character (char c)
{
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
|| c == '_' || Char.IsLetter (c);
Modified: trunk/mcs/gmcs/driver.cs
===================================================================
--- trunk/mcs/gmcs/driver.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/driver.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -68,8 +68,6 @@
//
static bool load_default_config = true;
- static Hashtable response_file_list;
-
//
// A list of resource files
//
@@ -451,18 +449,7 @@
//
static string GetSystemDir ()
{
- Assembly [] assemblies =
AppDomain.CurrentDomain.GetAssemblies ();
-
- foreach (Assembly a in assemblies){
- string codebase = a.Location;
- string fn = System.IO.Path.GetFileName
(codebase);
- if (fn == "corlib.dll" || fn == "mscorlib.dll"){
- return codebase.Substring (0,
codebase.LastIndexOf (System.IO.Path.DirectorySeparatorChar));
- }
- }
-
- Report.Error (-15, "Can not compute my system path");
- return "";
+ return Path.GetDirectoryName (typeof
(object).Assembly.Location);
}
//
@@ -614,11 +601,11 @@
Report.Error (
1900,
"--wlevel requires a value from 0 to
4");
- Environment.Exit (1);
+ return;
}
if (level < 0 || level > 4){
Report.Error (1900, "Warning level must be 0 to
4");
- Environment.Exit (1);
+ return;
}
RootContext.WarningLevel = level;
}
@@ -773,7 +760,6 @@
break;
default:
TargetUsage ();
- Environment.Exit (1);
break;
}
return true;
@@ -926,7 +912,6 @@
default:
TargetUsage ();
- Environment.Exit (1);
break;
}
return true;
@@ -1184,7 +1169,6 @@
Report.SetIgnoreWarning (warn);
} catch {
Report.Error (1904,
String.Format("'{0}' is not a valid warning number", wc));
- Environment.Exit (1);
}
}
return true;
@@ -1269,8 +1253,7 @@
return true;
}
Report.Error (1617, "Invalid option '{0}' for
/langversion; must be ISO-1 or Default", value);
- Environment.Exit (1);
- return false;
+ return true;
case "/codepage":
int cp = -1;
@@ -1294,7 +1277,6 @@
using_default_encoder = false;
} catch {
Report.Error (2016, String.Format("Code
page '{0}' is invalid or not installed", cp));
- Environment.Exit (1);
}
return true;
}
@@ -1363,6 +1345,8 @@
// path.
//
+ Hashtable response_file_list = null;
+
for (i = 0; i < args.Length; i++){
string arg = args [i];
if (arg == "")
@@ -1457,8 +1441,6 @@
if (parse_only)
return true;
- Tokenizer.Cleanup ();
-
//
// Load Core Library for default compilation
//
@@ -1500,12 +1482,13 @@
output_file = first_source +
RootContext.TargetExt;
}
- CodeGen.Init (output_file, output_file,
want_debugging_support);
+ if (!CodeGen.Init (output_file, output_file,
want_debugging_support))
+ return false;
if (RootContext.Target == Target.Module) {
PropertyInfo module_only = typeof
(AssemblyBuilder).GetProperty ("IsModuleOnly",
BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
if (module_only == null) {
- Report.Error (0, new Location (-1),
"Cannot use /target:module on this runtime: try the Mono runtime instead.");
+ Report.RuntimeMissingSupport
(Location.Null, "/target:module");
Environment.Exit (1);
}
@@ -1518,7 +1501,7 @@
if (modules.Count > 0) {
MethodInfo adder_method = typeof
(AssemblyBuilder).GetMethod ("AddModule",
BindingFlags.Instance|BindingFlags.NonPublic);
if (adder_method == null) {
- Report.Error (0, new Location (-1),
"Cannot use /addmodule on this runtime: Try the Mono runtime instead.");
+ Report.RuntimeMissingSupport
(Location.Null, "/addmodule");
Environment.Exit (1);
}
@@ -1677,8 +1660,7 @@
null, CallingConventions.Any, argst,
null);
if (embed_res == null) {
- Report.Warning (0, new Location (-1),
- "Cannot embed resources
on this runtime: try the Mono runtime instead.");
+ Report.RuntimeMissingSupport
(Location.Null, "Resource embedding");
} else {
foreach (string spec in
embedded_resources) {
int cp;
@@ -1766,16 +1748,25 @@
public class CompilerCallableEntryPoint : MarshalByRefObject {
static bool used = false;
- public bool InvokeCompiler (string [] args)
+ public static bool InvokeCompiler (string [] args)
{
if (used)
Reset ();
- bool ok = Driver.MainDriver (args);
- return ok && Report.Errors == 0;
+ else
+ used = true;
+
+ return Driver.MainDriver (args) && Report.Errors == 0;
}
- public void Reset ()
+ static void Reset ()
{
+ Location.Reset ();
+ RootContext.Reset ();
+ Report.Reset ();
+ TypeManager.Reset ();
+ TypeHandle.Reset ();
+ Namespace.Reset ();
+ CodeGen.Reset ();
}
}
}
Modified: trunk/mcs/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/ecore.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -868,7 +868,7 @@
if (e.Type == TypeManager.bool_type)
return e;
- Expression converted = Convert.ImplicitConversion (ec,
e, TypeManager.bool_type, new Location (-1));
+ Expression converted = Convert.ImplicitConversion (ec,
e, TypeManager.bool_type, Location.Null);
if (converted != null)
return converted;
Modified: trunk/mcs/gmcs/location.cs
===================================================================
--- trunk/mcs/gmcs/location.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/location.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -66,16 +66,23 @@
static int source_count;
static int current_source;
- public readonly static Location Null;
+ public readonly static Location Null = new Location (-1);
static Location ()
{
source_files = new Hashtable ();
source_list = new ArrayList ();
current_source = 0;
- Null.token = 0;
}
+ public static void Reset ()
+ {
+ source_files = new Hashtable ();
+ source_list = new ArrayList ();
+ current_source = 0;
+ source_count = 0;
+ }
+
// <summary>
// This must be called before parsing/tokenizing any files.
// </summary>
Modified: trunk/mcs/gmcs/namespace.cs
===================================================================
--- trunk/mcs/gmcs/namespace.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/namespace.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -18,8 +18,8 @@
/// compiler parse/intermediate tree during name resolution.
/// </summary>
public class Namespace : FullNamedExpression, IAlias {
- static ArrayList all_namespaces = new ArrayList ();
- static Hashtable namespaces_map = new Hashtable ();
+ static ArrayList all_namespaces;
+ static Hashtable namespaces_map;
Namespace parent;
string fullname;
@@ -27,6 +27,21 @@
Hashtable namespaces;
Hashtable defined_names;
+ public static Namespace Root;
+
+ static Namespace ()
+ {
+ Reset ();
+ }
+
+ public static void Reset ()
+ {
+ all_namespaces = new ArrayList ();
+ namespaces_map = new Hashtable ();
+
+ Root = new Namespace (null, "");
+ }
+
/// <summary>
/// Constructor Takes the current namespace and the
/// name. This is bootstrapped with parent == null
@@ -73,8 +88,6 @@
return namespaces_map [name] != null;
}
- public static Namespace Root = new Namespace (null, "");
-
public Namespace GetNamespace (string name, bool create)
{
int pos = name.IndexOf ('.');
Modified: trunk/mcs/gmcs/report.cs
===================================================================
--- trunk/mcs/gmcs/report.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/report.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -68,6 +68,14 @@
/// </summary>
static StringCollection extra_information = new
StringCollection ();
+ public static void Reset ()
+ {
+ Errors = Warnings = 0;
+ WarningsAreErrors = false;
+ warning_ignore_table = null;
+ warning_regions_table = null;
+ }
+
abstract class AbstractMessage {
static void Check (int code)
Modified: trunk/mcs/gmcs/rootcontext.cs
===================================================================
--- trunk/mcs/gmcs/rootcontext.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/rootcontext.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -42,7 +42,7 @@
// This is only used to tell whether `System.Object' should
// have a base class or not.
//
- public static bool StdLib = true;
+ public static bool StdLib;
//
// This keeps track of the order in which classes were defined
@@ -63,9 +63,9 @@
static TypeBuilder impl_details_class;
- public static int WarningLevel = 3;
+ public static int WarningLevel;
- public static Target Target = Target.Exe;
+ public static Target Target;
public static string TargetExt = ".exe";
public static bool VerifyClsCompliance = true;
@@ -75,7 +75,7 @@
/// </summary>
public static bool Optimize = true;
- public static LanguageVersion Version = LanguageVersion.Default;
+ public static LanguageVersion Version;
//
// We keep strongname related info here because
@@ -83,20 +83,39 @@
//
public static string StrongNameKeyFile;
public static string StrongNameKeyContainer;
- public static bool StrongNameDelaySign = false;
+ public static bool StrongNameDelaySign;
//
// If set, enable XML documentation generation
//
public static Documentation Documentation;
+ static public string MainClass;
+
//
// Constructor
//
static RootContext ()
{
+ Reset ();
+ }
+
+ public static void Reset ()
+ {
tree = new Tree ();
type_container_resolve_order = new ArrayList ();
+ EntryPoint = null;
+ WarningLevel = 3;
+ Checked = false;
+ Unsafe = false;
+ StdLib = true;
+ StrongNameKeyFile = null;
+ StrongNameKeyContainer = null;
+ StrongNameDelaySign = false;
+ MainClass = null;
+ Target = Target.Exe;
+ Version = LanguageVersion.Default;
+ Documentation = null;
}
public static bool NeedsEntryPoint {
@@ -111,8 +130,6 @@
}
}
- static public string MainClass;
-
public static void RegisterOrder (TypeContainer tc)
{
type_container_resolve_order.Add (tc);
@@ -121,12 +138,12 @@
//
// The default compiler checked state
//
- static public bool Checked = false;
+ static public bool Checked;
//
// Whether to allow Unsafe code
//
- static public bool Unsafe = false;
+ static public bool Unsafe;
static string MakeFQN (string nsn, string name)
{
@@ -265,7 +282,7 @@
object o = root.GetDefinition (name);
if (o == null){
Report.Error (518, "The predefined type `" +
name + "' is not defined");
- Environment.Exit (1);
+ return;
}
if (!(o is Delegate)){
Modified: trunk/mcs/gmcs/typemanager.cs
===================================================================
--- trunk/mcs/gmcs/typemanager.cs 2005-04-15 16:03:30 UTC (rev 43056)
+++ trunk/mcs/gmcs/typemanager.cs 2005-04-15 16:04:22 UTC (rev 43057)
@@ -270,6 +270,11 @@
// </remarks>
public static Hashtable all_imported_types;
+ static Hashtable negative_hits;
+ static Hashtable fieldbuilders_to_fields;
+ static Hashtable fields;
+ static Hashtable references;
+
struct Signature {
public string name;
public Type [] args;
@@ -377,6 +382,15 @@
static TypeManager ()
{
+ Reset ();
+
+ signature_filter = new MemberFilter (SignatureFilter);
+ InitExpressionTypes ();
+ InitGenerics ();
+ }
+
+ static public void Reset ()
+ {
assemblies = new Assembly [0];
modules = null;
user_types = new ArrayList ();
@@ -395,9 +409,10 @@
NoTypes = new Type [0];
NoTypeExprs = new TypeExpr [0];
- signature_filter = new MemberFilter (SignatureFilter);
- InitGenerics ();
- InitExpressionTypes ();
+ negative_hits = new Hashtable ();
+ fieldbuilders_to_fields = new Hashtable ();
+ fields = new Hashtable ();
+ references = new Hashtable ();
}
public static void HandleDuplicate (string name, Type t)
@@ -609,8 +624,6 @@
return modules;
}
}
-
- static Hashtable references = new Hashtable ();
//
// Gets the reference to T version of the Type (T&)
@@ -689,8 +702,6 @@
return null;
}
- static Hashtable negative_hits = new Hashtable ();
-
//
// This function is used when you want to avoid the lookups, and want
to go
// directly to the source. This will use the cache.
@@ -1024,10 +1035,8 @@
{
Type t = LookupTypeDirect (name);
- if (t == null){
+ if (t == null)
Report.Error (518, "The predefined type `" + name + "'
is not defined or imported");
- Environment.Exit (1);
- }
return t;
}
@@ -1988,7 +1997,6 @@
// This is a workaround the fact that GetValue is not
// supported for dynamic types
// </remarks>
- static Hashtable fields = new Hashtable ();
static public bool RegisterFieldValue (FieldBuilder fb, object value)
{
if (fields.Contains (fb))
@@ -2004,7 +2012,6 @@
return fields [fb];
}
- static Hashtable fieldbuilders_to_fields = new Hashtable ();
static public bool RegisterFieldBase (FieldBuilder fb, FieldBase f)
{
if (fieldbuilders_to_fields.Contains (fb))
@@ -3088,6 +3095,11 @@
readonly int id = ++next_id;
static int next_id = 0;
+ static TypeHandle ()
+ {
+ Reset ();
+ }
+
/// <summary>
/// Lookup a TypeHandle instance for the given type. If the type
doesn't have
/// a TypeHandle yet, a new instance of it is created. This static
method
@@ -3114,6 +3126,11 @@
type_hash = null;
}
+ public static void Reset ()
+ {
+ type_hash = new PtrHashtable ();
+ }
+
/// <summary>
/// Returns the TypeHandle for TypeManager.object_type.
/// </summary>
@@ -3142,7 +3159,7 @@
}
}
- private static PtrHashtable type_hash = new PtrHashtable ();
+ private static PtrHashtable type_hash;
private static TypeHandle object_type = null;
private static TypeHandle array_type = null;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches