Browse Source

[CSharp] Updated mcs.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
d29d429c22
  1. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  2. 13
      ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
  3. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  4. 8820
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  5. 16
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  6. 11
      ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs
  7. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
  8. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
  9. 12
      ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs
  10. 22
      ICSharpCode.NRefactory.CSharp/Parser/mcs/outline.cs
  11. 26
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  12. 25
      ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs

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

@ -1498,6 +1498,9 @@ namespace Mono.CSharp { @@ -1498,6 +1498,9 @@ namespace Mono.CSharp {
if (ec.HasSet (ResolveContext.Options.ExpressionTreeConversion))
flags |= ResolveContext.Options.ExpressionTreeConversion;
if (ec.HasSet (ResolveContext.Options.BaseInitializer))
flags |= ResolveContext.Options.BaseInitializer;
aec.Set (flags);
var errors = ec.Report.Errors;

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

@ -624,9 +624,16 @@ namespace Mono.CSharp @@ -624,9 +624,16 @@ namespace Mono.CSharp
new MemberAccess (system_security_permissions, "SecurityPermissionAttribute"),
new Arguments[] { pos, named }, loc, false);
g.AttachTo (module, module);
var ctor = g.Resolve ();
if (ctor != null) {
g.ExtractSecurityPermissionSet (ctor, ref declarative_security);
// Disable no-location warnings (e.g. obsolete) for compiler generated attribute
Compiler.Report.DisableReporting ();
try {
var ctor = g.Resolve ();
if (ctor != null) {
g.ExtractSecurityPermissionSet (ctor, ref declarative_security);
}
} finally {
Compiler.Report.EnableReporting ();
}
}

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

@ -351,7 +351,8 @@ namespace Mono.CSharp @@ -351,7 +351,8 @@ namespace Mono.CSharp
if (containers != null)
containers.Remove (cont);
defined_names.Remove (cont.Basename);
var tc = Parent == Module ? Module : this;
tc.defined_names.Remove (cont.Basename);
}
public virtual void VerifyMembers ()
@ -1928,7 +1929,7 @@ namespace Mono.CSharp @@ -1928,7 +1929,7 @@ namespace Mono.CSharp
continue;
//
// Don't be pendatic over serializable attributes
// Don't be pedantic when type requires specific layout
//
if (f.OptAttributes != null || PartialContainer.HasStructLayout)
continue;
@ -1940,10 +1941,6 @@ namespace Mono.CSharp @@ -1940,10 +1941,6 @@ namespace Mono.CSharp
} else if (TypeSpec.IsReferenceType (f.MemberType)) {
value = "null";
} else {
// Ignore this warning for struct value fields (they are always initialized)
if (f.MemberType.IsStruct)
continue;
value = null;
}

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

File diff suppressed because it is too large Load Diff

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

@ -10,12 +10,7 @@ @@ -10,12 +10,7 @@
//
// (C) 2001 Ximian, Inc (http://www.ximian.com)
// (C) 2004-2011 Novell, Inc
// Copyright 2011 Xamarin Inc.
//
// TODO:
// (1) Figure out why error productions dont work. `type-declaration' is a
// great spot to put an `error' because you can reproduce it with this input:
// "public X { }"
// Copyright 2011-2012 Xamarin Inc.
//
using System.Text;
@ -2669,6 +2664,7 @@ enum_member_declaration @@ -2669,6 +2664,7 @@ enum_member_declaration
$$ = em;
}
| attributes_without_members
;
delegate_declaration
@ -3196,6 +3192,14 @@ invocation_expression @@ -3196,6 +3192,14 @@ invocation_expression
$$ = new Invocation ((Expression) $1, (Arguments) $3);
lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4));
}
| primary_expression open_parens_any argument_list error
{
Error_SyntaxError (yyToken);
$$ = new Invocation ((Expression) $1, (Arguments) $3);
lbag.AddLocation ($$, GetLocation ($2));
}
;
opt_object_or_collection_initializer

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

