Browse Source

Updated mcs.

pull/45/merge
Mike Krüger 12 years ago
parent
commit
0ca084bb07
  1. 29
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  2. 29
      ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  3. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs
  4. 32
      ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
  5. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs
  6. 24
      ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs
  7. 65
      ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  8. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs
  9. 6
      ICSharpCode.NRefactory.CSharp/Parser/mcs/constant.cs
  10. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs
  11. 4697
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  12. 289
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  13. 74
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs
  14. 11
      ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs
  15. 18
      ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs
  16. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs
  17. 1
      ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs
  18. 50
      ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs
  19. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs
  20. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
  21. 65
      ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs
  22. 15
      ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs
  23. 73
      ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs
  24. 39
      ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs
  25. 31
      ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs
  26. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/linq.cs
  27. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/literal.cs
  28. 16
      ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs
  29. 280
      ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
  30. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/modifiers.cs
  31. 11
      ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs
  32. 6
      ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs
  33. 8
      ICSharpCode.NRefactory.CSharp/Parser/mcs/parameter.cs
  34. 34
      ICSharpCode.NRefactory.CSharp/Parser/mcs/pending.cs
  35. 16
      ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs
  36. 23
      ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs
  37. 26
      ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs
  38. 146
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  39. 24
      ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs
  40. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs
  41. 2
      ICSharpCode.NRefactory.Tests/CSharp/CodeActions/IterateViaForeachTests.cs
  42. 2
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/InvalidStatementsTests.cs

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

@ -213,9 +213,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -213,9 +213,10 @@ namespace ICSharpCode.NRefactory.CSharp
var memberType = new MemberType ();
memberType.AddChild (ConvertToType (ma.LeftExpression), MemberType.TargetRole);
if (!ma.DotLocation.IsNull)
memberType.AddChild (new CSharpTokenNode (Convert (ma.DotLocation), Roles.Dot), Roles.Dot);
var loc = LocationsBag.GetLocations (memberType);
if (loc != null)
memberType.AddChild (new CSharpTokenNode (Convert (loc[0]), Roles.Dot), Roles.Dot);
memberType.MemberNameToken = Identifier.Create (ma.Name, Convert (ma.Location));
AddTypeArguments (ma, memberType);
@ -424,9 +425,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -424,9 +425,9 @@ namespace ICSharpCode.NRefactory.CSharp
if (newIdent.Name != "<invalid>") {
namespaceDecl.InsertChildBefore (insertPos, newIdent, Roles.Identifier);
insertPos = newIdent;
if (!memberName.DotLocation.IsNull) {
var dotToken = new CSharpTokenNode (Convert (memberName.DotLocation), Roles.Dot);
var loc = LocationsBag.GetLocations (memberName);
if (loc != null) {
var dotToken = new CSharpTokenNode (Convert (loc[0]), Roles.Dot);
namespaceDecl.InsertChildBefore (insertPos, dotToken, Roles.Dot);
insertPos = dotToken;
}
@ -483,9 +484,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -483,9 +484,9 @@ namespace ICSharpCode.NRefactory.CSharp
var t = new MemberType ();
// t.IsDoubleColon = memberName.IsDoubleColon;
t.AddChild (ConvertImport (memberName.Left), MemberType.TargetRole);
if (!memberName.DotLocation.IsNull)
t.AddChild (new CSharpTokenNode (Convert (memberName.DotLocation), Roles.Dot), Roles.Dot);
var loc = LocationsBag.GetLocations (memberName);
if (loc != null)
t.AddChild (new CSharpTokenNode (Convert (loc[0]), Roles.Dot), Roles.Dot);
t.AddChild (Identifier.Create (memberName.Name, Convert (memberName.Location)), Roles.Identifier);
AddTypeArguments (t, memberName);
@ -1368,7 +1369,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1368,7 +1369,7 @@ namespace ICSharpCode.NRefactory.CSharp
return null;
}
public override object Visit (BlockVariableDeclaration blockVariableDeclaration)
public override object Visit (BlockVariable blockVariableDeclaration)
{
var result = new VariableDeclarationStatement ();
result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), Roles.Type);
@ -1405,7 +1406,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1405,7 +1406,7 @@ namespace ICSharpCode.NRefactory.CSharp
return result;
}
public override object Visit (BlockConstantDeclaration blockVariableDeclaration)
public override object Visit (BlockConstant blockVariableDeclaration)
{
var result = new VariableDeclarationStatement ();
@ -2155,8 +2156,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2155,8 +2156,10 @@ namespace ICSharpCode.NRefactory.CSharp
var leftExpr = memberAccess.LeftExpression.Accept (this);
result.AddChild ((Expression)leftExpr, Roles.TargetExpression);
}
if (!memberAccess.DotLocation.IsNull) {
result.AddChild (new CSharpTokenNode (Convert (memberAccess.DotLocation), Roles.Dot), Roles.Dot);
var loc = LocationsBag.GetLocations (memberAccess);
if (loc != null) {
result.AddChild (new CSharpTokenNode (Convert (loc[0]), Roles.Dot), Roles.Dot);
}
}

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

@ -570,6 +570,9 @@ namespace Mono.CSharp { @@ -570,6 +570,9 @@ namespace Mono.CSharp {
protected virtual void EmitHoistedParameters (EmitContext ec, List<HoistedParameter> hoisted)
{
foreach (HoistedParameter hp in hoisted) {
if (hp == null)
continue;
//
// Parameters could be proxied via local fields for value type storey
//
@ -852,6 +855,8 @@ namespace Mono.CSharp { @@ -852,6 +855,8 @@ namespace Mono.CSharp {
}
}
public bool IsAssigned { get; set; }
public ParameterReference Parameter {
get {
return parameter;
@ -1002,12 +1007,12 @@ namespace Mono.CSharp { @@ -1002,12 +1007,12 @@ namespace Mono.CSharp {
return delegate_type;
ec.Report.Error (835, loc, "Cannot convert `{0}' to an expression tree of non-delegate type `{1}'",
GetSignatureForError (), TypeManager.CSharpName (delegate_type));
GetSignatureForError (), delegate_type.GetSignatureForError ());
return null;
}
ec.Report.Error (1660, loc, "Cannot convert `{0}' to non-delegate type `{1}'",
GetSignatureForError (), TypeManager.CSharpName (delegate_type));
GetSignatureForError (), delegate_type.GetSignatureForError ());
return null;
}
@ -1019,7 +1024,7 @@ namespace Mono.CSharp { @@ -1019,7 +1024,7 @@ namespace Mono.CSharp {
if (!ec.IsInProbingMode)
ec.Report.Error (1661, loc,
"Cannot convert `{0}' to delegate type `{1}' since there is a parameter mismatch",
GetSignatureForError (), TypeManager.CSharpName (delegate_type));
GetSignatureForError (), delegate_type.GetSignatureForError ());
return false;
}
@ -1031,7 +1036,7 @@ namespace Mono.CSharp { @@ -1031,7 +1036,7 @@ namespace Mono.CSharp {
return false;
ec.Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments",
TypeManager.CSharpName (delegate_type), Parameters.Count.ToString ());
delegate_type.GetSignatureForError (), Parameters.Count.ToString ());
return false;
}
@ -1071,8 +1076,8 @@ namespace Mono.CSharp { @@ -1071,8 +1076,8 @@ namespace Mono.CSharp {
ec.Report.Error (1678, loc, "Parameter `{0}' is declared as type `{1}' but should be `{2}'",
(i+1).ToString (),
TypeManager.CSharpName (Parameters.Types [i]),
TypeManager.CSharpName (invoke_pd.Types [i]));
Parameters.Types [i].GetSignatureForError (),
invoke_pd.Types [i].GetSignatureForError ());
error = true;
}
}
@ -1376,7 +1381,7 @@ namespace Mono.CSharp { @@ -1376,7 +1381,7 @@ namespace Mono.CSharp {
return null;
}
b = b.ConvertToAsyncTask (ec, ec.CurrentMemberDefinition.Parent.PartialContainer, p, return_type, loc);
b = b.ConvertToAsyncTask (ec, ec.CurrentMemberDefinition.Parent.PartialContainer, p, return_type, delegate_type, loc);
}
return CompatibleMethodFactory (return_type ?? InternalType.ErrorType, delegate_type, p, b);
@ -1739,6 +1744,7 @@ namespace Mono.CSharp { @@ -1739,6 +1744,7 @@ namespace Mono.CSharp {
//
method = DoCreateMethodHost (ec);
method.Define ();
method.PrepareEmit ();
}
bool is_static = (method.ModFlags & Modifiers.STATIC) != 0;
@ -1865,7 +1871,7 @@ namespace Mono.CSharp { @@ -1865,7 +1871,7 @@ namespace Mono.CSharp {
public override string GetSignatureForError ()
{
return TypeManager.CSharpName (type);
return type.GetSignatureForError ();
}
}
@ -2004,7 +2010,7 @@ namespace Mono.CSharp { @@ -2004,7 +2010,7 @@ namespace Mono.CSharp {
}
var li_other = LocalVariable.CreateCompilerGenerated (CurrentType, equals_block, loc);
equals_block.AddStatement (new BlockVariableDeclaration (new TypeExpression (li_other.Type, loc), li_other));
equals_block.AddStatement (new BlockVariable (new TypeExpression (li_other.Type, loc), li_other));
var other_variable = new LocalVariableReference (li_other, loc);
MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
@ -2087,6 +2093,7 @@ namespace Mono.CSharp { @@ -2087,6 +2093,7 @@ namespace Mono.CSharp {
equals.Block = equals_block;
equals.Define ();
equals.PrepareEmit ();
Members.Add (equals);
//
@ -2116,7 +2123,7 @@ namespace Mono.CSharp { @@ -2116,7 +2123,7 @@ namespace Mono.CSharp {
hashcode_top.AddStatement (new Unchecked (hashcode_block, loc));
var li_hash = LocalVariable.CreateCompilerGenerated (Compiler.BuiltinTypes.Int, hashcode_top, loc);
hashcode_block.AddStatement (new BlockVariableDeclaration (new TypeExpression (li_hash.Type, loc), li_hash));
hashcode_block.AddStatement (new BlockVariable (new TypeExpression (li_hash.Type, loc), li_hash));
LocalVariableReference hash_variable_assign = new LocalVariableReference (li_hash, loc);
hashcode_block.AddStatement (new StatementExpression (
new SimpleAssign (hash_variable_assign, rs_hashcode)));
@ -2141,6 +2148,7 @@ namespace Mono.CSharp { @@ -2141,6 +2148,7 @@ namespace Mono.CSharp {
hashcode_block.AddStatement (new Return (hash_variable, loc));
hashcode.Block = hashcode_top;
hashcode.Define ();
hashcode.PrepareEmit ();
Members.Add (hashcode);
//
@ -2151,6 +2159,7 @@ namespace Mono.CSharp { @@ -2151,6 +2159,7 @@ namespace Mono.CSharp {
tostring_block.AddStatement (new Return (string_concat, loc));
tostring.Block = tostring_block;
tostring.Define ();
tostring.PrepareEmit ();
Members.Add (tostring);
return true;

4
ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs

@ -132,7 +132,7 @@ namespace Mono.CSharp @@ -132,7 +132,7 @@ namespace Mono.CSharp
if (Expr.eclass == ExprClass.MethodGroup)
return Expr.ExprClassName;
return TypeManager.CSharpName (Expr.Type);
return Expr.Type.GetSignatureForError ();
}
public bool ResolveMethodGroup (ResolveContext ec)
@ -347,7 +347,7 @@ namespace Mono.CSharp @@ -347,7 +347,7 @@ namespace Mono.CSharp
} else if (arg_type.Kind == MemberKind.Void || arg_type == InternalType.Arglist || arg_type.IsPointer) {
rc.Report.Error (1978, a.Expr.Location,
"An expression of type `{0}' cannot be used as an argument of dynamic operation",
TypeManager.CSharpName (arg_type));
arg_type.GetSignatureForError ());
}
info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags,

32
ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
//
// Copyright 2001, 2002, 2003 Ximian, Inc.
// Copyright 2004-2011 Novell, Inc.
// Copyright 2011 Xamarin Inc
// Copyright 2011-2013 Xamarin Inc
//
@ -74,6 +74,9 @@ namespace Mono.CSharp @@ -74,6 +74,9 @@ namespace Mono.CSharp
Dictionary<ITypeDefinition, Attribute> emitted_forwarders;
AssemblyAttributesPlaceholder module_target_attrs;
// Win32 version info values
string vi_product, vi_product_version, vi_company, vi_copyright, vi_trademark;
protected AssemblyDefinition (ModuleContainer module, string name)
{
this.module = module;
@ -288,7 +291,7 @@ namespace Mono.CSharp @@ -288,7 +291,7 @@ namespace Mono.CSharp
} else if (emitted_forwarders.ContainsKey (t.MemberDefinition)) {
Report.SymbolRelatedToPreviousError (emitted_forwarders[t.MemberDefinition].Location, null);
Report.Error (739, a.Location, "A duplicate type forward of type `{0}'",
TypeManager.CSharpName (t));
t.GetSignatureForError ());
return;
}
@ -297,13 +300,13 @@ namespace Mono.CSharp @@ -297,13 +300,13 @@ namespace Mono.CSharp
if (t.MemberDefinition.DeclaringAssembly == this) {
Report.SymbolRelatedToPreviousError (t);
Report.Error (729, a.Location, "Cannot forward type `{0}' because it is defined in this assembly",
TypeManager.CSharpName (t));
t.GetSignatureForError ());
return;
}
if (t.IsNested) {
Report.Error (730, a.Location, "Cannot forward type `{0}' because it is a nested type",
TypeManager.CSharpName (t));
t.GetSignatureForError ());
return;
}
@ -347,15 +350,24 @@ namespace Mono.CSharp @@ -347,15 +350,24 @@ namespace Mono.CSharp
} else if (a.Type == pa.RuntimeCompatibility) {
wrap_non_exception_throws_custom = true;
} else if (a.Type == pa.AssemblyFileVersion) {
string value = a.GetString ();
if (string.IsNullOrEmpty (value) || IsValidAssemblyVersion (value, false) == null) {
vi_product_version = a.GetString ();
if (string.IsNullOrEmpty (vi_product_version) || IsValidAssemblyVersion (vi_product_version, false) == null) {
Report.Warning (1607, 1, a.Location, "The version number `{0}' specified for `{1}' is invalid",
value, a.Name);
vi_product_version, a.Name);
return;
}
} else if (a.Type == pa.AssemblyProduct) {
vi_product = a.GetString ();
} else if (a.Type == pa.AssemblyCompany) {
vi_company = a.GetString ();
} else if (a.Type == pa.AssemblyDescription) {
// TODO: Needs extra api
} else if (a.Type == pa.AssemblyCopyright) {
vi_copyright = a.GetString ();
} else if (a.Type == pa.AssemblyTrademark) {
vi_trademark = a.GetString ();
}
SetCustomAttribute (ctor, cdata);
}
@ -370,7 +382,7 @@ namespace Mono.CSharp @@ -370,7 +382,7 @@ namespace Mono.CSharp
// no working SRE API
foreach (var entry in Importer.Assemblies) {
var a = entry as ImportedAssemblyDefinition;
if (a == null)
if (a == null || a.IsMissing)
continue;
if (public_key != null && !a.HasStrongName) {
@ -749,7 +761,7 @@ namespace Mono.CSharp @@ -749,7 +761,7 @@ namespace Mono.CSharp
if (Compiler.Settings.Win32ResourceFile != null) {
Builder.DefineUnmanagedResource (Compiler.Settings.Win32ResourceFile);
} else {
Builder.DefineVersionInfoResource ();
Builder.DefineVersionInfoResource (vi_product, vi_product_version, vi_company, vi_copyright, vi_trademark);
}
if (Compiler.Settings.Win32IconFile != null) {

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

@ -384,6 +384,10 @@ namespace Mono.CSharp @@ -384,6 +384,10 @@ namespace Mono.CSharp
}
}
public TypeSpec DelegateType {
get; set;
}
public override bool IsIterator {
get {
return false;

24
ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs

@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
//
// attribute.cs: Attribute Handler
// attribute.cs: Attributes handling
//
// Author: Ravi Pratap (ravi@ximian.com)
// Marek Safar (marek.safar@seznam.cz)
// Marek Safar (marek.safar@gmail.com)
//
// Dual licensed under the terms of the MIT X11 or GNU GPL
//
// Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
// Copyright 2003-2008 Novell, Inc.
// Copyright 2011 Xamarin Inc
// Copyright 2011-2013 Xamarin Inc
//
using System;
@ -264,7 +264,7 @@ namespace Mono.CSharp { @@ -264,7 +264,7 @@ namespace Mono.CSharp {
public void Error_AttributeEmitError (string inner)
{
Report.Error (647, Location, "Error during emitting `{0}' attribute. The reason is `{1}'",
TypeManager.CSharpName (Type), inner);
Type.GetSignatureForError (), inner);
}
public void Error_InvalidSecurityParent ()
@ -367,7 +367,7 @@ namespace Mono.CSharp { @@ -367,7 +367,7 @@ namespace Mono.CSharp {
public string GetSignatureForError ()
{
if (Type != null)
return TypeManager.CSharpName (Type);
return Type.GetSignatureForError ();
return expression.GetSignatureForError ();
}
@ -454,7 +454,7 @@ namespace Mono.CSharp { @@ -454,7 +454,7 @@ namespace Mono.CSharp {
ObsoleteAttribute obsolete_attr = Type.GetAttributeObsolete ();
if (obsolete_attr != null) {
AttributeTester.Report_ObsoleteMessage (obsolete_attr, TypeManager.CSharpName (Type), Location, Report);
AttributeTester.Report_ObsoleteMessage (obsolete_attr, Type.GetSignatureForError (), Location, Report);
}
ResolveContext rc = null;
@ -1669,6 +1669,11 @@ namespace Mono.CSharp { @@ -1669,6 +1669,11 @@ namespace Mono.CSharp {
public readonly PredefinedDecimalAttribute DecimalConstant;
public readonly PredefinedAttribute StructLayout;
public readonly PredefinedAttribute FieldOffset;
public readonly PredefinedAttribute AssemblyProduct;
public readonly PredefinedAttribute AssemblyCompany;
public readonly PredefinedAttribute AssemblyDescription;
public readonly PredefinedAttribute AssemblyCopyright;
public readonly PredefinedAttribute AssemblyTrademark;
public readonly PredefinedAttribute CallerMemberNameAttribute;
public readonly PredefinedAttribute CallerLineNumberAttribute;
public readonly PredefinedAttribute CallerFilePathAttribute;
@ -1722,6 +1727,11 @@ namespace Mono.CSharp { @@ -1722,6 +1727,11 @@ namespace Mono.CSharp {
DecimalConstant = new PredefinedDecimalAttribute (module, "System.Runtime.CompilerServices", "DecimalConstantAttribute");
StructLayout = new PredefinedAttribute (module, "System.Runtime.InteropServices", "StructLayoutAttribute");
FieldOffset = new PredefinedAttribute (module, "System.Runtime.InteropServices", "FieldOffsetAttribute");
AssemblyProduct = new PredefinedAttribute (module, "System.Reflection", "AssemblyProductAttribute");
AssemblyCompany = new PredefinedAttribute (module, "System.Reflection", "AssemblyCompanyAttribute");
AssemblyDescription = new PredefinedAttribute (module, "System.Reflection", "AssemblyDescriptionAttribute");
AssemblyCopyright = new PredefinedAttribute (module, "System.Reflection", "AssemblyCopyrightAttribute");
AssemblyTrademark = new PredefinedAttribute (module, "System.Reflection", "AssemblyTrademarkAttribute");
AsyncStateMachine = new PredefinedStateMachineAttribute (module, "System.Runtime.CompilerServices", "AsyncStateMachineAttribute");
@ -1839,7 +1849,7 @@ namespace Mono.CSharp { @@ -1839,7 +1849,7 @@ namespace Mono.CSharp {
//
// Handle all parameter-less attributes as optional
//
if (!IsDefined)
if (!Define ())
return false;
ctor = (MethodSpec) MemberCache.FindMember (type, MemberFilter.Constructor (ParametersCompiled.EmptyReadOnlyParameters), BindingRestriction.DeclaredOnly);

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

@ -17,7 +17,6 @@ using System.Collections.Generic; @@ -17,7 +17,6 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Mono.CompilerServices.SymbolWriter;
@ -1090,9 +1089,9 @@ namespace Mono.CSharp @@ -1090,9 +1089,9 @@ namespace Mono.CSharp
}
}
public virtual void AddBasesForPart (List<FullNamedExpression> bases)
public virtual void SetBaseTypes (List<FullNamedExpression> baseTypes)
{
type_bases = bases;
type_bases = baseTypes;
}
/// <summary>
@ -1283,8 +1282,10 @@ namespace Mono.CSharp @@ -1283,8 +1282,10 @@ namespace Mono.CSharp
all_tp_builders = TypeBuilder.DefineGenericParameters (tparam_names);
if (CurrentTypeParameters != null)
CurrentTypeParameters.Define (all_tp_builders, spec, CurrentTypeParametersStartIndex, this);
if (CurrentTypeParameters != null) {
CurrentTypeParameters.Create (spec, CurrentTypeParametersStartIndex, this);
CurrentTypeParameters.Define (all_tp_builders);
}
}
return true;
@ -1445,6 +1446,7 @@ namespace Mono.CSharp @@ -1445,6 +1446,7 @@ namespace Mono.CSharp
members.Add (proxy_method);
proxy_method.Define ();
proxy_method.PrepareEmit ();
hoisted_base_call_proxies.Add (method, proxy_method);
}
@ -1627,6 +1629,10 @@ namespace Mono.CSharp @@ -1627,6 +1629,10 @@ namespace Mono.CSharp
foreach (var member in members) {
var pm = member as IParametersMember;
if (pm != null) {
var mc = member as MethodOrOperator;
if (mc != null) {
mc.PrepareEmit ();
}
var p = pm.Parameters;
if (p.IsEmpty)
@ -1698,19 +1704,6 @@ namespace Mono.CSharp @@ -1698,19 +1704,6 @@ namespace Mono.CSharp
current_type = null;
}
void UpdateTypeParameterConstraints (TypeDefinition part)
{
for (int i = 0; i < CurrentTypeParameters.Count; i++) {
if (CurrentTypeParameters[i].AddPartialConstraints (part, part.MemberName.TypeParameters[i]))
continue;
Report.SymbolRelatedToPreviousError (Location, "");
Report.Error (265, part.Location,
"Partial declarations of `{0}' have inconsistent constraints for type parameter `{1}'",
GetSignatureForError (), CurrentTypeParameters[i].GetSignatureForError ());
}
}
public override void RemoveContainer (TypeContainer cont)
{
base.RemoveContainer (cont);
@ -1735,7 +1728,7 @@ namespace Mono.CSharp @@ -1735,7 +1728,7 @@ namespace Mono.CSharp
}
if (IsPartialPart) {
PartialContainer.UpdateTypeParameterConstraints (this);
PartialContainer.CurrentTypeParameters.UpdateConstraints (this);
}
return true;
@ -2296,7 +2289,7 @@ namespace Mono.CSharp @@ -2296,7 +2289,7 @@ namespace Mono.CSharp
Report.SymbolRelatedToPreviousError (mb.InterfaceType);
Report.Error (540, mb.Location, "`{0}': containing type does not implement interface `{1}'",
mb.GetSignatureForError (), TypeManager.CSharpName (mb.InterfaceType));
mb.GetSignatureForError (), mb.InterfaceType.GetSignatureForError ());
return false;
}
@ -2526,7 +2519,7 @@ namespace Mono.CSharp @@ -2526,7 +2519,7 @@ namespace Mono.CSharp
/// <summary>
/// Defines the default constructors
/// </summary>
protected Constructor DefineDefaultConstructor (bool is_static)
protected virtual Constructor DefineDefaultConstructor (bool is_static)
{
// The default instance constructor is public
// If the class is abstract, the default constructor is protected
@ -2607,14 +2600,14 @@ namespace Mono.CSharp @@ -2607,14 +2600,14 @@ namespace Mono.CSharp
visitor.Visit (this);
}
public override void AddBasesForPart (List<FullNamedExpression> bases)
public override void SetBaseTypes (List<FullNamedExpression> baseTypes)
{
var pmn = MemberName;
if (pmn.Name == "Object" && !pmn.IsGeneric && Parent.MemberName.Name == "System" && Parent.MemberName.Left == null)
Report.Error (537, Location,
"The class System.Object cannot have a base class or implement an interface.");
base.AddBasesForPart (bases);
base.SetBaseTypes (baseTypes);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
@ -3047,7 +3040,7 @@ namespace Mono.CSharp @@ -3047,7 +3040,7 @@ namespace Mono.CSharp
Report.SymbolRelatedToPreviousError (iface);
Report.Warning (3027, 1, Location, "`{0}' is not CLS-compliant because base interface `{1}' is not CLS-compliant",
GetSignatureForError (), TypeManager.CSharpName (iface));
GetSignatureForError (), iface.GetSignatureForError ());
}
}
@ -3282,10 +3275,10 @@ namespace Mono.CSharp @@ -3282,10 +3275,10 @@ namespace Mono.CSharp
Report.SymbolRelatedToPreviousError (base_member);
if (this is PropertyBasedMember) {
Report.Error (1715, Location, "`{0}': type must be `{1}' to match overridden member `{2}'",
GetSignatureForError (), TypeManager.CSharpName (base_member_type), TypeManager.CSharpSignature (base_member));
GetSignatureForError (), base_member_type.GetSignatureForError (), base_member.GetSignatureForError ());
} else {
Report.Error (508, Location, "`{0}': return type must be `{1}' to match overridden member `{2}'",
GetSignatureForError (), TypeManager.CSharpName (base_member_type), TypeManager.CSharpSignature (base_member));
GetSignatureForError (), base_member_type.GetSignatureForError (), base_member.GetSignatureForError ());
}
ok = false;
}
@ -3359,7 +3352,7 @@ namespace Mono.CSharp @@ -3359,7 +3352,7 @@ namespace Mono.CSharp
if (!InterfaceType.IsInterface) {
Report.SymbolRelatedToPreviousError (InterfaceType);
Report.Error (538, Location, "The type `{0}' in explicit interface declaration is not an interface",
TypeManager.CSharpName (InterfaceType));
InterfaceType.GetSignatureForError ());
} else {
Parent.PartialContainer.VerifyImplements (this);
}
@ -3390,15 +3383,15 @@ namespace Mono.CSharp @@ -3390,15 +3383,15 @@ namespace Mono.CSharp
if (this is Indexer)
Report.Error (55, Location,
"Inconsistent accessibility: parameter type `{0}' is less accessible than indexer `{1}'",
TypeManager.CSharpName (t), GetSignatureForError ());
t.GetSignatureForError (), GetSignatureForError ());
else if (this is Operator)
Report.Error (57, Location,
"Inconsistent accessibility: parameter type `{0}' is less accessible than operator `{1}'",
TypeManager.CSharpName (t), GetSignatureForError ());
t.GetSignatureForError (), GetSignatureForError ());
else
Report.Error (51, Location,
"Inconsistent accessibility: parameter type `{0}' is less accessible than method `{1}'",
TypeManager.CSharpName (t), GetSignatureForError ());
t.GetSignatureForError (), GetSignatureForError ());
error = true;
}
return !error;
@ -3507,7 +3500,7 @@ namespace Mono.CSharp @@ -3507,7 +3500,7 @@ namespace Mono.CSharp
// replacing predefined names which saves some space and name
// is still unique
//
return TypeManager.CSharpName (InterfaceType) + "." + name;
return InterfaceType.GetSignatureForError () + "." + name;
}
public override string GetSignatureForDocumentation ()
@ -3607,28 +3600,28 @@ namespace Mono.CSharp @@ -3607,28 +3600,28 @@ namespace Mono.CSharp
if (this is Property)
Report.Error (53, Location,
"Inconsistent accessibility: property type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
MemberType.GetSignatureForError () + "' is less " +
"accessible than property `" + GetSignatureForError () + "'");
else if (this is Indexer)
Report.Error (54, Location,
"Inconsistent accessibility: indexer return type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
MemberType.GetSignatureForError () + "' is less " +
"accessible than indexer `" + GetSignatureForError () + "'");
else if (this is MethodCore) {
if (this is Operator)
Report.Error (56, Location,
"Inconsistent accessibility: return type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
MemberType.GetSignatureForError () + "' is less " +
"accessible than operator `" + GetSignatureForError () + "'");
else
Report.Error (50, Location,
"Inconsistent accessibility: return type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
MemberType.GetSignatureForError () + "' is less " +
"accessible than method `" + GetSignatureForError () + "'");
} else {
Report.Error (52, Location,
"Inconsistent accessibility: field type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
MemberType.GetSignatureForError () + "' is less " +
"accessible than field `" + GetSignatureForError () + "'");
}
}

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

@ -100,10 +100,10 @@ namespace Mono.CSharp { @@ -100,10 +100,10 @@ namespace Mono.CSharp {
{
if (t.IsGenericParameter) {
Report.Error (1959, loc,
"Type parameter `{0}' cannot be declared const", TypeManager.CSharpName (t));
"Type parameter `{0}' cannot be declared const", t.GetSignatureForError ());
} else {
Report.Error (283, loc,
"The type `{0}' cannot be declared const", TypeManager.CSharpName (t));
"The type `{0}' cannot be declared const", t.GetSignatureForError ());
}
}

6
ICSharpCode.NRefactory.CSharp/Parser/mcs/constant.cs

@ -64,7 +64,7 @@ namespace Mono.CSharp { @@ -64,7 +64,7 @@ namespace Mono.CSharp {
BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (target) &&
BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (type)) {
ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
GetValueAsLiteral (), TypeManager.CSharpName (target));
GetValueAsLiteral (), target.GetSignatureForError ());
} else {
base.Error_ValueCannotBeConverted (ec, target, expl);
}
@ -100,7 +100,7 @@ namespace Mono.CSharp { @@ -100,7 +100,7 @@ namespace Mono.CSharp {
// reached, by calling Convert.ImplicitStandardConversionExists
//
throw new InternalErrorException ("Missing constant conversion between `{0}' and `{1}'",
TypeManager.CSharpName (Type), TypeManager.CSharpName (type));
Type.GetSignatureForError (), type.GetSignatureForError ());
}
return CreateConstantFromValue (type, constant_value, loc);
@ -402,7 +402,7 @@ namespace Mono.CSharp { @@ -402,7 +402,7 @@ namespace Mono.CSharp {
catch
{
ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
GetValue ().ToString (), TypeManager.CSharpName (target));
GetValue ().ToString (), target.GetSignatureForError ());
}
}

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

