Browse Source

Updated mcs sources.

newNRvisualizers
Mike Krüger 15 years ago
parent
commit
48b696888c
  1. 17
      ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
  2. 23
      ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs
  3. 57
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  4. 24
      ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs
  5. 26
      ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs

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

@ -318,17 +318,16 @@ namespace Mono.CSharp
string assembly_name = a.GetString (); string assembly_name = a.GetString ();
if (assembly_name.Length == 0) if (assembly_name.Length == 0)
return; return;
#if STATIC
AssemblyName aname = null; ParsedAssemblyName aname;
try { ParseAssemblyResult r = Fusion.ParseAssemblyName (assembly_name, out aname);
aname = new AssemblyName (assembly_name); if (r != ParseAssemblyResult.OK) {
} catch (Exception) {
Report.Warning (1700, 3, a.Location, "Assembly reference `{0}' is invalid and cannot be resolved", Report.Warning (1700, 3, a.Location, "Assembly reference `{0}' is invalid and cannot be resolved",
assembly_name); assembly_name);
return; return;
} }
if (aname.Version != null || aname.CultureInfo != null || aname.ProcessorArchitecture != ProcessorArchitecture.None) { if (aname.Version != null || aname.Culture != null || aname.ProcessorArchitecture != ProcessorArchitecture.None) {
Report.Error (1725, a.Location, Report.Error (1725, a.Location,
"Friend assembly reference `{0}' is invalid. InternalsVisibleTo declarations cannot have a version, culture or processor architecture specified", "Friend assembly reference `{0}' is invalid. InternalsVisibleTo declarations cannot have a version, culture or processor architecture specified",
assembly_name); assembly_name);
@ -336,13 +335,13 @@ namespace Mono.CSharp
return; return;
} }
// TODO: GetPublicKey () does not work on .NET when AssemblyName is constructed from a string if (public_key != null && !aname.HasPublicKey) {
if (public_key != null && aname.GetPublicKey () == null) {
Report.Error (1726, a.Location, Report.Error (1726, a.Location,
"Friend assembly reference `{0}' is invalid. Strong named assemblies must specify a public key in their InternalsVisibleTo declarations", "Friend assembly reference `{0}' is invalid. Strong named assemblies must specify a public key in their InternalsVisibleTo declarations",
assembly_name); assembly_name);
return; return;
} }
#endif
} else if (a.Type == pa.RuntimeCompatibility) { } else if (a.Type == pa.RuntimeCompatibility) {
wrap_non_exception_throws_custom = true; wrap_non_exception_throws_custom = true;
} else if (a.Type == pa.AssemblyFileVersion) { } else if (a.Type == pa.AssemblyFileVersion) {
@ -827,7 +826,7 @@ namespace Mono.CSharp
Compiler.TimeReporter.Stop (TimeReporter.TimerType.OutputSave); Compiler.TimeReporter.Stop (TimeReporter.TimerType.OutputSave);
// Save debug symbols file // Save debug symbols file
if (symbol_writer != null) { if (symbol_writer != null && Compiler.Report.Errors == 0) {
// TODO: it should run in parallel // TODO: it should run in parallel
Compiler.TimeReporter.Start (TimeReporter.TimerType.DebugSave); Compiler.TimeReporter.Start (TimeReporter.TimerType.DebugSave);
symbol_writer.WriteSymbolFile (SymbolWriter.GetGuid (module.Builder)); symbol_writer.WriteSymbolFile (SymbolWriter.GetGuid (module.Builder));

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

@ -3264,7 +3264,7 @@ namespace Mono.CSharp {
return LowerBoundInference (u_ac.Element, v_i); return LowerBoundInference (u_ac.Element, v_i);
} }
if (TypeManager.IsGenericType (v)) { if (v.IsGenericOrParentIsGeneric) {
// //
// if V is a constructed type C<V1..Vk> and there is a unique type C<U1..Uk> // if V is a constructed type C<V1..Vk> and there is a unique type C<U1..Uk>
// such that U is identical to, inherits from (directly or indirectly), // such that U is identical to, inherits from (directly or indirectly),
@ -3293,7 +3293,7 @@ namespace Mono.CSharp {
} }
TypeSpec[] unique_candidate_targs = null; TypeSpec[] unique_candidate_targs = null;
TypeSpec[] ga_v = TypeManager.GetTypeArguments (v); var ga_v = TypeSpec.GetAllTypeArguments (v);
foreach (TypeSpec u_candidate in u_candidates) { foreach (TypeSpec u_candidate in u_candidates) {
// //
// The unique set of types U1..Uk means that if we have an interface I<T>, // The unique set of types U1..Uk means that if we have an interface I<T>,
@ -3301,7 +3301,7 @@ namespace Mono.CSharp {
// type I<T> by applying type U because T could be int or long // type I<T> by applying type U because T could be int or long
// //
if (unique_candidate_targs != null) { if (unique_candidate_targs != null) {
TypeSpec[] second_unique_candidate_targs = TypeManager.GetTypeArguments (u_candidate); TypeSpec[] second_unique_candidate_targs = TypeSpec.GetAllTypeArguments (u_candidate);
if (TypeSpecComparer.Equals (unique_candidate_targs, second_unique_candidate_targs)) { if (TypeSpecComparer.Equals (unique_candidate_targs, second_unique_candidate_targs)) {
unique_candidate_targs = second_unique_candidate_targs; unique_candidate_targs = second_unique_candidate_targs;
continue; continue;
@ -3327,15 +3327,25 @@ namespace Mono.CSharp {
for (int i = 0; i < unique_candidate_targs.Length; ++i) for (int i = 0; i < unique_candidate_targs.Length; ++i)
unique_candidate_targs[i] = u_candidate; unique_candidate_targs[i] = u_candidate;
} else { } else {
unique_candidate_targs = TypeManager.GetTypeArguments (u_candidate); unique_candidate_targs = TypeSpec.GetAllTypeArguments (u_candidate);
} }
} }
if (unique_candidate_targs != null) { if (unique_candidate_targs != null) {
var ga_open_v = open_v.TypeParameters;
int score = 0; int score = 0;
int tp_index = -1;
TypeParameterSpec[] tps = null;
for (int i = 0; i < unique_candidate_targs.Length; ++i) { for (int i = 0; i < unique_candidate_targs.Length; ++i) {
Variance variance = ga_open_v [i].Variance; if (tp_index < 0) {
while (v.Arity == 0)
v = v.DeclaringType;
tps = v.MemberDefinition.TypeParameters;
tp_index = tps.Length - 1;
}
Variance variance = tps [tp_index--].Variance;
TypeSpec u_i = unique_candidate_targs [i]; TypeSpec u_i = unique_candidate_targs [i];
if (variance == Variance.None || TypeSpec.IsValueType (u_i)) { if (variance == Variance.None || TypeSpec.IsValueType (u_i)) {
@ -3349,6 +3359,7 @@ namespace Mono.CSharp {
++score; ++score;
} }
} }
return score; return score;
} }
} }

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

@ -667,6 +667,32 @@ namespace Mono.CSharp {
} }
} }
public class StatementErrorExpression : Statement
{
readonly Expression expr;
public StatementErrorExpression (Expression expr)
{
this.expr = expr;
}
public Expression Expression {
get {
return expr;
}
}
protected override void DoEmit (EmitContext ec)
{
throw new NotSupportedException ();
}
protected override void CloneTo (CloneContext clonectx, Statement target)
{
throw new NotImplementedException ();
}
}
// //
// Simple version of statement list not requiring a block // Simple version of statement list not requiring a block
// //
@ -6161,35 +6187,4 @@ namespace Mono.CSharp {
return visitor.Visit (this); return visitor.Visit (this);
} }
} }
public class StatementErrorExpression : Statement
{
readonly Expression expr;
public Expression Expression {
get {
return expr;
}
}
public StatementErrorExpression (Expression expr)
{
this.expr = expr;
}
protected override void DoEmit (EmitContext ec)
{
throw new NotImplementedException ();
}
protected override void CloneTo (CloneContext clonectx, Statement target)
{
throw new NotImplementedException ();
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
} }

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