@ -2974,7 +2974,7 @@ namespace Mono.CSharp { @@ -2974,7 +2974,7 @@ namespace Mono.CSharp {
"An object reference is required to access non-static member `{0}'",
GetSignatureForError ());
InstanceExpression = new CompilerGeneratedThis (type, loc).Resolve (rc);
InstanceExpression = new CompilerGeneratedThis (rc.CurrentType, loc).Resolve (rc);
return false;
}
@ -3452,6 +3452,15 @@ namespace Mono.CSharp { @@ -3452,6 +3452,15 @@ namespace Mono.CSharp {
public override MemberExpr ResolveMemberAccess (ResolveContext ec, Expression left, SimpleName original)
{
var fe = left as FieldExpr;
if (fe != null) {
//
// Using method-group on struct fields makes the struct assigned. I am not sure
// why but that's what .net does
//
fe.Spec.MemberDefinition.SetIsAssigned ();
}
simple_name = original;
return base.ResolveMemberAccess (ec, left, original);
}

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

@ -976,7 +976,9 @@ namespace Mono.CSharp @@ -976,7 +976,9 @@ namespace Mono.CSharp
static public string help {
get {
return "Static methods:\n" +
#if !NET_2_1
" Describe (object); - Describes the object's type\n" +
#endif
" LoadPackage (package); - Loads the given Package (like -pkg:FILE)\n" +
" LoadAssembly (assembly); - Loads the given assembly (like -r:ASSEMBLY)\n" +
" ShowVars (); - Shows defined local variables.\n" +

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

@ -1432,7 +1432,7 @@ namespace Mono.CSharp { @@ -1432,7 +1432,7 @@ namespace Mono.CSharp {
base_ctor = ConstructorLookup (ec, type, ref argument_list, loc);
}
if (base_ctor.MemberDefinition == caller_builder.Spec.MemberDefinition) {
if (base_ctor != null && base_ctor.MemberDefinition == caller_builder.Spec.MemberDefinition) {
ec.Report.Error (516, loc, "Constructor `{0}' cannot call itself",
caller_builder.GetSignatureForError ());
}
@ -1964,7 +1964,7 @@ namespace Mono.CSharp { @@ -1964,7 +1964,7 @@ namespace Mono.CSharp {
//
if ((flags & MethodAttributes.MemberAccessMask) != MethodAttributes.Public) {
implementing = null;
} else if (optional && (container.Interfaces == null || Array.IndexOf (container.Interfaces, implementing.DeclaringType) < 0)) {
} else if (optional && (container.Interfaces == null || !container.Definition.Interfaces.Contains (implementing.DeclaringType))) {
//
// We are not implementing interface when base class already implemented it
//

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

@ -1182,11 +1182,23 @@ namespace Mono.CSharp { @@ -1182,11 +1182,23 @@ namespace Mono.CSharp {
entry.Define (this);
//
// It's needed for repl only, when using clause cannot be resolved don't hold it in
// global list which is resolved for each evaluation
//
if (entry.ResolvedExpression == null) {
clauses.RemoveAt (i--);
continue;
}
Namespace using_ns = entry.ResolvedExpression as Namespace;
if (using_ns == null)
continue;
if (list.Contains (using_ns)) {
// Ensure we don't report the warning multiple times in repl
clauses.RemoveAt (i--);
Compiler.Report.Warning (105, 3, entry.Location,
"The using directive for `{0}' appeared previously in this namespace", using_ns.GetSignatureForError ());
} else {

22
ICSharpCode.NRefactory.CSharp/Parser/mcs/outline.cs

@ -29,6 +29,8 @@ @@ -29,6 +29,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !NET_2_1
using System;
using System.Reflection;
using System.Collections;
@ -88,9 +90,7 @@ public class Outline { @@ -88,9 +90,7 @@ public class Outline {
OutlineParams (method.GetParameters ());
o.Write (")");
#if NET_2_0
WriteGenericConstraints (t.GetGenericArguments ());
#endif
o.WriteLine (";");
return;
@ -119,9 +119,9 @@ public class Outline { @@ -119,9 +119,9 @@ public class Outline {
if (underlyingType != typeof (int))
o.Write (" : {0}", FormatType (underlyingType));
}
#if NET_2_0
WriteGenericConstraints (t.GetGenericArguments ());
#endif
o.WriteLine (" {");
o.Indent++;
@ -382,15 +382,11 @@ public class Outline { @@ -382,15 +382,11 @@ public class Outline {
}
o.Write (mi.Name);
#if NET_2_0
o.Write (FormatGenericParams (mi.GetGenericArguments ()));
#endif
o.Write (" (");
OutlineParams (mi.GetParameters ());
o.Write (")");
#if NET_2_0
WriteGenericConstraints (mi.GetGenericArguments ());
#endif
o.Write (";");
}
@ -549,7 +545,6 @@ public class Outline { @@ -549,7 +545,6 @@ public class Outline {
}
}
#if NET_2_0
string FormatGenericParams (Type [] args)
{
StringBuilder sb = new StringBuilder ();
@ -565,7 +560,6 @@ public class Outline { @@ -565,7 +560,6 @@ public class Outline {
sb.Append (">");
return sb.ToString ();
}
#endif
// TODO: fine tune this so that our output is less verbose. We need to figure
// out a way to do this while not making things confusing.
@ -665,9 +659,7 @@ public class Outline { @@ -665,9 +659,7 @@ public class Outline {
void GetTypeName (StringBuilder sb, Type t)
{
sb.Append (RemoveGenericArity (t.Name));
#if NET_2_0
sb.Append (FormatGenericParams (t.GetGenericArguments ()));
#endif
}
string GetFullName (Type t)
@ -679,12 +671,10 @@ public class Outline { @@ -679,12 +671,10 @@ public class Outline {
void GetFullName_recursed (StringBuilder sb, Type t, bool recursed)
{
#if NET_2_0
if (t.IsGenericParameter) {
sb.Append (t.Name);
return;
}
#endif
if (t.DeclaringType != null) {
GetFullName_recursed (sb, t.DeclaringType, true);
@ -702,7 +692,6 @@ public class Outline { @@ -702,7 +692,6 @@ public class Outline {
GetTypeName (sb, t);
}
#if NET_2_0
void WriteGenericConstraints (Type [] args)
{
@ -758,7 +747,6 @@ public class Outline { @@ -758,7 +747,6 @@ public class Outline {
}
}
}
#endif
string OperatorFromName (string name)
{
@ -1022,3 +1010,5 @@ public class Comparer : IComparer { @@ -1022,3 +1010,5 @@ public class Comparer : IComparer {
}
}
}
#endif

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

@ -4749,21 +4749,9 @@ namespace Mono.CSharp { @@ -4749,21 +4749,9 @@ namespace Mono.CSharp {
locked = false;
}
using (ec.Set (ResolveContext.Options.LockScope)) {
ec.StartFlowBranching (this);
Statement.Resolve (ec);
ec.EndFlowBranching ();
}
if (lv != null) {
lv.IsLockedByStatement = locked;
}
base.Resolve (ec);
//
// Have to keep original lock value around to unlock same location
// in the case the original has changed or is null
// in the case of original value has changed or is null
//
expr_copy = TemporaryVariableReference.Create (ec.BuiltinTypes.Object, ec.CurrentBlock, loc);
expr_copy.Resolve (ec);
@ -4776,6 +4764,18 @@ namespace Mono.CSharp { @@ -4776,6 +4764,18 @@ namespace Mono.CSharp {
lock_taken.Resolve (ec);
}
using (ec.Set (ResolveContext.Options.LockScope)) {
ec.StartFlowBranching (this);
Statement.Resolve (ec);
ec.EndFlowBranching ();
}
if (lv != null) {
lv.IsLockedByStatement = locked;
}
base.Resolve (ec);
return true;
}

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

@ -23,6 +23,9 @@ using System.Reflection; @@ -23,6 +23,9 @@ using System.Reflection;
namespace Mono.CSharp
{
//
// Inflated or non-inflated representation of any type.
//
public class TypeSpec : MemberSpec
{
protected MetaType info;
@ -306,6 +309,9 @@ namespace Mono.CSharp @@ -306,6 +309,9 @@ namespace Mono.CSharp
}
}
//
// A cache of all type members (including nested types)
//
public MemberCache MemberCache {
get {
if (cache == null || (state & StateFlags.PendingMemberCacheMembers) != 0)
@ -435,6 +441,9 @@ namespace Mono.CSharp @@ -435,6 +441,9 @@ namespace Mono.CSharp
return aua;
}
//
// Return metadata information used during emit to describe the type
//
public virtual MetaType GetMetaInfo ()
{
return info;
@ -445,6 +454,9 @@ namespace Mono.CSharp @@ -445,6 +454,9 @@ namespace Mono.CSharp
return this;
}
//
// Text representation of type used by documentation writer
//
public override string GetSignatureForDocumentation ()
{
StringBuilder sb = new StringBuilder ();
@ -651,6 +663,9 @@ namespace Mono.CSharp @@ -651,6 +663,9 @@ namespace Mono.CSharp
return new InflatedTypeSpec (inflator.Context, this, inflator.TypeInstance, targs);
}
//
// Inflates current type using specific type arguments
//
public InflatedTypeSpec MakeGenericType (IModuleContext context, TypeSpec[] targs)
{
if (targs.Length == 0 && !IsNested)
@ -753,6 +768,10 @@ namespace Mono.CSharp @@ -753,6 +768,10 @@ namespace Mono.CSharp
}
}
//
// Special version used for types which must exist in corlib or
// the compiler cannot work
//
public sealed class BuiltinTypeSpec : TypeSpec
{
public enum Type
@ -934,6 +953,9 @@ namespace Mono.CSharp @@ -934,6 +953,9 @@ namespace Mono.CSharp
}
}
//
// Various type comparers used by compiler
//
static class TypeSpecComparer
{
//
@ -1459,6 +1481,9 @@ namespace Mono.CSharp @@ -1459,6 +1481,9 @@ namespace Mono.CSharp
#endregion
}
//
// Common base class for composite types
//
public abstract class ElementTypeSpec : TypeSpec, ITypeDefinition
{
protected ElementTypeSpec (MemberKind kind, TypeSpec element, MetaType info)

Loading…
Cancel
Save