@ -782,7 +782,7 @@ namespace Mono.CSharp @@ -782,7 +782,7 @@ namespace Mono.CSharp
public LocationsBag LocationsBag { get; set; }
public bool UseJayGlobalArrays { get; set; }
public Tokenizer.LocatedToken[] LocatedTokens { get; set; }
public LocatedToken[] LocatedTokens { get; set; }
public MD5 GetChecksumAlgorithm ()
{

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

File diff suppressed because it is too large Load Diff

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

@ -54,7 +54,7 @@ namespace Mono.CSharp @@ -54,7 +54,7 @@ namespace Mono.CSharp
/// </summary>
Block current_block;
BlockVariableDeclaration current_variable;
BlockVariable current_variable;
Delegate current_delegate;
@ -426,7 +426,7 @@ extern_alias_directives @@ -426,7 +426,7 @@ extern_alias_directives
extern_alias_directive
: EXTERN_ALIAS IDENTIFIER IDENTIFIER SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
string s = lt.Value;
if (s != "alias") {
syntax_error (lt.Location, "`alias' expected");
@ -434,7 +434,7 @@ extern_alias_directive @@ -434,7 +434,7 @@ extern_alias_directive
if (lang_version == LanguageVersion.ISO_1)
FeatureIsNotAvailable (lt.Location, "external alias");
lt = (Tokenizer.LocatedToken) $3;
lt = (LocatedToken) $3;
if (lt.Value == QualifiedAliasMember.GlobalAlias) {
RootNamespace.Error_GlobalNamespaceRedefined (report, lt.Location);
}
@ -474,7 +474,7 @@ using_namespace @@ -474,7 +474,7 @@ using_namespace
}
| USING IDENTIFIER ASSIGN namespace_or_type_expr SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
if (lang_version != LanguageVersion.ISO_1 && lt.Value == "global") {
report.Warning (440, 2, lt.Location,
"An alias named `global' will not be used when resolving `global::'. The global namespace will be used instead");
@ -563,15 +563,14 @@ opt_semicolon_error @@ -563,15 +563,14 @@ opt_semicolon_error
namespace_name
: IDENTIFIER
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new MemberName (lt.Value, lt.Location);
}
| namespace_name DOT IDENTIFIER
{
var lt = (Tokenizer.LocatedToken) $3;
$$ = new MemberName ((MemberName) $1, lt.Value, lt.Location) {
DotLocation = GetLocation ($2)
};
var lt = (LocatedToken) $3;
$$ = new MemberName ((MemberName) $1, lt.Value, lt.Location);
lbag.AddLocation ($$, GetLocation ($2));
}
| error
{
@ -747,7 +746,7 @@ attribute_section_cont @@ -747,7 +746,7 @@ attribute_section_cont
{
Error_SyntaxError (yyToken);
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
var tne = new SimpleName (lt.Value, null, lt.Location);
$$ = new List<Attribute> () {
@ -764,7 +763,7 @@ attribute_section_cont @@ -764,7 +763,7 @@ attribute_section_cont
attribute_target
: IDENTIFIER
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = CheckAttributeTarget (lt.Value, lt.Location);
savedCloseLocation = GetLocation ($1);
}
@ -894,14 +893,14 @@ named_attribute_argument @@ -894,14 +893,14 @@ named_attribute_argument
expression
{
--lexer.parsing_block;
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new NamedArgument (lt.Value, lt.Location, (Expression) $4);
lbag.AddLocation ($$, GetLocation($2));
}
;
named_argument
: identifier_inside_body COLON opt_named_modifier expression
: identifier_inside_body COLON opt_named_modifier expression_or_error
{
if (lang_version <= LanguageVersion.V_3)
FeatureIsNotAvailable (GetLocation ($1), "named argument");
@ -909,7 +908,7 @@ named_argument @@ -909,7 +908,7 @@ named_argument
// Avoid boxing in common case (no modifier)
var arg_mod = $3 == null ? Argument.AType.None : (Argument.AType) $3;
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new NamedArgument (lt.Value, lt.Location, (Expression) $4, arg_mod);
lbag.AddLocation ($$, GetLocation($2));
}
@ -1023,7 +1022,7 @@ constant_declaration @@ -1023,7 +1022,7 @@ constant_declaration
opt_modifiers
CONST type IDENTIFIER
{
var lt = (Tokenizer.LocatedToken) $5;
var lt = (LocatedToken) $5;
var mod = (Modifiers) $2;
current_field = new Const (current_type, (FullNamedExpression) $4, mod, new MemberName (lt.Value, lt.Location), (Attributes) $1);
current_type.AddMember (current_field);
@ -1074,7 +1073,7 @@ constant_declarators @@ -1074,7 +1073,7 @@ constant_declarators
constant_declarator
: COMMA IDENTIFIER constant_initializer
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) $3);
lbag.AddLocation ($$, GetLocation ($1));
}
@ -1114,7 +1113,7 @@ field_declaration @@ -1114,7 +1113,7 @@ field_declaration
if (type.Type != null && type.Type.Kind == MemberKind.Void)
report.Error (670, GetLocation ($3), "Fields cannot have void type");
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
current_field = new Field (current_type, type, (Modifiers) $2, new MemberName (lt.Value, lt.Location), (Attributes) $1);
current_type.AddField (current_field);
$$ = current_field;
@ -1139,7 +1138,7 @@ field_declaration @@ -1139,7 +1138,7 @@ field_declaration
if (lang_version < LanguageVersion.ISO_2)
FeatureIsNotAvailable (GetLocation ($3), "fixed size buffers");
var lt = (Tokenizer.LocatedToken) $5;
var lt = (LocatedToken) $5;
current_field = new FixedField (current_type, (FullNamedExpression) $4, (Modifiers) $2,
new MemberName (lt.Value, lt.Location), (Attributes) $1);
@ -1203,7 +1202,7 @@ field_declarators @@ -1203,7 +1202,7 @@ field_declarators
field_declarator
: COMMA IDENTIFIER
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null);
lbag.AddLocation ($$, GetLocation ($1));
}
@ -1214,7 +1213,7 @@ field_declarator @@ -1214,7 +1213,7 @@ field_declarator
variable_initializer
{
--lexer.parsing_block;
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (Expression) $5);
lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3));
}
@ -1239,7 +1238,7 @@ fixed_field_declarators @@ -1239,7 +1238,7 @@ fixed_field_declarators
fixed_field_declarator
: COMMA IDENTIFIER fixed_field_size
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) $3);
lbag.AddLocation ($$, GetLocation ($1));
}
@ -1383,8 +1382,10 @@ method_header @@ -1383,8 +1382,10 @@ method_header
current_type.AddMember (method);
if ($11 != null)
method.SetConstraints ((List<Constraints>) $11);
async_block = (method.ModFlags & Modifiers.ASYNC) != 0;
if ($12 != null)
method.SetConstraints ((List<Constraints>) $12);
if (doc_support)
method.DocComment = Lexer.consume_doc_comment ();
@ -1561,7 +1562,7 @@ fixed_parameter @@ -1561,7 +1562,7 @@ fixed_parameter
parameter_type
identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
$$ = new Parameter ((FullNamedExpression) $3, lt.Value, (Parameter.Modifier) $2, (Attributes) $1, lt.Location);
lbag.AddLocation ($$, parameterModifierLocation);
}
@ -1570,7 +1571,7 @@ fixed_parameter @@ -1570,7 +1571,7 @@ fixed_parameter
parameter_type
identifier_inside_body OPEN_BRACKET CLOSE_BRACKET
{
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
report.Error (1552, lt.Location, "Array type specifier, [], must appear before parameter name");
$$ = new Parameter ((FullNamedExpression) $3, lt.Value, (Parameter.Modifier) $2, (Attributes) $1, lt.Location);
lbag.AddLocation ($$, parameterModifierLocation);
@ -1629,7 +1630,7 @@ fixed_parameter @@ -1629,7 +1630,7 @@ fixed_parameter
if ((valid_param_mod & ParameterModifierType.DefaultValue) == 0)
report.Error (1065, GetLocation ($5), "Optional parameter is not valid in this context");
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
$$ = new Parameter ((FullNamedExpression) $3, lt.Value, mod, (Attributes) $1, lt.Location);
lbag.AddLocation ($$, parameterModifierLocation, GetLocation ($5)); // parameterModifierLocation should be ignored when mod == NONE
@ -1701,7 +1702,7 @@ parameter_modifier @@ -1701,7 +1702,7 @@ parameter_modifier
parameter_array
: opt_attributes params_modifier type IDENTIFIER
{
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
$$ = new ParamsParameter ((FullNamedExpression) $3, lt.Value, (Attributes) $1, lt.Location);
lbag.AddLocation ($$, savedLocation);
}
@ -1709,7 +1710,7 @@ parameter_array @@ -1709,7 +1710,7 @@ parameter_array
{
report.Error (1751, GetLocation ($2), "Cannot specify a default value for a parameter array");
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
$$ = new ParamsParameter ((FullNamedExpression) $3, lt.Value, (Attributes) $1, lt.Location);
lbag.AddLocation ($$, savedLocation);
}
@ -2135,11 +2136,11 @@ operator_declarator @@ -2135,11 +2136,11 @@ operator_declarator
Operator.GetName (op));
}
} else {
if (p_count > 2) {
if (p_count == 1) {
report.Error (1019, loc, "Overloadable unary operator expected");
} else if (p_count != 2) {
report.Error (1534, loc, "Overloaded binary operator `{0}' takes two parameters",
Operator.GetName (op));
} else if (p_count != 2) {
report.Error (1019, loc, "Overloadable unary operator expected");
}
}
@ -2276,7 +2277,7 @@ constructor_declarator @@ -2276,7 +2277,7 @@ constructor_declarator
valid_param_mod = 0;
current_local_parameters = (ParametersCompiled) $6;
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
var mods = (Modifiers) $2;
var c = new Constructor (current_type, lt.Value, mods, (Attributes) $1, current_local_parameters, lt.Location);
@ -2373,7 +2374,7 @@ destructor_declaration @@ -2373,7 +2374,7 @@ destructor_declaration
}
IDENTIFIER OPEN_PARENS CLOSE_PARENS method_body
{
var lt = (Tokenizer.LocatedToken) $5;
var lt = (LocatedToken) $5;
if (lt.Value != current_container.MemberName.Name){
report.Error (574, lt.Location, "Name of destructor must match name of class");
} else if (current_container.Kind != MemberKind.Class){
@ -2496,7 +2497,7 @@ event_declarators @@ -2496,7 +2497,7 @@ event_declarators
event_declarator
: COMMA IDENTIFIER
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null);
lbag.AddLocation ($$, GetLocation ($1));
}
@ -2507,7 +2508,7 @@ event_declarator @@ -2507,7 +2508,7 @@ event_declarator
event_variable_initializer
{
--lexer.parsing_block;
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (Expression) $5);
lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3));
}
@ -2729,7 +2730,7 @@ enum_member_declarations @@ -2729,7 +2730,7 @@ enum_member_declarations
enum_member_declaration
: opt_attributes IDENTIFIER
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var em = new EnumMember ((Enum) current_type, new MemberName (lt.Value, lt.Location), (Attributes) $1);
((Enum) current_type).AddEnumMember (em);
@ -2752,7 +2753,7 @@ enum_member_declaration @@ -2752,7 +2753,7 @@ enum_member_declaration
{
--lexer.parsing_block;
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var em = new EnumMember ((Enum) current_type, new MemberName (lt.Value, lt.Location), (Attributes) $1);
em.Initializer = new ConstInitializer (em, (Expression) $5, GetLocation ($4));
((Enum) current_type).AddEnumMember (em);
@ -2766,7 +2767,7 @@ enum_member_declaration @@ -2766,7 +2767,7 @@ enum_member_declaration
{
Error_SyntaxError (yyToken);
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var em = new EnumMember ((Enum) current_type, new MemberName (lt.Value, lt.Location), (Attributes) $1);
((Enum) current_type).AddEnumMember (em);
@ -2840,8 +2841,8 @@ namespace_or_type_expr @@ -2840,8 +2841,8 @@ namespace_or_type_expr
: member_name
| qualified_alias_member IDENTIFIER opt_type_argument_list
{
var lt1 = (Tokenizer.LocatedToken) $1;
var lt2 = (Tokenizer.LocatedToken) $2;
var lt1 = (LocatedToken) $1;
var lt2 = (LocatedToken) $2;
$$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (TypeArguments) $3, lt1.Location);
lbag.AddLocation ($$, savedLocation, GetLocation ($2));
@ -2852,17 +2853,16 @@ member_name @@ -2852,17 +2853,16 @@ member_name
: simple_name_expr
| namespace_or_type_expr DOT IDENTIFIER opt_type_argument_list
{
var lt = (Tokenizer.LocatedToken) $3;
$$ = new MemberAccess ((Expression) $1, lt.Value, (TypeArguments) $4, lt.Location) {
DotLocation = GetLocation ($2)
};
var lt = (LocatedToken) $3;
$$ = new MemberAccess ((Expression) $1, lt.Value, (TypeArguments) $4, lt.Location);
lbag.AddLocation ($$, GetLocation ($2));
}
;
simple_name_expr
: IDENTIFIER opt_type_argument_list
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new SimpleName (lt.Value, (TypeArguments)$2, lt.Location);
}
;
@ -2918,7 +2918,7 @@ type_declaration_name @@ -2918,7 +2918,7 @@ type_declaration_name
opt_type_parameter_list
{
lexer.parsing_generic_declaration = false;
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new MemberName (lt.Value, (TypeParameters)$3, lt.Location);
}
;
@ -2938,7 +2938,7 @@ method_declaration_name @@ -2938,7 +2938,7 @@ method_declaration_name
| explicit_interface IDENTIFIER opt_type_parameter_list
{
lexer.parsing_generic_declaration = false;
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new MemberName (lt.Value, (TypeParameters) $3, (ATypeNameExpression) $1, lt.Location);
}
;
@ -2959,21 +2959,21 @@ indexer_declaration_name @@ -2959,21 +2959,21 @@ indexer_declaration_name
explicit_interface
: IDENTIFIER opt_type_argument_list DOT
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new SimpleName (lt.Value, (TypeArguments) $2, lt.Location);
lbag.AddLocation ($$, GetLocation ($3));
}
| qualified_alias_member IDENTIFIER opt_type_argument_list DOT
{
var lt1 = (Tokenizer.LocatedToken) $1;
var lt2 = (Tokenizer.LocatedToken) $2;
var lt1 = (LocatedToken) $1;
var lt2 = (LocatedToken) $2;
$$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (TypeArguments) $3, lt1.Location);
lbag.AddLocation ($$, savedLocation, GetLocation ($4));
}
| explicit_interface IDENTIFIER opt_type_argument_list DOT
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new MemberAccess ((ATypeNameExpression) $1, lt.Value, (TypeArguments) $3, lt.Location);
lbag.AddLocation ($$, GetLocation ($4));
}
@ -3014,7 +3014,7 @@ type_parameters @@ -3014,7 +3014,7 @@ type_parameters
type_parameter
: opt_attributes opt_type_parameter_variance IDENTIFIER
{
var lt = (Tokenizer.LocatedToken)$3;
var lt = (LocatedToken)$3;
var variance = (Variance) $2;
$$ = new TypeParameter (new MemberName (lt.Value, lt.Location), (Attributes)$1, variance);
if (variance != Variance.None)
@ -3202,11 +3202,11 @@ primary_expression @@ -3202,11 +3202,11 @@ primary_expression
primary_expression_or_type
: IDENTIFIER opt_type_argument_list
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new SimpleName (lt.Value, (TypeArguments)$2, lt.Location);
}
| IDENTIFIER GENERATE_COMPLETION {
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new CompletionSimpleName (MemberName.MakeName (lt.Value, null), lt.Location);
}
| member_access
@ -3259,29 +3259,26 @@ parenthesized_expression @@ -3259,29 +3259,26 @@ parenthesized_expression
member_access
: primary_expression DOT identifier_inside_body opt_type_argument_list
{
var lt = (Tokenizer.LocatedToken) $3;
$$ = new MemberAccess ((Expression) $1, lt.Value, (TypeArguments) $4, lt.Location) {
DotLocation = GetLocation ($2)
};
var lt = (LocatedToken) $3;
$$ = new MemberAccess ((Expression) $1, lt.Value, (TypeArguments) $4, lt.Location);
lbag.AddLocation ($$, GetLocation ($2));
}
| builtin_types DOT identifier_inside_body opt_type_argument_list
{
var lt = (Tokenizer.LocatedToken) $3;
$$ = new MemberAccess ((Expression) $1, lt.Value, (TypeArguments) $4, lt.Location) {
DotLocation = GetLocation ($2)
};
var lt = (LocatedToken) $3;
$$ = new MemberAccess ((Expression) $1, lt.Value, (TypeArguments) $4, lt.Location);
lbag.AddLocation ($$, GetLocation ($2));
}
| BASE DOT identifier_inside_body opt_type_argument_list
{
var lt = (Tokenizer.LocatedToken) $3;
$$ = new MemberAccess (new BaseThis (GetLocation ($1)), lt.Value, (TypeArguments) $4, lt.Location) {
DotLocation = GetLocation ($2)
};
var lt = (LocatedToken) $3;
$$ = new MemberAccess (new BaseThis (GetLocation ($1)), lt.Value, (TypeArguments) $4, lt.Location);
lbag.AddLocation ($$, GetLocation ($2));
}
| qualified_alias_member identifier_inside_body opt_type_argument_list
{
var lt1 = (Tokenizer.LocatedToken) $1;
var lt2 = (Tokenizer.LocatedToken) $2;
var lt1 = (LocatedToken) $1;
var lt2 = (LocatedToken) $2;
$$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (TypeArguments) $3, lt1.Location);
lbag.AddLocation ($$, savedLocation, GetLocation ($2));
@ -3290,7 +3287,7 @@ member_access @@ -3290,7 +3287,7 @@ member_access
$$ = new CompletionMemberAccess ((Expression) $1, null,GetLocation ($3));
}
| primary_expression DOT IDENTIFIER GENERATE_COMPLETION {
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
$$ = new CompletionMemberAccess ((Expression) $1, lt.Value, lt.Location);
}
| builtin_types DOT GENERATE_COMPLETION
@ -3298,7 +3295,7 @@ member_access @@ -3298,7 +3295,7 @@ member_access
$$ = new CompletionMemberAccess ((Expression) $1, null, lexer.Location);
}
| builtin_types DOT IDENTIFIER GENERATE_COMPLETION {
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
$$ = new CompletionMemberAccess ((Expression) $1, lt.Value, lt.Location);
}
;
@ -3378,13 +3375,13 @@ member_initializer_list @@ -3378,13 +3375,13 @@ member_initializer_list
member_initializer
: IDENTIFIER ASSIGN initializer_value
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new ElementInitializer (lt.Value, (Expression)$3, lt.Location);
lbag.AddLocation ($$, GetLocation ($2));
}
| AWAIT ASSIGN initializer_value
{
var lt = (Tokenizer.LocatedToken) Error_AwaitAsIdentifier ($1);
var lt = (LocatedToken) Error_AwaitAsIdentifier ($1);
$$ = new ElementInitializer (lt.Value, (Expression)$3, lt.Location);
lbag.AddLocation ($$, GetLocation ($2));
}
@ -3722,13 +3719,13 @@ anonymous_type_parameters @@ -3722,13 +3719,13 @@ anonymous_type_parameters
anonymous_type_parameter
: identifier_inside_body ASSIGN variable_initializer
{
var lt = (Tokenizer.LocatedToken)$1;
var lt = (LocatedToken)$1;
$$ = new AnonymousTypeParameter ((Expression)$3, lt.Value, lt.Location);
lbag.AddLocation ($$, GetLocation ($2));
}
| identifier_inside_body
{
var lt = (Tokenizer.LocatedToken)$1;
var lt = (LocatedToken)$1;
$$ = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location),
lt.Value, lt.Location);
}
@ -3857,15 +3854,17 @@ typeof_type_expression @@ -3857,15 +3854,17 @@ typeof_type_expression
unbound_type_name
: identifier_inside_body generic_dimension
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
var sn = new SimpleName (lt.Value, (int) $2, lt.Location);
$$ = sn;
lbag.AddLocation (sn.TypeArguments, Lexer.GetGenericDimensionLocations ());
}
| qualified_alias_member identifier_inside_body generic_dimension
{
var lt1 = (Tokenizer.LocatedToken) $1;
var lt2 = (Tokenizer.LocatedToken) $2;
var lt1 = (LocatedToken) $1;
var lt2 = (LocatedToken) $2;
var qam = new QualifiedAliasMember (lt1.Value, lt2.Value, (int) $3, lt1.Location);
$$ = qam;
lbag.AddLocation (qam.TypeArguments, Lexer.GetGenericDimensionLocations ());
@ -3873,20 +3872,18 @@ unbound_type_name @@ -3873,20 +3872,18 @@ unbound_type_name
}
| unbound_type_name DOT identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
$$ = new MemberAccess ((Expression) $1, lt.Value, lt.Location) {
DotLocation = GetLocation ($2)
};
$$ = new MemberAccess ((Expression) $1, lt.Value, lt.Location);
lbag.AddLocation ($$, savedLocation, GetLocation ($2));
}
| unbound_type_name DOT identifier_inside_body generic_dimension
{
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
var ma = new MemberAccess ((Expression) $1, lt.Value, (int) $4, lt.Location) {
DotLocation = GetLocation ($2)
};
var ma = new MemberAccess ((Expression) $1, lt.Value, (int) $4, lt.Location);
$$ = ma;
lbag.AddLocation ($$, savedLocation, GetLocation ($2));
lbag.AddLocation (ma.TypeArguments, Lexer.GetGenericDimensionLocations ());
}
| namespace_or_type_expr DOT identifier_inside_body generic_dimension
@ -3895,10 +3892,8 @@ unbound_type_name @@ -3895,10 +3892,8 @@ unbound_type_name
if (tne.HasTypeArguments)
Error_TypeExpected (GetLocation ($4));
var lt = (Tokenizer.LocatedToken) $3;
var ma = new MemberAccess (tne, lt.Value, (int) $4, lt.Location) {
DotLocation = GetLocation ($2)
};
var lt = (LocatedToken) $3;
var ma = new MemberAccess (tne, lt.Value, (int) $4, lt.Location);
$$ = ma;
lbag.AddLocation (ma.TypeArguments, Lexer.GetGenericDimensionLocations ());
}
@ -3917,7 +3912,7 @@ generic_dimension @@ -3917,7 +3912,7 @@ generic_dimension
qualified_alias_member
: IDENTIFIER DOUBLE_COLON
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
if (lang_version == LanguageVersion.ISO_1)
FeatureIsNotAvailable (lt.Location, "namespace alias qualifier");
savedLocation = GetLocation ($2);
@ -3971,7 +3966,7 @@ unchecked_expression @@ -3971,7 +3966,7 @@ unchecked_expression
pointer_member_access
: primary_expression OP_PTR IDENTIFIER opt_type_argument_list
{
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
$$ = new MemberAccess (new Indirection ((Expression) $1, GetLocation ($2)), lt.Value, (TypeArguments) $4, lt.Location);
}
;
@ -4570,24 +4565,24 @@ lambda_parameter_list @@ -4570,24 +4565,24 @@ lambda_parameter_list
lambda_parameter
: parameter_modifier parameter_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
$$ = new Parameter ((FullNamedExpression) $2, lt.Value, (Parameter.Modifier) $1, null, lt.Location);
}
| parameter_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new Parameter ((FullNamedExpression) $1, lt.Value, Parameter.Modifier.NONE, null, lt.Location);
}
| IDENTIFIER
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
$$ = new ImplicitLambdaParameter (lt.Value, lt.Location);
}
| AWAIT
{
var lt = (Tokenizer.LocatedToken) Error_AwaitAsIdentifier ($1);
var lt = (LocatedToken) Error_AwaitAsIdentifier ($1);
$$ = new ImplicitLambdaParameter (lt.Value, lt.Location);
}
;
@ -4637,7 +4632,7 @@ expression_or_error @@ -4637,7 +4632,7 @@ expression_or_error
lambda_expression
: IDENTIFIER ARROW
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
start_anonymous (true, new ParametersCompiled (p), false, lt.Location);
}
@ -4648,7 +4643,7 @@ lambda_expression @@ -4648,7 +4643,7 @@ lambda_expression
}
| AWAIT ARROW
{
var lt = (Tokenizer.LocatedToken) Error_AwaitAsIdentifier ($1);
var lt = (LocatedToken) Error_AwaitAsIdentifier ($1);
Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
start_anonymous (true, new ParametersCompiled (p), false, lt.Location);
}
@ -4659,7 +4654,7 @@ lambda_expression @@ -4659,7 +4654,7 @@ lambda_expression
}
| ASYNC identifier_inside_body ARROW
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
start_anonymous (true, new ParametersCompiled (p), true, lt.Location);
}
@ -4923,14 +4918,14 @@ opt_class_base @@ -4923,14 +4918,14 @@ opt_class_base
: /* empty */
| COLON type_list
{
current_type.AddBasesForPart ((List<FullNamedExpression>) $2);
current_type.SetBaseTypes ((List<FullNamedExpression>) $2);
lbag.AppendToMember (current_type, GetLocation ($1));
}
| COLON type_list error
{
Error_SyntaxError (yyToken);
current_type.AddBasesForPart ((List<FullNamedExpression>) $2);
current_type.SetBaseTypes ((List<FullNamedExpression>) $2);
}
;
@ -4970,7 +4965,7 @@ type_parameter_constraints_clauses @@ -4970,7 +4965,7 @@ type_parameter_constraints_clauses
type_parameter_constraints_clause
: WHERE IDENTIFIER COLON type_parameter_constraints
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new Constraints (new SimpleMemberName (lt.Value, lt.Location), (List<FullNamedExpression>) $4, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($3));
}
@ -4978,7 +4973,7 @@ type_parameter_constraints_clause @@ -4978,7 +4973,7 @@ type_parameter_constraints_clause
{
Error_SyntaxError (yyToken);
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new Constraints (new SimpleMemberName (lt.Value, lt.Location), null, GetLocation ($1));
}
;
@ -5160,7 +5155,7 @@ statement @@ -5160,7 +5155,7 @@ statement
| IDENTIFIER error
{
Error_SyntaxError (yyToken);
var lt =(Tokenizer.LocatedToken) $1;
var lt =(LocatedToken) $1;
var sn = new SimpleName (lt.Value, lt.Location);
current_block.AddStatement(new StatementErrorExpression (sn));
$$ = null;
@ -5258,7 +5253,7 @@ empty_statement @@ -5258,7 +5253,7 @@ empty_statement
labeled_statement
: identifier_inside_body COLON
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location);
lbag.AddLocation (labeled, GetLocation ($2));
current_block.AddLabel (labeled);
@ -5375,10 +5370,10 @@ identifier_inside_body @@ -5375,10 +5370,10 @@ identifier_inside_body
block_variable_declaration
: variable_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var li = new LocalVariable (current_block, lt.Value, lt.Location);
current_block.AddLocalName (li);
current_variable = new BlockVariableDeclaration ((FullNamedExpression) $1, li);
current_variable = new BlockVariable ((FullNamedExpression) $1, li);
}
opt_local_variable_initializer opt_variable_declarators semicolon_or_handle_error_close_brace
{
@ -5391,10 +5386,10 @@ block_variable_declaration @@ -5391,10 +5386,10 @@ block_variable_declaration
}
| CONST variable_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location);
current_block.AddLocalName (li);
current_variable = new BlockConstantDeclaration ((FullNamedExpression) $2, li);
current_variable = new BlockConstant ((FullNamedExpression) $2, li);
}
const_variable_initializer opt_const_declarators SEMICOLON
{
@ -5461,18 +5456,18 @@ variable_declarators @@ -5461,18 +5456,18 @@ variable_declarators
variable_declarator
: COMMA identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location);
var d = new BlockVariableDeclaration.Declarator (li, null);
var d = new BlockVariableDeclarator (li, null);
current_variable.AddDeclarator (d);
current_block.AddLocalName (li);
lbag.AddLocation (d, GetLocation ($1));
}
| COMMA identifier_inside_body ASSIGN block_variable_initializer
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location);
var d = new BlockVariableDeclaration.Declarator (li, (Expression) $4);
var d = new BlockVariableDeclarator (li, (Expression) $4);
current_variable.AddDeclarator (d);
current_block.AddLocalName (li);
lbag.AddLocation (d, GetLocation ($1), GetLocation ($3));
@ -5504,9 +5499,9 @@ const_declarators @@ -5504,9 +5499,9 @@ const_declarators
const_declarator
: COMMA identifier_inside_body ASSIGN constant_initializer_expr
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location);
var d = new BlockVariableDeclaration.Declarator (li, (Expression) $4);
var d = new BlockVariableDeclarator (li, (Expression) $4);
current_variable.AddDeclarator (d);
current_block.AddLocalName (li);
lbag.AddLocation (d, GetLocation ($1), GetLocation ($3));
@ -5557,7 +5552,6 @@ statement_expression @@ -5557,7 +5552,6 @@ statement_expression
ExpressionStatement s = $1 as ExpressionStatement;
if (s == null) {
var expr = $1 as Expression;
expr.Error_InvalidExpressionStatement (report);
$$ = new StatementErrorExpression (expr);
} else {
$$ = new StatementExpression (s);
@ -5822,10 +5816,10 @@ opt_for_initializer @@ -5822,10 +5816,10 @@ opt_for_initializer
for_initializer
: variable_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var li = new LocalVariable (current_block, lt.Value, lt.Location);
current_block.AddLocalName (li);
current_variable = new BlockVariableDeclaration ((FullNamedExpression) $1, li);
current_variable = new BlockVariable ((FullNamedExpression) $1, li);
}
opt_local_variable_initializer opt_variable_declarators
{
@ -5891,7 +5885,7 @@ foreach_statement @@ -5891,7 +5885,7 @@ foreach_statement
start_block (GetLocation ($2));
current_block.IsCompilerGenerated = true;
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location);
current_block.AddLocalName (li);
@ -5905,7 +5899,8 @@ foreach_statement @@ -5905,7 +5899,8 @@ foreach_statement
{
start_block (GetLocation ($2));
current_block.IsCompilerGenerated = true;
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location);
current_block.AddLocalName (li);
$$ = li;
@ -5925,7 +5920,7 @@ foreach_statement @@ -5925,7 +5920,7 @@ foreach_statement
{
start_block (GetLocation ($2));
current_block.IsCompilerGenerated = true;
var lt = $4 as Tokenizer.LocatedToken;
var lt = $4 as LocatedToken;
var li = lt != null ? new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location) : null;
Foreach f = new Foreach ((Expression) $3, li, null, null, null, GetLocation ($1));
@ -5977,7 +5972,7 @@ continue_statement @@ -5977,7 +5972,7 @@ continue_statement
goto_statement
: GOTO identifier_inside_body SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
$$ = new Goto (lt.Value, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($2), GetLocation ($3));
}
@ -6027,7 +6022,7 @@ throw_statement @@ -6027,7 +6022,7 @@ throw_statement
yield_statement
: identifier_inside_body RETURN opt_expression SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
string s = lt.Value;
if (s != "yield"){
report.Error (1003, lt.Location, "; expected");
@ -6045,7 +6040,7 @@ yield_statement @@ -6045,7 +6040,7 @@ yield_statement
{
Error_SyntaxError (yyToken);
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
string s = lt.Value;
if (s != "yield"){
report.Error (1003, lt.Location, "; expected");
@ -6061,7 +6056,7 @@ yield_statement @@ -6061,7 +6056,7 @@ yield_statement
}
| identifier_inside_body BREAK SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $1;
var lt = (LocatedToken) $1;
string s = lt.Value;
if (s != "yield"){
report.Error (1003, lt.Location, "; expected");
@ -6069,7 +6064,7 @@ yield_statement @@ -6069,7 +6064,7 @@ yield_statement
FeatureIsNotAvailable (lt.Location, "iterators");
}
current_block.Explicit.RegisterIteratorYield ();
current_block.ParametersBlock.TopBlock.IsIterator = true;
$$ = new YieldBreak (lt.Location);
lbag.AddStatement ($$, GetLocation ($2), GetLocation ($3));
}
@ -6141,7 +6136,7 @@ catch_clause @@ -6141,7 +6136,7 @@ catch_clause
c.TypeExpression = (FullNamedExpression) $3;
if ($4 != null) {
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
current_block.AddLocalName (c.Variable);
}
@ -6174,12 +6169,12 @@ catch_clause @@ -6174,12 +6169,12 @@ catch_clause
c.TypeExpression = (FullNamedExpression) $3;
if ($4 != null) {
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
}
if ($4 != null) {
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
}
@ -6237,7 +6232,7 @@ fixed_statement @@ -6237,7 +6232,7 @@ fixed_statement
start_block (GetLocation ($2));
current_block.IsCompilerGenerated = true;
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.FixedVariable | LocalVariable.Flags.Used, lt.Location);
current_block.AddLocalName (li);
current_variable = new Fixed.VariableDeclaration ((FullNamedExpression) $3, li);
@ -6265,7 +6260,7 @@ using_statement @@ -6265,7 +6260,7 @@ using_statement
start_block (GetLocation ($2));
current_block.IsCompilerGenerated = true;
var lt = (Tokenizer.LocatedToken) $4;
var lt = (LocatedToken) $4;
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.UsingVariable | LocalVariable.Flags.Used, lt.Location);
current_block.AddLocalName (li);
current_variable = new Using.VariableDeclaration ((FullNamedExpression) $3, li);
@ -6371,7 +6366,7 @@ first_from_clause @@ -6371,7 +6366,7 @@ first_from_clause
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var rv = new Linq.RangeVariable (lt.Value, lt.Location);
var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1));
lbag.AddLocation (start, GetLocation ($3));
@ -6381,7 +6376,7 @@ first_from_clause @@ -6381,7 +6376,7 @@ first_from_clause
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
var rv = new Linq.RangeVariable (lt.Value, lt.Location);
var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) {
IdentifierType = (FullNamedExpression)$2
@ -6396,7 +6391,7 @@ nested_from_clause @@ -6396,7 +6391,7 @@ nested_from_clause
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var rv = new Linq.RangeVariable (lt.Value, lt.Location);
var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1));
lbag.AddLocation (start, GetLocation ($3));
@ -6406,7 +6401,7 @@ nested_from_clause @@ -6406,7 +6401,7 @@ nested_from_clause
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
var rv = new Linq.RangeVariable (lt.Value, lt.Location);
var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) {
IdentifierType = (FullNamedExpression)$2
@ -6423,7 +6418,7 @@ from_clause @@ -6423,7 +6418,7 @@ from_clause
}
expression_or_error
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.SelectMany ((Linq.QueryBlock)current_block, sn, (Expression)$5, GetLocation ($1));
@ -6439,7 +6434,7 @@ from_clause @@ -6439,7 +6434,7 @@ from_clause
}
expression_or_error
{
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.SelectMany ((Linq.QueryBlock)current_block, sn, (Expression)$6, GetLocation ($1)) {
@ -6571,7 +6566,7 @@ let_clause @@ -6571,7 +6566,7 @@ let_clause
}
expression_or_error
{
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.Let ((Linq.QueryBlock) current_block, sn, (Expression)$5, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($3));
@ -6630,7 +6625,7 @@ join_clause @@ -6630,7 +6625,7 @@ join_clause
var outer_selector = linq_clause_blocks.Pop ();
var block = linq_clause_blocks.Pop ();
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
Linq.RangeVariable into;
@ -6650,7 +6645,7 @@ join_clause @@ -6650,7 +6645,7 @@ join_clause
((Linq.QueryBlock)current_block).AddRangeVariable (sn);
lt = (Tokenizer.LocatedToken) $12;
lt = (LocatedToken) $12;
into = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.GroupJoin (block, sn, (Expression)$5, outer_selector, (Linq.QueryBlock) current_block, into, GetLocation ($1));
@ -6692,7 +6687,7 @@ join_clause @@ -6692,7 +6687,7 @@ join_clause
var outer_selector = linq_clause_blocks.Pop ();
var block = linq_clause_blocks.Pop ();
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
Linq.RangeVariable into;
@ -6714,7 +6709,7 @@ join_clause @@ -6714,7 +6709,7 @@ join_clause
((Linq.QueryBlock)current_block).AddRangeVariable (sn);
lt = (Tokenizer.LocatedToken) $13;
lt = (LocatedToken) $13;
into = new Linq.RangeVariable (lt.Value, lt.Location); // TODO:
$$ = new Linq.GroupJoin (block, sn, (Expression)$6, outer_selector, (Linq.QueryBlock) current_block, into, GetLocation ($1)) {
@ -6840,7 +6835,7 @@ opt_query_continuation @@ -6840,7 +6835,7 @@ opt_query_continuation
query_body
{
var current_block = linq_clause_blocks.Pop ();
var lt = (Tokenizer.LocatedToken) $2;
var lt = (LocatedToken) $2;
var rv = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, null, rv, GetLocation ($1)) {
next = (Linq.AQueryClause)$4
@ -6945,7 +6940,7 @@ doc_cref @@ -6945,7 +6940,7 @@ doc_cref
{
module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)$1;
module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)$4;
var lt = (Tokenizer.LocatedToken) $3;
var lt = (LocatedToken) $3;
$$ = new MemberName (lt.Value);
}
| doc_type_declaration_name DOT THIS
@ -7107,7 +7102,7 @@ object Error_AwaitAsIdentifier (object token) @@ -7107,7 +7102,7 @@ object Error_AwaitAsIdentifier (object token)
{
if (async_block) {
report.Error (4003, GetLocation (token), "`await' cannot be used as an identifier within an async method or lambda expression");
return new Tokenizer.LocatedToken ("await", GetLocation (token));
return new LocatedToken ("await", GetLocation (token));
}
return token;
@ -7301,7 +7296,7 @@ void FeatureIsNotAvailable (Location loc, string feature) @@ -7301,7 +7296,7 @@ void FeatureIsNotAvailable (Location loc, string feature)
Location GetLocation (object obj)
{
var lt = obj as Tokenizer.LocatedToken;
var lt = obj as LocatedToken;
if (lt != null)
return lt.Location;
@ -7379,7 +7374,7 @@ AnonymousMethodExpression end_anonymous (ParametersBlock anon_block) @@ -7379,7 +7374,7 @@ AnonymousMethodExpression end_anonymous (ParametersBlock anon_block)
retval = current_anonymous_method;
async_block = (bool) oob_stack.Pop ();
current_variable = (BlockVariableDeclaration) oob_stack.Pop ();
current_variable = (BlockVariable) oob_stack.Pop ();
current_local_parameters = (ParametersCompiled) oob_stack.Pop ();
current_anonymous_method = (AnonymousMethodExpression) oob_stack.Pop ();
@ -7488,7 +7483,7 @@ string GetSymbolName (int token) @@ -7488,7 +7483,7 @@ string GetSymbolName (int token)
case Token.LITERAL:
return ((Constant)lexer.Value).GetValue ().ToString ();
case Token.IDENTIFIER:
return ((Tokenizer.LocatedToken)lexer.Value).Value;
return ((LocatedToken)lexer.Value).Value;
case Token.BOOL:
return "bool";

74
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs

@ -20,6 +20,44 @@ using System.Collections; @@ -20,6 +20,44 @@ using System.Collections;
namespace Mono.CSharp
{
//
// This class has to be used by parser only, it reuses token
// details once a file is parsed
//
public class LocatedToken
{
public int row, column;
public string value;
public SourceFile file;
public LocatedToken ()
{
}
public LocatedToken (string value, Location loc)
{
this.value = value;
file = loc.SourceFile;
row = loc.Row;
column = loc.Column;
}
public override string ToString ()
{
return string.Format ("Token '{0}' at {1},{2}", Value, row, column);
}
public Location Location
{
get { return new Location (file, row, column); }
}
public string Value
{
get { return value; }
}
}
/// <summary>
/// Tokenizer for C# source code.
/// </summary>
@ -66,42 +104,6 @@ namespace Mono.CSharp @@ -66,42 +104,6 @@ namespace Mono.CSharp
}
}
//
// This class has to be used by parser only, it reuses token
// details after each file parse completion
//
public class LocatedToken
{
public int row, column;
public string value;
public SourceFile file;
public LocatedToken ()
{
}
public LocatedToken (string value, Location loc)
{
this.value = value;
file = loc.SourceFile;
row = loc.Row;
column = loc.Column;
}
public override string ToString ()
{
return string.Format ("Token '{0}' at {1},{2}", Value, row, column);
}
public Location Location {
get { return new Location (file, row, column); }
}
public string Value {
get { return value; }
}
}
public class LocatedTokenBuffer
{
readonly LocatedToken[] buffer;

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

@ -53,12 +53,6 @@ namespace Mono.CSharp { @@ -53,12 +53,6 @@ namespace Mono.CSharp {
: this (name, Location.Null)
{ }
#if FULL_AST
public Location DotLocation {
get;
set;
}
#endif
public MemberName (string name, Location loc)
: this (null, name, loc)
{ }
@ -1281,6 +1275,11 @@ namespace Mono.CSharp { @@ -1281,6 +1275,11 @@ namespace Mono.CSharp {
void SetIsUsed ();
}
public interface IMethodDefinition : IMemberDefinition
{
MethodBase Metadata { get; }
}
public interface IParametersMember : IInterfaceMemberSpec
{
AParametersCollection Parameters { get; }

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

@ -153,7 +153,7 @@ namespace Mono.CSharp { @@ -153,7 +153,7 @@ namespace Mono.CSharp {
Report.SymbolRelatedToPreviousError (partype);
Report.Error (59, Location,
"Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'",
TypeManager.CSharpName (partype), GetSignatureForError ());
partype.GetSignatureForError (), GetSignatureForError ());
}
}
@ -169,7 +169,7 @@ namespace Mono.CSharp { @@ -169,7 +169,7 @@ namespace Mono.CSharp {
Report.SymbolRelatedToPreviousError (ret_type);
Report.Error (58, Location,
"Inconsistent accessibility: return type `" +
TypeManager.CSharpName (ret_type) + "' is less " +
ret_type.GetSignatureForError () + "' is less " +
"accessible than delegate `" + GetSignatureForError () + "'");
return false;
}
@ -297,6 +297,12 @@ namespace Mono.CSharp { @@ -297,6 +297,12 @@ namespace Mono.CSharp {
if (!Parameters.IsEmpty) {
parameters.ResolveDefaultValues (this);
}
InvokeBuilder.PrepareEmit ();
if (BeginInvokeBuilder != null) {
BeginInvokeBuilder.PrepareEmit ();
EndInvokeBuilder.PrepareEmit ();
}
}
public override void Emit ()
@ -522,7 +528,7 @@ namespace Mono.CSharp { @@ -522,7 +528,7 @@ namespace Mono.CSharp {
TypeSpec e_type = emg.ExtensionExpression.Type;
if (TypeSpec.IsValueType (e_type)) {
ec.Report.Error (1113, loc, "Extension method `{0}' of value type `{1}' cannot be used to create delegates",
delegate_method.GetSignatureForError (), TypeManager.CSharpName (e_type));
delegate_method.GetSignatureForError (), e_type.GetSignatureForError ());
}
}
@ -586,8 +592,8 @@ namespace Mono.CSharp { @@ -586,8 +592,8 @@ namespace Mono.CSharp {
ec.Report.SymbolRelatedToPreviousError (method);
if (ec.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) {
ec.Report.Error (410, loc, "A method or delegate `{0} {1}' parameters and return type must be same as delegate `{2} {3}' parameters and return type",
TypeManager.CSharpName (method.ReturnType), member_name,
TypeManager.CSharpName (invoke_method.ReturnType), Delegate.FullDelegateDesc (invoke_method));
method.ReturnType.GetSignatureForError (), member_name,
invoke_method.ReturnType.GetSignatureForError (), Delegate.FullDelegateDesc (invoke_method));
return;
}
@ -599,7 +605,7 @@ namespace Mono.CSharp { @@ -599,7 +605,7 @@ namespace Mono.CSharp {
ec.Report.Error (407, loc, "A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' return type",
return_type.GetSignatureForError (), member_name,
TypeManager.CSharpName (invoke_method.ReturnType), Delegate.FullDelegateDesc (invoke_method));
invoke_method.ReturnType.GetSignatureForError (), Delegate.FullDelegateDesc (invoke_method));
}
public static bool ImplicitStandardConversionExists (ResolveContext ec, MethodGroupExpr mg, TypeSpec target_type)

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

@ -80,7 +80,7 @@ namespace Mono.CSharp @@ -80,7 +80,7 @@ namespace Mono.CSharp
var session = new ParserSession () {
UseJayGlobalArrays = true,
LocatedTokens = new Tokenizer.LocatedToken[15000]
LocatedTokens = new LocatedToken[15000]
};
for (int i = 0; i < sources.Count; ++i) {

1
ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs

@ -447,6 +447,7 @@ namespace Mono.CSharp @@ -447,6 +447,7 @@ namespace Mono.CSharp
d.CreateContainer ();
d.DefineContainer ();
d.Define ();
d.PrepareEmit ();
site.AddTypeContainer (d);
del_type = new TypeExpression (d.CurrentType, loc);

50
ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs

@ -251,7 +251,7 @@ namespace Mono.CSharp { @@ -251,7 +251,7 @@ namespace Mono.CSharp {
public void Error_ConstantCanBeInitializedWithNullOnly (ResolveContext rc, TypeSpec type, Location loc, string name)
{
rc.Report.Error (134, loc, "A constant `{0}' of reference type `{1}' can only be initialized with null",
name, TypeManager.CSharpName (type));
name, type.GetSignatureForError ());
}
protected virtual void Error_InvalidExpressionStatement (Report report, Location loc)
@ -282,7 +282,10 @@ namespace Mono.CSharp { @@ -282,7 +282,10 @@ namespace Mono.CSharp {
protected void Error_ValueCannotBeConvertedCore (ResolveContext ec, Location loc, TypeSpec target, bool expl)
{
// The error was already reported as CS1660
if (type == InternalType.AnonymousMethod || type == InternalType.ErrorType)
if (type == InternalType.AnonymousMethod)
return;
if (type == InternalType.ErrorType || target == InternalType.ErrorType)
return;
string from_type = type.GetSignatureForError ();
@ -351,13 +354,15 @@ namespace Mono.CSharp { @@ -351,13 +354,15 @@ namespace Mono.CSharp {
{
ec.Report.SymbolRelatedToPreviousError (type);
ec.Report.Error (117, loc, "`{0}' does not contain a definition for `{1}'",
TypeManager.CSharpName (type), name);
type.GetSignatureForError (), name);
}
public virtual void Error_ValueAssignment (ResolveContext rc, Expression rhs)
{
if (rhs == EmptyExpression.LValueMemberAccess || rhs == EmptyExpression.LValueMemberOutAccess) {
// Already reported as CS1612
} else if (rhs == EmptyExpression.OutAccess) {
rc.Report.Error (1510, loc, "A ref or out argument must be an assignable variable");
} else {
rc.Report.Error (131, loc, "The left-hand side of an assignment must be a variable, a property or an indexer");
}
@ -492,10 +497,7 @@ namespace Mono.CSharp { @@ -492,10 +497,7 @@ namespace Mono.CSharp {
if (e == null) {
if (errors == ec.Report.Errors) {
if (out_access)
ec.Report.Error (1510, loc, "A ref or out argument must be an assignable variable");
else
Error_ValueAssignment (ec, right_side);
Error_ValueAssignment (ec, right_side);
}
return null;
}
@ -1475,7 +1477,7 @@ namespace Mono.CSharp { @@ -1475,7 +1477,7 @@ namespace Mono.CSharp {
public override string GetSignatureForError()
{
return TypeManager.CSharpName (Type);
return Type.GetSignatureForError ();
}
public override object GetValue ()
@ -1534,7 +1536,7 @@ namespace Mono.CSharp { @@ -1534,7 +1536,7 @@ namespace Mono.CSharp {
}
}
public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type)
public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type)
{
if (Child.Type == target_type)
return Child;
@ -2418,15 +2420,15 @@ namespace Mono.CSharp { @@ -2418,15 +2420,15 @@ namespace Mono.CSharp {
}
}
public override FullNamedExpression ResolveAsTypeOrNamespace (IMemberContext ec)
public override FullNamedExpression ResolveAsTypeOrNamespace (IMemberContext mc)
{
FullNamedExpression fne = ec.LookupNamespaceOrType (Name, Arity, LookupMode.Normal, loc);
FullNamedExpression fne = mc.LookupNamespaceOrType (Name, Arity, LookupMode.Normal, loc);
if (fne != null) {
if (fne.Type != null && Arity > 0) {
if (HasTypeArguments) {
GenericTypeExpr ct = new GenericTypeExpr (fne.Type, targs, loc);
if (ct.ResolveAsType (ec) == null)
if (ct.ResolveAsType (mc) == null)
return null;
return ct;
@ -2442,21 +2444,21 @@ namespace Mono.CSharp { @@ -2442,21 +2444,21 @@ namespace Mono.CSharp {
return fne;
}
if (Arity == 0 && Name == "dynamic" && ec.Module.Compiler.Settings.Version > LanguageVersion.V_3) {
if (!ec.Module.PredefinedAttributes.Dynamic.IsDefined) {
ec.Module.Compiler.Report.Error (1980, Location,
if (Arity == 0 && Name == "dynamic" && mc.Module.Compiler.Settings.Version > LanguageVersion.V_3) {
if (!mc.Module.PredefinedAttributes.Dynamic.IsDefined) {
mc.Module.Compiler.Report.Error (1980, Location,
"Dynamic keyword requires `{0}' to be defined. Are you missing System.Core.dll assembly reference?",
ec.Module.PredefinedAttributes.Dynamic.GetSignatureForError ());
mc.Module.PredefinedAttributes.Dynamic.GetSignatureForError ());
}
fne = new DynamicTypeExpr (loc);
fne.ResolveAsType (ec);
fne.ResolveAsType (mc);
}
if (fne != null)
return fne;
Error_TypeOrNamespaceNotFound (ec);
Error_TypeOrNamespaceNotFound (mc);
return null;
}
@ -3297,8 +3299,12 @@ namespace Mono.CSharp { @@ -3297,8 +3299,12 @@ namespace Mono.CSharp {
if (ExtensionExpression == null)
return null;
var cand = candidates;
arguments.Insert (0, new Argument (ExtensionExpression, Argument.AType.ExtensionType));
var res = base.OverloadResolve (ec, ref arguments, ehandler ?? this, restr);
// Restore candidates in case we are running in probing mode
candidates = cand;
// Store resolved argument and restore original arguments
if (res == null) {
@ -3508,7 +3514,7 @@ namespace Mono.CSharp { @@ -3508,7 +3514,7 @@ namespace Mono.CSharp {
public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl)
{
ec.Report.Error (428, loc, "Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using parentheses to invoke the method",
Name, TypeManager.CSharpName (target));
Name, target.GetSignatureForError ());
}
public static bool IsExtensionMethodArgument (Expression expr)
@ -5050,14 +5056,14 @@ namespace Mono.CSharp { @@ -5050,14 +5056,14 @@ namespace Mono.CSharp {
string index = (idx + 1).ToString ();
if (((mod & Parameter.Modifier.RefOutMask) ^ (a.Modifier & Parameter.Modifier.RefOutMask)) != 0) {
if ((mod & Parameter.Modifier.RefOutMask) == 0)
ec.Report.Error (1615, loc, "Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' modifier",
ec.Report.Error (1615, a.Expr.Location, "Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' modifier",
index, Parameter.GetModifierSignature (a.Modifier));
else
ec.Report.Error (1620, loc, "Argument `#{0}' is missing `{1}' modifier",
ec.Report.Error (1620, a.Expr.Location, "Argument `#{0}' is missing `{1}' modifier",
index, Parameter.GetModifierSignature (mod));
} else {
string p1 = a.GetSignatureForError ();
string p2 = TypeManager.CSharpName (paramType);
string p2 = paramType.GetSignatureForError ();
if (p1 == p2) {
p1 = a.Type.GetSignatureForErrorIncludingAssemblyName ();

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

@ -269,7 +269,7 @@ namespace Mono.CSharp { @@ -269,7 +269,7 @@ namespace Mono.CSharp {
case BuiltinTypeSpec.Type.ULong:
case BuiltinTypeSpec.Type.UShort:
Report.Warning (3009, 1, Location, "`{0}': base type `{1}' is not CLS-compliant",
GetSignatureForError (), TypeManager.CSharpName (UnderlyingType));
GetSignatureForError (), UnderlyingType.GetSignatureForError ());
break;
}

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

@ -652,7 +652,7 @@ namespace Mono.CSharp @@ -652,7 +652,7 @@ namespace Mono.CSharp
new TypeExpression (base_class_imported, host.Location)
};
host.AddBasesForPart (baseclass_list);
host.SetBaseTypes (baseclass_list);
host.CreateContainer ();
host.DefineContainer ();
@ -679,6 +679,7 @@ namespace Mono.CSharp @@ -679,6 +679,7 @@ namespace Mono.CSharp
}
if (host != null){
host.PrepareEmit ();
host.EmitContainer ();
}

65
ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs

@ -1437,10 +1437,10 @@ namespace Mono.CSharp @@ -1437,10 +1437,10 @@ namespace Mono.CSharp
{
if (result)
ec.Report.Warning (183, 1, loc, "The given expression is always of the provided (`{0}') type",
TypeManager.CSharpName (probe_type_expr));
probe_type_expr.GetSignatureForError ());
else
ec.Report.Warning (184, 1, loc, "The given expression is never of the provided (`{0}') type",
TypeManager.CSharpName (probe_type_expr));
probe_type_expr.GetSignatureForError ());
return ReducedExpression.Create (new BoolConstant (ec.BuiltinTypes, result, loc), this);
}
@ -1630,7 +1630,7 @@ namespace Mono.CSharp @@ -1630,7 +1630,7 @@ namespace Mono.CSharp
} else {
ec.Report.Error (77, loc,
"The `as' operator cannot be used with a non-nullable value type `{0}'",
TypeManager.CSharpName (type));
type.GetSignatureForError ());
}
return null;
}
@ -1663,7 +1663,7 @@ namespace Mono.CSharp @@ -1663,7 +1663,7 @@ namespace Mono.CSharp
}
ec.Report.Error (39, loc, "Cannot convert type `{0}' to `{1}' via a built-in conversion",
TypeManager.CSharpName (etype), TypeManager.CSharpName (type));
etype.GetSignatureForError (), type.GetSignatureForError ());
return null;
}
@ -1702,7 +1702,7 @@ namespace Mono.CSharp @@ -1702,7 +1702,7 @@ namespace Mono.CSharp
return null;
if (type.IsStatic) {
ec.Report.Error (716, loc, "Cannot convert to static type `{0}'", TypeManager.CSharpName (type));
ec.Report.Error (716, loc, "Cannot convert to static type `{0}'", type.GetSignatureForError ());
return null;
}
@ -2255,6 +2255,12 @@ namespace Mono.CSharp @@ -2255,6 +2255,12 @@ namespace Mono.CSharp
}
}
public override Location StartLocation {
get {
return left.StartLocation;
}
}
#endregion
/// <summary>
@ -2340,8 +2346,8 @@ namespace Mono.CSharp @@ -2340,8 +2346,8 @@ namespace Mono.CSharp
return;
string l, r;
l = TypeManager.CSharpName (left.Type);
r = TypeManager.CSharpName (right.Type);
l = left.Type.GetSignatureForError ();
r = right.Type.GetSignatureForError ();
ec.Report.Error (19, loc, "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'",
oper, l, r);
@ -2716,9 +2722,10 @@ namespace Mono.CSharp @@ -2716,9 +2722,10 @@ namespace Mono.CSharp
// FIXME: consider constants
var ltype = lcast != null ? lcast.UnderlyingType : rcast.UnderlyingType;
ec.Report.Warning (675, 3, loc,
"The operator `|' used on the sign-extended type `{0}'. Consider casting to a smaller unsigned type first",
TypeManager.CSharpName (lcast != null ? lcast.UnderlyingType : rcast.UnderlyingType));
ltype.GetSignatureForError ());
}
public static PredefinedOperator[] CreatePointerOperatorsTable (BuiltinTypes types)
@ -2931,7 +2938,7 @@ namespace Mono.CSharp @@ -2931,7 +2938,7 @@ namespace Mono.CSharp
// FIXME: resolve right expression as unreachable
// right.Resolve (ec);
ec.Report.Warning (429, 4, loc, "Unreachable expression code detected");
ec.Report.Warning (429, 4, right.StartLocation, "Unreachable expression code detected");
return left;
}
@ -3557,7 +3564,7 @@ namespace Mono.CSharp @@ -3557,7 +3564,7 @@ namespace Mono.CSharp
if (best_operator == null) {
ec.Report.Error (34, loc, "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'",
OperName (oper), TypeManager.CSharpName (l), TypeManager.CSharpName (r));
OperName (oper), l.GetSignatureForError (), r.GetSignatureForError ());
best_operator = po;
break;
@ -3713,7 +3720,7 @@ namespace Mono.CSharp @@ -3713,7 +3720,7 @@ namespace Mono.CSharp
} catch (OverflowException) {
ec.Report.Warning (652, 2, loc,
"A comparison between a constant and a variable is useless. The constant is out of the range of the variable type `{0}'",
TypeManager.CSharpName (type));
type.GetSignatureForError ());
}
}
}
@ -4273,7 +4280,7 @@ namespace Mono.CSharp @@ -4273,7 +4280,7 @@ namespace Mono.CSharp
if (op_true == null || op_false == null) {
ec.Report.Error (218, loc,
"The type `{0}' must have operator `true' and operator `false' defined when `{1}' is used as a short circuit operator",
TypeManager.CSharpName (type), oper.GetSignatureForError ());
type.GetSignatureForError (), oper.GetSignatureForError ());
return null;
}
@ -4684,7 +4691,7 @@ namespace Mono.CSharp @@ -4684,7 +4691,7 @@ namespace Mono.CSharp
} else {
ec.Report.Error (173, true_expr.Location,
"Type of conditional expression cannot be determined because there is no implicit conversion between `{0}' and `{1}'",
TypeManager.CSharpName (true_type), TypeManager.CSharpName (false_type));
true_type.GetSignatureForError (), false_type.GetSignatureForError ());
return null;
}
}
@ -5194,6 +5201,9 @@ namespace Mono.CSharp @@ -5194,6 +5201,9 @@ namespace Mono.CSharp
void SetAssigned (ResolveContext ec)
{
if (Parameter.HoistedVariant != null)
Parameter.HoistedVariant.IsAssigned = true;
if (HasOutModifier && ec.DoFlowAnalysis)
ec.CurrentBranching.SetAssigned (VariableInfo);
}
@ -5777,7 +5787,7 @@ namespace Mono.CSharp @@ -5777,7 +5787,7 @@ namespace Mono.CSharp
if (type.IsPointer) {
ec.Report.Error (1919, loc, "Unsafe type `{0}' cannot be used in an object creation expression",
TypeManager.CSharpName (type));
type.GetSignatureForError ());
return null;
}
@ -5800,13 +5810,13 @@ namespace Mono.CSharp @@ -5800,13 +5810,13 @@ namespace Mono.CSharp
if ((tparam.SpecialConstraint & (SpecialConstraint.Struct | SpecialConstraint.Constructor)) == 0 && !TypeSpec.IsValueType (tparam)) {
ec.Report.Error (304, loc,
"Cannot create an instance of the variable type `{0}' because it does not have the new() constraint",
TypeManager.CSharpName (type));
type.GetSignatureForError ());
}
if ((arguments != null) && (arguments.Count != 0)) {
ec.Report.Error (417, loc,
"`{0}': cannot provide arguments when creating an instance of a variable type",
TypeManager.CSharpName (type));
type.GetSignatureForError ());
}
return this;
@ -5814,7 +5824,7 @@ namespace Mono.CSharp @@ -5814,7 +5824,7 @@ namespace Mono.CSharp
if (type.IsStatic) {
ec.Report.SymbolRelatedToPreviousError (type);
ec.Report.Error (712, loc, "Cannot create an instance of the static class `{0}'", TypeManager.CSharpName (type));
ec.Report.Error (712, loc, "Cannot create an instance of the static class `{0}'", type.GetSignatureForError ());
return null;
}
@ -5826,7 +5836,7 @@ namespace Mono.CSharp @@ -5826,7 +5836,7 @@ namespace Mono.CSharp
}
ec.Report.SymbolRelatedToPreviousError (type);
ec.Report.Error (144, loc, "Cannot create an instance of the abstract class or interface `{0}'", TypeManager.CSharpName (type));
ec.Report.Error (144, loc, "Cannot create an instance of the abstract class or interface `{0}'", type.GetSignatureForError ());
return null;
}
@ -6048,7 +6058,7 @@ namespace Mono.CSharp @@ -6048,7 +6058,7 @@ namespace Mono.CSharp
public class ArrayInitializer : Expression
{
List<Expression> elements;
BlockVariableDeclaration variable;
BlockVariable variable;
public ArrayInitializer (List<Expression> init, Location loc)
{
@ -6084,7 +6094,7 @@ namespace Mono.CSharp @@ -6084,7 +6094,7 @@ namespace Mono.CSharp
}
}
public BlockVariableDeclaration VariableDeclaration {
public BlockVariable VariableDeclaration {
get {
return variable;
}
@ -7823,7 +7833,7 @@ namespace Mono.CSharp @@ -7823,7 +7833,7 @@ namespace Mono.CSharp
if (!ec.IsUnsafe) {
ec.Report.Error (233, loc,
"`{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)",
TypeManager.CSharpName (type_queried));
type_queried.GetSignatureForError ());
}
type = ec.BuiltinTypes.Int;
@ -7941,13 +7951,6 @@ namespace Mono.CSharp @@ -7941,13 +7951,6 @@ namespace Mono.CSharp
public class MemberAccess : ATypeNameExpression
{
protected Expression expr;
#if FULL_AST
public Location DotLocation {
get;
set;
}
#endif
public MemberAccess (Expression expr, string id)
: base (id, expr.Location)
@ -10139,8 +10142,8 @@ namespace Mono.CSharp @@ -10139,8 +10142,8 @@ namespace Mono.CSharp
ec.Report.Error (1922, loc, "A field or property `{0}' cannot be initialized with a collection " +
"object initializer because type `{1}' does not implement `{2}' interface",
ec.CurrentInitializerVariable.GetSignatureForError (),
TypeManager.CSharpName (ec.CurrentInitializerVariable.Type),
TypeManager.CSharpName (ec.BuiltinTypes.IEnumerable));
ec.CurrentInitializerVariable.Type.GetSignatureForError (),
ec.BuiltinTypes.IEnumerable.GetSignatureForError ());
return null;
}
is_collection_initialization = true;
@ -10174,7 +10177,7 @@ namespace Mono.CSharp @@ -10174,7 +10177,7 @@ namespace Mono.CSharp
if (is_collection_initialization) {
if (TypeManager.HasElementType (type)) {
ec.Report.Error (1925, loc, "Cannot initialize object of type `{0}' with a collection initializer",
TypeManager.CSharpName (type));
type.GetSignatureForError ());
}
}

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

@ -42,6 +42,11 @@ namespace Mono.CSharp @@ -42,6 +42,11 @@ namespace Mono.CSharp
public Expression Initializer { get; private set; }
#endregion
public virtual FullNamedExpression GetFieldTypeExpression (FieldBase field)
{
return new TypeExpression (field.MemberType, Name.Location);
}
}
//
@ -407,9 +412,8 @@ namespace Mono.CSharp @@ -407,9 +412,8 @@ namespace Mono.CSharp
"`{0}': Fixed size buffers type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double",
GetSignatureForError ());
} else if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
foreach (var d in declarators) {
var f = new FixedField (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
var f = new FixedField (Parent, d.GetFieldTypeExpression (this), ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
f.initializer = d.Initializer;
((ConstInitializer) f.initializer).Name = d.Name.Value;
f.Define ();
@ -486,7 +490,7 @@ namespace Mono.CSharp @@ -486,7 +490,7 @@ namespace Mono.CSharp
if (buffer_size > int.MaxValue / type_size) {
Report.Error (1664, Location, "Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit",
GetSignatureForError (), buffer_size.ToString (), TypeManager.CSharpName (MemberType));
GetSignatureForError (), buffer_size.ToString (), MemberType.GetSignatureForError ());
return;
}
@ -645,8 +649,7 @@ namespace Mono.CSharp @@ -645,8 +649,7 @@ namespace Mono.CSharp
if (declarators != null) {
foreach (var d in declarators) {
var t = new TypeExpression (MemberType, d.Name.Location);
var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
var f = new Field (Parent, d.GetFieldTypeExpression (this), ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
if (d.Initializer != null)
f.initializer = d.Initializer;
@ -668,7 +671,7 @@ namespace Mono.CSharp @@ -668,7 +671,7 @@ namespace Mono.CSharp
if ((ModFlags & Modifiers.VOLATILE) != 0) {
if (!CanBeVolatile ()) {
Report.Error (677, Location, "`{0}': A volatile field cannot be of the type `{1}'",
GetSignatureForError (), TypeManager.CSharpName (MemberType));
GetSignatureForError (), MemberType.GetSignatureForError ());
}
if ((ModFlags & Modifiers.READONLY) != 0) {

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

@ -318,7 +318,7 @@ namespace Mono.CSharp { @@ -318,7 +318,7 @@ namespace Mono.CSharp {
if (type.IsSealed || !type.IsClass) {
context.Module.Compiler.Report.Error (701, loc,
"`{0}' is not a valid constraint. A constraint must be an interface, a non-sealed class or a type parameter",
TypeManager.CSharpName (type));
type.GetSignatureForError ());
continue;
}
@ -495,7 +495,7 @@ namespace Mono.CSharp { @@ -495,7 +495,7 @@ namespace Mono.CSharp {
//
// If partial type parameters constraints are not null and we don't
// already have constraints they become our constraints. If we already
// have constraints, we must check that they're the same.
// have constraints, we must check that they're same.
//
public bool AddPartialConstraints (TypeDefinition part, TypeParameter tp)
{
@ -551,15 +551,19 @@ namespace Mono.CSharp { @@ -551,15 +551,19 @@ namespace Mono.CSharp {
// with SRE (by calling `DefineGenericParameters()' on the TypeBuilder /
// MethodBuilder).
//
public void Define (GenericTypeParameterBuilder type, TypeSpec declaringType, TypeContainer parent)
public void Create (TypeSpec declaringType, TypeContainer parent)
{
if (builder != null)
throw new InternalErrorException ();
// Needed to get compiler reference
this.Parent = parent;
this.builder = type;
spec.DeclaringType = declaringType;
}
public void Define (GenericTypeParameterBuilder type)
{
this.builder = type;
spec.SetMetaInfo (type);
}
@ -1382,6 +1386,9 @@ namespace Mono.CSharp { @@ -1382,6 +1386,9 @@ namespace Mono.CSharp {
return ac;
}
if (type.Kind == MemberKind.MissingType)
return type;
//
// When inflating a nested type, inflate its parent first
// in case it's using same type parameters (was inflated within the type)
@ -2185,13 +2192,13 @@ namespace Mono.CSharp { @@ -2185,13 +2192,13 @@ namespace Mono.CSharp {
names.AddRange (tparams.names);
}
public void Define (GenericTypeParameterBuilder[] buiders, TypeSpec declaringType, int parentOffset, TypeContainer parent)
public void Create (TypeSpec declaringType, int parentOffset, TypeContainer parent)
{
types = new TypeParameterSpec[Count];
for (int i = 0; i < types.Length; ++i) {
var tp = names[i];
tp.Define (buiders[i + parentOffset], declaringType, parent);
tp.Create (declaringType, parent);
types[i] = tp.Type;
types[i].DeclaredPosition = i + parentOffset;
@ -2201,6 +2208,14 @@ namespace Mono.CSharp { @@ -2201,6 +2208,14 @@ namespace Mono.CSharp {
}
}
public void Define (GenericTypeParameterBuilder[] builders)
{
for (int i = 0; i < types.Length; ++i) {
var tp = names[i];
tp.Define (builders [types [i].DeclaredPosition]);
}
}
public TypeParameter this[int index] {
get {
return names [index];
@ -2240,6 +2255,44 @@ namespace Mono.CSharp { @@ -2240,6 +2255,44 @@ namespace Mono.CSharp {
return sb.ToString ();
}
public void CheckPartialConstraints (Method part)
{
var partTypeParameters = part.CurrentTypeParameters;
for (int i = 0; i < Count; i++) {
var tp_a = names[i];
var tp_b = partTypeParameters [i];
if (tp_a.Constraints == null) {
if (tp_b.Constraints == null)
continue;
} else if (tp_b.Constraints != null && tp_a.Type.HasSameConstraintsDefinition (tp_b.Type)) {
continue;
}
part.Compiler.Report.SymbolRelatedToPreviousError (this[i].CurrentMemberDefinition.Location, "");
part.Compiler.Report.Error (761, part.Location,
"Partial method declarations of `{0}' have inconsistent constraints for type parameter `{1}'",
part.GetSignatureForError (), partTypeParameters[i].GetSignatureForError ());
}
}
public void UpdateConstraints (TypeDefinition part)
{
var partTypeParameters = part.MemberName.TypeParameters;
for (int i = 0; i < Count; i++) {
var tp = names [i];
if (tp.AddPartialConstraints (part, partTypeParameters [i]))
continue;
part.Compiler.Report.SymbolRelatedToPreviousError (this[i].CurrentMemberDefinition);
part.Compiler.Report.Error (265, part.Location,
"Partial declarations of `{0}' have inconsistent constraints for type parameter `{1}'",
part.GetSignatureForError (), tp.GetSignatureForError ());
}
}
public void VerifyClsCompliance ()
{
foreach (var tp in names) {
@ -2270,7 +2323,7 @@ namespace Mono.CSharp { @@ -2270,7 +2323,7 @@ namespace Mono.CSharp {
public override string GetSignatureForError ()
{
return TypeManager.CSharpName (type);
return type.GetSignatureForError ();
}
public override TypeSpec ResolveAsType (IMemberContext mc)
@ -2418,7 +2471,7 @@ namespace Mono.CSharp { @@ -2418,7 +2471,7 @@ namespace Mono.CSharp {
if (mc != null) {
mc.Module.Compiler.Report.Error (452, loc,
"The type `{0}' must be a reference type in order to use it as type parameter `{1}' in the generic type or method `{2}'",
TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ());
atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError ());
}
return false;
@ -2428,7 +2481,7 @@ namespace Mono.CSharp { @@ -2428,7 +2481,7 @@ namespace Mono.CSharp {
if (mc != null) {
mc.Module.Compiler.Report.Error (453, loc,
"The type `{0}' must be a non-nullable value type in order to use it as type parameter `{1}' in the generic type or method `{2}'",
TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ());
atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError ());
}
return false;
@ -2489,7 +2542,7 @@ namespace Mono.CSharp { @@ -2489,7 +2542,7 @@ namespace Mono.CSharp {
mc.Module.Compiler.Report.SymbolRelatedToPreviousError (atype);
mc.Module.Compiler.Report.Error (310, loc,
"The type `{0}' must have a public parameterless constructor in order to use it as parameter `{1}' in the generic type or method `{2}'",
TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ());
atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError ());
}
return false;
}

39
ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs

@ -420,7 +420,7 @@ namespace Mono.CSharp @@ -420,7 +420,7 @@ namespace Mono.CSharp
}
}
IMemberDefinition definition;
IMethodDefinition definition;
if (tparams != null) {
var gmd = new ImportedGenericMethodDefinition ((MethodInfo) mb, returnType, parameters, tparams, this);
foreach (var tp in gmd.TypeParameters) {
@ -429,10 +429,10 @@ namespace Mono.CSharp @@ -429,10 +429,10 @@ namespace Mono.CSharp
definition = gmd;
} else {
definition = new ImportedParameterMemberDefinition (mb, returnType, parameters, this);
definition = new ImportedMethodDefinition (mb, returnType, parameters, this);
}
MethodSpec ms = new MethodSpec (kind, declaringType, definition, returnType, mb, parameters, mod);
MethodSpec ms = new MethodSpec (kind, declaringType, definition, returnType, parameters, mod);
if (tparams != null)
ms.IsGeneric = true;
@ -1683,7 +1683,7 @@ namespace Mono.CSharp @@ -1683,7 +1683,7 @@ namespace Mono.CSharp
{
readonly AParametersCollection parameters;
public ImportedParameterMemberDefinition (MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer)
protected ImportedParameterMemberDefinition (MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer)
: base (provider, type, importer)
{
this.parameters = parameters;
@ -1706,7 +1706,21 @@ namespace Mono.CSharp @@ -1706,7 +1706,21 @@ namespace Mono.CSharp
#endregion
}
class ImportedGenericMethodDefinition : ImportedParameterMemberDefinition, IGenericMethodDefinition
class ImportedMethodDefinition : ImportedParameterMemberDefinition, IMethodDefinition
{
public ImportedMethodDefinition (MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer)
: base (provider, type, parameters, importer)
{
}
MethodBase IMethodDefinition.Metadata {
get {
return (MethodBase) provider;
}
}
}
class ImportedGenericMethodDefinition : ImportedMethodDefinition, IGenericMethodDefinition
{
readonly TypeParameterSpec[] tparams;
@ -1877,33 +1891,36 @@ namespace Mono.CSharp @@ -1877,33 +1891,36 @@ namespace Mono.CSharp
// or referenced from the user core in which case compilation error has to
// be reported because compiler cannot continue anyway
//
var report = ctx.Module.Compiler.Report;
for (int i = 0; i < types.Count; ++i) {
var t = types [i];
//
// Report missing types only once per type
// Report missing types only once
//
if (i > 0 && types.IndexOf (t) < i)
if (report.Printer.MissingTypeReported (t.MemberDefinition))
continue;
string name = t.GetSignatureForError ();
if (t.MemberDefinition.DeclaringAssembly == ctx.Module.DeclaringAssembly) {
ctx.Module.Compiler.Report.Error (1683, loc,
report.Error (1683, loc,
"Reference to type `{0}' claims it is defined in this assembly, but it is not defined in source or any added modules",
name);
} else if (t.MemberDefinition.DeclaringAssembly.IsMissing) {
if (t.MemberDefinition.IsTypeForwarder) {
ctx.Module.Compiler.Report.Error (1070, loc,
report.Error (1070, loc,
"The type `{0}' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `{1}'",
name, t.MemberDefinition.DeclaringAssembly.FullName);
} else {
ctx.Module.Compiler.Report.Error (12, loc,
report.Error (12, loc,
"The type `{0}' is defined in an assembly that is not referenced. Consider adding a reference to assembly `{1}'",
name, t.MemberDefinition.DeclaringAssembly.FullName);
}
} else {
ctx.Module.Compiler.Report.Error (1684, loc,
report.Error (1684, loc,
"Reference to type `{0}' claims it is defined assembly `{1}', but it could not be found",
name, t.MemberDefinition.DeclaringAssembly.FullName);
}

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

@ -245,7 +245,7 @@ namespace Mono.CSharp @@ -245,7 +245,7 @@ namespace Mono.CSharp
for (int i = 0; i < host.hoisted_params.Count; ++i) {
HoistedParameter hp = host.hoisted_params [i];
HoistedParameter hp_cp = host.hoisted_params_copy [i];
HoistedParameter hp_cp = host.hoisted_params_copy [i] ?? hp;
FieldExpr from = new FieldExpr (hp_cp.Field, loc);
from.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc);
@ -431,6 +431,13 @@ namespace Mono.CSharp @@ -431,6 +431,13 @@ namespace Mono.CSharp
get { return hoisted_params; }
}
protected override Constructor DefineDefaultConstructor (bool is_static)
{
var ctor = base.DefineDefaultConstructor (is_static);
ctor.ModFlags |= Modifiers.DEBUGGER_HIDDEN;
return ctor;
}
protected override TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class)
{
var mtype = Iterator.OriginalIteratorType;
@ -469,17 +476,26 @@ namespace Mono.CSharp @@ -469,17 +476,26 @@ namespace Mono.CSharp
current_field = AddCompilerGeneratedField ("$current", iterator_type_expr);
disposing_field = AddCompilerGeneratedField ("$disposing", new TypeExpression (Compiler.BuiltinTypes.Bool, Location));
if (hoisted_params != null) {
if (Iterator.IsEnumerable && hoisted_params != null) {
//
// Iterators are independent, each GetEnumerator call has to
// create same enumerator therefore we have to keep original values
// around for re-initialization
//
// TODO: Do it for assigned/modified parameters only
//
hoisted_params_copy = new List<HoistedParameter> (hoisted_params.Count);
foreach (HoistedParameter hp in hoisted_params) {
hoisted_params_copy.Add (new HoistedParameter (hp, "<$>" + hp.Field.Name));
//
// Don't create field copy for unmodified captured parameters
//
HoistedParameter hp_copy;
if (hp.IsAssigned) {
hp_copy = new HoistedParameter (hp, "<$>" + hp.Field.Name);
} else {
hp_copy = null;
}
hoisted_params_copy.Add (hp_copy);
}
}
@ -565,7 +581,8 @@ namespace Mono.CSharp @@ -565,7 +581,8 @@ namespace Mono.CSharp
protected override void EmitHoistedParameters (EmitContext ec, List<HoistedParameter> hoisted)
{
base.EmitHoistedParameters (ec, hoisted);
base.EmitHoistedParameters (ec, hoisted_params_copy);
if (hoisted_params_copy != null)
base.EmitHoistedParameters (ec, hoisted_params_copy);
}
}
@ -1101,7 +1118,7 @@ namespace Mono.CSharp @@ -1101,7 +1118,7 @@ namespace Mono.CSharp
"The body of `{0}' cannot be an iterator block " +
"because `{1}' is not an iterator interface type",
method.GetSignatureForError (),
TypeManager.CSharpName (ret));
ret.GetSignatureForError ());
return;
}

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

@ -135,7 +135,7 @@ namespace Mono.CSharp.Linq @@ -135,7 +135,7 @@ namespace Mono.CSharp.Linq
if (!Convert.ImplicitConversionExists (rc, a.Expr, source_type)) {
rc.Report.Error (1936, loc, "An implementation of `{0}' query expression pattern for source type `{1}' could not be found",
best.Name, TypeManager.CSharpName (a.Type));
best.Name, a.Type.GetSignatureForError ());
return true;
}
}

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

@ -61,7 +61,7 @@ namespace Mono.CSharp @@ -61,7 +61,7 @@ namespace Mono.CSharp
if (TypeSpec.IsValueType (t)) {
ec.Report.Error(37, loc, "Cannot convert null to `{0}' because it is a value type",
TypeManager.CSharpName(t));
t.GetSignatureForError ());
return;
}

16
ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs

@ -795,13 +795,14 @@ namespace Mono.CSharp { @@ -795,13 +795,14 @@ namespace Mono.CSharp {
while (true) {
foreach (var entry in abstract_type.MemberCache.member_hash) {
foreach (var name_entry in entry.Value) {
if ((name_entry.Modifiers & (Modifiers.ABSTRACT | Modifiers.OVERRIDE)) != Modifiers.ABSTRACT)
if ((name_entry.Modifiers & Modifiers.ABSTRACT) == 0)
continue;
if (name_entry.Kind != MemberKind.Method)
var ms = name_entry as MethodSpec;
if (ms == null)
continue;
abstract_methods.Add ((MethodSpec) name_entry);
abstract_methods.Add (ms);
}
}
@ -1445,9 +1446,12 @@ namespace Mono.CSharp { @@ -1445,9 +1446,12 @@ namespace Mono.CSharp {
"A partial method declaration and partial method implementation must be both `static' or neither");
}
Report.SymbolRelatedToPreviousError (ce);
Report.Error (764, member.Location,
"A partial method declaration and partial method implementation must be both `unsafe' or neither");
if ((method_a.ModFlags & Modifiers.UNSAFE) != (method_b.ModFlags & Modifiers.UNSAFE)) {
Report.SymbolRelatedToPreviousError (ce);
Report.Error (764, member.Location,
"A partial method declaration and partial method implementation must be both `unsafe' or neither");
}
return false;
}

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

@ -188,7 +188,7 @@ namespace Mono.CSharp { @@ -188,7 +188,7 @@ namespace Mono.CSharp {
}
}
public interface IGenericMethodDefinition : IMemberDefinition
public interface IGenericMethodDefinition : IMethodDefinition
{
TypeParameterSpec[] TypeParameters { get; }
int TypeParametersCount { get; }
@ -198,18 +198,17 @@ namespace Mono.CSharp { @@ -198,18 +198,17 @@ namespace Mono.CSharp {
public sealed class MethodSpec : MemberSpec, IParametersMember
{
MethodBase metaInfo, inflatedMetaInfo;
MethodBase inflatedMetaInfo;
AParametersCollection parameters;
TypeSpec returnType;
TypeSpec[] targs;
TypeParameterSpec[] constraints;
public MethodSpec (MemberKind kind, TypeSpec declaringType, IMemberDefinition details, TypeSpec returnType,
MethodBase info, AParametersCollection parameters, Modifiers modifiers)
public MethodSpec (MemberKind kind, TypeSpec declaringType, IMethodDefinition details, TypeSpec returnType,
AParametersCollection parameters, Modifiers modifiers)
: base (kind, declaringType, details, modifiers)
{
this.metaInfo = info;
this.parameters = parameters;
this.returnType = returnType;
}
@ -237,6 +236,12 @@ namespace Mono.CSharp { @@ -237,6 +236,12 @@ namespace Mono.CSharp {
}
}
public new IMethodDefinition MemberDefinition {
get {
return (IMethodDefinition) definition;
}
}
public IGenericMethodDefinition GenericDefinition {
get {
return (IGenericMethodDefinition) definition;
@ -322,21 +327,21 @@ namespace Mono.CSharp { @@ -322,21 +327,21 @@ namespace Mono.CSharp {
if (DeclaringType.IsTypeBuilder) {
if (IsConstructor)
inflatedMetaInfo = TypeBuilder.GetConstructor (dt_meta, (ConstructorInfo) metaInfo);
inflatedMetaInfo = TypeBuilder.GetConstructor (dt_meta, (ConstructorInfo) MemberDefinition.Metadata);
else
inflatedMetaInfo = TypeBuilder.GetMethod (dt_meta, (MethodInfo) metaInfo);
inflatedMetaInfo = TypeBuilder.GetMethod (dt_meta, (MethodInfo) MemberDefinition.Metadata);
} else {
#if STATIC
// it should not be reached
throw new NotImplementedException ();
#else
inflatedMetaInfo = MethodInfo.GetMethodFromHandle (metaInfo.MethodHandle, dt_meta.TypeHandle);
inflatedMetaInfo = MethodInfo.GetMethodFromHandle (MemberDefinition.Metadata.MethodHandle, dt_meta.TypeHandle);
#endif
}
state &= ~StateFlags.PendingMetaInflate;
} else {
inflatedMetaInfo = metaInfo;
inflatedMetaInfo = MemberDefinition.Metadata;
}
}
@ -518,19 +523,10 @@ namespace Mono.CSharp { @@ -518,19 +523,10 @@ namespace Mono.CSharp {
return missing;
}
public void SetMetaInfo (MethodInfo info)
{
if (this.metaInfo != null)
throw new InternalErrorException ("MetaInfo reset");
this.metaInfo = info;
}
}
public abstract class MethodOrOperator : MethodCore, IMethodData
public abstract class MethodOrOperator : MethodCore, IMethodData, IMethodDefinition
{
public MethodBuilder MethodBuilder;
ReturnParameter return_attributes;
SecurityType declarative_security;
protected MethodData MethodData;
@ -583,6 +579,19 @@ namespace Mono.CSharp { @@ -583,6 +579,19 @@ namespace Mono.CSharp {
}
}
MethodBase IMethodDefinition.Metadata {
get {
return MethodData.MethodBuilder;
}
}
// TODO: Remove and use MethodData abstraction
public MethodBuilder MethodBuilder {
get {
return MethodData.MethodBuilder;
}
}
protected override bool CheckForDuplications ()
{
return Parent.MemberCache.CheckExistingMembersOverloads (this, parameters);
@ -609,41 +618,34 @@ namespace Mono.CSharp { @@ -609,41 +618,34 @@ namespace Mono.CSharp {
else
kind = MemberKind.Method;
string explicit_name;
if (IsPartialDefinition) {
caching_flags &= ~Flags.Excluded_Undetected;
caching_flags |= Flags.Excluded;
// Add to member cache only when a partial method implementation has not been found yet
if ((caching_flags & Flags.PartialDefinitionExists) == 0) {
// MethodBase mb = new PartialMethodDefinitionInfo (this);
if ((caching_flags & Flags.PartialDefinitionExists) != 0)
return true;
spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, null, parameters, ModFlags);
if (MemberName.Arity > 0) {
spec.IsGeneric = true;
if (IsExplicitImpl)
return true;
// TODO: Have to move DefineMethod after Define (ideally to Emit)
throw new NotImplementedException ("Generic partial methods");
}
explicit_name = null;
} else {
MethodData = new MethodData (this, ModFlags, flags, this, base_method);
Parent.MemberCache.AddMember (spec);
}
if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName)))
return false;
return true;
explicit_name = MethodData.MetadataName;
}
MethodData = new MethodData (
this, ModFlags, flags, this, MethodBuilder, base_method);
if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName)))
return false;
MethodBuilder = MethodData.MethodBuilder;
spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, MethodBuilder, parameters, ModFlags);
spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, parameters, ModFlags);
if (MemberName.Arity > 0)
spec.IsGeneric = true;
Parent.MemberCache.AddMember (this, MethodBuilder.Name, spec);
Parent.MemberCache.AddMember (this, explicit_name, spec);
return true;
}
@ -713,7 +715,8 @@ namespace Mono.CSharp { @@ -713,7 +715,8 @@ namespace Mono.CSharp {
if (MethodData != null)
MethodData.Emit (Parent);
Block = null;
if ((ModFlags & Modifiers.PARTIAL) == 0)
Block = null;
}
protected void Error_ConditionalAttributeIsNotValid ()
@ -798,9 +801,36 @@ namespace Mono.CSharp { @@ -798,9 +801,36 @@ namespace Mono.CSharp {
#endregion
public virtual void PrepareEmit ()
{
var mb = MethodData.DefineMethodBuilder (Parent);
if (CurrentTypeParameters != null) {
string[] gnames = new string[CurrentTypeParameters.Count];
for (int i = 0; i < gnames.Length; ++i) {
gnames[i] = CurrentTypeParameters[i].Name;
}
var gen_params = MethodBuilder.DefineGenericParameters (gnames);
for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
var tp = CurrentTypeParameters[i];
tp.Define (gen_params[i]);
}
}
//
// Generic method has been already defined to resolve method parameters
// correctly when they use type parameters
//
mb.SetParameters (parameters.GetMetaInfo ());
mb.SetReturnType (ReturnType.GetMetaInfo ());
}
public override void WriteDebugSymbol (MonoSymbolFile file)
{
if (MethodData != null)
if (MethodData != null && !IsPartialDefinition)
MethodData.WriteDebugSymbol (file);
}
}
@ -844,7 +874,7 @@ namespace Mono.CSharp { @@ -844,7 +874,7 @@ namespace Mono.CSharp {
}
}
#endregion
#endregion
public override void Accept (StructuralVisitor visitor)
{
@ -972,10 +1002,9 @@ namespace Mono.CSharp { @@ -972,10 +1002,9 @@ namespace Mono.CSharp {
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++) {
for (int i = 0; i < MemberName.Arity; i++) {
string type_argument_name = tparams[i].MemberName.Name;
if (block == null) {
@ -1000,12 +1029,9 @@ namespace Mono.CSharp { @@ -1000,12 +1029,9 @@ namespace Mono.CSharp {
tparams[i].WarningParentNameConflict (tp);
}
}
snames[i] = type_argument_name;
}
GenericTypeParameterBuilder[] gen_params = MethodBuilder.DefineGenericParameters (snames);
tparams.Define (gen_params, null, 0, Parent);
tparams.Create (null, 0, Parent);
}
protected virtual void DefineTypeParameters ()
@ -1171,9 +1197,6 @@ namespace Mono.CSharp { @@ -1171,9 +1197,6 @@ namespace Mono.CSharp {
"Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?");
}
if (partialMethodImplementation != null && IsPartialDefinition)
MethodBuilder = partialMethodImplementation.MethodBuilder;
if (Compiler.Settings.StdLib && ReturnType.IsSpecialRuntimeType) {
Error1599 (Location, ReturnType, Report);
return false;
@ -1208,7 +1231,7 @@ namespace Mono.CSharp { @@ -1208,7 +1231,7 @@ namespace Mono.CSharp {
Report.Error (1983, Location, "The return type of an async method must be void, Task, or Task<T>");
}
block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, Location);
block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, null, Location);
ModFlags |= Modifiers.DEBUGGER_HIDDEN;
}
@ -1272,6 +1295,22 @@ namespace Mono.CSharp { @@ -1272,6 +1295,22 @@ namespace Mono.CSharp {
return true;
}
public override void PrepareEmit ()
{
if (IsPartialDefinition) {
//
// Use partial method implementation builder for partial method declaration attributes
//
if (partialMethodImplementation != null) {
MethodData = partialMethodImplementation.MethodData;
}
return;
}
base.PrepareEmit ();
}
//
// Emits the code
//
@ -1279,11 +1318,8 @@ namespace Mono.CSharp { @@ -1279,11 +1318,8 @@ namespace Mono.CSharp {
{
try {
if (IsPartialDefinition) {
//
// Use partial method implementation builder for partial method declaration attributes
//
if (partialMethodImplementation != null) {
MethodBuilder = partialMethodImplementation.MethodBuilder;
if (partialMethodImplementation != null && CurrentTypeParameters != null) {
CurrentTypeParameters.CheckPartialConstraints (partialMethodImplementation);
}
return;
@ -1297,6 +1333,7 @@ namespace Mono.CSharp { @@ -1297,6 +1333,7 @@ namespace Mono.CSharp {
if (CurrentTypeParameters != null) {
for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
var tp = CurrentTypeParameters [i];
tp.CheckGenericConstraints (false);
tp.Emit ();
}
@ -1312,10 +1349,8 @@ namespace Mono.CSharp { @@ -1312,10 +1349,8 @@ namespace Mono.CSharp {
Module.PredefinedAttributes.Extension.EmitAttribute (MethodBuilder);
base.Emit ();
} catch {
Console.WriteLine ("Internal compiler error at {0}: exception caught while emitting {1}",
Location, MethodBuilder);
throw;
} catch (Exception e) {
throw new InternalErrorException (this, e);
}
}
@ -1329,13 +1364,12 @@ namespace Mono.CSharp { @@ -1329,13 +1364,12 @@ namespace Mono.CSharp {
public static void Error1599 (Location loc, TypeSpec t, Report Report)
{
Report.Error (1599, loc, "Method or delegate cannot return type `{0}'", TypeManager.CSharpName (t));
Report.Error (1599, loc, "Method or delegate cannot return type `{0}'", t.GetSignatureForError ());
}
protected override bool ResolveMemberType ()
{
if (CurrentTypeParameters != null) {
MethodBuilder = Parent.TypeBuilder.DefineMethod (GetFullName (MemberName), flags);
CreateTypeParameters ();
}
@ -1485,7 +1519,7 @@ namespace Mono.CSharp { @@ -1485,7 +1519,7 @@ namespace Mono.CSharp {
}
}
public class Constructor : MethodCore, IMethodData
public class Constructor : MethodCore, IMethodData, IMethodDefinition
{
public ConstructorBuilder ConstructorBuilder;
public ConstructorInitializer Initializer;
@ -1533,6 +1567,13 @@ namespace Mono.CSharp { @@ -1533,6 +1567,13 @@ namespace Mono.CSharp {
}
}
MethodBase IMethodDefinition.Metadata {
get {
return ConstructorBuilder;
}
}
//
// Returns true if this is a default constructor
//
@ -1620,7 +1661,7 @@ namespace Mono.CSharp { @@ -1620,7 +1661,7 @@ namespace Mono.CSharp {
ca, CallingConventions,
parameters.GetMetaInfo ());
spec = new MethodSpec (MemberKind.Constructor, Parent.Definition, this, Compiler.BuiltinTypes.Void, ConstructorBuilder, parameters, ModFlags);
spec = new MethodSpec (MemberKind.Constructor, Parent.Definition, this, Compiler.BuiltinTypes.Void, parameters, ModFlags);
Parent.MemberCache.AddMember (spec);
@ -1828,10 +1869,6 @@ namespace Mono.CSharp { @@ -1828,10 +1869,6 @@ namespace Mono.CSharp {
//
public class MethodData
{
#if !STATIC
static FieldInfo methodbuilder_attrs_field;
#endif
public readonly IMethodData method;
//
@ -1848,6 +1885,7 @@ namespace Mono.CSharp { @@ -1848,6 +1885,7 @@ namespace Mono.CSharp {
protected TypeSpec declaring_type;
protected MethodSpec parent_method;
SourceMethodBuilder debug_builder;
string full_name;
MethodBuilder builder;
public MethodBuilder MethodBuilder {
@ -1862,6 +1900,12 @@ namespace Mono.CSharp { @@ -1862,6 +1900,12 @@ namespace Mono.CSharp {
}
}
public string MetadataName {
get {
return full_name;
}
}
public MethodData (InterfaceMemberBase member,
Modifiers modifiers, MethodAttributes flags, IMethodData method)
{
@ -1874,11 +1918,10 @@ namespace Mono.CSharp { @@ -1874,11 +1918,10 @@ namespace Mono.CSharp {
public MethodData (InterfaceMemberBase member,
Modifiers modifiers, MethodAttributes flags,
IMethodData method, MethodBuilder builder,
IMethodData method,
MethodSpec parent_method)
: this (member, modifiers, flags, method)
{
this.builder = builder;
this.parent_method = parent_method;
}
@ -1896,13 +1939,13 @@ namespace Mono.CSharp { @@ -1896,13 +1939,13 @@ namespace Mono.CSharp {
if (member is PropertyBase) {
container.Compiler.Report.Error (550, method.Location,
"`{0}' is an accessor not found in interface member `{1}{2}'",
method.GetSignatureForError (), TypeManager.CSharpName (member.InterfaceType),
method.GetSignatureForError (), member.InterfaceType.GetSignatureForError (),
member.GetSignatureForError ().Substring (member.GetSignatureForError ().LastIndexOf ('.')));
} else {
container.Compiler.Report.Error (539, method.Location,
"`{0}.{1}' in explicit interface declaration is not a member of interface",
TypeManager.CSharpName (member.InterfaceType), member.ShortName);
member.InterfaceType.GetSignatureForError (), member.ShortName);
}
return false;
}
@ -1910,7 +1953,7 @@ namespace Mono.CSharp { @@ -1910,7 +1953,7 @@ namespace Mono.CSharp {
container.Compiler.Report.SymbolRelatedToPreviousError (implementing);
container.Compiler.Report.Error (683, method.Location,
"`{0}' explicit method implementation cannot implement `{1}' because it is an accessor",
member.GetSignatureForError (), TypeManager.CSharpSignature (implementing));
member.GetSignatureForError (), implementing.GetSignatureForError ());
return false;
}
} else {
@ -2033,58 +2076,45 @@ namespace Mono.CSharp { @@ -2033,58 +2076,45 @@ namespace Mono.CSharp {
method_full_name = implementing.MemberDefinition.Name;
}
DefineMethodBuilder (container, method_full_name, method.ParameterInfo);
full_name = method_full_name;
declaring_type = container.Definition;
if (builder == null)
return false;
return true;
}
// if (container.CurrentType != null)
// declaring_type = container.CurrentType;
// else
declaring_type = container.Definition;
void DefineOverride (TypeDefinition container)
{
if (implementing == null)
return;
if (implementing != null && member.IsExplicitImpl) {
container.TypeBuilder.DefineMethodOverride (builder, (MethodInfo) implementing.GetMetaInfo ());
}
if (!member.IsExplicitImpl)
return;
return true;
container.TypeBuilder.DefineMethodOverride (builder, (MethodInfo) implementing.GetMetaInfo ());
}
/// <summary>
/// Create the MethodBuilder for the method
/// </summary>
void DefineMethodBuilder (TypeDefinition container, string method_name, ParametersCompiled param)
//
// Creates partial MethodBuilder for the method when has generic parameters used
// as arguments or return type
//
public MethodBuilder DefineMethodBuilder (TypeDefinition container)
{
var return_type = method.ReturnType.GetMetaInfo ();
var p_types = param.GetMetaInfo ();
if (builder != null)
throw new InternalErrorException ();
if (builder == null) {
builder = container.TypeBuilder.DefineMethod (
method_name, flags, method.CallingConventions,
return_type, p_types);
return;
}
builder = container.TypeBuilder.DefineMethod (full_name, flags, method.CallingConventions);
return builder;
}
//
// Generic method has been already defined to resolve method parameters
// correctly when they use type parameters
//
builder.SetParameters (p_types);
builder.SetReturnType (return_type);
if (builder.Attributes != flags) {
#if STATIC
builder.__SetAttributes (flags);
#else
try {
if (methodbuilder_attrs_field == null)
methodbuilder_attrs_field = typeof (MethodBuilder).GetField ("attrs", BindingFlags.NonPublic | BindingFlags.Instance);
methodbuilder_attrs_field.SetValue (builder, flags);
} catch {
container.Compiler.Report.RuntimeMissingSupport (method.Location, "Generic method MethodAttributes");
}
#endif
}
//
// Creates full MethodBuilder for the method
//
public MethodBuilder DefineMethodBuilder (TypeDefinition container, ParametersCompiled param)
{
DefineMethodBuilder (container);
builder.SetReturnType (method.ReturnType.GetMetaInfo ());
builder.SetParameters (param.GetMetaInfo ());
return builder;
}
//
@ -2092,6 +2122,8 @@ namespace Mono.CSharp { @@ -2092,6 +2122,8 @@ namespace Mono.CSharp {
//
public void Emit (TypeDefinition parent)
{
DefineOverride (parent);
var mc = (IMemberContext) method;
method.ParameterInfo.ApplyAttributes (mc, MethodBuilder);
@ -2231,7 +2263,7 @@ namespace Mono.CSharp { @@ -2231,7 +2263,7 @@ namespace Mono.CSharp {
// Ooouh Martin, templates are missing here.
// When it will be possible move here a lot of child code and template method type.
public abstract class AbstractPropertyEventMethod : MemberCore, IMethodData {
public abstract class AbstractPropertyEventMethod : MemberCore, IMethodData, IMethodDefinition {
protected MethodData method_data;
protected ToplevelBlock block;
protected SecurityType declarative_security;
@ -2297,6 +2329,12 @@ namespace Mono.CSharp { @@ -2297,6 +2329,12 @@ namespace Mono.CSharp {
}
}
MethodBase IMethodDefinition.Metadata {
get {
return method_data.MethodBuilder;
}
}
public abstract ParametersCompiled ParameterInfo { get ; }
public abstract TypeSpec ReturnType { get; }
@ -2307,7 +2345,7 @@ namespace Mono.CSharp { @@ -2307,7 +2345,7 @@ namespace Mono.CSharp {
if (a.Type == pa.CLSCompliant || a.Type == pa.Obsolete || a.Type == pa.Conditional) {
Report.Error (1667, a.Location,
"Attribute `{0}' is not valid on property or event accessors. It is valid on `{1}' declarations only",
TypeManager.CSharpName (a.Type), a.GetValidTargets ());
a.Type.GetSignatureForError (), a.GetValidTargets ());
return;
}

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

@ -262,7 +262,7 @@ namespace Mono.CSharp @@ -262,7 +262,7 @@ namespace Mono.CSharp
return mod;
}
for (i = 1; i <= (int) Modifiers.TOP; i <<= 1) {
for (i = 1; i < (int) Modifiers.TOP; i <<= 1) {
if ((i & invalid_flags) == 0)
continue;

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

@ -276,16 +276,7 @@ namespace Mono.CSharp { @@ -276,16 +276,7 @@ namespace Mono.CSharp {
public Namespace AddNamespace (MemberName name)
{
Namespace ns_parent;
if (name.Left != null) {
if (parent != null)
ns_parent = parent.AddNamespace (name.Left);
else
ns_parent = AddNamespace (name.Left);
} else {
ns_parent = this;
}
var ns_parent = name.Left == null ? this : AddNamespace (name.Left);
return ns_parent.TryAddNamespace (name.Basename);
}

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

@ -320,7 +320,7 @@ namespace Mono.CSharp.Nullable @@ -320,7 +320,7 @@ namespace Mono.CSharp.Nullable
public static Constant CreateFromExpression (ResolveContext ec, Expression e)
{
ec.Report.Warning (458, 2, e.Location, "The result of the expression is always `null' of type `{0}'",
TypeManager.CSharpName (e.Type));
e.Type.GetSignatureForError ());
return ReducedExpression.Create (Create (e.Type, e.Location), e);
}
@ -592,10 +592,10 @@ namespace Mono.CSharp.Nullable @@ -592,10 +592,10 @@ namespace Mono.CSharp.Nullable
if ((Oper & Operator.EqualityMask) != 0) {
ec.Report.Warning (472, 2, loc, "The result of comparing value type `{0}' with null is always `{1}'",
TypeManager.CSharpName (expr.Type), c.GetValueAsLiteral ());
expr.Type.GetSignatureForError (), c.GetValueAsLiteral ());
} else {
ec.Report.Warning (464, 2, loc, "The result of comparing type `{0}' with null is always `{1}'",
TypeManager.CSharpName (expr.Type), c.GetValueAsLiteral ());
expr.Type.GetSignatureForError (), c.GetValueAsLiteral ());
}
return ReducedExpression.Create (c, this);

8
ICSharpCode.NRefactory.CSharp/Parser/mcs/parameter.cs

@ -338,7 +338,7 @@ namespace Mono.CSharp { @@ -338,7 +338,7 @@ namespace Mono.CSharp {
if (HasOptionalExpression) {
a.Report.Error (1745, a.Location,
"Cannot specify `{0}' attribute on optional parameter `{1}'",
TypeManager.CSharpName (a.Type).Replace ("Attribute", ""), Name);
a.Type.GetSignatureForError ().Replace ("Attribute", ""), Name);
}
if (a.Type == pa.DefaultParameterValue)
@ -406,7 +406,7 @@ namespace Mono.CSharp { @@ -406,7 +406,7 @@ namespace Mono.CSharp {
if ((modFlags & Modifier.This) != 0 && (parameter_type.IsPointer || parameter_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)) {
rc.Module.Compiler.Report.Error (1103, Location, "The extension method cannot be of type `{0}'",
TypeManager.CSharpName (parameter_type));
parameter_type.GetSignatureForError ());
}
return parameter_type;
@ -582,7 +582,7 @@ namespace Mono.CSharp { @@ -582,7 +582,7 @@ namespace Mono.CSharp {
{
string type_name;
if (parameter_type != null)
type_name = TypeManager.CSharpName (parameter_type);
type_name = parameter_type.GetSignatureForError ();
else
type_name = texpr.GetSignatureForError ();
@ -989,7 +989,7 @@ namespace Mono.CSharp { @@ -989,7 +989,7 @@ namespace Mono.CSharp {
if (types == null || types [pos] == null)
return ((Parameter)FixedParameters [pos]).GetSignatureForError ();
string type = TypeManager.CSharpName (types [pos]);
string type = types [pos].GetSignatureForError ();
if (FixedParameters [pos].HasExtensionMethodModifier)
return "this " + type;

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

@ -534,10 +534,14 @@ namespace Mono.CSharp { @@ -534,10 +534,14 @@ namespace Mono.CSharp {
// about mismatch at return type when the check bellow rejects them
//
var parameters = mi.Parameters;
MethodSpec close_match = null;
while (true) {
var candidates = MemberCache.FindMembers (base_type, mi.Name, false);
if (candidates == null)
if (candidates == null) {
base_method = close_match;
return false;
}
MethodSpec similar_candidate = null;
foreach (var candidate in candidates) {
@ -590,19 +594,29 @@ namespace Mono.CSharp { @@ -590,19 +594,29 @@ namespace Mono.CSharp {
// From this point the candidate is used for detailed error reporting
// because it's very close match to what we are looking for
//
base_method = (MethodSpec) candidate;
var m = (MethodSpec) candidate;
if (!m.IsPublic) {
if (close_match == null)
close_match = m;
if (!candidate.IsPublic)
return false;
continue;
}
if (!TypeSpecComparer.Override.IsEqual (mi.ReturnType, base_method.ReturnType))
return false;
if (!TypeSpecComparer.Override.IsEqual (mi.ReturnType, m.ReturnType)) {
if (close_match == null)
close_match = m;
if (mi.IsGeneric && !Method.CheckImplementingMethodConstraints (container, base_method, mi)) {
continue;
}
base_method = m;
if (mi.IsGeneric && !Method.CheckImplementingMethodConstraints (container, m, mi)) {
return true;
}
}
if (base_method != null) {
if (similar_candidate != null) {
Report.SymbolRelatedToPreviousError (similar_candidate);
@ -617,8 +631,10 @@ namespace Mono.CSharp { @@ -617,8 +631,10 @@ namespace Mono.CSharp {
}
base_type = candidates[0].DeclaringType.BaseType;
if (base_type == null)
if (base_type == null) {
base_method = close_match;
return false;
}
}
if (!base_method.IsVirtual) {

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

@ -201,14 +201,14 @@ namespace Mono.CSharp @@ -201,14 +201,14 @@ namespace Mono.CSharp
{
base.Define (parent);
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, null, ParameterInfo, ModFlags);
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, ModFlags);
method_data = new MethodData (method, ModFlags, flags, this);
if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName)))
return null;
Spec.SetMetaInfo (method_data.MethodBuilder);
method_data.DefineMethodBuilder (parent.PartialContainer, ParameterInfo);
return method_data.MethodBuilder;
}
@ -268,14 +268,14 @@ namespace Mono.CSharp @@ -268,14 +268,14 @@ namespace Mono.CSharp
base.Define (parent);
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, null, ParameterInfo, ModFlags);
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, ModFlags);
method_data = new MethodData (method, ModFlags, flags, this);
if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName)))
return null;
Spec.SetMetaInfo (method_data.MethodBuilder);
method_data.DefineMethodBuilder (parent.PartialContainer, ParameterInfo);
return method_data.MethodBuilder;
}
@ -1198,15 +1198,15 @@ namespace Mono.CSharp @@ -1198,15 +1198,15 @@ namespace Mono.CSharp
if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName)))
return null;
method_data.DefineMethodBuilder (parent.PartialContainer, ParameterInfo);
if (Compiler.Settings.WriteMetadataOnly)
block = null;
MethodBuilder mb = method_data.MethodBuilder;
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, mb, ParameterInfo, method.ModFlags);
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, method.ModFlags);
Spec.IsAccessor = true;
return mb;
return method_data.MethodBuilder;
}
public override TypeSpec ReturnType {

23
ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs

@ -550,6 +550,8 @@ namespace Mono.CSharp { @@ -550,6 +550,8 @@ namespace Mono.CSharp {
//
public abstract class ReportPrinter
{
protected HashSet<ITypeDefinition> reported_missing_definitions;
#region Properties
public int ErrorsCount { get; protected set; }
@ -605,6 +607,22 @@ namespace Mono.CSharp { @@ -605,6 +607,22 @@ namespace Mono.CSharp {
}
}
//
// Tracks reported missing types. It needs to be session specific
// because we can run in probing mode
//
public bool MissingTypeReported (ITypeDefinition typeDefinition)
{
if (reported_missing_definitions == null)
reported_missing_definitions = new HashSet<ITypeDefinition> ();
if (reported_missing_definitions.Contains (typeDefinition))
return true;
reported_missing_definitions.Add (typeDefinition);
return false;
}
public void Reset ()
{
// HACK: Temporary hack for broken repl flow
@ -735,6 +753,11 @@ namespace Mono.CSharp { @@ -735,6 +753,11 @@ namespace Mono.CSharp {
error_msg |= !msg.IsWarning;
}
if (reported_missing_definitions != null) {
foreach (var missing in reported_missing_definitions)
dest.MissingTypeReported (missing);
}
return error_msg;
}
}

26
ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs

@ -350,6 +350,17 @@ namespace Mono.CSharp { @@ -350,6 +350,17 @@ namespace Mono.CSharp {
public CompilerSettings ParseArguments (string[] args)
{
CompilerSettings settings = new CompilerSettings ();
if (!ParseArguments (settings, args))
return null;
return settings;
}
public bool ParseArguments (CompilerSettings settings, string[] args)
{
if (settings == null)
throw new ArgumentNullException ("settings");
List<string> response_file_list = null;
bool parsing_options = true;
stop_argument = false;
@ -369,7 +380,7 @@ namespace Mono.CSharp { @@ -369,7 +380,7 @@ namespace Mono.CSharp {
if (response_file_list.Contains (response_file)) {
report.Error (1515, "Response file `{0}' specified multiple times", response_file);
return null;
return false;
}
response_file_list.Add (response_file);
@ -377,7 +388,7 @@ namespace Mono.CSharp { @@ -377,7 +388,7 @@ namespace Mono.CSharp {
extra_args = LoadArgs (response_file);
if (extra_args == null) {
report.Error (2011, "Unable to open response file: " + response_file);
return null;
return false;
}
args = AddArgs (args, extra_args);
@ -399,7 +410,7 @@ namespace Mono.CSharp { @@ -399,7 +410,7 @@ namespace Mono.CSharp {
continue;
case ParseResult.Stop:
stop_argument = true;
return settings;
return true;
case ParseResult.UnknownOption:
if (UnknownOptionHandler != null) {
var ret = UnknownOptionHandler (args, i);
@ -433,11 +444,11 @@ namespace Mono.CSharp { @@ -433,11 +444,11 @@ namespace Mono.CSharp {
}
Error_WrongOption (arg);
return null;
return false;
case ParseResult.Stop:
stop_argument = true;
return settings;
return true;
}
}
}
@ -445,10 +456,7 @@ namespace Mono.CSharp { @@ -445,10 +456,7 @@ namespace Mono.CSharp {
ProcessSourceFiles (arg, false, settings.SourceFiles);
}
if (report.Errors > 0)
return null;
return settings;
return report.Errors == 0;
}
void ProcessSourceFiles (string spec, bool recurse, List<SourceFile> sourceFiles)

146
ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs

@ -706,6 +706,7 @@ namespace Mono.CSharp { @@ -706,6 +706,7 @@ namespace Mono.CSharp {
public StatementErrorExpression (Expression expr)
{
this.expr = expr;
this.loc = expr.StartLocation;
}
public Expression Expr {
@ -714,6 +715,12 @@ namespace Mono.CSharp { @@ -714,6 +715,12 @@ namespace Mono.CSharp {
}
}
public override bool Resolve (BlockContext bc)
{
expr.Error_InvalidExpressionStatement (bc);
return true;
}
protected override void DoEmit (EmitContext ec)
{
throw new NotSupportedException ();
@ -903,9 +910,18 @@ namespace Mono.CSharp { @@ -903,9 +910,18 @@ namespace Mono.CSharp {
if (this is ContextualReturn)
return true;
ec.Report.Error (1997, loc,
"`{0}': A return keyword must not be followed by an expression when async method returns `Task'. Consider using `Task<T>' return type",
ec.GetSignatureForError ());
// Same error code as .NET but better error message
if (async_block.DelegateType != null) {
ec.Report.Error (1997, loc,
"`{0}': A return keyword must not be followed by an expression when async delegate returns `Task'. Consider using `Task<T>' return type",
async_block.DelegateType.GetSignatureForError ());
} else {
ec.Report.Error (1997, loc,
"`{0}': A return keyword must not be followed by an expression when async method returns `Task'. Consider using `Task<T>' return type",
ec.GetSignatureForError ());
}
return false;
}
@ -1252,7 +1268,7 @@ namespace Mono.CSharp { @@ -1252,7 +1268,7 @@ namespace Mono.CSharp {
if (!Convert.ImplicitStandardConversionExists (c, type))
ec.Report.Warning (469, 2, loc,
"The `goto case' value is not implicitly convertible to type `{0}'",
TypeManager.CSharpName (type));
type.GetSignatureForError ());
}
@ -1420,69 +1436,72 @@ namespace Mono.CSharp { @@ -1420,69 +1436,72 @@ namespace Mono.CSharp {
Location Location { get; }
}
public class BlockVariableDeclaration : Statement
public class BlockVariableDeclarator
{
public class Declarator
LocalVariable li;
Expression initializer;
public BlockVariableDeclarator (LocalVariable li, Expression initializer)
{
LocalVariable li;
Expression initializer;
if (li.Type != null)
throw new ArgumentException ("Expected null variable type");
public Declarator (LocalVariable li, Expression initializer)
{
if (li.Type != null)
throw new ArgumentException ("Expected null variable type");
this.li = li;
this.initializer = initializer;
}
this.li = li;
this.initializer = initializer;
}
#region Properties
public Declarator (Declarator clone, Expression initializer)
{
this.li = clone.li;
this.initializer = initializer;
public LocalVariable Variable {
get {
return li;
}
}
#region Properties
public LocalVariable Variable {
get {
return li;
}
public Expression Initializer {
get {
return initializer;
}
public Expression Initializer {
get {
return initializer;
}
set {
initializer = value;
}
set {
initializer = value;
}
}
#endregion
#endregion
public virtual BlockVariableDeclarator Clone (CloneContext cloneCtx)
{
var t = (BlockVariableDeclarator) MemberwiseClone ();
if (initializer != null)
t.initializer = initializer.Clone (cloneCtx);
return t;
}
}
public class BlockVariable : Statement
{
Expression initializer;
protected FullNamedExpression type_expr;
protected LocalVariable li;
protected List<Declarator> declarators;
protected List<BlockVariableDeclarator> declarators;
TypeSpec type;
public BlockVariableDeclaration (FullNamedExpression type, LocalVariable li)
public BlockVariable (FullNamedExpression type, LocalVariable li)
{
this.type_expr = type;
this.li = li;
this.loc = type_expr.Location;
}
protected BlockVariableDeclaration (LocalVariable li)
protected BlockVariable (LocalVariable li)
{
this.li = li;
}
#region Properties
public List<Declarator> Declarators {
public List<BlockVariableDeclarator> Declarators {
get {
return declarators;
}
@ -1511,10 +1530,10 @@ namespace Mono.CSharp { @@ -1511,10 +1530,10 @@ namespace Mono.CSharp {
#endregion
public void AddDeclarator (Declarator decl)
public void AddDeclarator (BlockVariableDeclarator decl)
{
if (declarators == null)
declarators = new List<Declarator> ();
declarators = new List<BlockVariableDeclarator> ();
declarators.Add (decl);
}
@ -1607,7 +1626,7 @@ namespace Mono.CSharp { @@ -1607,7 +1626,7 @@ namespace Mono.CSharp {
bool eval_global = bc.Module.Compiler.Settings.StatementMode && bc.CurrentBlock is ToplevelBlock;
if (eval_global) {
CreateEvaluatorVariable (bc, li);
} else {
} else if (type != InternalType.ErrorType) {
li.PrepareForFlowAnalysis (bc);
}
@ -1621,7 +1640,7 @@ namespace Mono.CSharp { @@ -1621,7 +1640,7 @@ namespace Mono.CSharp {
d.Variable.Type = li.Type;
if (eval_global) {
CreateEvaluatorVariable (bc, d.Variable);
} else {
} else if (type != InternalType.ErrorType) {
d.Variable.PrepareForFlowAnalysis (bc);
}
@ -1661,7 +1680,7 @@ namespace Mono.CSharp { @@ -1661,7 +1680,7 @@ namespace Mono.CSharp {
protected override void CloneTo (CloneContext clonectx, Statement target)
{
BlockVariableDeclaration t = (BlockVariableDeclaration) target;
BlockVariable t = (BlockVariable) target;
if (type_expr != null)
t.type_expr = (FullNamedExpression) type_expr.Clone (clonectx);
@ -1672,7 +1691,7 @@ namespace Mono.CSharp { @@ -1672,7 +1691,7 @@ namespace Mono.CSharp {
if (declarators != null) {
t.declarators = null;
foreach (var d in declarators)
t.AddDeclarator (new Declarator (d, d.Initializer == null ? null : d.Initializer.Clone (clonectx)));
t.AddDeclarator (d.Clone (clonectx));
}
}
@ -1682,9 +1701,9 @@ namespace Mono.CSharp { @@ -1682,9 +1701,9 @@ namespace Mono.CSharp {
}
}
public class BlockConstantDeclaration : BlockVariableDeclaration
public class BlockConstant : BlockVariable
{
public BlockConstantDeclaration (FullNamedExpression type, LocalVariable li)
public BlockConstant (FullNamedExpression type, LocalVariable li)
: base (type, li)
{
}
@ -2059,7 +2078,8 @@ namespace Mono.CSharp { @@ -2059,7 +2078,8 @@ namespace Mono.CSharp {
HasAsyncModifier = 1 << 10,
Resolved = 1 << 11,
YieldBlock = 1 << 12,
AwaitBlock = 1 << 13
AwaitBlock = 1 << 13,
Iterator = 1 << 14
}
public Block Parent;
@ -2646,6 +2666,7 @@ namespace Mono.CSharp { @@ -2646,6 +2666,7 @@ namespace Mono.CSharp {
}
storey.Define ();
storey.PrepareEmit ();
storey.Parent.PartialContainer.AddCompilerGeneratedClass (storey);
}
@ -2664,6 +2685,8 @@ namespace Mono.CSharp { @@ -2664,6 +2685,8 @@ namespace Mono.CSharp {
public void RegisterIteratorYield ()
{
ParametersBlock.TopBlock.IsIterator = true;
var block = this;
while ((block.flags & Flags.YieldBlock) == 0) {
block.flags |= Flags.YieldBlock;
@ -3112,7 +3135,7 @@ namespace Mono.CSharp { @@ -3112,7 +3135,7 @@ namespace Mono.CSharp {
return tlb;
}
public ParametersBlock ConvertToAsyncTask (IMemberContext context, TypeDefinition host, ParametersCompiled parameters, TypeSpec returnType, Location loc)
public ParametersBlock ConvertToAsyncTask (IMemberContext context, TypeDefinition host, ParametersCompiled parameters, TypeSpec returnType, TypeSpec delegateType, Location loc)
{
for (int i = 0; i < parameters.Count; i++) {
Parameter p = parameters[i];
@ -3144,6 +3167,7 @@ namespace Mono.CSharp { @@ -3144,6 +3167,7 @@ namespace Mono.CSharp {
var block_type = host.Module.Compiler.BuiltinTypes.Void;
var initializer = new AsyncInitializer (this, host, block_type);
initializer.Type = block_type;
initializer.DelegateType = delegateType;
var stateMachine = new AsyncTaskStorey (this, context, initializer, returnType);
@ -3207,7 +3231,10 @@ namespace Mono.CSharp { @@ -3207,7 +3231,10 @@ namespace Mono.CSharp {
public bool IsIterator {
get {
return HasYield;
return (flags & Flags.Iterator) != 0;
}
set {
flags = value ? flags | Flags.Iterator : flags & ~Flags.Iterator;
}
}
@ -4110,10 +4137,13 @@ namespace Mono.CSharp { @@ -4110,10 +4137,13 @@ namespace Mono.CSharp {
new_expr = SwitchGoverningType (ec, unwrap);
}
if (new_expr == null){
ec.Report.Error (151, loc,
"A switch expression of type `{0}' cannot be converted to an integral type, bool, char, string, enum or nullable type",
TypeManager.CSharpName (Expr.Type));
if (new_expr == null) {
if (Expr.Type != InternalType.ErrorType) {
ec.Report.Error (151, loc,
"A switch expression of type `{0}' cannot be converted to an integral type, bool, char, string, enum or nullable type",
Expr.Type.GetSignatureForError ());
}
return false;
}
@ -4512,6 +4542,7 @@ namespace Mono.CSharp { @@ -4512,6 +4542,7 @@ namespace Mono.CSharp {
if (finally_host != null) {
finally_host.Define ();
finally_host.PrepareEmit ();
finally_host.Emit ();
// Now it's safe to add, to close it properly and emit sequence points
@ -5049,8 +5080,7 @@ namespace Mono.CSharp { @@ -5049,8 +5080,7 @@ namespace Mono.CSharp {
}
}
public class VariableDeclaration : BlockVariableDeclaration
public class VariableDeclaration : BlockVariable
{
public VariableDeclaration (FullNamedExpression type, LocalVariable li)
: base (type, li)
@ -5175,7 +5205,7 @@ namespace Mono.CSharp { @@ -5175,7 +5205,7 @@ namespace Mono.CSharp {
}
}
public BlockVariableDeclaration Variables {
public BlockVariable Variables {
get {
return decl;
}
@ -5557,7 +5587,7 @@ namespace Mono.CSharp { @@ -5557,7 +5587,7 @@ namespace Mono.CSharp {
public class Using : TryFinallyBlock
{
public class VariableDeclaration : BlockVariableDeclaration
public class VariableDeclaration : BlockVariable
{
Statement dispose_call;
@ -5734,7 +5764,7 @@ namespace Mono.CSharp { @@ -5734,7 +5764,7 @@ namespace Mono.CSharp {
}
}
public BlockVariableDeclaration Variables {
public BlockVariable Variables {
get {
return decl;
}

24
ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs

@ -691,6 +691,7 @@ namespace Mono.CSharp @@ -691,6 +691,7 @@ namespace Mono.CSharp
readonly MemberKind kind;
protected readonly ModuleContainer module;
protected TypeSpec type;
bool defined;
public PredefinedType (ModuleContainer module, MemberKind kind, string ns, string name, int arity)
: this (module, kind, ns, name)
@ -753,7 +754,11 @@ namespace Mono.CSharp @@ -753,7 +754,11 @@ namespace Mono.CSharp
if (type != null)
return true;
type = Resolve (module, kind, ns, name, arity, false, false);
if (!defined) {
defined = true;
type = Resolve (module, kind, ns, name, arity, false, false);
}
return type != null;
}
@ -771,12 +776,13 @@ namespace Mono.CSharp @@ -771,12 +776,13 @@ namespace Mono.CSharp
// fake namespaces when type is optional and does not exist (e.g. System.Linq).
//
Namespace type_ns = module.GlobalRootNamespace.GetNamespace (ns, required);
IList<TypeSpec> found = null;
if (type_ns != null)
found = type_ns.GetAllTypes (name);
if (found == null) {
if (reportErrors )
if (reportErrors)
module.Compiler.Report.Error (518, "The predefined type `{0}.{1}' is not defined or imported", ns, name);
return null;
@ -984,15 +990,7 @@ namespace Mono.CSharp @@ -984,15 +990,7 @@ namespace Mono.CSharp
partial class TypeManager {
/// <summary>
/// Returns the C# name of a type if possible, or the full type name otherwise
/// </summary>
static public string CSharpName (TypeSpec t)
{
return t.GetSignatureForError ();
}
static public string CSharpName (IList<TypeSpec> types)
static public string CSharpName(IList<TypeSpec> types)
{
if (types.Count == 0)
return string.Empty;
@ -1002,7 +1000,7 @@ namespace Mono.CSharp @@ -1002,7 +1000,7 @@ namespace Mono.CSharp
if (i > 0)
sb.Append (",");
sb.Append (CSharpName (types [i]));
sb.Append (types [i].GetSignatureForError ());
}
return sb.ToString ();
}
@ -1090,7 +1088,7 @@ namespace Mono.CSharp @@ -1090,7 +1088,7 @@ namespace Mono.CSharp
rc.Compiler.Report.SymbolRelatedToPreviousError (t);
rc.Compiler.Report.Error (208, loc,
"Cannot take the address of, get the size of, or declare a pointer to a managed type `{0}'",
CSharpName (t));
t.GetSignatureForError ());
return false;
}

4
ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs

@ -130,12 +130,12 @@ namespace Mono.CSharp @@ -130,12 +130,12 @@ namespace Mono.CSharp
return null;
}
public virtual object Visit (BlockVariableDeclaration blockVariableDeclaration)
public virtual object Visit (BlockVariable blockVariableDeclaration)
{
return null;
}
public virtual object Visit (BlockConstantDeclaration blockConstantDeclaration)
public virtual object Visit (BlockConstant blockConstantDeclaration)
{
return null;
}

2
ICSharpCode.NRefactory.Tests/CSharp/CodeActions/IterateViaForeachTests.cs

@ -147,7 +147,7 @@ class TestClass @@ -147,7 +147,7 @@ class TestClass
foreach (var c in s as IEnumerable<char>) {
}
}
}", 0, true);
}", 0, false);
}
[Test]

2
ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/InvalidStatementsTests.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
[Test]
public void AsExpressionStatementPositions()
{
ExpressionStatement expr = ParseUtilCSharp.ParseStatement<ExpressionStatement>("\t\t\"\" as IEnumerable<char>;", true);
ExpressionStatement expr = ParseUtilCSharp.ParseStatement<ExpressionStatement>("\t\t\"\" as IEnumerable<char>;", false);
Assert.AreEqual(new TextLocation(1, 3), expr.StartLocation);
Assert.AreEqual(new TextLocation(1, 27), expr.EndLocation);
}

Loading…
Cancel
Save