@ -390,6 +390,30 @@ namespace Mono.CSharp
return true; return true;
} }
//
// Returns all type arguments, usefull for nested types
//
public static TypeSpec[] GetAllTypeArguments (TypeSpec type)
{
IList<TypeSpec> targs = TypeSpec.EmptyTypes;
do {
if (type.Arity > 0) {
if (targs.Count == 0) {
targs = type.TypeArguments;
} else {
var list = targs as List<TypeSpec> ?? new List<TypeSpec> (targs);
list.AddRange (type.TypeArguments);
targs = list;
}
}
type = type.declaringType;
} while (type != null);
return targs as TypeSpec[] ?? ((List<TypeSpec>) targs).ToArray ();
}
public AttributeUsageAttribute GetAttributeUsage (PredefinedAttribute pa) public AttributeUsageAttribute GetAttributeUsage (PredefinedAttribute pa)
{ {
if (Kind != MemberKind.Class) if (Kind != MemberKind.Class)

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

@ -7,6 +7,7 @@
// Dual licensed under the terms of the MIT X11 or GNU GPL // Dual licensed under the terms of the MIT X11 or GNU GPL
// //
// Copyright (c) 2010 Novell, Inc (http://www.novell.com) // Copyright (c) 2010 Novell, Inc (http://www.novell.com)
// Copyright 2011 Xamarin Inc
// //
using System; using System;
@ -200,73 +201,66 @@ namespace Mono.CSharp
return null; return null;
} }
public virtual object Visit (While whileStatement) public virtual object Visit (While whileStatement)
{ {
return null; return null;
} }
public virtual object Visit (For forStatement) public virtual object Visit (For forStatement)
{ {
return null; return null;
} }
public virtual object Visit (StatementExpression statementExpression) public virtual object Visit (StatementExpression statementExpression)
{ {
return null; return null;
} }
public virtual object Visit (StatementErrorExpression errorStatement)
{
return null;
}
public virtual object Visit (Return returnStatement) public virtual object Visit (Return returnStatement)
{ {
return null; return null;
} }
public virtual object Visit (Goto gotoStatement) public virtual object Visit (Goto gotoStatement)
{ {
return null; return null;
} }
public virtual object Visit (LabeledStatement labeledStatement) public virtual object Visit (LabeledStatement labeledStatement)
{ {
return null; return null;
} }
public virtual object Visit (GotoDefault gotoDefault) public virtual object Visit (GotoDefault gotoDefault)
{ {
return null; return null;
} }
public virtual object Visit (GotoCase gotoCase) public virtual object Visit (GotoCase gotoCase)
{ {
return null; return null;
} }
public virtual object Visit (Throw throwStatement) public virtual object Visit (Throw throwStatement)
{ {
return null; return null;
} }
public virtual object Visit (Break breakStatement) public virtual object Visit (Break breakStatement)
{ {
return null; return null;
} }
public virtual object Visit (Continue continueStatement) public virtual object Visit (Continue continueStatement)
{ {
return null; return null;
} }
public virtual object Visit (Block blockStatement) public virtual object Visit (Block blockStatement)
{ {
return null; return null;
@ -287,19 +281,16 @@ namespace Mono.CSharp
return null; return null;
} }
public virtual object Visit (Unchecked uncheckedStatement) public virtual object Visit (Unchecked uncheckedStatement)
{ {
return null; return null;
} }
public virtual object Visit (Checked checkedStatement) public virtual object Visit (Checked checkedStatement)
{ {
return null; return null;
} }
public virtual object Visit (Unsafe unsafeStatement) public virtual object Visit (Unsafe unsafeStatement)
{ {
return null; return null;
@ -317,7 +308,6 @@ namespace Mono.CSharp
return null; return null;
} }
public virtual object Visit (TryCatch tryCatchStatement) public virtual object Visit (TryCatch tryCatchStatement)
{ {
return null; return null;
@ -445,7 +435,6 @@ namespace Mono.CSharp
return null; return null;
} }
public virtual object Visit (Conditional conditionalExpression) public virtual object Visit (Conditional conditionalExpression)
{ {
return null; return null;
@ -646,10 +635,5 @@ namespace Mono.CSharp
{ {
return null; return null;
} }
public virtual object Visit (StatementErrorExpression statementErrorExpression)
{
return null;
}
} }
} }
Loading…
Cancel
Save