Author: martin
Date: 2005-04-07 05:47:52 -0400 (Thu, 07 Apr 2005)
New Revision: 42627
Modified:
trunk/mcs/gmcs/AssemblyInfo.cs
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/attribute.cs
trunk/mcs/gmcs/class.cs
trunk/mcs/gmcs/const.cs
trunk/mcs/gmcs/cs-parser.jay
trunk/mcs/gmcs/delegate.cs
trunk/mcs/gmcs/driver.cs
trunk/mcs/gmcs/ecore.cs
trunk/mcs/gmcs/expression.cs
trunk/mcs/gmcs/location.cs
trunk/mcs/gmcs/namespace.cs
trunk/mcs/gmcs/rootcontext.cs
trunk/mcs/gmcs/statement.cs
Log:
**** Merged r39544-40298 from MCS ****
Modified: trunk/mcs/gmcs/AssemblyInfo.cs
===================================================================
--- trunk/mcs/gmcs/AssemblyInfo.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/AssemblyInfo.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -1,7 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-[assembly: AssemblyVersion("1.1.3")]
+[assembly: AssemblyVersion("1.1.4")]
[assembly: AssemblyTitle ("Mono C# Compiler")]
[assembly: AssemblyDescription ("Mono C# Compiler with Generics")]
[assembly: AssemblyCopyright ("2001, 2002, 2003 Ximian, Inc.")]
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/ChangeLog 2005-04-07 09:47:52 UTC (rev 42627)
@@ -1,3 +1,141 @@
+2005-02-08 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #72015.
+ * delegate.cs (Delegate.DefineType): When bootstrapping corlib, if
+ TypeManager.multicast_delegate_type is null, resolve it by looking
+ up "System.MulticastDelegate".
+ * rootcontext.cs (RootContext.ResolveCore): Simplify.
+
+2005-02-07 Abin Thomas (NOSIP) <[EMAIL PROTECTED]>
+ Anoob V.E (NOSIP) <[EMAIL PROTECTED]>
+ Harilal P.R (NOSIP) <[EMAIL PROTECTED]>
+
+ Fix cs0164.cs.
+ * statement.cs (LabeledStatement.Resolve): Don't set 'referenced'.
+ (LabeledStatement.AddReference): New. Set 'referenced'.
+ (Goto.Resolve): Use it.
+
+2005-02-05 John Luke <[EMAIL PROTECTED]>
+
+ * driver.cs: remove duplicate -doc line in Usage ()
+
+2005-02-04 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * location.cs (Location.AddFile): Fix CS2002 error report.
+
+2005-02-02 Martin Baulig <[EMAIL PROTECTED]>
+
+ * delegate.cs (Delegate.DefineType): Report an internal error if
+ TypeManager.multicast_delegate_type is null. See bug #72015 for
+ details.
+
+2005-02-02 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix a crasher in a variant of #31984.
+ * const.cs (Constant.CheckBase): New override that defers the
+ new-or-override check in case the base type hasn't been populated
+ yet.
+ (Constant.Define): Ensure the new-or-override check is performed.
+
+2005-02-01 Duncan Mak <[EMAIL PROTECTED]>
+
+ * const.cs (LookupConstantValue): Check that `ce' is not null
+ before calling GetValue ().
+
+2005-02-01 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix test-334.cs (#69519).
+ * cs-parser.jay (using_alias_directive): Pass in an expression to
+ NamespaceEntry.UsingAlias.
+ (using_namespace_directive): Pass in an expression to
+ NamespaceEntry.Using.
+ (namespace_name): Don't flatten to a string.
+ * namespace.cs (NamespaceEntry.AliasEntry): Store an expression.
+ (NamespaceEntry.AliasEntry.Resolve): Lookup using
+ ResolveAsTypeStep.
+ (NamespaceEntry.UsingEntry): Likewise.
+ (NamespaceEntry.Using,NamespaceEntry.UsingAlias): Update to
+ changes.
+ (NamespaceEntry.LookupForUsing): Remove.
+ (NamespaceEntry.LookupNamespaceOrType): Add support for dotted
+ names.
+ (NamespaceEntry.Lookup): Remove support for dotted names.
+
+2005-02-01 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * namespace.cs (NamespaceEntry.NamespaceEntry): Simplify, and
+ split into two.
+ (NamespaceEntry.ImplicitParent): Compute on demand.
+ (NamespaceEntry.Doppelganger): New implicit namespace-entry that
+ parallels the current.
+ (NamespaceEntry.LookupForUsing): Use it.
+ (NamespaceEntry.Lookup): If the current namespace-entry is
+ implicit, don't search aliases and using tables.
+
+2005-02-01 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #31984.
+ * class.cs (TypeContainer.DoDefineMembers): Don't initialize
+ BaseCache here.
+ (TypeContainer.BaseCache): Compute on demand.
+ (TypeContainer.FindMembers): Define constants and types if they're
+ not already created.
+ (FieldMember.Define): Move resetting of ec.InUnsafe before error
+ check.
+ * const.cs (Constant.Define): Make idempotent.
+
+2005-01-29 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * pending.cs: Produce better code (no nops produced by using Ldarg
+ + value).
+
+ * pending.cs (PendingImplementation.DefineProxy): It was not `arg
+ i - 1' it should be arg + 1.
+
+ Fixes bug #71819.
+
+2005-01-28 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * attribute.cs (Attribute.CheckAttributeType): Make private
+ non-virtual.
+ (Attribute.ResolveType): Make virtual.
+ (GlobalAttribute.ResolveType,GlobalAttribute.Resolve): Simplify
+ handling of RootContext.Tree.Types.
+
+2005-01-27 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Update attribute-handling to use the SimpleName/MemberAccess
+ mechanisms.
+ * cs-parser.jay (attribute): Pass in an expression to the
+ constructors of Attribute and GlobalAttribute.
+ * attribute.cs (Attribute): Take an expression for the name.
+ (Attribute.ResolvePossibleAttributeTypes): New. Resolves the
+ passed in attribute name expression.
+ (Attribute.CheckAttributeType): Use it.
+ * ecore.cs (FullNamedExpression.ResolveAsTypeStep): New.
+ * expression.cs (MemberAccess.ResolveAsTypeStep): Move body to ...
+ (MemberAccess.ResolveNamespaceOrType): ... here. Add 'silent'
+ argument to prevent error messages if the lookup fails.
+
+2005-01-27 Marek Safar <[EMAIL PROTECTED]>
+
+ * expression.cs (Indirection): Implemented IVariable interface
+ to support indirection in AddressOf operator.
+ (PointerArithmetic.Emit): Add optimalization for case where
+ result can be precomputed.
+
+2005-01-26 Martin Baulig <[EMAIL PROTECTED]>
+
+ * class.cs (TypeContainer.AttributeTargets): Return the correct
+ AttributeTargets depending on our `Kind' instead of throwing an
+ exception; fixes #71632.
+
+2005-01-26 Marek Safar <[EMAIL PROTECTED]>
+
+ Fix #71257
+ * expression.cs (MemberAccess.ResolveMemberAccess): Add CS0176 test for
+ constant members.
+
2005-03-17 Martin Baulig <[EMAIL PROTECTED]>
* anonymous.cs (AnonymousMethod.method_modifiers): Change default
Modified: trunk/mcs/gmcs/attribute.cs
===================================================================
--- trunk/mcs/gmcs/attribute.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/attribute.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -72,6 +72,9 @@
public AttributeTargets Target;
public readonly string Name;
+ public readonly Expression LeftExpr;
+ public readonly string Identifier;
+
public readonly ArrayList Arguments;
public readonly Location Location;
@@ -102,9 +105,11 @@
static PtrHashtable usage_attr_cache = new PtrHashtable ();
- public Attribute (string target, string name, ArrayList args,
Location loc)
+ public Attribute (string target, Expression left_expr, string
identifier, ArrayList args, Location loc)
{
- Name = name;
+ LeftExpr = left_expr;
+ Identifier = identifier;
+ Name = LeftExpr == null ? identifier : LeftExpr + "." +
identifier;
Arguments = args;
Location = loc;
ExplicitTarget = target;
@@ -114,7 +119,7 @@
{
Report.Error (617, Location, "Invalid attribute
argument: '{0}'. Argument must be fields " +
"fields which are not readonly, static or
const; or read-write instance properties.",
- Name);
+ name);
}
static void Error_AttributeArgumentNotValid (string extra,
Location loc)
@@ -155,27 +160,50 @@
"Could not find a constructor for this
argument list.");
}
+ void ResolvePossibleAttributeTypes (EmitContext ec, out Type
t1, out Type t2)
+ {
+ t1 = null;
+ t2 = null;
+
+ FullNamedExpression n1 = null;
+ FullNamedExpression n2 = null;
+ string IdentifierAttribute = Identifier + "Attribute";
+ if (LeftExpr == null) {
+ n1 = new SimpleName (Identifier,
Location).ResolveAsTypeStep (ec);
+
+ // FIXME: Shouldn't do this for quoted
attributes: [EMAIL PROTECTED]
+ n2 = new SimpleName (IdentifierAttribute,
Location).ResolveAsTypeStep (ec);
+ } else {
+ FullNamedExpression l =
LeftExpr.ResolveAsTypeStep (ec);
+ if (l == null) {
+ Report.Error (246, Location, "Couldn't
find namespace or type '{0}'", LeftExpr);
+ return;
+ }
+ n1 = new MemberAccess (l, Identifier,
Location).ResolveNamespaceOrType (ec, true);
+
+ // FIXME: Shouldn't do this for quoted
attributes: [EMAIL PROTECTED]
+ n2 = new MemberAccess (l, IdentifierAttribute,
Location).ResolveNamespaceOrType (ec, true);
+ }
+
+ TypeExpr te1 = n1 == null ? null : n1 as TypeExpr;
+ TypeExpr te2 = n2 == null ? null : n2 as TypeExpr;
+
+ if (te1 != null)
+ t1 = te1.ResolveType (ec);
+ if (te2 != null)
+ t2 = te2.ResolveType (ec);
+ }
+
/// <summary>
/// Tries to resolve the type of the attribute. Flags an
error if it can't, and complain is true.
/// </summary>
- protected virtual Type CheckAttributeType (EmitContext ec)
+ Type CheckAttributeType (EmitContext ec)
{
+ Type t1, t2;
+ ResolvePossibleAttributeTypes (ec, out t1, out t2);
+
string NameAttribute = Name + "Attribute";
- FullNamedExpression n1 = ec.ResolvingTypeTree
- ? ec.DeclSpace.FindType (Location, Name)
- : ec.DeclSpace.LookupType (Name, true,
Location);
- // FIXME: Shouldn't do this for quoted attributes:
[EMAIL PROTECTED]
- FullNamedExpression n2 = ec.ResolvingTypeTree
- ? ec.DeclSpace.FindType (Location,
NameAttribute)
- : ec.DeclSpace.LookupType (NameAttribute, true,
Location);
-
- TypeExpr e1 = n1 == null ? null : n1 as TypeExpr;
- TypeExpr e2 = n2 == null ? null : n2 as TypeExpr;
-
- Type t1 = e1 == null ? null : e1.ResolveType (ec);
- Type t2 = e2 == null ? null : e2.ResolveType (ec);
-
String err0616 = null;
if (t1 != null && ! t1.IsSubclassOf
(TypeManager.attribute_type)) {
t1 = null;
@@ -210,7 +238,7 @@
return null;
}
- public Type ResolveType (EmitContext ec)
+ public virtual Type ResolveType (EmitContext ec)
{
if (Type == null)
Type = CheckAttributeType (ec);
@@ -1191,52 +1219,46 @@
{
public readonly NamespaceEntry ns;
- public GlobalAttribute (TypeContainer container, string target,
string name, ArrayList args, Location loc):
- base (target, name, args, loc)
+ public GlobalAttribute (TypeContainer container, string target,
+ Expression left_expr, string
identifier, ArrayList args, Location loc):
+ base (target, left_expr, identifier, args, loc)
{
ns = container.NamespaceEntry;
}
- protected override Type CheckAttributeType (EmitContext ec)
+ void Enter ()
{
// RootContext.Tree.Types has a single NamespaceEntry
which gets overwritten
// each time a new file is parsed. However, we need to
use the NamespaceEntry
// in effect where the attribute was used. Since code
elsewhere cannot assume
// that the NamespaceEntry is right, just overwrite it.
//
- // Precondition: RootContext.Tree.Types == null ||
RootContext.Tree.Types == ns.
- // The second case happens when we are
recursively invoked from inside Emit.
+ // Precondition: RootContext.Tree.Types == null
- NamespaceEntry old = null;
- if (ec.DeclSpace == RootContext.Tree.Types) {
- old = ec.DeclSpace.NamespaceEntry;
- ec.DeclSpace.NamespaceEntry = ns;
- if (old != null && old != ns)
- throw new InternalErrorException
(Location + " non-null NamespaceEntry " + old);
- }
+ if (RootContext.Tree.Types.NamespaceEntry != null)
+ throw new InternalErrorException (Location + "
non-null NamespaceEntry");
- Type retval = base.CheckAttributeType (ec);
+ RootContext.Tree.Types.NamespaceEntry = ns;
+ }
- if (ec.DeclSpace == RootContext.Tree.Types)
- ec.DeclSpace.NamespaceEntry = old;
+ void Leave ()
+ {
+ RootContext.Tree.Types.NamespaceEntry = null;
+ }
+ public override Type ResolveType (EmitContext ec)
+ {
+ Enter ();
+ Type retval = base.ResolveType (ec);
+ Leave ();
return retval;
}
public override CustomAttributeBuilder Resolve (EmitContext ec)
{
- if (ec.DeclSpace == RootContext.Tree.Types) {
- NamespaceEntry old =
ec.DeclSpace.NamespaceEntry;
- ec.DeclSpace.NamespaceEntry = ns;
- if (old != null)
- throw new InternalErrorException
(Location + " non-null NamespaceEntry " + old);
- }
-
+ Enter ();
CustomAttributeBuilder retval = base.Resolve (ec);
-
- if (ec.DeclSpace == RootContext.Tree.Types)
- ec.DeclSpace.NamespaceEntry = null;
-
+ Leave ();
return retval;
}
}
Modified: trunk/mcs/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/class.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -1470,15 +1470,6 @@
protected virtual bool DoDefineMembers ()
{
- //
- // We need to be able to use the member cache while we
are checking/defining
- //
- if (TypeBuilder.BaseType != null)
- base_cache = TypeManager.LookupMemberCache
(TypeBuilder.BaseType);
-
- if (TypeBuilder.IsInterface)
- base_cache =
TypeManager.LookupBaseInterfacesCache (TypeBuilder);
-
if (IsTopLevel) {
if ((ModFlags & Modifiers.NEW) != 0)
Error_KeywordNotAllowed (Location);
@@ -1799,6 +1790,10 @@
continue;
FieldBuilder fb =
con.FieldBuilder;
+ if (fb == null) {
+ if (con.Define ())
+ fb =
con.FieldBuilder;
+ }
if (fb != null && filter (fb,
criteria) == true) {
if (members == null)
members = new
ArrayList ();
@@ -1986,6 +1981,9 @@
continue;
TypeBuilder tb = t.TypeBuilder;
+ if (tb == null)
+ tb = t.DefineType ();
+
if (tb != null && (filter (tb,
criteria) == true)) {
if (members == null)
members = new
ArrayList ();
@@ -2588,6 +2586,12 @@
public virtual MemberCache BaseCache {
get {
+ if (base_cache != null)
+ return base_cache;
+ if (TypeBuilder.BaseType != null)
+ base_cache =
TypeManager.LookupMemberCache (TypeBuilder.BaseType);
+ if (TypeBuilder.IsInterface)
+ base_cache =
TypeManager.LookupBaseInterfacesCache (TypeBuilder);
return base_cache;
}
}
@@ -5661,9 +5665,9 @@
}
if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE))
== 0) {
- Report.SymbolRelatedToPreviousError
(conflict_symbol);
- Report.Warning (108, Location, "The keyword new
is required on '{0}' because it hides inherited member", GetSignatureForError
(Parent));
- }
+ Report.SymbolRelatedToPreviousError
(conflict_symbol);
+ Report.Warning (108, Location, "The keyword new
is required on '{0}' because it hides inherited member", GetSignatureForError
(Parent));
+ }
return true;
}
@@ -5762,13 +5766,13 @@
MemberType = texpr.Type;
+ ec.InUnsafe = old_unsafe;
+
if (MemberType == TypeManager.void_type) {
Report.Error (1547, Location, "Keyword 'void'
cannot be used in this context");
return false;
}
- ec.InUnsafe = old_unsafe;
-
if (!CheckBase ())
return false;
Modified: trunk/mcs/gmcs/const.cs
===================================================================
--- trunk/mcs/gmcs/const.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/const.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -62,11 +62,25 @@
}
#endif
+ protected override bool CheckBase ()
+ {
+ // Constant.Define can be called when the parent type
hasn't yet been populated
+ // and it's base types need not have been populated.
So, we defer this check
+ // to the second time Define () is called on this
member.
+ if (Parent.BaseCache == null)
+ return true;
+ return base.CheckBase ();
+ }
+
/// <summary>
/// Defines the constant in the @parent
/// </summary>
public override bool Define ()
{
+ // Make Define () idempotent, but ensure that the error
check happens.
+ if (FieldBuilder != null)
+ return base.CheckBase ();
+
if (!base.Define ())
return false;
@@ -248,8 +262,10 @@
}
Expr = ce;
}
- ConstantValue = ce.GetValue ();
+ if (ce != null)
+ ConstantValue = ce.GetValue ();
+
if (MemberType.IsEnum){
//
// This sadly does not work for our
user-defined enumerations types ;-(
Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/cs-parser.jay 2005-04-07 09:47:52 UTC (rev 42627)
@@ -338,7 +338,8 @@
: USING IDENTIFIER ASSIGN
namespace_or_type_name SEMICOLON
{
- current_namespace.UsingAlias ((string) $2, (MemberName) $4,
lexer.Location);
+ MemberName name = (MemberName) $4;
+ current_namespace.UsingAlias ((string) $2,
name.GetTypeExpression (lexer.Location), lexer.Location);
}
| USING error {
CheckIdentifierToken (yyToken);
@@ -348,7 +349,8 @@
using_namespace_directive
: USING namespace_name SEMICOLON
{
- current_namespace.Using ((string) $2, lexer.Location);
+ MemberName ns_name = (MemberName) $2;
+ current_namespace.Using (ns_name.GetTypeExpression
(lexer.Location), lexer.Location);
}
;
@@ -401,7 +403,7 @@
if (name.TypeArguments != null)
syntax_error (lexer.Location, "namespace name
expected");
- $$ = name.GetName ();
+ $$ = name;
}
;
@@ -622,19 +624,23 @@
}
opt_attribute_arguments
{
+ Location loc = (Location) $2;
MemberName mname = (MemberName) $1;
if (mname.IsGeneric) {
Report.Error (404, lexer.Location,
"'<' unexpected: attributes cannot be
generic");
}
- string name = mname.GetName ();
+ MemberName left = mname.Left;
+ string identifier = mname.Name;
+
+ Expression left_expr = left == null ? null :
left.GetTypeExpression (loc);
+
if (current_attr_target == "assembly" || current_attr_target ==
"module")
$$ = new GlobalAttribute (current_container,
current_attr_target,
- name, (ArrayList) $3,
(Location) $2);
+ left_expr, identifier,
(ArrayList) $3, loc);
else
- $$ = new Attribute (current_attr_target, name,
(ArrayList) $3,
- (Location) $2);
+ $$ = new Attribute (current_attr_target, left_expr,
identifier, (ArrayList) $3, loc);
}
;
Modified: trunk/mcs/gmcs/delegate.cs
===================================================================
--- trunk/mcs/gmcs/delegate.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/delegate.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -90,6 +90,11 @@
TypeAttributes attr = Modifiers.TypeAttr (ModFlags,
IsTopLevel) |
TypeAttributes.Class | TypeAttributes.Sealed;
+ if (TypeManager.multicast_delegate_type == null &&
!RootContext.StdLib) {
+ TypeExpr expr = new TypeLookupExpression
("System.MulticastDelegate");
+ TypeManager.multicast_delegate_type =
expr.ResolveType (ec);
+ }
+
if (TypeManager.multicast_delegate_type == null)
Report.Error (-100, Location, "Internal error:
delegate used before " +
"System.MulticastDelegate is
resolved. This can only " +
@@ -154,13 +159,15 @@
{
MethodAttributes mattr;
int i;
- ec = new EmitContext (this, this, Location, null, null,
ModFlags, false);
if (IsGeneric) {
foreach (TypeParameter type_param in
TypeParameters)
type_param.DefineType (ec);
}
+ if (ec == null)
+ throw new InternalErrorException ("Define
called before DefineType?");
+
// FIXME: POSSIBLY make this static, as it is always
constant
//
Type [] const_arg_types = new Type [2];
Modified: trunk/mcs/gmcs/driver.cs
===================================================================
--- trunk/mcs/gmcs/driver.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/driver.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -221,7 +221,6 @@
" -nostdlib[+|-] Does not load core
libraries\n" +
" -nowarn:W1[,W2] Disables one or more
warnings\n" +
" -out:FNAME Specifies output file\n"
+
- " -doc:XMLFILE Generates xml
documentation into specified file\n" +
" -pkg:P1[,Pn] References packages
P1..Pn\n" +
" --expect-error X Expect that error X will
be encountered\n" +
" -recurse:SPEC Recursively compiles the
files in SPEC ([dir]/file)\n" +
Modified: trunk/mcs/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/ecore.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -944,7 +944,7 @@
sb.Append (valid [i]);
}
- Error (119, "Expression denotes a `" + ExprClassName ()
+ "' where " +
+ Report.Error (119, loc, "Expression denotes a `" +
ExprClassName () + "' where " +
"a `" + sb.ToString () + "' was expected");
}
@@ -2278,6 +2278,11 @@
/// section 10.8.1 (Fully Qualified Names).
/// </summary>
public abstract class FullNamedExpression : Expression {
+ public override FullNamedExpression ResolveAsTypeStep
(EmitContext ec)
+ {
+ return this;
+ }
+
public abstract string FullName {
get;
}
Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/expression.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -431,13 +431,15 @@
}
IVariable variable = Expr as IVariable;
- if (!ec.InFixedInitializer && ((variable ==
null) || !variable.VerifyFixed (false))) {
+ bool is_fixed = variable != null &&
variable.VerifyFixed (false);
+
+ if (!ec.InFixedInitializer && !is_fixed) {
Error (212, "You can only take the
address of an unfixed expression inside " +
"of a fixed statement
initializer");
return null;
}
- if (ec.InFixedInitializer && ((variable !=
null) && variable.VerifyFixed (false))) {
+ if (ec.InFixedInitializer && is_fixed) {
Error (213, "You can not fix an already
fixed expression");
return null;
}
@@ -661,7 +663,7 @@
// after semantic analysis (this is so we can take the address
// of an indirection).
//
- public class Indirection : Expression, IMemoryLocation, IAssignMethod {
+ public class Indirection : Expression, IMemoryLocation, IAssignMethod,
IVariable {
Expression expr;
LocalTemporary temporary;
bool prepared;
@@ -735,6 +737,21 @@
{
return "*(" + expr + ")";
}
+
+ #region IVariable Members
+
+ public VariableInfo VariableInfo {
+ get {
+ return null;
+ }
+ }
+
+ public bool VerifyFixed (bool is_expression)
+ {
+ return true;
+ }
+
+ #endregion
}
/// <summary>
@@ -3458,17 +3475,26 @@
//
left.Emit (ec);
ig.Emit (OpCodes.Conv_I);
- right.Emit (ec);
- if (size != 1){
- if (size == 0)
- ig.Emit (OpCodes.Sizeof,
element);
- else
- IntLiteral.EmitInt (ig, size);
- if (rtype == TypeManager.int64_type)
- ig.Emit (OpCodes.Conv_I8);
- else if (rtype ==
TypeManager.uint64_type)
- ig.Emit (OpCodes.Conv_U8);
- ig.Emit (OpCodes.Mul);
+
+ Constant right_const = right as Constant;
+ if (right_const != null && size != 0) {
+ Expression ex = ConstantFold.BinaryFold
(ec, Binary.Operator.Multiply, new IntConstant (size), right_const, loc);
+ if (ex == null)
+ return;
+ ex.Emit (ec);
+ } else {
+ right.Emit (ec);
+ if (size != 1){
+ if (size == 0)
+ ig.Emit
(OpCodes.Sizeof, element);
+ else
+ IntLiteral.EmitInt (ig,
size);
+ if (rtype ==
TypeManager.int64_type)
+ ig.Emit
(OpCodes.Conv_I8);
+ else if (rtype ==
TypeManager.uint64_type)
+ ig.Emit
(OpCodes.Conv_U8);
+ ig.Emit (OpCodes.Mul);
+ }
}
if (rtype == TypeManager.int64_type || rtype ==
TypeManager.uint64_type)
@@ -7283,7 +7309,15 @@
object real_value = ((Constant)
c.Expr).GetValue ();
- return Constantify (real_value,
t);
+ Expression exp = Constantify
(real_value, t);
+
+ if (left_is_explicit &&
!left_is_type && !IdenticalNameAndTypeName (ec, left_original, left, loc)) {
+
Report.SymbolRelatedToPreviousError (c);
+ error176 (loc,
c.GetSignatureForError ());
+ return null;
+ }
+
+ return exp;
}
}
@@ -7607,6 +7641,11 @@
public override FullNamedExpression ResolveAsTypeStep
(EmitContext ec)
{
+ return ResolveNamespaceOrType (ec, false);
+ }
+
+ public FullNamedExpression ResolveNamespaceOrType (EmitContext
ec, bool silent)
+ {
FullNamedExpression new_expr = expr.ResolveAsTypeStep
(ec);
if (new_expr == null)
@@ -7619,7 +7658,7 @@
FullNamedExpression retval = ns.Lookup
(ec.DeclSpace, lookup_id, loc);
if ((retval != null) && (args != null))
retval = new ConstructedType (retval,
args, loc).ResolveAsTypeStep (ec);
- if (retval == null)
+ if (!silent && retval == null)
Report.Error (234, loc, "The type or
namespace name `{0}' could not be found in namespace `{1}'", Identifier,
ns.FullName);
return retval;
}
@@ -7638,7 +7677,7 @@
Expression member_lookup;
member_lookup = MemberLookupFinal (ec, expr_type,
expr_type, lookup_id, loc);
- if (member_lookup == null) {
+ if (!silent && member_lookup == null) {
Report.Error (234, loc, "The type name `{0}'
could not be found in type `{1}'",
Identifier, new_expr.FullName);
return null;
Modified: trunk/mcs/gmcs/location.cs
===================================================================
--- trunk/mcs/gmcs/location.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/location.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -57,7 +57,7 @@
/// in 8 bits (and say, map anything after char 255 to be `255+').
/// </remarks>
public struct Location {
- public int token;
+ int token;
static ArrayList source_list;
static Hashtable source_files;
@@ -84,7 +84,12 @@
string path = Path.GetFullPath (name);
if (source_files.Contains (path)){
- Report.Warning (2002, name, "Source file '{0}'
specified multiple times", path);
+ int id = (int) source_files [path];
+ string other_name = ((SourceFile) source_list
[id - 1]).Name;
+ if (name.Equals (other_name))
+ Report.Warning (2002, "Source file
'{0}' specified multiple times", name);
+ else
+ Report.Warning (2002, "Source filenames
'{0}' and '{1}' both refer to the same file: {2}", name, other_name, path);
return;
}
Modified: trunk/mcs/gmcs/namespace.cs
===================================================================
--- trunk/mcs/gmcs/namespace.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/namespace.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -229,37 +229,40 @@
// exist.
//
public class UsingEntry {
- public readonly string Name;
+ public Expression Name;
public readonly NamespaceEntry NamespaceEntry;
public readonly Location Location;
- public UsingEntry (NamespaceEntry entry, string name,
Location loc)
+ public UsingEntry (NamespaceEntry entry, Expression
name, Location loc)
{
Name = name;
NamespaceEntry = entry;
Location = loc;
}
- Namespace resolved_ns;
+ internal FullNamedExpression resolved;
public Namespace Resolve ()
{
- if (resolved_ns != null)
- return resolved_ns;
+ if (resolved != null)
+ return resolved as Namespace;
- FullNamedExpression resolved =
NamespaceEntry.LookupForUsing (Name, Location);
- resolved_ns = resolved as Namespace;
- return resolved_ns;
+ DeclSpace root = RootContext.Tree.Types;
+ root.NamespaceEntry = NamespaceEntry;
+ resolved = Name.ResolveAsTypeStep
(root.EmitContext);
+ root.NamespaceEntry = null;
+
+ return resolved as Namespace;
}
}
public class AliasEntry {
public readonly string Name;
- public readonly MemberName Alias;
+ public readonly Expression Alias;
public readonly NamespaceEntry NamespaceEntry;
public readonly Location Location;
- public AliasEntry (NamespaceEntry entry, string name,
MemberName alias, Location loc)
+ public AliasEntry (NamespaceEntry entry, string name,
Expression alias, Location loc)
{
Name = name;
Alias = alias;
@@ -274,55 +277,62 @@
if (resolved != null)
return resolved;
- //
- // GENERICS: Cope with the expression and not
with the string
- // this will fail with `using A = Stack<int>'
- //
-
- string alias = Alias.GetTypeName ();
+ DeclSpace root = RootContext.Tree.Types;
+ root.NamespaceEntry = NamespaceEntry;
+ resolved = Alias.ResolveAsTypeStep
(root.EmitContext);
+ root.NamespaceEntry = null;
- resolved = NamespaceEntry.LookupForUsing
(alias, Location);
- if (resolved == null)
- return null;
-
- if (Alias.TypeArguments == null)
- return resolved;
-
- EmitContext ec =
RootContext.Tree.Types.EmitContext;
- resolved = new TypeAliasExpression (resolved,
Alias.TypeArguments, Location);
- resolved = resolved.ResolveAsTypeStep (ec);
-
return resolved;
}
}
public NamespaceEntry (NamespaceEntry parent, SourceFile file,
string name, Location loc)
- : this (parent, file, name, false, loc)
- { }
-
- protected NamespaceEntry (NamespaceEntry parent, SourceFile
file, string name, bool is_implicit, Location loc)
{
this.parent = parent;
this.file = file;
- this.IsImplicit = is_implicit;
+ this.IsImplicit = false;
this.ID = ++next_id;
- if (!is_implicit && (parent != null))
+ if (parent != null)
ns = parent.NS.GetNamespace (name, true);
else if (name != null)
ns = Namespace.LookupNamespace (name, true);
else
ns = Namespace.Root;
ns.AddNamespaceEntry (this);
+ this.FullName = ns.Name;
+ }
- if ((parent != null) && (parent.NS != ns.Parent))
- implicit_parent = new NamespaceEntry (parent,
file, ns.Parent.Name, true, loc);
- else
- implicit_parent = parent;
+ private NamespaceEntry (NamespaceEntry parent, SourceFile file,
Namespace ns)
+ {
+ this.parent = parent;
+ this.file = file;
+ this.IsImplicit = true;
+ this.ID = ++next_id;
+ this.ns = ns;
this.FullName = ns.Name;
}
+ //
+ // According to section 16.3.1 (using-alias-directive), the
namespace-or-type-name is
+ // resolved as if the immediately containing namespace body has
no using-directives.
+ //
+ // Section 16.3.2 says that the same rule is applied when
resolving the namespace-name
+ // in the using-namespace-directive.
+ //
+ // To implement these rules, the expressions in the using
directives are resolved using
+ // the "doppelganger" (ghostly bodiless duplicate).
+ //
+ NamespaceEntry doppelganger;
+ NamespaceEntry Doppelganger {
+ get {
+ if (!IsImplicit && doppelganger == null)
+ doppelganger = new NamespaceEntry
(ImplicitParent, file, ns);
+ return doppelganger;
+ }
+ }
+
static int next_id = 0;
public readonly string FullName;
public readonly int ID;
@@ -342,6 +352,13 @@
public NamespaceEntry ImplicitParent {
get {
+ if (parent == null)
+ return null;
+ if (implicit_parent == null) {
+ implicit_parent = (parent.NS ==
ns.Parent)
+ ? parent
+ : new NamespaceEntry (parent,
file, ns.Parent);
+ }
return implicit_parent;
}
}
@@ -354,32 +371,34 @@
/// <summary>
/// Records a new namespace for resolving name references
/// </summary>
- public void Using (string ns, Location loc)
+ public void Using (Expression ns, Location loc)
{
+ string name = ns.ToString ();
if (DeclarationFound){
Report.Error (1529, loc, "A using clause must
precede all other namespace elements");
return;
}
- if (ns == FullName)
+ if (name == FullName)
return;
if (using_clauses == null)
using_clauses = new ArrayList ();
foreach (UsingEntry old_entry in using_clauses) {
- if (old_entry.Name == ns) {
+ if (old_entry.Name.ToString () == name) {
if (RootContext.WarningLevel >= 3)
- Report.Warning (105, loc, "The
using directive for '{0}' appeared previously in this namespace", ns);
+ Report.Warning (105, loc, "The
using directive for '{0}' appeared previously in this namespace", name);
return;
}
}
-
- UsingEntry ue = new UsingEntry (this, ns, loc);
+
+
+ UsingEntry ue = new UsingEntry (Doppelganger, ns, loc);
using_clauses.Add (ue);
}
- public void UsingAlias (string name, MemberName alias, Location
loc)
+ public void UsingAlias (string name, Expression alias, Location
loc)
{
if (DeclarationFound){
Report.Error (1529, loc, "A using clause must
precede all other namespace elements");
@@ -395,7 +414,7 @@
return;
}
- aliases [name] = new AliasEntry (this, name, alias,
loc);
+ aliases [name] = new AliasEntry (Doppelganger, name,
alias, loc);
}
public FullNamedExpression LookupAlias (string alias)
@@ -407,93 +426,51 @@
return entry == null ? null : entry.Resolve ();
}
- //
- // According to section 16.3.1 (using-alias-directive), the
namespace-or-type-name is
- // resolved as if the immediately containing namespace body has
no using-directives.
- //
- // Section 16.3.2 says that the same rule is applied when
resolving the namespace-name
- // in the using-namespace-directive.
- //
- public FullNamedExpression LookupForUsing (string dotted_name,
Location loc)
+ public FullNamedExpression LookupNamespaceOrType (DeclSpace ds,
string name, Location loc)
{
- int pos = dotted_name.IndexOf ('.');
- string simple_name = dotted_name;
+ FullNamedExpression resolved = null;
string rest = null;
+
+ // If name is of the form `N.I', first lookup `N', then
search a member `I' in it.
+ int pos = name.IndexOf ('.');
if (pos >= 0) {
- simple_name = dotted_name.Substring (0, pos);
- rest = dotted_name.Substring (pos + 1);
+ rest = name.Substring (pos + 1);
+ name = name.Substring (0, pos);
}
- FullNamedExpression o = NS.Lookup (null, simple_name,
loc);
- if (o == null && ImplicitParent != null)
- o = ImplicitParent.LookupNamespaceOrType (null,
simple_name, loc);
+ for (NamespaceEntry curr_ns = this; curr_ns != null;
curr_ns = curr_ns.ImplicitParent) {
+ if ((resolved = curr_ns.Lookup (ds, name, loc))
!= null)
+ break;
+ }
- if (o == null || rest == null)
- return o;
+ if (resolved == null || rest == null)
+ return resolved;
- Namespace ns = o as Namespace;
+ Namespace ns = resolved as Namespace;
if (ns != null)
- return ns.Lookup (null, rest, loc);
-
- Type nested = TypeManager.LookupType (o.FullName + "."
+ rest);
- if (nested == null)
+ return ns.Lookup (ds, rest, loc);
+
+ Type nested = TypeManager.LookupType (resolved.FullName
+ "." + rest);
+ if ((nested == null) || ((ds != null) &&
!ds.CheckAccessLevel (nested)))
return null;
return new TypeExpression (nested, Location.Null);
}
- public FullNamedExpression LookupNamespaceOrType (DeclSpace ds,
string name, Location loc)
- {
- FullNamedExpression resolved = null;
- for (NamespaceEntry curr_ns = this; curr_ns != null;
curr_ns = curr_ns.ImplicitParent) {
- if ((resolved = curr_ns.Lookup (ds, name, loc))
!= null)
- break;
- }
- return resolved;
- }
-
private FullNamedExpression Lookup (DeclSpace ds, string name,
Location loc)
{
- FullNamedExpression o;
- Namespace ns;
+ // Precondition: Only simple names (no dots) will be
looked up with this function.
//
- // If name is of the form `N.I', first lookup `N', then
search a member `I' in it.
- //
- // FIXME: Remove this block. Only simple names should
come here.
- // The bug: The loop in LookupNamespaceOrType
continues if
- // the lookup for N succeeds but the nested
lookup for I fails.
- // This is one part of #52697.
- //
- int pos = name.IndexOf ('.');
- if (pos >= 0) {
- string first = name.Substring (0, pos);
- string last = name.Substring (pos + 1);
-
- o = Lookup (ds, first, loc);
- if (o == null)
- return null;
-
- ns = o as Namespace;
- if (ns != null) {
- o = ns.Lookup (ds, last, loc);
- return o;
- }
-
- Type nested = TypeManager.LookupType
(o.FullName + "." + last);
- if ((nested == null) || ((ds != null) &&
!ds.CheckAccessLevel (nested)))
- return null;
-
- return new TypeExpression (nested,
Location.Null);
- }
-
- //
// Check whether it's in the namespace.
//
- o = NS.Lookup (ds, name, loc);
+ FullNamedExpression o = NS.Lookup (ds, name, loc);
if (o != null)
return o;
+ if (IsImplicit)
+ return null;
+
//
// Check aliases.
//
@@ -501,9 +478,6 @@
if (o != null)
return o;
- if (name.IndexOf ('.') > 0)
- return null;
-
//
// Check using entries.
//
@@ -561,7 +535,7 @@
if (using_clauses != null) {
using_list = new string [using_clauses.Count];
for (int i = 0; i < using_clauses.Count; i++)
- using_list [i] = ((UsingEntry)
using_clauses [i]).Name;
+ using_list [i] = ((UsingEntry)
using_clauses [i]).Name.ToString ();
} else {
using_list = new string [0];
}
@@ -629,8 +603,8 @@
if (ue.Resolve () != null)
continue;
- if (LookupForUsing (ue.Name,
ue.Location) == null)
- error246 (ue.Location, ue.Name);
+ if (ue.resolved == null)
+ error246 (ue.Location,
ue.Name.ToString ());
else
Report.Error (138, ue.Location,
"The using keyword only lets you specify a namespace, " +
"`" + ue.Name +
"' is a class not a namespace.");
@@ -645,7 +619,7 @@
if (alias.Resolve () != null)
continue;
- error246 (alias.Location,
alias.Alias.GetTypeName ());
+ error246 (alias.Location,
alias.Alias.ToString ());
}
}
}
Modified: trunk/mcs/gmcs/rootcontext.cs
===================================================================
--- trunk/mcs/gmcs/rootcontext.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/rootcontext.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -364,6 +364,9 @@
// These are classes that depends on the core interfaces
//
string [] classes_second_stage = {
+ "System.Enum",
+ "System.String",
+ "System.Array",
"System.Reflection.MemberInfo",
"System.Type",
"System.Exception",
@@ -400,19 +403,18 @@
"System.Security.CodeAccessPermission"
};
- // We must store them here before calling
BootstrapCorlib_ResolveDelegate.
- TypeManager.string_type = BootstrapCorlib_ResolveClass
(root, "System.String");
- TypeManager.enum_type = BootstrapCorlib_ResolveClass
(root, "System.Enum");
- TypeManager.array_type = BootstrapCorlib_ResolveClass
(root, "System.Array");
- TypeManager.multicast_delegate_type =
BootstrapCorlib_ResolveClass (root, "System.MulticastDelegate");
- TypeManager.delegate_type =
BootstrapCorlib_ResolveClass (root, "System.Delegate");
-
foreach (string cname in classes_second_stage)
BootstrapCorlib_ResolveClass (root, cname);
BootstrapCorlib_ResolveStruct (root,
"System.Nullable`1");
BootstrapCorlib_ResolveDelegate (root,
"System.AsyncCallback");
+
+ // These will be defined indirectly during the previous
ResolveDelegate.
+ // However make sure the rest of the checks happen.
+ string [] delegate_types = { "System.Delegate",
"System.MulticastDelegate" };
+ foreach (string cname in delegate_types)
+ BootstrapCorlib_ResolveClass (root, cname);
}
// <summary>
Modified: trunk/mcs/gmcs/statement.cs
===================================================================
--- trunk/mcs/gmcs/statement.cs 2005-04-07 09:36:31 UTC (rev 42626)
+++ trunk/mcs/gmcs/statement.cs 2005-04-07 09:47:52 UTC (rev 42627)
@@ -646,6 +646,7 @@
label.AddUsageVector
(ec.CurrentBranching.CurrentUsageVector);
ec.CurrentBranching.CurrentUsageVector.Goto ();
+ label.AddReference ();
return true;
}
@@ -718,8 +719,6 @@
{
ec.CurrentBranching.Label (vectors);
- referenced = true;
-
return true;
}
@@ -732,6 +731,11 @@
LabelTarget (ec);
ec.ig.MarkLabel (label);
}
+
+ public void AddReference ()
+ {
+ referenced = true;
+ }
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches