Browse Source

Updated mcs.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
4917151657
  1. 47
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  2. 34
      ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  3. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs
  4. 294
      ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  5. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs
  6. 1347
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  7. 63
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  8. 307
      ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs
  9. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs
  10. 10
      ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs
  11. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs
  12. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
  13. 17
      ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs
  14. 136
      ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs
  15. 10
      ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs
  16. 141
      ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
  17. 83
      ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs
  18. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs
  19. 42
      ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs
  20. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/roottypes.cs
  21. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs

47
ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs

@ -420,7 +420,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -420,7 +420,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
AddConstraints (newType, c);
AddConstraints (newType, c.CurrentTypeParameters);
if (location != null && curLoc < location.Count)
newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace);
typeStack.Push (newType);
@ -466,7 +466,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -466,7 +466,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
AddConstraints (newType, s);
AddConstraints (newType, s.CurrentTypeParameters);
if (location != null && curLoc < location.Count)
newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace);
typeStack.Push (newType);
@ -511,7 +511,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -511,7 +511,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
AddConstraints (newType, i);
AddConstraints (newType, i.CurrentTypeParameters);
if (location != null && curLoc < location.Count)
newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace);
typeStack.Push (newType);
@ -548,7 +548,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -548,7 +548,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (location != null) {
newDelegate.AddChild (new CSharpTokenNode (Convert (location[2]), 1), DelegateDeclaration.Roles.RPar);
}
AddConstraints (newDelegate, d);
AddConstraints (newDelegate, d.CurrentTypeParameters);
if (location != null) {
newDelegate.AddChild (new CSharpTokenNode (Convert (location[3]), 1), DelegateDeclaration.Roles.Semicolon);
}
@ -643,7 +643,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -643,7 +643,7 @@ namespace ICSharpCode.NRefactory.CSharp
AddModifiers (newField, location);
if (location != null)
newField.AddChild (new CSharpTokenNode (Convert (location [0]), "fixed".Length), FixedFieldDeclaration.Roles.Keyword);
newField.AddChild (ConvertToType (f.TypeName), FixedFieldDeclaration.Roles.Type);
newField.AddChild (ConvertToType (f.TypeExpression), FixedFieldDeclaration.Roles.Type);
var variable = new FixedVariableInitializer ();
variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), FixedFieldDeclaration.Roles.Identifier);
@ -690,7 +690,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -690,7 +690,7 @@ namespace ICSharpCode.NRefactory.CSharp
FieldDeclaration newField = new FieldDeclaration ();
AddAttributeSection (newField, f);
AddModifiers (newField, location);
newField.AddChild (ConvertToType (f.TypeName), FieldDeclaration.Roles.Type);
newField.AddChild (ConvertToType (f.TypeExpression), FieldDeclaration.Roles.Type);
VariableInitializer variable = new VariableInitializer ();
variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), FieldDeclaration.Roles.Identifier);
@ -732,7 +732,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -732,7 +732,7 @@ namespace ICSharpCode.NRefactory.CSharp
AddModifiers (newField, location);
if (location != null)
newField.AddChild (new CSharpModifierToken (Convert (location [0]), Modifiers.Const), AttributedNode.ModifierRole);
newField.AddChild (ConvertToType (f.TypeName), FieldDeclaration.Roles.Type);
newField.AddChild (ConvertToType (f.TypeExpression), FieldDeclaration.Roles.Type);
VariableInitializer variable = new VariableInitializer ();
variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), VariableInitializer.Roles.Identifier);
@ -780,15 +780,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -780,15 +780,15 @@ namespace ICSharpCode.NRefactory.CSharp
newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "implicit".Length), OperatorDeclaration.OperatorTypeRole);
newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
}
newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type);
newOperator.AddChild (ConvertToType (o.TypeExpression), AstNode.Roles.Type);
} else if (o.OperatorType == Operator.OpType.Explicit) {
if (location != null) {
newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "explicit".Length), OperatorDeclaration.OperatorTypeRole);
newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
}
newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type);
newOperator.AddChild (ConvertToType (o.TypeExpression), AstNode.Roles.Type);
} else {
newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type);
newOperator.AddChild (ConvertToType (o.TypeExpression), AstNode.Roles.Type);
if (location != null)
newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
@ -834,7 +834,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -834,7 +834,7 @@ namespace ICSharpCode.NRefactory.CSharp
AddAttributeSection (newIndexer, indexer);
var location = LocationsBag.GetMemberLocation (indexer);
AddModifiers (newIndexer, location);
newIndexer.AddChild (ConvertToType (indexer.TypeName), IndexerDeclaration.Roles.Type);
newIndexer.AddChild (ConvertToType (indexer.TypeExpression), IndexerDeclaration.Roles.Type);
AddExplicitInterface (newIndexer, indexer.MemberName);
var name = indexer.MemberName;
newIndexer.AddChild (Identifier.Create ("this", Convert (name.Location)), IndexerDeclaration.Roles.Identifier);
@ -895,7 +895,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -895,7 +895,7 @@ namespace ICSharpCode.NRefactory.CSharp
AddAttributeSection (newMethod, m);
var location = LocationsBag.GetMemberLocation (m);
AddModifiers (newMethod, location);
newMethod.AddChild (ConvertToType (m.TypeName), AstNode.Roles.Type);
newMethod.AddChild (ConvertToType (m.TypeExpression), AstNode.Roles.Type);
AddExplicitInterface (newMethod, m.MethodName);
newMethod.AddChild (Identifier.Create (m.MethodName.Name, Convert (m.Location)), AstNode.Roles.Identifier);
@ -908,7 +908,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -908,7 +908,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (location != null)
newMethod.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MethodDeclaration.Roles.RPar);
AddConstraints (newMethod, m.GenericMethod);
AddConstraints (newMethod, m.CurrentTypeParameters);
if (m.Block != null) {
var bodyBlock = (BlockStatement)m.Block.Accept (this);
@ -991,7 +991,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -991,7 +991,7 @@ namespace ICSharpCode.NRefactory.CSharp
AddAttributeSection (newProperty, p);
var location = LocationsBag.GetMemberLocation (p);
AddModifiers (newProperty, location);
newProperty.AddChild (ConvertToType (p.TypeName), AstNode.Roles.Type);
newProperty.AddChild (ConvertToType (p.TypeExpression), AstNode.Roles.Type);
AddExplicitInterface (newProperty, p.MemberName);
newProperty.AddChild (Identifier.Create (p.MemberName.Name, Convert (p.Location)), PropertyDeclaration.Roles.Identifier);
@ -1121,7 +1121,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1121,7 +1121,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (location != null)
newEvent.AddChild (new CSharpTokenNode (Convert (location[0]), "event".Length), EventDeclaration.Roles.Keyword);
newEvent.AddChild (ConvertToType (e.TypeName), AstNode.Roles.Type);
newEvent.AddChild (ConvertToType (e.TypeExpression), AstNode.Roles.Type);
VariableInitializer variable = new VariableInitializer ();
variable.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), FieldDeclaration.Roles.Identifier);
@ -1176,7 +1176,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1176,7 +1176,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (location != null)
newEvent.AddChild (new CSharpTokenNode (Convert (location[0]), "event".Length), CustomEventDeclaration.Roles.Keyword);
newEvent.AddChild (ConvertToType (ep.TypeName), CustomEventDeclaration.Roles.Type);
newEvent.AddChild (ConvertToType (ep.TypeExpression), CustomEventDeclaration.Roles.Type);
AddExplicitInterface (newEvent, ep.MemberName);
@ -2249,7 +2249,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2249,7 +2249,7 @@ namespace ICSharpCode.NRefactory.CSharp
result.Operator = BinaryOperatorType.NullCoalescing;
result.AddChild ((Expression)nullCoalescingOperator.LeftExpression.Accept (this), BinaryOperatorExpression.LeftRole);
result.AddChild (new CSharpTokenNode (Convert (nullCoalescingOperator.Location), 2), BinaryOperatorExpression.OperatorRole);
result.AddChild ((Expression)nullCoalescingOperator.Right.Accept (this), BinaryOperatorExpression.RightRole);
result.AddChild ((Expression)nullCoalescingOperator.RightExpression.Accept (this), BinaryOperatorExpression.RightRole);
return result;
}
@ -2416,12 +2416,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2416,12 +2416,17 @@ namespace ICSharpCode.NRefactory.CSharp
parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 1]), 1), InvocationExpression.Roles.RChevron);
}
void AddConstraints (AstNode parent, DeclSpace d)
void AddConstraints (AstNode parent, TypeParameters d)
{
if (d == null || d.Constraints == null)
if (d == null)
return;
for (int i = 0; i < d.PlainConstraints.Count; i++) {
Constraints c = d.PlainConstraints [i];
for (int i = d.Count - 1; i >= 0; i--) {
var typeParameter = d[i];
if (typeParameter == null)
continue;
var c = typeParameter.Constraints;
if (c == null)
continue;
var location = LocationsBag.GetLocations (c);
var constraint = new Constraint ();
constraint.AddChild (new CSharpTokenNode (Convert (c.Location), "where".Length), InvocationExpression.Roles.Keyword);

34
ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs

@ -39,7 +39,7 @@ namespace Mono.CSharp { @@ -39,7 +39,7 @@ namespace Mono.CSharp {
protected static MemberName MakeMemberName (MemberBase host, string name, int unique_id, TypeParameters tparams, Location loc)
{
string host_name = host == null ? null : host is InterfaceMemberBase ? ((InterfaceMemberBase)host).GetFullName (host.MemberName) : host.Name;
string host_name = host == null ? null : host is InterfaceMemberBase ? ((InterfaceMemberBase)host).GetFullName (host.MemberName) : host.MemberName.Name;
string tname = MakeName (host_name, "c", name, unique_id);
TypeParameters args = null;
if (tparams != null) {
@ -95,7 +95,7 @@ namespace Mono.CSharp { @@ -95,7 +95,7 @@ namespace Mono.CSharp {
var dst = new TypeParameterSpec[tparams.Count];
for (int i = 0; i < tparams.Count; ++i) {
type_params[i] = tparams[i].CreateHoistedCopy (this, spec);
type_params[i] = tparams[i].CreateHoistedCopy (spec);
src[i] = tparams[i].Type;
dst[i] = type_params[i].Type;
@ -127,7 +127,7 @@ namespace Mono.CSharp { @@ -127,7 +127,7 @@ namespace Mono.CSharp {
public HoistedStoreyClass GetGenericStorey ()
{
DeclSpace storey = this;
TypeContainer storey = this;
while (storey != null && storey.CurrentTypeParameters == null)
storey = storey.Parent;
@ -231,7 +231,7 @@ namespace Mono.CSharp { @@ -231,7 +231,7 @@ namespace Mono.CSharp {
CheckMembersDefined ();
FullNamedExpression field_type = new TypeExpression (type, Location);
if (!IsGeneric)
if (!spec.IsGenericOrParentIsGeneric)
return AddCompilerGeneratedField (name, field_type);
const Modifiers mod = Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED;
@ -718,7 +718,7 @@ namespace Mono.CSharp { @@ -718,7 +718,7 @@ namespace Mono.CSharp {
}
if (inner_access == null) {
if (field.Parent.IsGeneric) {
if (field.Parent.IsGenericOrParentIsGeneric) {
var fs = MemberCache.GetMember (field.Parent.CurrentType, field.Spec);
inner_access = new FieldExpr (fs, field.Location);
} else {
@ -1326,11 +1326,11 @@ namespace Mono.CSharp { @@ -1326,11 +1326,11 @@ namespace Mono.CSharp {
public readonly AnonymousMethodStorey Storey;
readonly string RealName;
public AnonymousMethodMethod (DeclSpace parent, AnonymousExpression am, AnonymousMethodStorey storey,
GenericMethod generic, TypeExpr return_type,
public AnonymousMethodMethod (TypeContainer parent, AnonymousExpression am, AnonymousMethodStorey storey,
TypeExpr return_type,
Modifiers mod, string real_name, MemberName name,
ParametersCompiled parameters)
: base (parent, generic, return_type, mod | Modifiers.COMPILER_GENERATED,
: base (parent, return_type, mod | Modifiers.COMPILER_GENERATED,
name, parameters, null)
{
this.AnonymousMethod = am;
@ -1590,22 +1590,17 @@ namespace Mono.CSharp { @@ -1590,22 +1590,17 @@ namespace Mono.CSharp {
"m", null, unique_id++);
MemberName member_name;
GenericMethod generic_method;
if (storey == null && ec.CurrentTypeParameters != null) {
var hoisted_tparams = ec.CurrentTypeParameters;
var type_params = new TypeParameters (hoisted_tparams.Count);
for (int i = 0; i < hoisted_tparams.Count; ++i) {
type_params.Add (hoisted_tparams[i].CreateHoistedCopy (parent, null));
type_params.Add (hoisted_tparams[i].CreateHoistedCopy (null));
}
member_name = new MemberName (name, type_params, Location);
generic_method = new GenericMethod (parent.NamespaceEntry, parent, member_name, //type_params,
new TypeExpression (ReturnType, Location), parameters);
} else {
member_name = new MemberName (name, Location);
generic_method = null;
}
string real_name = String.Format (
@ -1613,7 +1608,7 @@ namespace Mono.CSharp { @@ -1613,7 +1608,7 @@ namespace Mono.CSharp {
parameters.GetSignatureForError ());
return new AnonymousMethodMethod (parent,
this, storey, generic_method, new TypeExpression (ReturnType, Location), modifiers,
this, storey, new TypeExpression (ReturnType, Location), modifiers,
real_name, member_name, parameters);
}
@ -1825,9 +1820,6 @@ namespace Mono.CSharp { @@ -1825,9 +1820,6 @@ namespace Mono.CSharp {
AnonymousTypeClass a_type = new AnonymousTypeClass (parent.NamespaceEntry.SlaveDeclSpace,
new MemberName (name, tparams, loc), parameters, loc);
if (parameters.Count > 0)
a_type.SetParameterInfo (null);
Constructor c = new Constructor (a_type, name, Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
null, all_parameters, loc);
c.Block = new ToplevelBlock (parent.Module.Compiler, c.ParameterInfo, loc);
@ -1903,13 +1895,13 @@ namespace Mono.CSharp { @@ -1903,13 +1895,13 @@ namespace Mono.CSharp {
var equals_parameters = ParametersCompiled.CreateFullyResolved (
new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc), Compiler.BuiltinTypes.Object);
Method equals = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
Method equals = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Equals", loc),
equals_parameters, null);
equals_parameters[0].Resolve (equals, 0);
Method tostring = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.String, loc),
Method tostring = new Method (this, new TypeExpression (Compiler.BuiltinTypes.String, loc),
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("ToString", loc),
Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);
@ -2021,7 +2013,7 @@ namespace Mono.CSharp { @@ -2021,7 +2013,7 @@ namespace Mono.CSharp {
//
// GetHashCode () override
//
Method hashcode = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.Int, loc),
Method hashcode = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Int, loc),
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN,
new MemberName ("GetHashCode", loc),
Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs

@ -783,7 +783,7 @@ namespace Mono.CSharp @@ -783,7 +783,7 @@ namespace Mono.CSharp
class StackField : Field
{
public StackField (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name)
public StackField (TypeContainer parent, FullNamedExpression type, Modifiers mod, MemberName name)
: base (parent, type, mod, name, null)
{
}

294
ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs

@ -45,7 +45,7 @@ namespace Mono.CSharp @@ -45,7 +45,7 @@ namespace Mono.CSharp
/// <summary>
/// This is the base class for structs and classes.
/// </summary>
public abstract class TypeContainer : DeclSpace, ITypeDefinition, ITypesContainer
public abstract class TypeContainer : MemberCore, ITypeDefinition, ITypesContainer
{
//
// Different context is needed when resolving type container base
@ -180,6 +180,7 @@ namespace Mono.CSharp @@ -180,6 +180,7 @@ namespace Mono.CSharp
Dictionary<MethodSpec, Method> hoisted_base_call_proxies;
protected Dictionary<string, MemberCore> defined_names;
Dictionary<string, FullNamedExpression> Cache = new Dictionary<string, FullNamedExpression> ();
//
@ -211,7 +212,9 @@ namespace Mono.CSharp @@ -211,7 +212,9 @@ namespace Mono.CSharp
bool type_defined;
TypeContainer InTransit;
public TypeContainer PartialContainer;
public TypeBuilder TypeBuilder;
GenericTypeParameterBuilder[] all_tp_builders;
//
// All recursive type parameters put together sharing same
@ -219,6 +222,13 @@ namespace Mono.CSharp @@ -219,6 +222,13 @@ namespace Mono.CSharp
//
TypeParameters all_type_parameters;
//
// This is the namespace in which this typecontainer
// was declared. We use this to resolve names.
//
public NamespaceContainer NamespaceEntry;
public readonly string Basename;
public const string DefaultIndexerName = "Item";
private bool seen_normal_indexers = false;
@ -235,21 +245,26 @@ namespace Mono.CSharp @@ -235,21 +245,26 @@ namespace Mono.CSharp
public int DynamicSitesCounter;
static readonly string[] attribute_targets = new string[] { "type" };
/// <remarks>
/// The pending methods that need to be implemented
// (interfaces or abstract methods)
/// </remarks>
PendingImplementation pending;
public TypeContainer (NamespaceContainer ns, DeclSpace parent, MemberName name,
Attributes attrs, MemberKind kind)
: base (ns, parent, name, attrs)
public TypeContainer (NamespaceContainer ns, TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
: base (parent, name, attrs)
{
if (parent != null && parent.NamespaceEntry != ns)
throw new InternalErrorException ("A nested type should be in the same NamespaceEntry as its enclosing class");
this.Kind = kind;
this.PartialContainer = this;
this.Basename = name.Basename;
this.NamespaceEntry = ns;
defined_names = new Dictionary<string, MemberCore> ();
}
List<MemberCore> orderedAllMembers = new List<MemberCore> ();
@ -270,7 +285,7 @@ namespace Mono.CSharp @@ -270,7 +285,7 @@ namespace Mono.CSharp
public override TypeSpec CurrentType {
get {
if (current_type == null) {
if (IsGeneric) {
if (IsGenericOrParentIsGeneric) {
//
// Switch to inflated version as it's used by all expressions
//
@ -337,12 +352,58 @@ namespace Mono.CSharp @@ -337,12 +352,58 @@ namespace Mono.CSharp
}
}
public bool IsGenericOrParentIsGeneric {
get {
return all_type_parameters != null;
}
}
//
// root_types contains all the types. All TopLevel types
// hence have a parent that points to `root_types', that is
// why there is a non-obvious test down here.
//
public bool IsTopLevel {
get {
return Parent != null && Parent.Parent == null;
}
}
string ITypeDefinition.Namespace {
get {
return NamespaceEntry.NS.MemberName.GetSignatureForError ();
}
}
public TypeParameters TypeParametersAll {
get {
return all_type_parameters;
}
}
public override string[] ValidAttributeTargets {
get {
return attribute_targets;
}
}
#if FULL_AST
public bool HasOptionalSemicolon {
get;
private set;
}
Location optionalSemicolon;
public Location OptionalSemicolon {
get {
return optionalSemicolon;
}
set {
optionalSemicolon = value;
HasOptionalSemicolon = true;
}
}
#endif
#endregion
public override void Accept (StructuralVisitor visitor)
@ -367,7 +428,7 @@ namespace Mono.CSharp @@ -367,7 +428,7 @@ namespace Mono.CSharp
protected virtual void RemoveMemberType (TypeContainer ds)
{
RemoveFromContainer (ds.Basename);
defined_names.Remove (ds.Basename);
}
public void AddConstant (Const constant)
@ -381,12 +442,62 @@ namespace Mono.CSharp @@ -381,12 +442,62 @@ namespace Mono.CSharp
constants.Add (constant);
}
//
// Adds the member to defined_names table. It tests for duplications and enclosing name conflicts
//
protected virtual bool AddToContainer (MemberCore symbol, string name)
{
MemberCore mc;
if (!defined_names.TryGetValue (name, out mc)) {
defined_names.Add (name, symbol);
return true;
}
if (((mc.ModFlags | symbol.ModFlags) & Modifiers.COMPILER_GENERATED) != 0)
return true;
if (symbol.EnableOverloadChecks (mc))
return true;
InterfaceMemberBase im = mc as InterfaceMemberBase;
if (im != null && im.IsExplicitImpl)
return true;
Report.SymbolRelatedToPreviousError (mc);
if ((mc.ModFlags & Modifiers.PARTIAL) != 0 && (symbol is ClassOrStruct || symbol is Interface)) {
Error_MissingPartialModifier (symbol);
return false;
}
if (symbol is TypeParameter) {
Report.Error (692, symbol.Location,
"Duplicate type parameter `{0}'", symbol.GetSignatureForError ());
} else {
Report.Error (102, symbol.Location,
"The type `{0}' already contains a definition for `{1}'",
GetSignatureForError (), name);
}
return false;
}
public TypeContainer AddTypeContainer (TypeContainer tc)
{
orderedAllMembers.Add (tc);
if (!AddMemberType (tc))
return tc;
var tparams = tc.MemberName.TypeParameters;
if (tparams != null) {
for (int i = 0; i < tparams.Count; ++i) {
var tp = tparams[i];
if (tp.MemberName == null)
continue;
tc.AddMember (tp, tp.Name);
}
}
if (types == null)
types = new List<TypeContainer> ();
@ -427,6 +538,26 @@ namespace Mono.CSharp @@ -427,6 +538,26 @@ namespace Mono.CSharp
next_part.GetSignatureForError ());
}
var tc_names = tc.CurrentTypeParameters;
if (tc_names != null) {
for (int i = 0; i < tc_names.Count; ++i) {
var tp = next_part.MemberName.TypeParameters[i];
if (tc_names[i].MemberName.Name != tp.MemberName.Name) {
Report.SymbolRelatedToPreviousError (tc.Location, "");
Report.Error (264, next_part.Location, "Partial declarations of `{0}' must have the same type parameter names in the same order",
next_part.GetSignatureForError ());
break;
}
if (tc_names[i].Variance != tp.Variance) {
Report.SymbolRelatedToPreviousError (tc.Location, "");
Report.Error (1067, next_part.Location, "Partial declarations of `{0}' must have the same type parameter variance modifiers",
next_part.GetSignatureForError ());
break;
}
}
}
if (tc.partial_parts == null)
tc.partial_parts = new List<TypeContainer> (1);
@ -692,7 +823,7 @@ namespace Mono.CSharp @@ -692,7 +823,7 @@ namespace Mono.CSharp
}
}
protected override TypeAttributes TypeAttr {
protected virtual TypeAttributes TypeAttr {
get {
return ModifiersExtensions.TypeAttr (ModFlags, IsTopLevel);
}
@ -724,12 +855,6 @@ namespace Mono.CSharp @@ -724,12 +855,6 @@ namespace Mono.CSharp
}
}
string ITypeDefinition.Namespace {
get {
return NamespaceEntry.NS.MemberName.GetSignatureForError ();
}
}
public virtual void RegisterFieldForInitialization (MemberCore field, FieldInitializer expression)
{
if ((field.ModFlags & Modifiers.STATIC) != 0){
@ -898,11 +1023,9 @@ namespace Mono.CSharp @@ -898,11 +1023,9 @@ namespace Mono.CSharp
return a.GetAttributeUsageAttribute ();
}
public virtual void AddBasesForPart (DeclSpace part, List<FullNamedExpression> bases)
public virtual void AddBasesForPart (TypeContainer part, List<FullNamedExpression> bases)
{
// FIXME: get rid of partial_parts and store lists of bases of each part here
// assumed, not verified: 'part' is in 'partial_parts'
((TypeContainer) part).type_bases = bases;
part.type_bases = bases;
}
/// <summary>
@ -980,6 +1103,19 @@ namespace Mono.CSharp @@ -980,6 +1103,19 @@ namespace Mono.CSharp
return ifaces;
}
//
// Returns the MemberCore associated with a given name in the declaration
// space. It doesn't return method based symbols !!
//
// TODO: protected or private
//
public MemberCore GetDefinition (string name)
{
MemberCore mc = null;
defined_names.TryGetValue (name, out mc);
return mc;
}
TypeSpec[] GetNormalPartialBases ()
{
var ifaces = new List<TypeSpec> (0);
@ -1018,6 +1154,16 @@ namespace Mono.CSharp @@ -1018,6 +1154,16 @@ namespace Mono.CSharp
return ifaces.ToArray ();
}
public override string GetSignatureForDocumentation ()
{
return MemberName.GetName (true);
}
public override string GetSignatureForError ()
{
return MemberName.GetSignatureForError ();
}
//
// Checks that some operators come in pairs:
// == and !=
@ -1097,7 +1243,7 @@ namespace Mono.CSharp @@ -1097,7 +1243,7 @@ namespace Mono.CSharp
int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null ? 1 : 0;
if (IsTopLevel) {
TypeBuilder = Module.CreateBuilder (Name, TypeAttr, type_size);
TypeBuilder = Module.CreateBuilder (MemberName.GetName (true), TypeAttr, type_size);
} else {
TypeBuilder = Parent.TypeBuilder.DefineNestedType (Basename, TypeAttr, null, type_size);
}
@ -1112,7 +1258,7 @@ namespace Mono.CSharp @@ -1112,7 +1258,7 @@ namespace Mono.CSharp
if (!IsTopLevel)
Parent.MemberCache.AddMember (spec);
if (IsGeneric) {
if (MemberName.TypeParameters != null || Parent.IsGenericOrParentIsGeneric) {
var tparam_names = CreateTypeParameters ();
all_tp_builders = TypeBuilder.DefineGenericParameters (tparam_names);
@ -1204,7 +1350,6 @@ namespace Mono.CSharp @@ -1204,7 +1350,6 @@ namespace Mono.CSharp
cloned_params.Types[0] = Module.PredefinedTypes.RuntimeArgumentHandle.Resolve ();
}
GenericMethod generic_method;
MemberName member_name;
TypeArguments targs = null;
if (method.IsGeneric) {
@ -1218,22 +1363,19 @@ namespace Mono.CSharp @@ -1218,22 +1363,19 @@ namespace Mono.CSharp
targs.Arguments = new TypeSpec[hoisted_tparams.Length];
for (int i = 0; i < hoisted_tparams.Length; ++i) {
var tp = hoisted_tparams[i];
tparams.Add (new TypeParameter (tp, this, null, new MemberName (tp.Name, Location), null));
tparams.Add (new TypeParameter (tp, null, new MemberName (tp.Name, Location), null));
targs.Add (new SimpleName (tp.Name, Location));
targs.Arguments[i] = tp;
}
member_name = new MemberName (name, tparams, Location);
generic_method = new GenericMethod (NamespaceEntry, this, member_name,
new TypeExpression (method.ReturnType, Location), cloned_params);
} else {
member_name = new MemberName (name);
generic_method = null;
}
// Compiler generated proxy
proxy_method = new Method (this, generic_method, new TypeExpression (method.ReturnType, Location),
proxy_method = new Method (this, new TypeExpression (method.ReturnType, Location),
Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
member_name, cloned_params, null);
@ -1412,7 +1554,7 @@ namespace Mono.CSharp @@ -1412,7 +1554,7 @@ namespace Mono.CSharp
return true;
}
public override void DefineType ()
public void DefineType ()
{
if (error)
return;
@ -1441,32 +1583,6 @@ namespace Mono.CSharp @@ -1441,32 +1583,6 @@ namespace Mono.CSharp
}
}
public override void SetParameterInfo (List<Constraints> constraints_list)
{
base.SetParameterInfo (constraints_list);
if (PartialContainer.CurrentTypeParameters == null || PartialContainer == this)
return;
var tc_names = PartialContainer.CurrentTypeParameters;
for (int i = 0; i < tc_names.Count; ++i) {
var tp = MemberName.TypeParameters[i];
if (tc_names[i].MemberName.Name != tp.MemberName.Name) {
Report.SymbolRelatedToPreviousError (PartialContainer.Location, "");
Report.Error (264, Location, "Partial declarations of `{0}' must have the same type parameter names in the same order",
GetSignatureForError ());
break;
}
if (tc_names[i].Variance != tp.Variance) {
Report.SymbolRelatedToPreviousError (PartialContainer.Location, "");
Report.Error (1067, Location, "Partial declarations of `{0}' must have the same type parameter variance modifiers",
GetSignatureForError ());
break;
}
}
}
//
// Replaces normal spec with predefined one when compiling corlib
// and this type container defines predefined type
@ -1667,7 +1783,7 @@ namespace Mono.CSharp @@ -1667,7 +1783,7 @@ namespace Mono.CSharp
if (obsolete_attr != null && !IsObsolete)
AttributeTester.Report_ObsoleteMessage (obsolete_attr, base_type.GetSignatureForError (), base_type_expr.Location, Report);
if (IsGeneric && base_type.IsAttribute) {
if (IsGenericOrParentIsGeneric && base_type.IsAttribute) {
Report.Error (698, base_type_expr.Location,
"A generic type cannot derive from `{0}' because it is an attribute class",
base_type.GetSignatureForError ());
@ -2078,6 +2194,13 @@ namespace Mono.CSharp @@ -2078,6 +2194,13 @@ namespace Mono.CSharp
}
}
protected void Error_MissingPartialModifier (MemberCore type)
{
Report.Error (260, type.Location,
"Missing partial modifier on declaration of type `{0}'. Another partial declaration of this type exists",
type.GetSignatureForError ());
}
public virtual void CloseType ()
{
if ((caching_flags & Flags.CloseTypeCreated) != 0)
@ -2279,6 +2402,11 @@ namespace Mono.CSharp @@ -2279,6 +2402,11 @@ namespace Mono.CSharp
return Module.DeclaringAssembly == assembly;
}
public virtual bool IsUnmanagedType ()
{
return false;
}
public void LoadMembers (TypeSpec declaringType, bool onlyTypes, ref MemberCache cache)
{
throw new NotSupportedException ("Not supported for compiled definition " + GetSignatureForError ());
@ -2401,8 +2529,7 @@ namespace Mono.CSharp @@ -2401,8 +2529,7 @@ namespace Mono.CSharp
{
SecurityType declarative_security;
public ClassOrStruct (NamespaceContainer ns, DeclSpace parent,
MemberName name, Attributes attrs, MemberKind kind)
public ClassOrStruct (NamespaceContainer ns, TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
: base (ns, parent, name, attrs, kind)
{
}
@ -2527,8 +2654,7 @@ namespace Mono.CSharp @@ -2527,8 +2654,7 @@ namespace Mono.CSharp
public override ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
{
DeclSpace top_level = Parent;
if (top_level != null) {
if (Parent != null) {
var methods = NamespaceEntry.NS.LookupExtensionMethod (this, extensionType, name, arity);
if (methods != null) {
return new ExtensionMethodCandidates (methods, NamespaceEntry, NamespaceEntry.NS) {
@ -2566,8 +2692,7 @@ namespace Mono.CSharp @@ -2566,8 +2692,7 @@ namespace Mono.CSharp
public const TypeAttributes StaticClassAttribute = TypeAttributes.Abstract | TypeAttributes.Sealed;
public Class (NamespaceContainer ns, DeclSpace parent, MemberName name, Modifiers mod,
Attributes attrs)
public Class (NamespaceContainer ns, TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs)
: base (ns, parent, name, attrs, MemberKind.Class)
{
var accmods = (Parent == null || Parent.Parent == null) ? Modifiers.INTERNAL : Modifiers.PRIVATE;
@ -2580,9 +2705,10 @@ namespace Mono.CSharp @@ -2580,9 +2705,10 @@ namespace Mono.CSharp
visitor.Visit (this);
}
public override void AddBasesForPart (DeclSpace part, List<FullNamedExpression> bases)
public override void AddBasesForPart (TypeContainer part, List<FullNamedExpression> bases)
{
if (part.Name == "System.Object")
var pmn = part.MemberName;
if (pmn.Name == "Object" && pmn.Left != null && pmn.Left.Name == "System" && pmn.TypeParameters == null)
Report.Error (537, part.Location,
"The class System.Object cannot have a base class or implement an interface.");
base.AddBasesForPart (part, bases);
@ -2800,8 +2926,7 @@ namespace Mono.CSharp @@ -2800,8 +2926,7 @@ namespace Mono.CSharp
Modifiers.UNSAFE |
Modifiers.PRIVATE;
public Struct (NamespaceContainer ns, DeclSpace parent, MemberName name,
Modifiers mod, Attributes attrs)
public Struct (NamespaceContainer ns, TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs)
: base (ns, parent, name, attrs, MemberKind.Struct)
{
var accmods = parent.Parent == null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
@ -2912,7 +3037,7 @@ namespace Mono.CSharp @@ -2912,7 +3037,7 @@ namespace Mono.CSharp
if (requires_delayed_unmanagedtype_check)
return true;
if (Parent != null && Parent.IsGeneric) {
if (Parent != null && Parent.IsGenericOrParentIsGeneric) {
has_unmanaged_check_done = true;
return false;
}
@ -2991,8 +3116,7 @@ namespace Mono.CSharp @@ -2991,8 +3116,7 @@ namespace Mono.CSharp
Modifiers.UNSAFE |
Modifiers.PRIVATE;
public Interface (NamespaceContainer ns, DeclSpace parent, MemberName name, Modifiers mod,
Attributes attrs)
public Interface (NamespaceContainer ns, TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs)
: base (ns, parent, name, attrs, MemberKind.Interface)
{
var accmods = parent.Parent == null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
@ -3122,11 +3246,8 @@ namespace Mono.CSharp @@ -3122,11 +3246,8 @@ namespace Mono.CSharp
readonly Modifiers explicit_mod_flags;
public MethodAttributes flags;
public InterfaceMemberBase (DeclSpace parent, GenericMethod generic,
FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
MemberName name, Attributes attrs)
: base (parent, generic, type, mod, allowed_mod, Modifiers.PRIVATE,
name, attrs)
public InterfaceMemberBase (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod, allowed_mod, Modifiers.PRIVATE, name, attrs)
{
IsInterface = parent.PartialContainer.Kind == MemberKind.Interface;
IsExplicitImpl = (MemberName.ExplicitInterface != null);
@ -3523,18 +3644,6 @@ namespace Mono.CSharp @@ -3523,18 +3644,6 @@ namespace Mono.CSharp
return Parent.GetSignatureForDocumentation () + "." + ShortName;
}
protected override bool VerifyClsCompliance ()
{
if (!base.VerifyClsCompliance ()) {
return false;
}
if (GenericMethod != null)
GenericMethod.VerifyClsCompliance ();
return true;
}
public override bool IsUsed
{
get { return IsExplicitImpl || base.IsUsed; }
@ -3547,26 +3656,11 @@ namespace Mono.CSharp @@ -3547,26 +3656,11 @@ namespace Mono.CSharp
protected FullNamedExpression type_expr;
protected TypeSpec member_type;
public readonly DeclSpace ds;
public readonly GenericMethod GenericMethod;
public FullNamedExpression TypeName {
get {
return type_expr;
}
}
protected MemberBase (DeclSpace parent, GenericMethod generic,
FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers def_mod,
MemberName name, Attributes attrs)
protected MemberBase (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers def_mod, MemberName name, Attributes attrs)
: base (parent, name, attrs)
{
this.ds = generic != null ? generic : (DeclSpace) parent;
this.type_expr = type;
ModFlags = ModifiersExtensions.Check (allowed_mod, mod, def_mod, Location, Report);
GenericMethod = generic;
if (GenericMethod != null)
GenericMethod.ModFlags = ModFlags;
}
#region Properties
@ -3679,7 +3773,7 @@ namespace Mono.CSharp @@ -3679,7 +3773,7 @@ namespace Mono.CSharp
public override string GetSignatureForDocumentation ()
{
return Parent.Name + "." + Name;
return Parent.GetSignatureForDocumentation () + "." + MemberName.Basename;
}
protected virtual bool ResolveMemberType ()

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs

@ -26,7 +26,7 @@ namespace Mono.CSharp { @@ -26,7 +26,7 @@ namespace Mono.CSharp {
Modifiers.INTERNAL |
Modifiers.PRIVATE;
public Const (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
public Const (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, AllowedModifiers, name, attrs)
{
ModFlags |= Modifiers.STATIC;

1347
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs

File diff suppressed because it is too large Load Diff

63
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

@ -47,7 +47,7 @@ namespace Mono.CSharp @@ -47,7 +47,7 @@ namespace Mono.CSharp
NamespaceContainer current_namespace;
TypeContainer current_container;
DeclSpace current_class;
TypeContainer current_class;
PropertyBase current_property;
EventProperty current_event;
EventField current_event_field;
@ -946,7 +946,8 @@ struct_declaration @@ -946,7 +946,8 @@ struct_declaration
{
lexer.ConstraintsParsing = false;
current_class.SetParameterInfo ((List<Constraints>) $9);
if ($9 != null)
current_class.SetConstraints ((List<Constraints>) $9);
if (doc_support)
current_container.DocComment = Lexer.consume_doc_comment ();
@ -1284,19 +1285,11 @@ method_header @@ -1284,19 +1285,11 @@ method_header
MemberName name = (MemberName) $4;
current_local_parameters = (ParametersCompiled) $7;
GenericMethod generic = null;
if (name.TypeParameters != null) {
generic = new GenericMethod (current_namespace, current_class, name,
(FullNamedExpression) $3, current_local_parameters);
generic.SetParameterInfo ((List<Constraints>) $10);
} else if ($10 != null) {
report.Error (80, GetLocation ($10),
"Constraints are not allowed on non-generic declarations");
}
var method = Method.Create (current_class, generic, (FullNamedExpression) $3, (Modifiers) $2,
var method = Method.Create (current_class, (FullNamedExpression) $3, (Modifiers) $2,
name, current_local_parameters, (Attributes) $1, $10 != null);
if ($10 != null)
method.SetConstraints ((List<Constraints>) $10);
if (doc_support)
method.DocComment = Lexer.consume_doc_comment ();
@ -1329,25 +1322,15 @@ method_header @@ -1329,25 +1322,15 @@ method_header
MemberName name = (MemberName) $6;
current_local_parameters = (ParametersCompiled) $9;
if ($11 != null && name.TypeParameters == null)
report.Error (80, lexer.Location,
"Constraints are not allowed on non-generic declarations");
GenericMethod generic = null;
if (name.TypeParameters != null) {
generic = new GenericMethod (current_namespace, current_class, name,
new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($4)),
current_local_parameters);
generic.SetParameterInfo ((List<Constraints>) $11);
}
var modifiers = (Modifiers) $2;
modifiers |= Modifiers.PARTIAL;
var method = Method.Create (current_class, generic, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($4)),
var method = Method.Create (current_class, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($4)),
modifiers, name, current_local_parameters, (Attributes) $1, $11 != null);
if ($11 != null)
method.SetConstraints ((List<Constraints>) $11);
if (doc_support)
method.DocComment = Lexer.consume_doc_comment ();
@ -1364,7 +1347,7 @@ method_header @@ -1364,7 +1347,7 @@ method_header
report.Error (1585, name.Location,
"Member modifier `{0}' must precede the member type and name", ModifiersExtensions.Name ((Modifiers) $4));
var method = Method.Create (current_class, null, (FullNamedExpression) $3,
var method = Method.Create (current_class, (FullNamedExpression) $3,
0, name, (ParametersCompiled) $7, (Attributes) $1, false);
current_local_parameters = (ParametersCompiled) $7;
@ -1919,7 +1902,8 @@ interface_declaration @@ -1919,7 +1902,8 @@ interface_declaration
{
lexer.ConstraintsParsing = false;
current_class.SetParameterInfo ((List<Constraints>) $9);
if ($9 != null)
current_class.SetConstraints ((List<Constraints>) $9);
if (doc_support) {
current_container.DocComment = Lexer.consume_doc_comment ();
@ -2177,8 +2161,6 @@ constructor_declaration @@ -2177,8 +2161,6 @@ constructor_declaration
if (doc_support)
c.DocComment = ConsumeStoredComment ();
current_container.AddConstructor (c);
current_local_parameters = null;
if (doc_support)
Lexer.doc_state = XmlCommentState.Allowed;
@ -2216,6 +2198,7 @@ constructor_declarator @@ -2216,6 +2198,7 @@ constructor_declarator
}
}
current_container.AddConstructor (c);
lbag.AddMember (c, GetModifierLocations (), GetLocation ($5), GetLocation ($7));
$$ = c;
@ -2236,7 +2219,6 @@ constructor_declarator @@ -2236,7 +2219,6 @@ constructor_declarator
"`{0}': static constructor cannot have an explicit `this' or `base' constructor call",
c.GetSignatureForError ());
}
lbag.AddMember (c, GetModifierLocations (), GetLocation ($5), GetLocation ($7));
}
$$ = $8;
@ -2686,7 +2668,8 @@ delegate_declaration @@ -2686,7 +2668,8 @@ delegate_declaration
Lexer.doc_state = XmlCommentState.Allowed;
}
current_delegate.SetParameterInfo ((List<Constraints>) $11);
if ($11 != null)
current_delegate.SetConstraints ((List<Constraints>) $11);
lbag.AddMember (current_delegate, GetModifierLocations (), GetLocation ($3), GetLocation ($6), GetLocation ($9), GetLocation ($13));
$$ = current_delegate;
@ -4333,14 +4316,15 @@ class_declaration @@ -4333,14 +4316,15 @@ class_declaration
}
push_current_class (c, $3);
lbag.AddMember (current_class, GetModifierLocations (), GetLocation ($4));
}
opt_class_base
opt_type_parameter_constraints_clauses
{
lexer.ConstraintsParsing = false;
current_class.SetParameterInfo ((List<Constraints>) $9);
if ($9 != null)
current_class.SetConstraints ((List<Constraints>) $9);
lbag.AddMember (current_class, GetModifierLocations (), GetLocation ($4));
if (doc_support) {
current_container.DocComment = Lexer.consume_doc_comment ();
@ -4608,7 +4592,7 @@ opt_type_parameter_variance @@ -4608,7 +4592,7 @@ opt_type_parameter_variance
{
if (lang_version <= LanguageVersion.V_3)
FeatureIsNotAvailable (lexer.Location, "generic type variance");
$$ = $1;
}
;
@ -6302,7 +6286,6 @@ interactive_parsing @@ -6302,7 +6286,6 @@ interactive_parsing
current_local_parameters = pars;
Method method = new Method (
current_class,
null, // generic
new TypeExpression (compiler.BuiltinTypes.Void, Location.Null),
mods,
new MemberName ("Host"),
@ -6545,9 +6528,9 @@ void push_current_class (TypeContainer tc, object partial_token) @@ -6545,9 +6528,9 @@ void push_current_class (TypeContainer tc, object partial_token)
ubag.PushTypeDeclaration (tc);
}
DeclSpace pop_current_class ()
TypeContainer pop_current_class ()
{
DeclSpace retval = current_class;
var retval = current_class;
current_class = current_class.Parent;
current_container = current_class.PartialContainer;

307
ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs

@ -220,20 +220,6 @@ namespace Mono.CSharp { @@ -220,20 +220,6 @@ namespace Mono.CSharp {
[System.Diagnostics.DebuggerDisplay ("{GetSignatureForError()}")]
public abstract class MemberCore : Attributable, IMemberContext, IMemberDefinition
{
/// <summary>
/// Public name
/// </summary>
protected string cached_name;
// TODO: Remove in favor of MemberName
public string Name {
get {
if (cached_name == null)
cached_name = MemberName.GetName (!(this is GenericMethod) && !(this is Method));
return cached_name;
}
}
string IMemberDefinition.Name {
get {
return member_name.Name;
@ -312,9 +298,9 @@ namespace Mono.CSharp { @@ -312,9 +298,9 @@ namespace Mono.CSharp {
/// </summary>
internal Flags caching_flags;
public MemberCore (DeclSpace parent, MemberName name, Attributes attrs)
public MemberCore (TypeContainer parent, MemberName name, Attributes attrs)
{
this.Parent = parent as TypeContainer;
this.Parent = parent;
member_name = name;
caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected;
AddAttributes (attrs, this);
@ -323,7 +309,6 @@ namespace Mono.CSharp { @@ -323,7 +309,6 @@ namespace Mono.CSharp {
protected virtual void SetMemberName (MemberName new_name)
{
member_name = new_name;
cached_name = null;
}
public virtual void Accept (StructuralVisitor visitor)
@ -467,6 +452,26 @@ namespace Mono.CSharp { @@ -467,6 +452,26 @@ namespace Mono.CSharp {
caching_flags |= Flags.IsAssigned;
}
public void SetConstraints (List<Constraints> constraints_list)
{
var tparams = member_name.TypeParameters;
if (tparams == null) {
Report.Error (80, Location, "Constraints are not allowed on non-generic declarations");
return;
}
foreach (var c in constraints_list) {
var tp = tparams.Find (c.TypeParameter.Value);
if (tp == null) {
Report.Error (699, c.Location, "`{0}': A constraint references nonexistent type parameter `{1}'",
GetSignatureForError (), c.TypeParameter.Value);
continue;
}
tp.Constraints = c;
}
}
/// <summary>
/// Returns instance of ObsoleteAttribute for this MemberCore
/// </summary>
@ -640,7 +645,7 @@ namespace Mono.CSharp { @@ -640,7 +645,7 @@ namespace Mono.CSharp {
if ((ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0)
return false;
DeclSpace parentContainer = Parent.PartialContainer;
var parentContainer = Parent.PartialContainer;
while (parentContainer != null && parentContainer.ModFlags != 0) {
if ((parentContainer.ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0)
return false;
@ -769,6 +774,9 @@ namespace Mono.CSharp { @@ -769,6 +774,9 @@ namespace Mono.CSharp {
Report.Warning (3008, 1, Location, "Identifier `{0}' is not CLS-compliant", GetSignatureForError () );
}
if (member_name.TypeParameters != null)
member_name.TypeParameters.VerifyClsCompliance ();
return true;
}
@ -1054,7 +1062,13 @@ namespace Mono.CSharp { @@ -1054,7 +1062,13 @@ namespace Mono.CSharp {
public virtual string GetSignatureForError ()
{
var bf = MemberDefinition as Property.BackingField;
var name = bf == null ? Name : bf.OriginalName;
string name;
if (bf == null) {
name = Name;
} else {
name = bf.OriginalProperty.MemberName.Name;
}
return DeclaringType.GetSignatureForError () + "." + name;
}
@ -1197,259 +1211,4 @@ namespace Mono.CSharp { @@ -1197,259 +1211,4 @@ namespace Mono.CSharp {
{
TypeSpec MemberType { get; }
}
//
// Base type container declaration. It exists to handle partial types
// which share same definition (PartialContainer) but have different
// resolve scopes
//
public abstract class DeclSpace : MemberCore {
/// <summary>
/// This points to the actual definition that is being
/// created with System.Reflection.Emit
/// </summary>
public TypeBuilder TypeBuilder;
//
// This is the namespace in which this typecontainer
// was declared. We use this to resolve names.
//
public NamespaceContainer NamespaceEntry;
public readonly string Basename;
protected Dictionary<string, MemberCore> defined_names;
public TypeContainer PartialContainer;
protected readonly bool is_generic;
//
// Whether we are Generic
//
public bool IsGeneric {
get {
if (is_generic)
return true;
else if (Parent != null)
return Parent.IsGeneric;
else
return false;
}
}
static readonly string[] attribute_targets = new string [] { "type" };
public DeclSpace (NamespaceContainer ns, DeclSpace parent, MemberName name,
Attributes attrs)
: base (parent, name, attrs)
{
NamespaceEntry = ns;
Basename = name.Basename;
defined_names = new Dictionary<string, MemberCore> ();
PartialContainer = null;
if (name.TypeParameters != null) {
is_generic = true;
}
}
/// <summary>
/// Adds the member to defined_names table. It tests for duplications and enclosing name conflicts
/// </summary>
protected virtual bool AddToContainer (MemberCore symbol, string name)
{
MemberCore mc;
if (!defined_names.TryGetValue (name, out mc)) {
defined_names.Add (name, symbol);
return true;
}
if (((mc.ModFlags | symbol.ModFlags) & Modifiers.COMPILER_GENERATED) != 0)
return true;
if (symbol.EnableOverloadChecks (mc))
return true;
InterfaceMemberBase im = mc as InterfaceMemberBase;
if (im != null && im.IsExplicitImpl)
return true;
Report.SymbolRelatedToPreviousError (mc);
if ((mc.ModFlags & Modifiers.PARTIAL) != 0 && (symbol is ClassOrStruct || symbol is Interface)) {
Error_MissingPartialModifier (symbol);
return false;
}
if (symbol is TypeParameter) {
Report.Error (692, symbol.Location,
"Duplicate type parameter `{0}'", symbol.GetSignatureForError ());
} else {
Report.Error (102, symbol.Location,
"The type `{0}' already contains a definition for `{1}'",
GetSignatureForError (), name);
}
return false;
}
protected void RemoveFromContainer (string name)
{
defined_names.Remove (name);
}
/// <summary>
/// Returns the MemberCore associated with a given name in the declaration
/// space. It doesn't return method based symbols !!
/// </summary>
///
public MemberCore GetDefinition (string name)
{
MemberCore mc = null;
defined_names.TryGetValue (name, out mc);
return mc;
}
//
// root_types contains all the types. All TopLevel types
// hence have a parent that points to `root_types', that is
// why there is a non-obvious test down here.
//
public bool IsTopLevel {
get { return (Parent != null && Parent.Parent == null); }
}
public virtual bool IsUnmanagedType ()
{
return false;
}
protected abstract TypeAttributes TypeAttr { get; }
/// <remarks>
/// Should be overriten by the appropriate declaration space
/// </remarks>
public abstract void DefineType ();
protected void Error_MissingPartialModifier (MemberCore type)
{
Report.Error (260, type.Location,
"Missing partial modifier on declaration of type `{0}'. Another partial declaration of this type exists",
type.GetSignatureForError ());
}
public override string GetSignatureForDocumentation ()
{
return Name;
}
public override string GetSignatureForError ()
{
return MemberName.GetSignatureForError ();
}
#if FULL_AST
public List<Constraints> PlainConstraints {
get;
private set;
}
public bool HasOptionalSemicolon {
get;
private set;
}
Location optionalSemicolon;
public Location OptionalSemicolon {
get {
return optionalSemicolon;
}
set {
optionalSemicolon = value;
HasOptionalSemicolon = true;
}
}
#endif
public List<Constraints> Constraints {
get;
private set;
}
public virtual void SetParameterInfo (List<Constraints> constraints_list)
{
#if FULL_AST
if (constraints_list != null) {
this.PlainConstraints = constraints_list;
constraints_list = this.Constraints = new List<Constraints> (constraints_list);
}
#else
this.Constraints = constraints_list;
#endif
if (!is_generic) {
if (constraints_list != null) {
Report.Error (
80, Location, "Constraints are not allowed " +
"on non-generic declarations");
}
return;
}
//
// Register all the names
//
for (int i = 0; i < MemberName.TypeParameters.Count; i++) {
var name = MemberName.TypeParameters [i];
Constraints constraints = null;
if (constraints_list != null) {
int total = constraints_list.Count;
for (int ii = 0; ii < total; ++ii) {
Constraints constraints_at = constraints_list[ii];
// TODO: it is used by iterators only
if (constraints_at == null) {
constraints_list.RemoveAt (ii);
--total;
continue;
}
if (constraints_at.TypeParameter.Value == name.MemberName.Name) {
constraints = constraints_at;
constraints_list.RemoveAt(ii);
break;
}
}
}
if (name.Variance != Variance.None && !(this is Delegate || this is Interface)) {
Report.Error (1960, name.Location, "Variant type parameters can only be used with interfaces and delegates");
}
MemberName.TypeParameters[i].Constraints = constraints;
if (name.MemberName != null)
AddToContainer (name, name.MemberName.Name);
}
if (constraints_list != null && constraints_list.Count > 0) {
foreach (Constraints constraint in constraints_list) {
Report.Error(699, constraint.Location, "`{0}': A constraint references nonexistent type parameter `{1}'",
GetSignatureForError (), constraint.TypeParameter.Value);
}
}
}
public override string[] ValidAttributeTargets {
get { return attribute_targets; }
}
protected override bool VerifyClsCompliance ()
{
if (!base.VerifyClsCompliance ()) {
return false;
}
if (CurrentTypeParameters != null) {
CurrentTypeParameters.VerifyClsCompliance ();
}
return true;
}
}
}

9
ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs

@ -55,8 +55,7 @@ namespace Mono.CSharp { @@ -55,8 +55,7 @@ namespace Mono.CSharp {
Modifiers.UNSAFE |
Modifiers.PRIVATE;
public Delegate (NamespaceContainer ns, DeclSpace parent, FullNamedExpression type,
Modifiers mod_flags, MemberName name, ParametersCompiled param_list,
public Delegate (NamespaceContainer ns, TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, ParametersCompiled param_list,
Attributes attrs)
: base (ns, parent, name, attrs, MemberKind.Delegate)
@ -185,7 +184,7 @@ namespace Mono.CSharp { @@ -185,7 +184,7 @@ namespace Mono.CSharp {
TypeManager.CheckTypeVariance (ret_type, Variance.Covariant, this);
var resolved_rt = new TypeExpression (ret_type, Location);
InvokeBuilder = new Method (this, null, resolved_rt, MethodModifiers, new MemberName (InvokeMethodName), p, null);
InvokeBuilder = new Method (this, resolved_rt, MethodModifiers, new MemberName (InvokeMethodName), p, null);
InvokeBuilder.Define ();
//
@ -239,7 +238,7 @@ namespace Mono.CSharp { @@ -239,7 +238,7 @@ namespace Mono.CSharp {
}
);
BeginInvokeBuilder = new Method (this, null,
BeginInvokeBuilder = new Method (this,
new TypeExpression (iasync_result.TypeSpec, Location), MethodModifiers,
new MemberName ("BeginInvoke"), async_parameters, null);
BeginInvokeBuilder.Define ();
@ -289,7 +288,7 @@ namespace Mono.CSharp { @@ -289,7 +288,7 @@ namespace Mono.CSharp {
//
// Create method, define parameters, register parameters with type system
//
EndInvokeBuilder = new Method (this, null, returnType, MethodModifiers, new MemberName ("EndInvoke"), end_parameters, null);
EndInvokeBuilder = new Method (this, returnType, MethodModifiers, new MemberName ("EndInvoke"), end_parameters, null);
EndInvokeBuilder.Define ();
}

10
ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs

@ -141,7 +141,7 @@ namespace Mono.CSharp @@ -141,7 +141,7 @@ namespace Mono.CSharp
}
// FIXME: it could be done with XmlReader
DeclSpace ds_target = mc as DeclSpace;
var ds_target = mc as TypeContainer;
if (ds_target == null)
ds_target = mc.Parent;
@ -213,7 +213,7 @@ namespace Mono.CSharp @@ -213,7 +213,7 @@ namespace Mono.CSharp
//
// Handles <see> elements.
//
void HandleSee (MemberCore mc, DeclSpace ds, XmlElement see)
void HandleSee (MemberCore mc, TypeContainer ds, XmlElement see)
{
HandleXrefCommon (mc, ds, see);
}
@ -221,7 +221,7 @@ namespace Mono.CSharp @@ -221,7 +221,7 @@ namespace Mono.CSharp
//
// Handles <seealso> elements.
//
void HandleSeeAlso (MemberCore mc, DeclSpace ds, XmlElement seealso)
void HandleSeeAlso (MemberCore mc, TypeContainer ds, XmlElement seealso)
{
HandleXrefCommon (mc, ds, seealso);
}
@ -229,7 +229,7 @@ namespace Mono.CSharp @@ -229,7 +229,7 @@ namespace Mono.CSharp
//
// Handles <exception> elements.
//
void HandleException (MemberCore mc, DeclSpace ds, XmlElement seealso)
void HandleException (MemberCore mc, TypeContainer ds, XmlElement seealso)
{
HandleXrefCommon (mc, ds, seealso);
}
@ -304,7 +304,7 @@ namespace Mono.CSharp @@ -304,7 +304,7 @@ namespace Mono.CSharp
//
// Processes "see" or "seealso" elements from cref attribute.
//
void HandleXrefCommon (MemberCore mc, DeclSpace ds, XmlElement xref)
void HandleXrefCommon (MemberCore mc, TypeContainer ds, XmlElement xref)
{
string cref = xref.GetAttribute ("cref");
// when, XmlReader, "if (cref == null)"

3
ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs

@ -164,8 +164,7 @@ namespace Mono.CSharp { @@ -164,8 +164,7 @@ namespace Mono.CSharp {
readonly TypeExpr underlying_type_expr;
public Enum (NamespaceContainer ns, DeclSpace parent, TypeExpression type,
Modifiers mod_flags, MemberName name, Attributes attrs)
public Enum (NamespaceContainer ns, TypeContainer parent, TypeExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (ns, parent, name, attrs, MemberKind.Enum)
{
underlying_type_expr = type;

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs

@ -695,7 +695,7 @@ namespace Mono.CSharp @@ -695,7 +695,7 @@ namespace Mono.CSharp
// work from MethodBuilders. Retarded, I know.
//
var tt = assembly.Builder.GetType (host.TypeBuilder.Name);
var mi = tt.GetMethod (expression_method.Name);
var mi = tt.GetMethod (expression_method.MemberName.Name);
if (host.Fields != null) {
//

17
ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs

@ -62,10 +62,8 @@ namespace Mono.CSharp @@ -62,10 +62,8 @@ namespace Mono.CSharp
static readonly string[] attribute_targets = new string [] { "field" };
protected FieldBase (DeclSpace parent, FullNamedExpression type, Modifiers mod,
Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, null, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE,
name, attrs)
protected FieldBase (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE, name, attrs)
{
if ((mod & Modifiers.ABSTRACT) != 0)
Report.Error (681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead");
@ -88,6 +86,12 @@ namespace Mono.CSharp @@ -88,6 +86,12 @@ namespace Mono.CSharp
}
}
public string Name {
get {
return MemberName.Name;
}
}
public FieldSpec Spec {
get {
return spec;
@ -371,7 +375,7 @@ namespace Mono.CSharp @@ -371,7 +375,7 @@ namespace Mono.CSharp
Modifiers.PRIVATE |
Modifiers.UNSAFE;
public FixedField (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
public FixedField (TypeContainer parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
: base (parent, type, mod, AllowedModifiers, name, attrs)
{
}
@ -573,8 +577,7 @@ namespace Mono.CSharp @@ -573,8 +577,7 @@ namespace Mono.CSharp
Modifiers.UNSAFE |
Modifiers.READONLY;
public Field (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name,
Attributes attrs)
public Field (TypeContainer parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
: base (parent, type, mod, AllowedModifiers, name, attrs)
{
}

136
ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs

@ -382,7 +382,7 @@ namespace Mono.CSharp { @@ -382,7 +382,7 @@ namespace Mono.CSharp {
this.spec = new TypeParameterSpec (null, -1, this, SpecialConstraint.None, variance, null);
}
public TypeParameter (TypeParameterSpec spec, DeclSpace parent, TypeSpec parentSpec, MemberName name, Attributes attrs)
public TypeParameter (TypeParameterSpec spec, TypeSpec parentSpec, MemberName name, Attributes attrs)
: base (null, name, attrs)
{
this.spec = new TypeParameterSpec (parentSpec, spec.DeclaredPosition, spec.MemberDefinition, spec.SpecialConstraint, spec.Variance, null) {
@ -428,6 +428,12 @@ namespace Mono.CSharp { @@ -428,6 +428,12 @@ namespace Mono.CSharp {
}
}
public string Name {
get {
return MemberName.Name;
}
}
public string Namespace {
get {
return null;
@ -511,9 +517,9 @@ namespace Mono.CSharp { @@ -511,9 +517,9 @@ namespace Mono.CSharp {
constraints.CheckGenericConstraints (this, obsoleteCheck);
}
public TypeParameter CreateHoistedCopy (TypeContainer declaringType, TypeSpec declaringSpec)
public TypeParameter CreateHoistedCopy (TypeSpec declaringSpec)
{
return new TypeParameter (spec, declaringType, declaringSpec, MemberName, null);
return new TypeParameter (spec, declaringSpec, MemberName, null);
}
public override bool Define ()
@ -2057,9 +2063,15 @@ namespace Mono.CSharp { @@ -2057,9 +2063,15 @@ namespace Mono.CSharp {
{
types = new TypeParameterSpec[Count];
for (int i = 0; i < types.Length; ++i) {
names[i].Define (buiders[i + parentOffset], declaringType, parent);
types[i] = names[i].Type;
var tp = names[i];
tp.Define (buiders[i + parentOffset], declaringType, parent);
types[i] = tp.Type;
types[i].DeclaredPosition = i + parentOffset;
if (tp.Variance != Variance.None && !(declaringType != null && (declaringType.Kind == MemberKind.Interface || declaringType.Kind == MemberKind.Delegate))) {
parent.Compiler.Report.Error (1960, tp.Location, "Variant type parameters can only be used with interfaces and delegates");
}
}
}
@ -2506,120 +2518,6 @@ namespace Mono.CSharp { @@ -2506,120 +2518,6 @@ namespace Mono.CSharp {
}
}
/// <summary>
/// A generic method definition.
/// </summary>
public class GenericMethod : DeclSpace
{
ParametersCompiled parameters;
public GenericMethod (NamespaceContainer ns, DeclSpace parent, MemberName name,
FullNamedExpression return_type, ParametersCompiled parameters)
: base (ns, parent, name, null)
{
this.parameters = parameters;
}
public override TypeParameters CurrentTypeParameters {
get {
return MemberName.TypeParameters;
}
}
protected override TypeAttributes TypeAttr {
get {
throw new NotSupportedException ();
}
}
public override void DefineType ()
{
throw new Exception ();
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
throw new NotSupportedException ();
}
public override bool Define ()
{
throw new NotSupportedException ();
}
/// <summary>
/// Define and resolve the type parameters.
/// We're called from Method.Define().
/// </summary>
public bool Define (MethodOrOperator m)
{
var tparams = MemberName.TypeParameters;
string[] snames = new string[MemberName.Arity];
var block = m.Block;
var parent_tparams = Parent.TypeParametersAll;
for (int i = 0; i < snames.Length; i++) {
string type_argument_name = tparams[i].MemberName.Name;
if (block == null) {
int idx = parameters.GetParameterIndexByName (type_argument_name);
if (idx >= 0) {
var b = m.Block;
if (b == null)
b = new ToplevelBlock (Compiler, Location);
b.Error_AlreadyDeclaredTypeParameter (type_argument_name, parameters[i].Location);
}
} else {
INamedBlockVariable variable = null;
block.GetLocalName (type_argument_name, m.Block, ref variable);
if (variable != null)
variable.Block.Error_AlreadyDeclaredTypeParameter (type_argument_name, variable.Location);
}
if (parent_tparams != null) {
var tp = parent_tparams.Find (type_argument_name);
if (tp != null) {
tparams[i].WarningParentNameConflict (tp);
}
}
snames[i] = type_argument_name;
}
GenericTypeParameterBuilder[] gen_params = m.MethodBuilder.DefineGenericParameters (snames);
tparams.Define (gen_params, null, 0, Parent);
return true;
}
public void EmitAttributes ()
{
if (OptAttributes != null)
OptAttributes.Emit ();
}
public override string GetSignatureForError ()
{
return base.GetSignatureForError () + parameters.GetSignatureForError ();
}
public override AttributeTargets AttributeTargets {
get {
return AttributeTargets.Method | AttributeTargets.ReturnValue;
}
}
public override string DocCommentHeader {
get { return "M:"; }
}
public new void VerifyClsCompliance ()
{
MemberName.TypeParameters.VerifyClsCompliance ();
}
}
public partial class TypeManager
{
public static Variance CheckTypeVariance (TypeSpec t, Variance expected, IMemberContext member)

10
ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs

@ -394,7 +394,7 @@ namespace Mono.CSharp @@ -394,7 +394,7 @@ namespace Mono.CSharp
public IteratorStorey (Iterator iterator)
: base (iterator.Container.ParametersBlock, iterator.Host,
iterator.OriginalMethod as MemberBase, iterator.GenericMethod == null ? null : iterator.GenericMethod.CurrentTypeParameters, "Iterator")
iterator.OriginalMethod as MemberBase, iterator.OriginalMethod.CurrentTypeParameters, "Iterator")
{
this.Iterator = iterator;
}
@ -532,7 +532,7 @@ namespace Mono.CSharp @@ -532,7 +532,7 @@ namespace Mono.CSharp
void Define_Reset ()
{
Method reset = new Method (
this, null, new TypeExpression (Compiler.BuiltinTypes.Void, Location),
this, new TypeExpression (Compiler.BuiltinTypes.Void, Location),
Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
new MemberName ("Reset", Location),
ParametersCompiled.EmptyReadOnlyParameters, null);
@ -564,7 +564,7 @@ namespace Mono.CSharp @@ -564,7 +564,7 @@ namespace Mono.CSharp
readonly StateMachineInitializer expr;
public StateMachineMethod (StateMachine host, StateMachineInitializer expr, FullNamedExpression returnType, Modifiers mod, MemberName name)
: base (host, null, returnType, mod | Modifiers.COMPILER_GENERATED,
: base (host, returnType, mod | Modifiers.COMPILER_GENERATED,
name, ParametersCompiled.EmptyReadOnlyParameters, null)
{
this.expr = expr;
@ -910,10 +910,6 @@ namespace Mono.CSharp @@ -910,10 +910,6 @@ namespace Mono.CSharp
get { return OriginalMethod.Block; }
}
public GenericMethod GenericMethod {
get { return OriginalMethod.GenericMethod; }
}
public override string ContainerType {
get { return "iterator"; }
}

141
ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs

@ -47,10 +47,9 @@ namespace Mono.CSharp { @@ -47,10 +47,9 @@ namespace Mono.CSharp {
protected ToplevelBlock block;
protected MethodSpec spec;
public MethodCore (DeclSpace parent, GenericMethod generic,
FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
public MethodCore (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
MemberName name, Attributes attrs, ParametersCompiled parameters)
: base (parent, generic, type, mod, allowed_mod, name, attrs)
: base (parent, type, mod, allowed_mod, name, attrs)
{
this.parameters = parameters;
}
@ -518,11 +517,9 @@ namespace Mono.CSharp { @@ -518,11 +517,9 @@ namespace Mono.CSharp {
static readonly string[] attribute_targets = new string [] { "method", "return" };
protected MethodOrOperator (DeclSpace parent, GenericMethod generic, FullNamedExpression type, Modifiers mod,
Modifiers allowed_mod, MemberName name,
protected MethodOrOperator (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name,
Attributes attrs, ParametersCompiled parameters)
: base (parent, generic, type, mod, allowed_mod, name,
attrs, parameters)
: base (parent, type, mod, allowed_mod, name, attrs, parameters)
{
}
@ -612,7 +609,7 @@ namespace Mono.CSharp { @@ -612,7 +609,7 @@ namespace Mono.CSharp {
}
MethodData = new MethodData (
this, ModFlags, flags, this, MethodBuilder, GenericMethod, base_method);
this, ModFlags, flags, this, MethodBuilder, base_method);
if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName)))
return false;
@ -777,12 +774,6 @@ namespace Mono.CSharp { @@ -777,12 +774,6 @@ namespace Mono.CSharp {
return conditions;
}
GenericMethod IMethodData.GenericMethod {
get {
return GenericMethod;
}
}
public virtual void EmitExtraSymbolInfo (SourceMethod source)
{ }
@ -795,7 +786,7 @@ namespace Mono.CSharp { @@ -795,7 +786,7 @@ namespace Mono.CSharp {
MethodBase method;
SourceMethodBuilder builder;
protected SourceMethod (DeclSpace parent, MethodBase method, ICompileUnit file)
protected SourceMethod (TypeContainer parent, MethodBase method, ICompileUnit file)
{
this.method = method;
@ -833,7 +824,7 @@ namespace Mono.CSharp { @@ -833,7 +824,7 @@ namespace Mono.CSharp {
builder.SetRealMethodName (name);
}
public static SourceMethod Create (DeclSpace parent, MethodBase method, Block block)
public static SourceMethod Create (TypeContainer parent, MethodBase method, Block block)
{
if (!SymbolWriter.HasSymbolWriter)
return null;
@ -856,10 +847,8 @@ namespace Mono.CSharp { @@ -856,10 +847,8 @@ namespace Mono.CSharp {
{
Method partialMethodImplementation;
public Method (DeclSpace parent, GenericMethod generic,
FullNamedExpression return_type, Modifiers mod,
MemberName name, ParametersCompiled parameters, Attributes attrs)
: base (parent, generic, return_type, mod,
public Method (TypeContainer parent, FullNamedExpression return_type, Modifiers mod, MemberName name, ParametersCompiled parameters, Attributes attrs)
: base (parent, return_type, mod,
parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface :
parent.PartialContainer.Kind == MemberKind.Struct ? AllowedModifiersStruct | Modifiers.ASYNC :
AllowedModifiersClass | Modifiers.ASYNC,
@ -867,9 +856,9 @@ namespace Mono.CSharp { @@ -867,9 +856,9 @@ namespace Mono.CSharp {
{
}
protected Method (DeclSpace parent, FullNamedExpression return_type, Modifiers mod, Modifiers amod,
protected Method (TypeContainer parent, FullNamedExpression return_type, Modifiers mod, Modifiers amod,
MemberName name, ParametersCompiled parameters, Attributes attrs)
: base (parent, null, return_type, mod, amod, name, attrs, parameters)
: base (parent, return_type, mod, amod, name, attrs, parameters)
{
}
@ -877,10 +866,7 @@ namespace Mono.CSharp { @@ -877,10 +866,7 @@ namespace Mono.CSharp {
public override TypeParameters CurrentTypeParameters {
get {
if (GenericMethod != null)
return GenericMethod.CurrentTypeParameters;
return null;
return MemberName.TypeParameters;
}
}
@ -903,10 +889,10 @@ namespace Mono.CSharp { @@ -903,10 +889,10 @@ namespace Mono.CSharp {
visitor.Visit (this);
}
public static Method Create (DeclSpace parent, GenericMethod generic, FullNamedExpression returnType, Modifiers mod,
public static Method Create (TypeContainer parent, FullNamedExpression returnType, Modifiers mod,
MemberName name, ParametersCompiled parameters, Attributes attrs, bool hasConstraints)
{
var m = new Method (parent, generic, returnType, mod, name, parameters, attrs);
var m = new Method (parent, returnType, mod, name, parameters, attrs);
if (hasConstraints && ((mod & Modifiers.OVERRIDE) != 0 || m.IsExplicitImpl)) {
m.Report.Error (460, m.Location,
@ -1027,6 +1013,45 @@ namespace Mono.CSharp { @@ -1027,6 +1013,45 @@ namespace Mono.CSharp {
base.ApplyAttributeBuilder (a, ctor, cdata, pa);
}
void CreateTypeParameters ()
{
var tparams = MemberName.TypeParameters;
string[] snames = new string[MemberName.Arity];
var parent_tparams = Parent.TypeParametersAll;
for (int i = 0; i < snames.Length; i++) {
string type_argument_name = tparams[i].MemberName.Name;
if (block == null) {
int idx = parameters.GetParameterIndexByName (type_argument_name);
if (idx >= 0) {
var b = block;
if (b == null)
b = new ToplevelBlock (Compiler, Location);
b.Error_AlreadyDeclaredTypeParameter (type_argument_name, parameters[i].Location);
}
} else {
INamedBlockVariable variable = null;
block.GetLocalName (type_argument_name, block, ref variable);
if (variable != null)
variable.Block.Error_AlreadyDeclaredTypeParameter (type_argument_name, variable.Location);
}
if (parent_tparams != null) {
var tp = parent_tparams.Find (type_argument_name);
if (tp != null) {
tparams[i].WarningParentNameConflict (tp);
}
}
snames[i] = type_argument_name;
}
GenericTypeParameterBuilder[] gen_params = MethodBuilder.DefineGenericParameters (snames);
tparams.Define (gen_params, null, 0, Parent);
}
protected virtual void DefineTypeParameters ()
{
var tparams = CurrentTypeParameters;
@ -1201,10 +1226,10 @@ namespace Mono.CSharp { @@ -1201,10 +1226,10 @@ namespace Mono.CSharp {
}
if (CurrentTypeParameters == null) {
if (base_method != null) {
if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && Name == "Equals")
if (base_method != null && !IsExplicitImpl) {
if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && MemberName.Name == "Equals")
Parent.PartialContainer.Mark_HasEquals ();
else if (parameters.IsEmpty && Name == "GetHashCode")
else if (parameters.IsEmpty && MemberName.Name == "GetHashCode")
Parent.PartialContainer.Mark_HasGetHashCode ();
}
@ -1237,7 +1262,7 @@ namespace Mono.CSharp { @@ -1237,7 +1262,7 @@ namespace Mono.CSharp {
return true;
if (parameters.HasExtensionMethodType) {
if (Parent.PartialContainer.IsStatic && !Parent.IsGeneric) {
if (Parent.PartialContainer.IsStatic && !Parent.IsGenericOrParentIsGeneric) {
if (!Parent.IsTopLevel)
Report.Error (1109, Location, "`{0}': Extension methods cannot be defined in a nested class",
GetSignatureForError ());
@ -1263,10 +1288,10 @@ namespace Mono.CSharp { @@ -1263,10 +1288,10 @@ namespace Mono.CSharp {
// This is used to track the Entry Point,
//
var settings = Compiler.Settings;
if (settings.NeedsEntryPoint && Name == "Main" && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) {
if (settings.NeedsEntryPoint && MemberName.Name == "Main" && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) {
if (IsEntryPoint ()) {
if (Parent.DeclaringAssembly.EntryPoint == null) {
if (Parent.IsGeneric || MemberName.IsGeneric) {
if (Parent.IsGenericOrParentIsGeneric || MemberName.IsGeneric) {
Report.Warning (402, 4, Location, "`{0}': an entry point cannot be generic or in a generic type",
GetSignatureForError ());
} else if ((ModFlags & Modifiers.ASYNC) != 0) {
@ -1349,10 +1374,9 @@ namespace Mono.CSharp { @@ -1349,10 +1374,9 @@ namespace Mono.CSharp {
protected override bool ResolveMemberType ()
{
if (GenericMethod != null) {
if (CurrentTypeParameters != null) {
MethodBuilder = Parent.TypeBuilder.DefineMethod (GetFullName (MemberName), flags);
if (!GenericMethod.Define (this))
return false;
CreateTypeParameters ();
}
return base.ResolveMemberType ();
@ -1527,9 +1551,8 @@ namespace Mono.CSharp { @@ -1527,9 +1551,8 @@ namespace Mono.CSharp {
public static readonly string ConstructorName = ".ctor";
public static readonly string TypeConstructorName = ".cctor";
public Constructor (DeclSpace parent, string name, Modifiers mod, Attributes attrs, ParametersCompiled args, Location loc)
: base (parent, null, null, mod, AllowedModifiers,
new MemberName (name, loc), attrs, args)
public Constructor (TypeContainer parent, string name, Modifiers mod, Attributes attrs, ParametersCompiled args, Location loc)
: base (parent, null, mod, AllowedModifiers, new MemberName (name, loc), attrs, args)
{
}
@ -1802,12 +1825,6 @@ namespace Mono.CSharp { @@ -1802,12 +1825,6 @@ namespace Mono.CSharp {
return false;
}
GenericMethod IMethodData.GenericMethod {
get {
return null;
}
}
void IMethodData.EmitExtraSymbolInfo (SourceMethod source)
{ }
@ -1823,7 +1840,6 @@ namespace Mono.CSharp { @@ -1823,7 +1840,6 @@ namespace Mono.CSharp {
Location Location { get; }
MemberName MethodName { get; }
TypeSpec ReturnType { get; }
GenericMethod GenericMethod { get; }
ParametersCompiled ParameterInfo { get; }
MethodSpec Spec { get; }
bool IsAccessor { get; }
@ -1846,8 +1862,6 @@ namespace Mono.CSharp { @@ -1846,8 +1862,6 @@ namespace Mono.CSharp {
public readonly IMethodData method;
public readonly GenericMethod GenericMethod;
//
// Are we implementing an interface ?
//
@ -1888,11 +1902,12 @@ namespace Mono.CSharp { @@ -1888,11 +1902,12 @@ namespace Mono.CSharp {
public MethodData (InterfaceMemberBase member,
Modifiers modifiers, MethodAttributes flags,
IMethodData method, MethodBuilder builder,
GenericMethod generic, MethodSpec parent_method)
//GenericMethod generic,
MethodSpec parent_method)
: this (member, modifiers, flags, method)
{
this.builder = builder;
this.GenericMethod = generic;
//this.GenericMethod = generic;
this.parent_method = parent_method;
}
@ -2104,11 +2119,8 @@ namespace Mono.CSharp { @@ -2104,11 +2119,8 @@ namespace Mono.CSharp {
//
// Emits the code
//
public void Emit (DeclSpace parent)
public void Emit (TypeContainer parent)
{
if (GenericMethod != null)
GenericMethod.EmitAttributes ();
var mc = (IMemberContext) method;
method.ParameterInfo.ApplyAttributes (mc, MethodBuilder);
@ -2142,9 +2154,8 @@ namespace Mono.CSharp { @@ -2142,9 +2154,8 @@ namespace Mono.CSharp {
public static readonly string MetadataName = "Finalize";
public Destructor (DeclSpace parent, Modifiers mod, ParametersCompiled parameters, Attributes attrs, Location l)
: base (parent, null, null, mod, AllowedModifiers,
new MemberName (MetadataName, l), attrs, parameters)
public Destructor (TypeContainer parent, Modifiers mod, ParametersCompiled parameters, Attributes attrs, Location l)
: base (parent, null, mod, AllowedModifiers, new MemberName (MetadataName, l), attrs, parameters)
{
ModFlags &= ~Modifiers.PRIVATE;
ModFlags |= Modifiers.PROTECTED | Modifiers.OVERRIDE;
@ -2280,12 +2291,6 @@ namespace Mono.CSharp { @@ -2280,12 +2291,6 @@ namespace Mono.CSharp {
return false;
}
GenericMethod IMethodData.GenericMethod {
get {
return null;
}
}
public MemberName MethodName {
get {
return MemberName;
@ -2344,7 +2349,7 @@ namespace Mono.CSharp { @@ -2344,7 +2349,7 @@ namespace Mono.CSharp {
throw new NotSupportedException ();
}
public virtual void Emit (DeclSpace parent)
public virtual void Emit (TypeContainer parent)
{
method_data.Emit (parent);
@ -2500,11 +2505,9 @@ namespace Mono.CSharp { @@ -2500,11 +2505,9 @@ namespace Mono.CSharp {
names [(int) OpType.Explicit] = new string [] { "explicit", "op_Explicit" };
}
public Operator (DeclSpace parent, OpType type, FullNamedExpression ret_type,
Modifiers mod_flags, ParametersCompiled parameters,
public Operator (TypeContainer parent, OpType type, FullNamedExpression ret_type, Modifiers mod_flags, ParametersCompiled parameters,
ToplevelBlock block, Attributes attrs, Location loc)
: base (parent, null, ret_type, mod_flags, AllowedModifiers,
new MemberName (GetMetadataName (type), loc), attrs, parameters)
: base (parent, ret_type, mod_flags, AllowedModifiers, new MemberName (GetMetadataName (type), loc), attrs, parameters)
{
OperatorType = type;
Block = block;

83
ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs

@ -593,7 +593,6 @@ namespace Mono.CSharp { @@ -593,7 +593,6 @@ namespace Mono.CSharp {
readonly CompilationSourceFile file;
readonly MemberName name;
NamespaceContainer implicit_parent;
int symfile_id;
List<UsingNamespace> clauses;
@ -603,7 +602,6 @@ namespace Mono.CSharp { @@ -603,7 +602,6 @@ namespace Mono.CSharp {
bool resolved;
public readonly bool IsImplicit;
public readonly TypeContainer SlaveDeclSpace;
Namespace[] namespace_using_table;
@ -626,16 +624,6 @@ namespace Mono.CSharp { @@ -626,16 +624,6 @@ namespace Mono.CSharp {
SlaveDeclSpace = new RootDeclSpace (module, this);
}
private NamespaceContainer (ModuleContainer module, NamespaceContainer parent, CompilationSourceFile file, Namespace ns, bool slave)
{
this.module = module;
this.parent = parent;
this.file = file;
this.IsImplicit = true;
this.ns = ns;
this.SlaveDeclSpace = slave ? new RootDeclSpace (module, this) : null;
}
#region Properties
public Location Location {
@ -650,6 +638,12 @@ namespace Mono.CSharp { @@ -650,6 +638,12 @@ namespace Mono.CSharp {
}
}
public Namespace NS {
get {
return ns;
}
}
public NamespaceContainer Parent {
get {
return parent;
@ -670,23 +664,6 @@ namespace Mono.CSharp { @@ -670,23 +664,6 @@ namespace Mono.CSharp {
#endregion
public Namespace NS {
get { return ns; }
}
public NamespaceContainer ImplicitParent {
get {
if (parent == null)
return null;
if (implicit_parent == null) {
implicit_parent = (parent.ns == ns.Parent)
? parent
: new NamespaceContainer (module, parent, file, ns.Parent, false);
}
return implicit_parent;
}
}
public void AddUsing (UsingNamespace un)
{
if (DeclarationFound){
@ -767,21 +744,35 @@ namespace Mono.CSharp { @@ -767,21 +744,35 @@ namespace Mono.CSharp {
public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
// Precondition: Only simple names (no dots) will be looked up with this function.
FullNamedExpression resolved = null;
for (NamespaceContainer curr_ns = this; curr_ns != null; curr_ns = curr_ns.ImplicitParent) {
if ((resolved = curr_ns.Lookup (name, arity, mode, loc)) != null)
break;
//
// Only simple names (no dots) will be looked up with this function
//
FullNamedExpression resolved;
for (NamespaceContainer container = this; container != null; container = container.parent) {
resolved = container.Lookup (name, arity, mode, loc);
if (resolved != null)
return resolved;
var container_ns = container.ns.Parent;
var mn = container.MemberName.Left;
while (mn != null) {
resolved = container_ns.LookupTypeOrNamespace (this, name, arity, mode, loc);
if (resolved != null)
return resolved;
mn = mn.Left;
container_ns = container_ns.Parent;
}
}
return resolved;
return null;
}
public IList<string> CompletionGetTypesStartingWith (string prefix)
{
IEnumerable<string> all = Enumerable.Empty<string> ();
for (NamespaceContainer curr_ns = this; curr_ns != null; curr_ns = curr_ns.ImplicitParent){
for (NamespaceContainer curr_ns = this; curr_ns != null; curr_ns = curr_ns.parent){
foreach (Namespace using_ns in namespace_using_table){
if (prefix.StartsWith (using_ns.Name)){
int ld = prefix.LastIndexOf ('.');
@ -819,7 +810,7 @@ namespace Mono.CSharp { @@ -819,7 +810,7 @@ namespace Mono.CSharp {
//
public FullNamedExpression LookupNamespaceAlias (string name)
{
for (NamespaceContainer n = this; n != null; n = n.ImplicitParent) {
for (NamespaceContainer n = this; n != null; n = n.parent) {
if (n.aliases == null)
continue;
@ -860,9 +851,6 @@ namespace Mono.CSharp { @@ -860,9 +851,6 @@ namespace Mono.CSharp {
if (fne != null)
return fne;
if (IsImplicit)
return null;
//
// Check using entries.
//
@ -1241,8 +1229,19 @@ namespace Mono.CSharp { @@ -1241,8 +1229,19 @@ namespace Mono.CSharp {
if (fne != null)
return fne;
if (ns.ImplicitParent != null)
return ns.ImplicitParent.LookupNamespaceOrType (name, arity, mode, loc);
var container_ns = ns.NS.Parent;
var mn = ns.MemberName.Left;
while (mn != null) {
fne = container_ns.LookupTypeOrNamespace (this, name, arity, mode, loc);
if (fne != null)
return fne;
mn = mn.Left;
container_ns = container_ns.Parent;
}
if (ns.Parent != null)
return ns.Parent.LookupNamespaceOrType (name, arity, mode, loc);
return null;
}

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs

@ -1014,7 +1014,7 @@ namespace Mono.CSharp.Nullable @@ -1014,7 +1014,7 @@ namespace Mono.CSharp.Nullable
}
}
public Expression Right {
public Expression RightExpression {
get {
return right;
}

42
ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs

@ -34,10 +34,8 @@ namespace Mono.CSharp @@ -34,10 +34,8 @@ namespace Mono.CSharp
// This includes properties, indexers, and events
public abstract class PropertyBasedMember : InterfaceMemberBase
{
public PropertyBasedMember (DeclSpace parent, GenericMethod generic,
FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
MemberName name, Attributes attrs)
: base (parent, generic, type, mod, allowed_mod, name, attrs)
public PropertyBasedMember (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod, allowed_mod, name, attrs)
{
}
@ -198,7 +196,7 @@ namespace Mono.CSharp @@ -198,7 +196,7 @@ namespace Mono.CSharp
{
}
public override MethodBuilder Define (DeclSpace parent)
public override MethodBuilder Define (TypeContainer parent)
{
base.Define (parent);
@ -263,7 +261,7 @@ namespace Mono.CSharp @@ -263,7 +261,7 @@ namespace Mono.CSharp
}
}
public override MethodBuilder Define (DeclSpace parent)
public override MethodBuilder Define (TypeContainer parent)
{
parameters.Resolve (this);
@ -335,7 +333,7 @@ namespace Mono.CSharp @@ -335,7 +333,7 @@ namespace Mono.CSharp
return method.IsClsComplianceRequired ();
}
public virtual MethodBuilder Define (DeclSpace parent)
public virtual MethodBuilder Define (TypeContainer parent)
{
TypeContainer container = parent.PartialContainer;
@ -404,9 +402,8 @@ namespace Mono.CSharp @@ -404,9 +402,8 @@ namespace Mono.CSharp
PropertyMethod get, set, first;
PropertyBuilder PropertyBuilder;
public PropertyBase (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags,
Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, null, type, mod_flags, allowed_mod, name, attrs)
public PropertyBase (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, allowed_mod, name, attrs)
{
}
@ -711,9 +708,9 @@ namespace Mono.CSharp @@ -711,9 +708,9 @@ namespace Mono.CSharp
this.property = p;
}
public string OriginalName {
public Property OriginalProperty {
get {
return property.Name;
return property;
}
}
@ -723,7 +720,7 @@ namespace Mono.CSharp @@ -723,7 +720,7 @@ namespace Mono.CSharp
}
}
public Property (DeclSpace parent, FullNamedExpression type, Modifiers mod,
public Property (TypeContainer parent, FullNamedExpression type, Modifiers mod,
MemberName name, Attributes attrs)
: base (parent, type, mod,
parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface :
@ -823,7 +820,7 @@ namespace Mono.CSharp @@ -823,7 +820,7 @@ namespace Mono.CSharp
{
}
public override MethodBuilder Define (DeclSpace ds)
public override MethodBuilder Define (TypeContainer ds)
{
CheckAbstractAndExtern (block != null);
return base.Define (ds);
@ -853,7 +850,7 @@ namespace Mono.CSharp @@ -853,7 +850,7 @@ namespace Mono.CSharp
static readonly string[] attribute_targets = new string [] { "event" };
public EventProperty (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
public EventProperty (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, name, attrs)
{
}
@ -893,7 +890,7 @@ namespace Mono.CSharp @@ -893,7 +890,7 @@ namespace Mono.CSharp
protected abstract MethodSpec GetOperation (Location loc);
public override void Emit (DeclSpace parent)
public override void Emit (TypeContainer parent)
{
if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0) {
block = new ToplevelBlock (Compiler, ParameterInfo, Location);
@ -992,7 +989,7 @@ namespace Mono.CSharp @@ -992,7 +989,7 @@ namespace Mono.CSharp
Field backing_field;
List<FieldDeclarator> declarators;
public EventField (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
public EventField (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, name, attrs)
{
Add = new AddDelegateMethod (this);
@ -1169,7 +1166,7 @@ namespace Mono.CSharp @@ -1169,7 +1166,7 @@ namespace Mono.CSharp
return method.IsClsComplianceRequired ();
}
public virtual MethodBuilder Define (DeclSpace parent)
public virtual MethodBuilder Define (TypeContainer parent)
{
// Fill in already resolved event type to speed things up and
// avoid confusing duplicate errors
@ -1218,8 +1215,8 @@ namespace Mono.CSharp @@ -1218,8 +1215,8 @@ namespace Mono.CSharp
EventBuilder EventBuilder;
protected EventSpec spec;
protected Event (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, null, type, mod_flags,
protected Event (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, type, mod_flags,
parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface :
parent.PartialContainer.Kind == MemberKind.Struct ? AllowedModifiersStruct :
AllowedModifiersClass,
@ -1420,7 +1417,7 @@ namespace Mono.CSharp @@ -1420,7 +1417,7 @@ namespace Mono.CSharp
this.parameters = parameters;
}
public override MethodBuilder Define (DeclSpace parent)
public override MethodBuilder Define (TypeContainer parent)
{
parameters.Resolve (this);
return base.Define (parent);
@ -1491,8 +1488,7 @@ namespace Mono.CSharp @@ -1491,8 +1488,7 @@ namespace Mono.CSharp
readonly ParametersCompiled parameters;
public Indexer (DeclSpace parent, FullNamedExpression type, MemberName name, Modifiers mod,
ParametersCompiled parameters, Attributes attrs)
public Indexer (TypeContainer parent, FullNamedExpression type, MemberName name, Modifiers mod, ParametersCompiled parameters, Attributes attrs)
: base (parent, type, mod,
parent.PartialContainer.Kind == MemberKind.Interface ? AllowedInterfaceModifiers : AllowedModifiers,
name, attrs)

9
ICSharpCode.NRefactory.CSharp/Parser/mcs/roottypes.cs

@ -301,7 +301,7 @@ namespace Mono.CSharp @@ -301,7 +301,7 @@ namespace Mono.CSharp
public override TypeContainer AddPartial (TypeContainer nextPart)
{
return AddPartial (nextPart, nextPart.Name);
return AddPartial (nextPart, nextPart.MemberName.GetName (true));
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
@ -516,7 +516,7 @@ namespace Mono.CSharp @@ -516,7 +516,7 @@ namespace Mono.CSharp
{
if (AddTypesContainer (tc)) {
if ((tc.ModFlags & Modifiers.PARTIAL) != 0)
defined_names.Add (tc.Name, tc);
defined_names.Add (tc.MemberName.GetName (true), tc);
tc.NamespaceEntry.NS.AddType (this, tc.Definition);
return true;
@ -605,11 +605,6 @@ namespace Mono.CSharp @@ -605,11 +605,6 @@ namespace Mono.CSharp
get { throw new InternalErrorException ("should not be called"); }
}
public override void DefineType ()
{
throw new InternalErrorException ("should not be called");
}
public override ModuleContainer Module {
get {
return PartialContainer.Module;

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs

@ -292,7 +292,7 @@ namespace Mono.CSharp @@ -292,7 +292,7 @@ namespace Mono.CSharp
if (IsPointer)
return ((ElementTypeSpec) this).Element.IsUnmanaged;
var ds = MemberDefinition as DeclSpace;
var ds = MemberDefinition as TypeContainer;
if (ds != null)
return ds.IsUnmanagedType ();

Loading…
Cancel
Save