Browse Source

Revert "Updated mcs."

This reverts commit 19c344c55c.
newNRvisualizers
Mike Krüger 14 years ago
parent
commit
e9903adbf9
  1. 30
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  2. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  3. 11
      ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
  4. 13
      ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs
  5. 6
      ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs
  6. 103
      ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs
  7. 20
      ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  8. 9902
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  9. 168
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  10. 7
      ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs
  11. 7
      ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs
  12. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs
  13. 5
      ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs
  14. 14
      ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
  15. 256
      ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs
  16. 24
      ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs
  17. 8
      ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs
  18. 7
      ICSharpCode.NRefactory.CSharp/Parser/mcs/lambda.cs
  19. 26
      ICSharpCode.NRefactory.CSharp/Parser/mcs/linq.cs
  20. 70
      ICSharpCode.NRefactory.CSharp/Parser/mcs/literal.cs
  21. 39
      ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
  22. 568
      ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs
  23. 20
      ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs
  24. 19
      ICSharpCode.NRefactory.CSharp/Parser/mcs/parameter.cs
  25. 56
      ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs
  26. 14
      ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs
  27. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/roottypes.cs
  28. 215
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  29. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs

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

@ -208,8 +208,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -208,8 +208,8 @@ namespace ICSharpCode.NRefactory.CSharp
if (loc != null)
result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.LPar);
if (attr.PositionalArguments != null) {
foreach (var arg in attr.PositionalArguments) {
if (attr.PosArguments != null) {
foreach (var arg in attr.PosArguments) {
var na = arg as NamedArgument;
if (na != null) {
var newArg = new NamedArgumentExpression ();
@ -1465,7 +1465,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1465,7 +1465,7 @@ namespace ICSharpCode.NRefactory.CSharp
public override object Visit (StatementErrorExpression statementErrorExpression)
{
var result = new ExpressionStatement ();
var expr = statementErrorExpression.Expr.Accept (this) as Expression;
var expr = statementErrorExpression.Expression.Accept (this) as Expression;
if (expr != null)
result.AddChild ((Expression)expr, ExpressionStatement.Roles.Expression);
return result;
@ -1849,14 +1849,14 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1849,14 +1849,14 @@ namespace ICSharpCode.NRefactory.CSharp
result.AddChild (new CSharpTokenNode (Convert (tryCatchStatement.loc), "try".Length), TryCatchStatement.TryKeywordRole);
if (tryCatchStatement.Block != null)
result.AddChild ((BlockStatement)tryCatchStatement.Block.Accept (this), TryCatchStatement.TryBlockRole);
if (tryCatchStatement.Clauses != null) {
foreach (Catch ctch in tryCatchStatement.Clauses) {
if (tryCatchStatement.Specific != null) {
foreach (Catch ctch in tryCatchStatement.Specific) {
result.AddChild (ConvertCatch (ctch), TryCatchStatement.CatchClauseRole);
}
}
/* if (tryCatchStatement. != null)
if (tryCatchStatement.General != null)
result.AddChild (ConvertCatch (tryCatchStatement.General), TryCatchStatement.CatchClauseRole);
*/
return result;
}
@ -1868,8 +1868,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1868,8 +1868,8 @@ namespace ICSharpCode.NRefactory.CSharp
result.AddChild (new CSharpTokenNode (Convert (usingStatement.loc), "using".Length), UsingStatement.Roles.Keyword);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), UsingStatement.Roles.LPar);
if (usingStatement.Expr != null)
result.AddChild ((AstNode)usingStatement.Expr.Accept (this), UsingStatement.ResourceAcquisitionRole);
if (usingStatement.Expression != null)
result.AddChild ((AstNode)usingStatement.Expression.Accept (this), UsingStatement.ResourceAcquisitionRole);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), UsingStatement.Roles.RPar);
@ -1889,8 +1889,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1889,8 +1889,8 @@ namespace ICSharpCode.NRefactory.CSharp
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ForeachStatement.Roles.LPar);
if (foreachStatement.TypeExpression != null)
result.AddChild (ConvertToType (foreachStatement.TypeExpression), ForeachStatement.Roles.Type);
if (foreachStatement.TypeExpr != null)
result.AddChild (ConvertToType (foreachStatement.TypeExpr), ForeachStatement.Roles.Type);
if (foreachStatement.Variable != null)
result.AddChild (Identifier.Create (foreachStatement.Variable.Name, Convert (foreachStatement.Variable.Location)), ForeachStatement.Roles.Identifier);
@ -2260,7 +2260,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2260,7 +2260,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
var result = new BinaryOperatorExpression ();
result.Operator = BinaryOperatorType.NullCoalescing;
result.AddChild ((Expression)nullCoalescingOperator.LeftExpression.Accept (this), BinaryOperatorExpression.LeftRole);
result.AddChild ((Expression)nullCoalescingOperator.Left.Accept (this), BinaryOperatorExpression.LeftRole);
result.AddChild (new CSharpTokenNode (Convert (nullCoalescingOperator.Location), 2), BinaryOperatorExpression.OperatorRole);
result.AddChild ((Expression)nullCoalescingOperator.Right.Accept (this), BinaryOperatorExpression.RightRole);
return result;
@ -2489,8 +2489,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2489,8 +2489,8 @@ namespace ICSharpCode.NRefactory.CSharp
{
var result = new InvocationExpression ();
var location = LocationsBag.GetLocations (invocationExpression);
if (invocationExpression.Exp != null)
result.AddChild ((Expression)invocationExpression.Exp.Accept (this), InvocationExpression.Roles.TargetExpression);
if (invocationExpression.Expression != null)
result.AddChild ((Expression)invocationExpression.Expression.Accept (this), InvocationExpression.Roles.TargetExpression);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), InvocationExpression.Roles.LPar);
AddArguments (result, location, invocationExpression.Arguments);
@ -2796,7 +2796,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2796,7 +2796,7 @@ namespace ICSharpCode.NRefactory.CSharp
result.AddChild (new CSharpTokenNode (Convert (sizeOfExpression.Location), "sizeof".Length), TypeOfExpression.Roles.Keyword);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar);
result.AddChild (ConvertToType (sizeOfExpression.TypeExpression), TypeOfExpression.Roles.Type);
result.AddChild (ConvertToType (sizeOfExpression.QueriedType), TypeOfExpression.Roles.Type);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar);
return result;

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

@ -885,8 +885,9 @@ namespace Mono.CSharp { @@ -885,8 +885,9 @@ namespace Mono.CSharp {
public ParametersBlock Block;
public AnonymousMethodExpression (Location loc)
public AnonymousMethodExpression (bool isAsync, Location loc)
{
this.IsAsync = isAsync;
this.loc = loc;
this.compatibles = new Dictionary<TypeSpec, Expression> ();
}

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

@ -1090,7 +1090,8 @@ namespace Mono.CSharp @@ -1090,7 +1090,8 @@ namespace Mono.CSharp
public abstract bool HasObjectType (T assembly);
protected abstract string[] GetDefaultReferences ();
public abstract T LoadAssemblyFile (string fileName, bool isImplicitReference);
public abstract T LoadAssemblyFile (string fileName);
public abstract T LoadAssemblyDefault (string assembly);
public abstract void LoadReferences (ModuleContainer module);
protected void Error_FileNotFound (string fileName)
@ -1127,14 +1128,14 @@ namespace Mono.CSharp @@ -1127,14 +1128,14 @@ namespace Mono.CSharp
// Load mscorlib.dll as the first
//
if (module.Compiler.Settings.StdLib) {
corlib_assembly = LoadAssemblyFile ("mscorlib.dll", true);
corlib_assembly = LoadAssemblyDefault ("mscorlib.dll");
} else {
corlib_assembly = default (T);
}
T a;
foreach (string r in module.Compiler.Settings.AssemblyReferences) {
a = LoadAssemblyFile (r, false);
a = LoadAssemblyFile (r);
if (a == null || EqualityComparer<T>.Default.Equals (a, corlib_assembly))
continue;
@ -1152,7 +1153,7 @@ namespace Mono.CSharp @@ -1152,7 +1153,7 @@ namespace Mono.CSharp
}
foreach (var entry in module.Compiler.Settings.AssemblyReferencesAliases) {
a = LoadAssemblyFile (entry.Item2, false);
a = LoadAssemblyFile (entry.Item2);
if (a == null)
continue;
@ -1165,7 +1166,7 @@ namespace Mono.CSharp @@ -1165,7 +1166,7 @@ namespace Mono.CSharp
if (compiler.Settings.LoadDefaultReferences) {
foreach (string r in GetDefaultReferences ()) {
a = LoadAssemblyFile (r, true);
a = LoadAssemblyDefault (r);
if (a == null)
continue;

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

@ -418,11 +418,6 @@ namespace Mono.CSharp { @@ -418,11 +418,6 @@ namespace Mono.CSharp {
_target.target = target.Clone (clonectx);
_target.source = source.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class SimpleAssign : Assign
@ -658,12 +653,6 @@ namespace Mono.CSharp { @@ -658,12 +653,6 @@ namespace Mono.CSharp {
this.left = left;
}
public Binary.Operator Operator {
get {
return op;
}
}
protected override Expression DoResolve (ResolveContext ec)
{
right = right.Resolve (ec);
@ -822,10 +811,10 @@ namespace Mono.CSharp { @@ -822,10 +811,10 @@ namespace Mono.CSharp {
ctarget.right = ctarget.source = source.Clone (clonectx);
ctarget.target = target.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
}

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

@ -40,12 +40,6 @@ namespace Mono.CSharp @@ -40,12 +40,6 @@ namespace Mono.CSharp
this.loc = loc;
}
public Expression Expr {
get {
return expr;
}
}
protected override void CloneTo (CloneContext clonectx, Expression target)
{
var t = (Await) target;

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

@ -89,7 +89,8 @@ namespace Mono.CSharp { @@ -89,7 +89,8 @@ namespace Mono.CSharp {
public AttributeTargets Target;
readonly ATypeNameExpression expression;
Arguments pos_args, named_args;
public Arguments PosArguments;
public Arguments NamedArguments;
bool resolve_error;
bool arg_resolved;
@ -117,8 +118,8 @@ namespace Mono.CSharp { @@ -117,8 +118,8 @@ namespace Mono.CSharp {
{
this.expression = expr;
if (args != null) {
pos_args = args[0];
named_args = args[1];
PosArguments = args[0];
NamedArguments = args[1];
}
this.loc = loc;
ExplicitTarget = target;
@ -131,24 +132,6 @@ namespace Mono.CSharp { @@ -131,24 +132,6 @@ namespace Mono.CSharp {
}
}
public Arguments NamedArguments {
get {
return named_args;
}
}
public Arguments PositionalArguments {
get {
return pos_args;
}
}
public ATypeNameExpression TypeExpression {
get {
return expression;
}
}
void AddModuleCharSet (ResolveContext rc)
{
const string dll_import_char_set = "CharSet";
@ -164,7 +147,7 @@ namespace Mono.CSharp { @@ -164,7 +147,7 @@ namespace Mono.CSharp {
}
if (NamedArguments == null)
named_args = new Arguments (1);
NamedArguments = new Arguments (1);
var value = Constant.CreateConstant (rc.Module.PredefinedTypes.CharSet.TypeSpec, rc.Module.DefaultCharSet, Location);
NamedArguments.Add (new NamedArgument (dll_import_char_set, loc, value));
@ -173,8 +156,8 @@ namespace Mono.CSharp { @@ -173,8 +156,8 @@ namespace Mono.CSharp {
public Attribute Clone ()
{
Attribute a = new Attribute (ExplicitTarget, expression, null, loc, nameEscaped);
a.pos_args = pos_args;
a.named_args = NamedArguments;
a.PosArguments = PosArguments;
a.NamedArguments = NamedArguments;
return a;
}
@ -449,14 +432,14 @@ namespace Mono.CSharp { @@ -449,14 +432,14 @@ namespace Mono.CSharp {
MethodSpec ctor;
// Try if the attribute is simple and has been resolved before
if (pos_args != null || !context.Module.AttributeConstructorCache.TryGetValue (Type, out ctor)) {
if (PosArguments != null || !context.Module.AttributeConstructorCache.TryGetValue (Type, out ctor)) {
rc = CreateResolveContext ();
ctor = ResolveConstructor (rc);
if (ctor == null) {
return null;
}
if (pos_args == null && ctor.Parameters.IsEmpty)
if (PosArguments == null && ctor.Parameters.IsEmpty)
context.Module.AttributeConstructorCache.Add (Type, ctor);
}
@ -485,16 +468,16 @@ namespace Mono.CSharp { @@ -485,16 +468,16 @@ namespace Mono.CSharp {
MethodSpec ResolveConstructor (ResolveContext ec)
{
if (pos_args != null) {
if (PosArguments != null) {
bool dynamic;
pos_args.Resolve (ec, out dynamic);
PosArguments.Resolve (ec, out dynamic);
if (dynamic) {
Error_AttributeArgumentIsDynamic (ec.MemberContext, loc);
return null;
}
}
return Expression.ConstructorLookup (ec, Type, ref pos_args, loc);
return Expression.ConstructorLookup (ec, Type, ref PosArguments, loc);
}
bool ResolveNamedArguments (ResolveContext ec)
@ -654,7 +637,7 @@ namespace Mono.CSharp { @@ -654,7 +637,7 @@ namespace Mono.CSharp {
if (resolve_error)
return DefaultUsageAttribute;
AttributeUsageAttribute usage_attribute = new AttributeUsageAttribute ((AttributeTargets) ((Constant) pos_args[0].Expr).GetValue ());
AttributeUsageAttribute usage_attribute = new AttributeUsageAttribute ((AttributeTargets)((Constant) PosArguments [0].Expr).GetValue ());
var field = GetNamedValue ("AllowMultiple") as BoolConstant;
if (field != null)
@ -677,10 +660,10 @@ namespace Mono.CSharp { @@ -677,10 +660,10 @@ namespace Mono.CSharp {
// But because a lot of attribute class code must be rewritten will be better to wait...
Resolve ();
if (resolve_error || pos_args.Count != 1 || !(pos_args[0].Expr is Constant))
if (resolve_error || PosArguments.Count != 1 || !(PosArguments [0].Expr is Constant))
return null;
return ((Constant) pos_args[0].Expr).GetValue () as string;
return ((Constant) PosArguments [0].Expr).GetValue () as string;
}
/// <summary>
@ -696,7 +679,7 @@ namespace Mono.CSharp { @@ -696,7 +679,7 @@ namespace Mono.CSharp {
if (resolve_error)
return null;
return ((Constant) pos_args[0].Expr).GetValue () as string;
return ((Constant) PosArguments[0].Expr).GetValue () as string;
}
/// <summary>
@ -718,14 +701,14 @@ namespace Mono.CSharp { @@ -718,14 +701,14 @@ namespace Mono.CSharp {
if (resolve_error)
return null;
if (pos_args == null)
if (PosArguments == null)
return new ObsoleteAttribute ();
string msg = ((Constant) pos_args[0].Expr).GetValue () as string;
if (pos_args.Count == 1)
string msg = ((Constant) PosArguments[0].Expr).GetValue () as string;
if (PosArguments.Count == 1)
return new ObsoleteAttribute (msg);
return new ObsoleteAttribute (msg, ((BoolConstant) pos_args[1].Expr).Value);
return new ObsoleteAttribute (msg, ((BoolConstant) PosArguments[1].Expr).Value);
}
/// <summary>
@ -743,7 +726,7 @@ namespace Mono.CSharp { @@ -743,7 +726,7 @@ namespace Mono.CSharp {
if (resolve_error)
return false;
return ((BoolConstant) pos_args[0].Expr).Value;
return ((BoolConstant) PosArguments[0].Expr).Value;
}
public TypeSpec GetCoClassAttributeValue ()
@ -829,7 +812,7 @@ namespace Mono.CSharp { @@ -829,7 +812,7 @@ namespace Mono.CSharp {
System.Security.Permissions.SecurityAction GetSecurityActionValue ()
{
return (SecurityAction) ((Constant) pos_args[0].Expr).GetValue ();
return (SecurityAction) ((Constant) PosArguments[0].Expr).GetValue ();
}
/// <summary>
@ -839,9 +822,9 @@ namespace Mono.CSharp { @@ -839,9 +822,9 @@ namespace Mono.CSharp {
public void ExtractSecurityPermissionSet (MethodSpec ctor, ref SecurityType permissions)
{
#if STATIC
object[] values = new object[pos_args.Count];
object[] values = new object [PosArguments.Count];
for (int i = 0; i < values.Length; ++i)
values[i] = ((Constant) pos_args[i].Expr).GetValue ();
values [i] = ((Constant) PosArguments [i].Expr).GetValue ();
PropertyInfo[] prop;
object[] prop_values;
@ -882,7 +865,7 @@ namespace Mono.CSharp { @@ -882,7 +865,7 @@ namespace Mono.CSharp {
public CharSet GetCharSetValue ()
{
return (CharSet) System.Enum.Parse (typeof (CharSet), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
return (CharSet)System.Enum.Parse (typeof (CharSet), ((Constant) PosArguments [0].Expr).GetValue ().ToString ());
}
public bool HasField (string fieldName)
@ -904,8 +887,8 @@ namespace Mono.CSharp { @@ -904,8 +887,8 @@ namespace Mono.CSharp {
public bool IsInternalCall ()
{
MethodImplOptions options = 0;
if (pos_args.Count == 1) {
options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
if (PosArguments.Count == 1) {
options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), ((Constant) PosArguments[0].Expr).GetValue ().ToString ());
} else if (HasField ("Value")) {
var named = GetNamedValue ("Value");
options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), named.GetValue ().ToString ());
@ -919,19 +902,19 @@ namespace Mono.CSharp { @@ -919,19 +902,19 @@ namespace Mono.CSharp {
//
public bool IsExplicitLayoutKind ()
{
if (pos_args == null || pos_args.Count != 1)
if (PosArguments == null || PosArguments.Count != 1)
return false;
var value = (LayoutKind) System.Enum.Parse (typeof (LayoutKind), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
var value = (LayoutKind) System.Enum.Parse (typeof (LayoutKind), ((Constant) PosArguments[0].Expr).GetValue ().ToString ());
return value == LayoutKind.Explicit;
}
public Expression GetParameterDefaultValue ()
{
if (pos_args == null)
if (PosArguments == null)
return null;
return pos_args[0].Expr;
return PosArguments[0].Expr;
}
public override bool Equals (object obj)
@ -968,16 +951,16 @@ namespace Mono.CSharp { @@ -968,16 +951,16 @@ namespace Mono.CSharp {
}
byte[] cdata;
if (pos_args == null && named_values == null) {
if (PosArguments == null && named_values == null) {
cdata = AttributeEncoder.Empty;
} else {
AttributeEncoder encoder = new AttributeEncoder ();
if (pos_args != null) {
if (PosArguments != null) {
var param_types = ctor.Parameters.Types;
for (int j = 0; j < pos_args.Count; ++j) {
for (int j = 0; j < PosArguments.Count; ++j) {
var pt = param_types[j];
var arg_expr = pos_args[j].Expr;
var arg_expr = PosArguments[j].Expr;
if (j == 0) {
if ((Type == predefined.IndexerName || Type == predefined.Conditional) && arg_expr is Constant) {
string v = ((Constant) arg_expr).GetValue () as string;
@ -1001,15 +984,15 @@ namespace Mono.CSharp { @@ -1001,15 +984,15 @@ namespace Mono.CSharp {
"System.AttributeUsage");
}
} else if (Type == predefined.MarshalAs) {
if (pos_args.Count == 1) {
var u_type = (UnmanagedType) System.Enum.Parse (typeof (UnmanagedType), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
if (PosArguments.Count == 1) {
var u_type = (UnmanagedType) System.Enum.Parse (typeof (UnmanagedType), ((Constant) PosArguments[0].Expr).GetValue ().ToString ());
if (u_type == UnmanagedType.ByValArray && !(Owner is FieldBase)) {
Error_AttributeEmitError ("Specified unmanaged type is only valid on fields");
}
}
} else if (Type == predefined.DllImport) {
if (pos_args.Count == 1 && pos_args[0].Expr is Constant) {
var value = ((Constant) pos_args[0].Expr).GetValue () as string;
if (PosArguments.Count == 1 && PosArguments[0].Expr is Constant) {
var value = ((Constant) PosArguments[0].Expr).GetValue () as string;
if (string.IsNullOrEmpty (value))
Error_AttributeEmitError ("DllName cannot be empty");
}
@ -1072,8 +1055,8 @@ namespace Mono.CSharp { @@ -1072,8 +1055,8 @@ namespace Mono.CSharp {
// Here we are testing attribute arguments for array usage (error 3016)
if (Owner.IsClsComplianceRequired ()) {
if (pos_args != null)
pos_args.CheckArrayAsAttribute (context.Module.Compiler);
if (PosArguments != null)
PosArguments.CheckArrayAsAttribute (context.Module.Compiler);
if (NamedArguments == null)
return;
@ -1084,10 +1067,10 @@ namespace Mono.CSharp { @@ -1084,10 +1067,10 @@ namespace Mono.CSharp {
private Expression GetValue ()
{
if (pos_args == null || pos_args.Count < 1)
if (PosArguments == null || PosArguments.Count < 1)
return null;
return pos_args[0].Expr;
return PosArguments [0].Expr;
}
public string GetString ()

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

@ -201,7 +201,7 @@ namespace Mono.CSharp @@ -201,7 +201,7 @@ namespace Mono.CSharp
// from classes from the arraylist `type_bases'
//
protected TypeSpec base_type;
FullNamedExpression base_type_expr; // TODO: It's temporary variable
protected FullNamedExpression base_type_expr; // TODO: It's temporary variable
protected TypeSpec[] iface_exprs;
protected List<FullNamedExpression> type_bases;
@ -256,12 +256,6 @@ namespace Mono.CSharp @@ -256,12 +256,6 @@ namespace Mono.CSharp
#region Properties
public List<FullNamedExpression> BaseTypeExpressions {
get {
return type_bases;
}
}
public override TypeSpec CurrentType {
get {
if (current_type == null) {
@ -338,7 +332,7 @@ namespace Mono.CSharp @@ -338,7 +332,7 @@ namespace Mono.CSharp
{
visitor.Visit (this);
}
public bool AddMember (MemberCore symbol)
{
return AddToContainer (symbol, symbol.MemberName.Basename);
@ -1372,13 +1366,9 @@ namespace Mono.CSharp @@ -1372,13 +1366,9 @@ namespace Mono.CSharp
type_defined = true;
// Nested type share same namespace
if (IsTopLevel && !IsCompilerGenerated) {
NamespaceEntry.Define ();
if (partial_parts != null) {
foreach (var part in partial_parts)
part.NamespaceEntry.Define ();
}
// TODO: Driver resolves only first level of namespace, do the rest here for now
if (IsTopLevel && (ModFlags & Modifiers.COMPILER_GENERATED) == 0) {
NamespaceEntry.Resolve ();
}
if (!DefineBaseTypes ()) {

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

File diff suppressed because it is too large Load Diff

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

@ -428,26 +428,19 @@ extern_alias_directive @@ -428,26 +428,19 @@ extern_alias_directive
{
var lt = (Tokenizer.LocatedToken) $2;
string s = lt.Value;
if (s != "alias") {
if (s != "alias"){
syntax_error (lt.Location, "`alias' expected");
} else if (lang_version == LanguageVersion.ISO_1) {
FeatureIsNotAvailable (lt.Location, "external alias");
} else {
if (lang_version == LanguageVersion.ISO_1)
FeatureIsNotAvailable (lt.Location, "external alias");
lt = (Tokenizer.LocatedToken) $3;
if (lt.Value == QualifiedAliasMember.GlobalAlias) {
RootNamespace.Error_GlobalNamespaceRedefined (report, lt.Location);
}
var na = new UsingExternAlias (new MemberName (lt.Value, lt.Location), GetLocation ($1));
current_namespace.AddUsing (na);
lbag.AddLocation (na, GetLocation ($2), GetLocation ($4));
lt = (Tokenizer.LocatedToken) $3;
current_namespace.AddUsingExternalAlias (lt.Value, lt.Location, report);
ubag.AddExternAlias (GetLocation ($1), GetLocation ($2), lt, GetLocation ($4));
}
}
| EXTERN_ALIAS error
{
Error_SyntaxError (yyToken);
syntax_error (GetLocation ($1), "`alias' expected"); // TODO: better
}
;
@ -457,22 +450,20 @@ using_directives @@ -457,22 +450,20 @@ using_directives
;
using_directive
: using_namespace
: using_alias_directive
{
if (doc_support)
Lexer.doc_state = XmlCommentState.Allowed;
}
;
using_namespace
: USING namespace_name SEMICOLON
| using_namespace_directive
{
var un = new UsingNamespace ((MemberName) $2, GetLocation ($1));
current_namespace.AddUsing (un);
lbag.AddLocation (un, GetLocation ($3));
if (doc_support)
Lexer.doc_state = XmlCommentState.Allowed;
}
| USING IDENTIFIER ASSIGN namespace_or_type_name SEMICOLON
;
using_alias_directive
: USING IDENTIFIER ASSIGN namespace_or_type_name SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $2;
if (lang_version != LanguageVersion.ISO_1 && lt.Value == "global") {
@ -480,16 +471,22 @@ using_namespace @@ -480,16 +471,22 @@ using_namespace
"An alias named `global' will not be used when resolving `global::'. The global namespace will be used instead");
}
var un = new UsingAliasNamespace (new MemberName (lt.Value, lt.Location), (MemberName) $4, GetLocation ($1));
current_namespace.AddUsing (un);
lbag.AddLocation (un, GetLocation ($3), GetLocation ($5));
}
current_namespace.AddUsingAlias (lt.Value, (MemberName) $4, GetLocation ($1));
ubag.AddUsingAlias (GetLocation ($1), lt, GetLocation ($3), (MemberName) $4, GetLocation ($5));
}
| USING error
{
Error_SyntaxError (yyToken);
$$ = null;
}
}
;
using_namespace_directive
: USING namespace_name SEMICOLON
{
current_namespace.AddUsing ((MemberName) $2, GetLocation ($1));
ubag.AddUsing (GetLocation ($1), (MemberName) $2, GetLocation ($3));
}
;
//
@ -5106,7 +5103,7 @@ statement_expression @@ -5106,7 +5103,7 @@ statement_expression
ExpressionStatement s = $1 as ExpressionStatement;
if (s == null) {
Expression.Error_InvalidExpressionStatement (report, GetLocation ($1));
$$ = new StatementErrorExpression ($1 as Expression);
$$ = new InvalidStatementExpression ($1 as Expression);
} else {
$$ = new StatementExpression (s);
}
@ -5155,10 +5152,9 @@ if_statement @@ -5155,10 +5152,9 @@ if_statement
if ($7 is EmptyStatement)
Warning_EmptyStatement (GetLocation ($7));
}
| IF open_parens_any boolean_expression error
{
Error_SyntaxError (yyToken);
| IF open_parens_any boolean_expression error {
var eloc = GetLocation ($3);
report.Error (1026, eloc, "Expected a ')'");
$$ = new If ((BooleanExpression) $3, null, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($2));
}
@ -5175,13 +5171,6 @@ switch_statement @@ -5175,13 +5171,6 @@ switch_statement
end_block (GetLocation ($8));
lbag.AddStatement ($$, GetLocation ($2), GetLocation ($4), GetLocation ($5), GetLocation ($8));
}
| SWITCH open_parens_any expression error
{
Error_SyntaxError (yyToken);
$$ = new Switch ((Expression) $3, null, null, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($2));
}
;
opt_switch_sections
@ -5210,7 +5199,7 @@ switch_sections @@ -5210,7 +5199,7 @@ switch_sections
}
| error
{
Error_SyntaxError (yyToken);
Error_SyntaxError (yyToken);
$$ = new List<SwitchSection> ();
}
;
@ -5271,30 +5260,24 @@ while_statement @@ -5271,30 +5260,24 @@ while_statement
$$ = new While ((BooleanExpression) $3, (Statement) $5, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($2), GetLocation ($4));
}
| WHILE open_parens_any boolean_expression error
{
Error_SyntaxError (yyToken);
$$ = new While ((BooleanExpression) $3, null, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($2));
}
;
do_statement
: DO embedded_statement WHILE open_parens_any boolean_expression CLOSE_PARENS SEMICOLON
: DO embedded_statement
WHILE open_parens_any boolean_expression CLOSE_PARENS SEMICOLON
{
$$ = new Do ((Statement) $2, (BooleanExpression) $5, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($3), GetLocation ($4), GetLocation ($6), GetLocation ($7));
}
| DO embedded_statement error
{
Error_SyntaxError (yyToken);
$$ = new Do ((Statement) $2, null, GetLocation ($1));
var loc = GetLocation ($1);
report.Error (-100, loc, "Expected `while'");
$$ = new Do ((Statement) $2, null, loc);
}
| DO embedded_statement WHILE open_parens_any boolean_expression error
| DO embedded_statement
WHILE open_parens_any boolean_expression error
{
Error_SyntaxError (yyToken);
$$ = new Do ((Statement) $2, (BooleanExpression) $5, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($3), GetLocation ($4));
}
@ -5400,35 +5383,10 @@ statement_expression_list @@ -5400,35 +5383,10 @@ statement_expression_list
;
foreach_statement
: FOREACH open_parens_any type error
: FOREACH open_parens_any type IN expression CLOSE_PARENS
{
report.Error (230, GetLocation ($1), "Type and identifier are both required in a foreach statement");
start_block (GetLocation ($2));
current_block.IsCompilerGenerated = true;
Foreach f = new Foreach ((Expression) $3, null, null, null, GetLocation ($1));
current_block.AddStatement (f);
lbag.AddStatement (f, GetLocation ($2));
$$ = end_block (GetLocation ($4));
}
| FOREACH open_parens_any type identifier_inside_body error
{
Error_SyntaxError (yyToken);
start_block (GetLocation ($2));
current_block.IsCompilerGenerated = true;
var lt = (Tokenizer.LocatedToken) $4;
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location);
current_block.AddLocalName (li);
Foreach f = new Foreach ((Expression) $3, li, null, null, GetLocation ($1));
current_block.AddStatement (f);
lbag.AddStatement (f, GetLocation ($2));
$$ = end_block (GetLocation ($5));
$$ = null;
}
| FOREACH open_parens_any type identifier_inside_body IN expression CLOSE_PARENS
{
@ -5586,9 +5544,9 @@ try_statement @@ -5586,9 +5544,9 @@ try_statement
$$ = new TryFinally (new TryCatch ((Block) $2, (List<Catch>) $3, GetLocation ($1), true), (Block) $5, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($4));
}
| TRY block error
| TRY block error
{
Error_SyntaxError (1524, yyToken);
report.Error (1524, GetLocation ($1), "Expected catch or finally");
$$ = new TryCatch ((Block) $2, null, GetLocation ($1), false);
}
;
@ -5606,11 +5564,15 @@ catch_clauses @@ -5606,11 +5564,15 @@ catch_clauses
var l = (List<Catch>) $1;
Catch c = (Catch) $2;
if (l [l.Count - 1].IsGeneral) {
if (l [0].IsGeneral) {
report.Error (1017, c.loc, "Try statement already has an empty catch block");
} else {
if (c.IsGeneral)
l.Insert (0, c);
else
l.Add (c);
}
l.Add (c);
$$ = l;
}
;
@ -5690,13 +5652,6 @@ lock_statement @@ -5690,13 +5652,6 @@ lock_statement
$$ = new Lock ((Expression) $3, (Statement) $5, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($2), GetLocation ($4));
}
| LOCK open_parens_any expression error
{
Error_SyntaxError (yyToken);
$$ = new Lock ((Expression) $3, null, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($2));
}
;
fixed_statement
@ -5758,15 +5713,9 @@ using_statement @@ -5758,15 +5713,9 @@ using_statement
if ($5 is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
Warning_EmptyStatement (GetLocation ($5));
$$ = new Using ((Expression) $3, (Statement) $5, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($2), GetLocation ($4));
}
| USING open_parens_any expression error
{
Error_SyntaxError (yyToken);
$$ = new Using ((Expression) $3, null, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($2));
Using u = new Using ((Expression) $3, (Statement) $5, GetLocation ($1));
lbag.AddStatement (u, GetLocation ($2), GetLocation ($4));
$$ = u;
}
;
@ -6010,7 +5959,7 @@ let_clause @@ -6010,7 +5959,7 @@ let_clause
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));
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
@ -6798,12 +6747,12 @@ void start_anonymous (bool isLambda, ParametersCompiled parameters, bool isAsync @@ -6798,12 +6747,12 @@ void start_anonymous (bool isLambda, ParametersCompiled parameters, bool isAsync
if (lang_version <= LanguageVersion.ISO_2)
FeatureIsNotAvailable (loc, "lambda expressions");
current_anonymous_method = new LambdaExpression (loc);
current_anonymous_method = new LambdaExpression (isAsync, loc);
} else {
if (lang_version == LanguageVersion.ISO_1)
FeatureIsNotAvailable (loc, "anonymous methods");
current_anonymous_method = new AnonymousMethodExpression (loc);
current_anonymous_method = new AnonymousMethodExpression (isAsync, loc);
}
async_block = isAsync;
@ -6835,12 +6784,7 @@ AnonymousMethodExpression end_anonymous (ParametersBlock anon_block) @@ -6835,12 +6784,7 @@ AnonymousMethodExpression end_anonymous (ParametersBlock anon_block)
void Error_SyntaxError (int token)
{
Error_SyntaxError (0, token);
}
void Error_SyntaxError (int error_code, int token)
{
Error_SyntaxError (error_code, token, "Unexpected symbol");
Error_SyntaxError (0, token, "Unexpected symbol");
}
void Error_SyntaxError (int error_code, int token, string msg)

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

@ -47,6 +47,7 @@ namespace Mono.CSharp { @@ -47,6 +47,7 @@ namespace Mono.CSharp {
bool is_double_colon;
public bool IsDoubleColon { get { return is_double_colon; } }
#if FULL_AST
public Location DotLocation {
@ -123,12 +124,6 @@ namespace Mono.CSharp { @@ -123,12 +124,6 @@ namespace Mono.CSharp {
}
}
public bool IsDoubleColon {
get {
return is_double_colon;
}
}
public bool IsGeneric {
get {
if (TypeArguments != null)

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

@ -81,13 +81,6 @@ namespace Mono.CSharp { @@ -81,13 +81,6 @@ namespace Mono.CSharp {
return parameters;
}
}
public FullNamedExpression TypExpression {
get {
return ReturnType;
}
}
#endregion
public override void Accept (StructuralVisitor visitor)

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

@ -300,7 +300,7 @@ namespace Mono.CSharp @@ -300,7 +300,7 @@ namespace Mono.CSharp
tr.Start (TimeReporter.TimerType.UsingResolve);
foreach (var source_file in ctx.SourceFiles) {
source_file.NamespaceContainer.Define ();
source_file.NamespaceContainer.Resolve ();
}
tr.Stop (TimeReporter.TimerType.UsingResolve);

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

@ -4418,10 +4418,7 @@ namespace Mono.CSharp { @@ -4418,10 +4418,7 @@ namespace Mono.CSharp {
var ac_p = p as ArrayContainer;
if (ac_p != null) {
var ac_q = q as ArrayContainer;
if (ac_q == null)
return null;
var ac_q = ((ArrayContainer) q);
TypeSpec specific = MoreSpecific (ac_p.Element, ac_q.Element);
if (specific == ac_p.Element)
return p;

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

@ -373,7 +373,6 @@ namespace Mono.CSharp @@ -373,7 +373,6 @@ namespace Mono.CSharp
// Need to setup MemberCache
parser_result.CreateType ();
parser_result.NamespaceEntry.Define ();
var method = parser_result.Methods[0] as Method;
BlockContext bc = new BlockContext (method, method.Block, ctx.BuiltinTypes.Void);
@ -769,17 +768,12 @@ namespace Mono.CSharp @@ -769,17 +768,12 @@ namespace Mono.CSharp
return sb.ToString ();
}
internal List<string> GetUsingList ()
internal ICollection<string> GetUsingList ()
{
var res = new List<string> ();
foreach (var ue in source_file.NamespaceContainer.Usings) {
if (ue.Alias != null)
continue;
res.Add (ue.NamespaceName.Name);
}
foreach (var ue in source_file.NamespaceContainer.Usings)
res.Add (ue.Name);
return res;
}
@ -820,7 +814,7 @@ namespace Mono.CSharp @@ -820,7 +814,7 @@ namespace Mono.CSharp
public void LoadAssembly (string file)
{
var loader = new DynamicLoader (importer, ctx);
var assembly = loader.LoadAssemblyFile (file, false);
var assembly = loader.LoadAssemblyFile (file);
if (assembly == null)
return;

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

@ -801,17 +801,17 @@ namespace Mono.CSharp @@ -801,17 +801,17 @@ namespace Mono.CSharp
LocalTemporary temporary;
bool prepared;
public Indirection (Expression expr, Location l)
{
this.expr = expr;
loc = l;
}
public Expression Expr {
get {
return expr;
}
}
public Indirection (Expression expr, Location l)
{
this.expr = expr;
loc = l;
}
public bool IsFixed {
get { return true; }
@ -1017,13 +1017,6 @@ namespace Mono.CSharp @@ -1017,13 +1017,6 @@ namespace Mono.CSharp
// Holds the real operation
Expression operation;
public UnaryMutator (Mode m, Expression e, Location loc)
{
mode = m;
this.loc = loc;
expr = e;
}
public Mode UnaryMutatorMode {
get {
return mode;
@ -1036,6 +1029,13 @@ namespace Mono.CSharp @@ -1036,6 +1029,13 @@ namespace Mono.CSharp
}
}
public UnaryMutator (Mode m, Expression e, Location loc)
{
mode = m;
this.loc = loc;
expr = e;
}
public override bool ContainsEmitWithAwait ()
{
return expr.ContainsEmitWithAwait ();
@ -1283,7 +1283,6 @@ namespace Mono.CSharp @@ -1283,7 +1283,6 @@ namespace Mono.CSharp
target.expr = expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -1372,10 +1371,6 @@ namespace Mono.CSharp @@ -1372,10 +1371,6 @@ namespace Mono.CSharp
{
}
protected override string OperatorName {
get { return "is"; }
}
public override Expression CreateExpressionTree (ResolveContext ec)
{
Arguments args = Arguments.CreateForExpressionTree (ec, null,
@ -1550,6 +1545,10 @@ namespace Mono.CSharp @@ -1550,6 +1545,10 @@ namespace Mono.CSharp
return this;
}
protected override string OperatorName {
get { return "is"; }
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -1567,10 +1566,6 @@ namespace Mono.CSharp @@ -1567,10 +1566,6 @@ namespace Mono.CSharp
{
}
protected override string OperatorName {
get { return "as"; }
}
public override Expression CreateExpressionTree (ResolveContext ec)
{
Arguments args = Arguments.CreateForExpressionTree (ec, null,
@ -1649,10 +1644,14 @@ namespace Mono.CSharp @@ -1649,10 +1644,14 @@ namespace Mono.CSharp
return null;
}
protected override string OperatorName {
get { return "as"; }
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
//
@ -1754,6 +1753,13 @@ namespace Mono.CSharp @@ -1754,6 +1753,13 @@ namespace Mono.CSharp
public class DefaultValueExpression : Expression
{
Expression expr;
public Expression Expr {
get {
return this.expr;
}
}
public DefaultValueExpression (Expression expr, Location loc)
{
@ -1761,12 +1767,6 @@ namespace Mono.CSharp @@ -1761,12 +1767,6 @@ namespace Mono.CSharp
this.loc = loc;
}
public Expression Expr {
get {
return this.expr;
}
}
public override bool IsSideEffectFree {
get {
return true;
@ -2225,15 +2225,11 @@ namespace Mono.CSharp @@ -2225,15 +2225,11 @@ namespace Mono.CSharp
}
public Expression Left {
get {
return this.left;
}
get { return this.left; }
}
public Expression Right {
get {
return this.right;
}
get { return this.right; }
}
#endregion
@ -5239,7 +5235,7 @@ namespace Mono.CSharp @@ -5239,7 +5235,7 @@ namespace Mono.CSharp
}
}
public Expression Exp {
public Expression Expression {
get {
return expr;
}
@ -5494,7 +5490,6 @@ namespace Mono.CSharp @@ -5494,7 +5490,6 @@ namespace Mono.CSharp
return SLE.Expression.Call (instance_expr, (MethodInfo) mi.GetMetaInfo (), Arguments.MakeExpression (args, ctx));
#endif
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -5546,12 +5541,6 @@ namespace Mono.CSharp @@ -5546,12 +5541,6 @@ namespace Mono.CSharp
}
}
public Expression TypeExpression {
get {
return RequestedType;
}
}
#endregion
/// <summary>
@ -5944,12 +5933,6 @@ namespace Mono.CSharp @@ -5944,12 +5933,6 @@ namespace Mono.CSharp
get { return elements.Count; }
}
public List<Expression> Elements {
get {
return elements;
}
}
public Expression this [int index] {
get {
return elements [index];
@ -5964,6 +5947,12 @@ namespace Mono.CSharp @@ -5964,6 +5947,12 @@ namespace Mono.CSharp
variable = value;
}
}
public List<Expression> Elements {
get {
return this.elements;
}
}
#endregion
public void Add (Expression expr)
@ -6055,16 +6044,24 @@ namespace Mono.CSharp @@ -6055,16 +6044,24 @@ namespace Mono.CSharp
// The number of constants in array initializers
int const_initializers_count;
bool only_constant_initializers;
// bool only_constant_initializers;
public List<Expression> Arguments {
get { return this.arguments; }
}
public ComposedTypeSpecifier Rank {
get { return this.rank; }
}
public FullNamedExpression NewType {
get { return this.requested_base_type; }
}
public ArrayInitializer Initializers {
get { return this.initializers; }
}
public ArrayCreation (FullNamedExpression requested_base_type, List<Expression> exprs, ComposedTypeSpecifier rank, ArrayInitializer initializers, Location l)
: this (requested_base_type, rank, initializers, l)
{
@ -6102,24 +6099,6 @@ namespace Mono.CSharp @@ -6102,24 +6099,6 @@ namespace Mono.CSharp
{
}
public ComposedTypeSpecifier Rank {
get {
return this.rank;
}
}
public FullNamedExpression TypeExpression {
get {
return this.requested_base_type;
}
}
public ArrayInitializer Initializers {
get {
return this.initializers;
}
}
bool CheckIndices (ResolveContext ec, ArrayInitializer probe, int idx, bool specified_dims, int child_bounds)
{
if (initializers != null && bounds == null) {
@ -6200,7 +6179,7 @@ namespace Mono.CSharp @@ -6200,7 +6179,7 @@ namespace Mono.CSharp
++const_initializers_count;
}
} else {
only_constant_initializers = false;
// only_constant_initializers = false;
}
array_data.Add (element);
@ -6305,7 +6284,7 @@ namespace Mono.CSharp @@ -6305,7 +6284,7 @@ namespace Mono.CSharp
protected bool ResolveInitializers (ResolveContext ec)
{
only_constant_initializers = true;
// only_constant_initializers = true;
if (arguments != null) {
bool res = true;
@ -7145,8 +7124,8 @@ namespace Mono.CSharp @@ -7145,8 +7124,8 @@ namespace Mono.CSharp
/// </summary>
public class Arglist : Expression
{
Arguments arguments;
public Arguments Arguments { get; private set; }
public Arglist (Location loc)
: this (null, loc)
{
@ -7154,24 +7133,18 @@ namespace Mono.CSharp @@ -7154,24 +7133,18 @@ namespace Mono.CSharp
public Arglist (Arguments args, Location l)
{
arguments = args;
Arguments = args;
loc = l;
}
public Arguments Arguments {
get {
return arguments;
}
}
public MetaType[] ArgumentTypes {
get {
if (arguments == null)
if (Arguments == null)
return MetaType.EmptyTypes;
var retval = new MetaType[arguments.Count];
for (int i = 0; i < retval.Length; i++)
retval[i] = arguments[i].Expr.Type.GetMetaInfo ();
var retval = new MetaType[Arguments.Count];
for (int i = 0; i < retval.Length; i++)
retval[i] = Arguments[i].Expr.Type.GetMetaInfo ();
return retval;
}
@ -7192,9 +7165,9 @@ namespace Mono.CSharp @@ -7192,9 +7165,9 @@ namespace Mono.CSharp
{
eclass = ExprClass.Variable;
type = InternalType.Arglist;
if (arguments != null) {
if (Arguments != null) {
bool dynamic; // Can be ignored as there is always only 1 overload
arguments.Resolve (ec, out dynamic);
Arguments.Resolve (ec, out dynamic);
}
return this;
@ -7202,18 +7175,17 @@ namespace Mono.CSharp @@ -7202,18 +7175,17 @@ namespace Mono.CSharp
public override void Emit (EmitContext ec)
{
if (arguments != null)
arguments.Emit (ec);
if (Arguments != null)
Arguments.Emit (ec);
}
protected override void CloneTo (CloneContext clonectx, Expression t)
{
Arglist target = (Arglist) t;
if (arguments != null)
target.arguments = arguments.Clone (clonectx);
if (Arguments != null)
target.Arguments = Arguments.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -7235,12 +7207,6 @@ namespace Mono.CSharp @@ -7235,12 +7207,6 @@ namespace Mono.CSharp
this.loc = loc;
}
public FullNamedExpression TypeExpression {
get {
return texpr;
}
}
public override bool ContainsEmitWithAwait ()
{
return false;
@ -7631,12 +7597,12 @@ namespace Mono.CSharp @@ -7631,12 +7597,12 @@ namespace Mono.CSharp
/// Implements the sizeof expression
/// </summary>
public class SizeOf : Expression {
readonly Expression texpr;
public readonly Expression QueriedType;
TypeSpec type_queried;
public SizeOf (Expression queried_type, Location l)
{
this.texpr = queried_type;
this.QueriedType = queried_type;
loc = l;
}
@ -7646,12 +7612,6 @@ namespace Mono.CSharp @@ -7646,12 +7612,6 @@ namespace Mono.CSharp
}
}
public Expression TypeExpression {
get {
return texpr;
}
}
public override bool ContainsEmitWithAwait ()
{
return false;
@ -7665,7 +7625,7 @@ namespace Mono.CSharp @@ -7665,7 +7625,7 @@ namespace Mono.CSharp
protected override Expression DoResolve (ResolveContext ec)
{
type_queried = texpr.ResolveAsType (ec);
type_queried = QueriedType.ResolveAsType (ec);
if (type_queried == null)
return null;
@ -7733,12 +7693,6 @@ namespace Mono.CSharp @@ -7733,12 +7693,6 @@ namespace Mono.CSharp
this.alias = alias;
}
public string Alias {
get {
return alias;
}
}
public override FullNamedExpression ResolveAsTypeOrNamespace (IMemberContext ec)
{
if (alias == GlobalAlias) {
@ -7753,8 +7707,19 @@ namespace Mono.CSharp @@ -7753,8 +7707,19 @@ namespace Mono.CSharp
ec.Module.Compiler.Report.Error (432, loc, "Alias `{0}' not found", alias);
return null;
}
return base.ResolveAsTypeOrNamespace (ec);
FullNamedExpression fne = base.ResolveAsTypeOrNamespace (ec);
if (fne == null)
return null;
if (expr.eclass == ExprClass.Type) {
ec.Module.Compiler.Report.Error (431, loc,
"Alias `{0}' cannot be used with '::' since it denotes a type. Consider replacing '::' with '.'", alias);
return null;
}
return fne;
}
protected override Expression DoResolve (ResolveContext ec)
@ -7762,6 +7727,13 @@ namespace Mono.CSharp @@ -7762,6 +7727,13 @@ namespace Mono.CSharp
return ResolveAsTypeOrNamespace (ec);
}
protected override void Error_IdentifierNotFound (IMemberContext rc, TypeSpec expr_type, string identifier)
{
rc.Module.Compiler.Report.Error (687, loc,
"A namespace alias qualifier `{0}' did not resolve to a namespace or a type",
GetSignatureForError ());
}
public override string GetSignatureForError ()
{
string name = Name;
@ -7774,14 +7746,6 @@ namespace Mono.CSharp @@ -7774,14 +7746,6 @@ namespace Mono.CSharp
public override Expression LookupNameExpression (ResolveContext rc, MemberLookupRestrictions restrictions)
{
if ((restrictions & MemberLookupRestrictions.InvocableOnly) != 0) {
rc.Module.Compiler.Report.Error (687, loc,
"The namespace alias qualifier `::' cannot be used to invoke a method. Consider using `.' instead",
GetSignatureForError ());
return null;
}
return DoResolve (rc);
}
@ -8141,14 +8105,6 @@ namespace Mono.CSharp @@ -8141,14 +8105,6 @@ namespace Mono.CSharp
return null;
}
var qam = this as QualifiedAliasMember;
if (qam != null) {
rc.Module.Compiler.Report.Error (431, loc,
"Alias `{0}' cannot be used with `::' since it denotes a type. Consider replacing `::' with `.'",
qam.Alias);
}
TypeSpec nested = null;
while (expr_type != null) {
nested = MemberCache.FindNestedType (expr_type, Name, Arity);
@ -8309,7 +8265,6 @@ namespace Mono.CSharp @@ -8309,7 +8265,6 @@ namespace Mono.CSharp
target.Expr = Expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -8374,7 +8329,6 @@ namespace Mono.CSharp @@ -8374,7 +8329,6 @@ namespace Mono.CSharp
target.Expr = Expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -9585,7 +9539,15 @@ namespace Mono.CSharp @@ -9585,7 +9539,15 @@ namespace Mono.CSharp
TypeSpec otype;
Expression t;
Expression count;
public Expression TypeExpression {
get { return this.t; }
}
public Expression CountExpression {
get { return this.count; }
}
public StackAlloc (Expression type, Expression count, Location l)
{
t = type;
@ -9593,18 +9555,6 @@ namespace Mono.CSharp @@ -9593,18 +9555,6 @@ namespace Mono.CSharp
loc = l;
}
public Expression TypeExpression {
get {
return this.t;
}
}
public Expression CountExpression {
get {
return this.count;
}
}
public override bool ContainsEmitWithAwait ()
{
return false;
@ -10083,18 +10033,18 @@ namespace Mono.CSharp @@ -10083,18 +10033,18 @@ namespace Mono.CSharp
CollectionOrObjectInitializers initializers;
IMemoryLocation instance;
public NewInitialize (FullNamedExpression requested_type, Arguments arguments, CollectionOrObjectInitializers initializers, Location l)
: base (requested_type, arguments, l)
{
this.initializers = initializers;
}
public CollectionOrObjectInitializers Initializers {
get {
return initializers;
}
}
public NewInitialize (FullNamedExpression requested_type, Arguments arguments, CollectionOrObjectInitializers initializers, Location l)
: base (requested_type, arguments, l)
{
this.initializers = initializers;
}
protected override void CloneTo (CloneContext clonectx, Expression t)
{
base.CloneTo (clonectx, t);
@ -10205,6 +10155,10 @@ namespace Mono.CSharp @@ -10205,6 +10155,10 @@ namespace Mono.CSharp
readonly TypeContainer parent;
AnonymousTypeClass anonymous_type;
public List<AnonymousTypeParameter> Parameters {
get { return this.parameters; }
}
public NewAnonymousType (List<AnonymousTypeParameter> parameters, TypeContainer parent, Location loc)
: base (null, null, loc)
{
@ -10212,12 +10166,6 @@ namespace Mono.CSharp @@ -10212,12 +10166,6 @@ namespace Mono.CSharp
this.parent = parent;
}
public List<AnonymousTypeParameter> Parameters {
get {
return this.parameters;
}
}
protected override void CloneTo (CloneContext clonectx, Expression target)
{
if (parameters == null)

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

@ -94,12 +94,6 @@ namespace Mono.CSharp { @@ -94,12 +94,6 @@ namespace Mono.CSharp {
#region Properties
public List<FullNamedExpression> TypeExpressions {
get {
return constraints;
}
}
public Location Location {
get {
return loc;
@ -391,12 +385,6 @@ namespace Mono.CSharp { @@ -391,12 +385,6 @@ namespace Mono.CSharp {
}
}
public Constraints Constraints {
get {
return constraints;
}
}
public IAssemblyDefinition DeclaringAssembly {
get {
return Module.DeclaringAssembly;
@ -452,6 +440,12 @@ namespace Mono.CSharp { @@ -452,6 +440,12 @@ namespace Mono.CSharp {
}
}
public Constraints Constraints {
get {
return this.constraints;
}
}
#endregion
//
@ -1917,12 +1911,6 @@ namespace Mono.CSharp { @@ -1917,12 +1911,6 @@ namespace Mono.CSharp {
}
}
public List<FullNamedExpression> TypeExpressions {
get {
return this.args;
}
}
public string GetSignatureForError()
{
StringBuilder sb = new StringBuilder ();

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

@ -33,16 +33,16 @@ namespace Mono.CSharp @@ -33,16 +33,16 @@ namespace Mono.CSharp
protected T machine_initializer;
int resume_pc;
public Expression Expr {
get { return this.expr; }
}
protected YieldStatement (Expression expr, Location l)
{
this.expr = expr;
loc = l;
}
public Expression Expr {
get { return this.expr; }
}
protected override void CloneTo (CloneContext clonectx, Statement t)
{
var target = (YieldStatement<T>) t;

7
ICSharpCode.NRefactory.CSharp/Parser/mcs/lambda.cs

@ -24,8 +24,13 @@ namespace Mono.CSharp { @@ -24,8 +24,13 @@ namespace Mono.CSharp {
// A list of Parameters (explicitly typed parameters)
// An ImplicitLambdaParameter
//
public LambdaExpression (bool isAsync, Location loc)
: base (isAsync, loc)
{
}
public LambdaExpression (Location loc)
: base (loc)
: this (false, loc)
{
}

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

@ -287,12 +287,6 @@ namespace Mono.CSharp.Linq @@ -287,12 +287,6 @@ namespace Mono.CSharp.Linq
this.identifier = identifier;
}
public RangeVariable Identifier {
get {
return identifier;
}
}
public FullNamedExpression IdentifierType { get; set; }
protected Invocation CreateCastExpression (Expression lSide)
@ -482,12 +476,6 @@ namespace Mono.CSharp.Linq @@ -482,12 +476,6 @@ namespace Mono.CSharp.Linq
}
}
public Expression SelectorExpression {
get {
return element_selector;
}
}
protected override void CreateArguments (ResolveContext ec, Parameter parameter, ref Arguments args)
{
base.CreateArguments (ec, parameter, ref args);
@ -531,13 +519,6 @@ namespace Mono.CSharp.Linq @@ -531,13 +519,6 @@ namespace Mono.CSharp.Linq
get { return this.GetIntoVariable (); }
}
public Join (QueryBlock block, RangeVariable lt, Expression inner, QueryBlock outerSelector, QueryBlock innerSelector, Location loc)
: base (block, lt, inner, loc)
{
this.outer_selector = outerSelector;
this.inner_selector = innerSelector;
}
public QueryBlock InnerSelector {
get {
return inner_selector;
@ -549,6 +530,13 @@ namespace Mono.CSharp.Linq @@ -549,6 +530,13 @@ namespace Mono.CSharp.Linq
return outer_selector;
}
}
public Join (QueryBlock block, RangeVariable lt, Expression inner, QueryBlock outerSelector, QueryBlock innerSelector, Location loc)
: base (block, lt, inner, loc)
{
this.outer_selector = outerSelector;
this.inner_selector = innerSelector;
}
protected override void CreateArguments (ResolveContext ec, Parameter parameter, ref Arguments args)
{

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

@ -95,13 +95,8 @@ namespace Mono.CSharp @@ -95,13 +95,8 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class CharLiteral : CharConstant, ILiteralConstant
@ -116,13 +111,8 @@ namespace Mono.CSharp @@ -116,13 +111,8 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class IntLiteral : IntConstant, ILiteralConstant
@ -153,13 +143,8 @@ namespace Mono.CSharp @@ -153,13 +143,8 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class UIntLiteral : UIntConstant, ILiteralConstant
@ -174,13 +159,8 @@ namespace Mono.CSharp @@ -174,13 +159,8 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class LongLiteral : LongConstant, ILiteralConstant
@ -195,13 +175,8 @@ namespace Mono.CSharp @@ -195,13 +175,8 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class ULongLiteral : ULongConstant, ILiteralConstant
@ -216,13 +191,8 @@ namespace Mono.CSharp @@ -216,13 +191,8 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class FloatLiteral : FloatConstant, ILiteralConstant
@ -237,13 +207,8 @@ namespace Mono.CSharp @@ -237,13 +207,8 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class DoubleLiteral : DoubleConstant, ILiteralConstant
@ -280,13 +245,8 @@ namespace Mono.CSharp @@ -280,13 +245,8 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class DecimalLiteral : DecimalConstant, ILiteralConstant
@ -301,13 +261,8 @@ namespace Mono.CSharp @@ -301,13 +261,8 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class StringLiteral : StringConstant, ILiteralConstant
@ -322,12 +277,7 @@ namespace Mono.CSharp @@ -322,12 +277,7 @@ namespace Mono.CSharp
}
#if FULL_AST
public char[] ParsedValue { get; set; }
char[] ILiteralConstant.ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
}

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

@ -899,11 +899,6 @@ namespace Mono.CSharp { @@ -899,11 +899,6 @@ namespace Mono.CSharp {
#endregion
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public static Method Create (DeclSpace parent, GenericMethod generic, FullNamedExpression returnType, Modifiers mod,
MemberName name, ParametersCompiled parameters, Attributes attrs, bool hasConstraints)
{
@ -1180,6 +1175,11 @@ namespace Mono.CSharp { @@ -1180,6 +1175,11 @@ namespace Mono.CSharp {
return true;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
//
// Creates the type
//
@ -1569,11 +1569,6 @@ namespace Mono.CSharp { @@ -1569,11 +1569,6 @@ namespace Mono.CSharp {
(Initializer.Arguments == null);
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.IsValidSecurityAttribute ()) {
@ -1619,6 +1614,11 @@ namespace Mono.CSharp { @@ -1619,6 +1614,11 @@ namespace Mono.CSharp {
return true;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
//
// Creates the ConstructorBuilder
//
@ -2155,11 +2155,6 @@ namespace Mono.CSharp { @@ -2155,11 +2155,6 @@ namespace Mono.CSharp {
ModFlags |= Modifiers.PROTECTED | Modifiers.OVERRIDE;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.Conditional) {
@ -2169,6 +2164,10 @@ namespace Mono.CSharp { @@ -2169,6 +2164,10 @@ namespace Mono.CSharp {
base.ApplyAttributeBuilder (a, ctor, cdata, pa);
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
protected override bool CheckBase ()
{
@ -2515,11 +2514,6 @@ namespace Mono.CSharp { @@ -2515,11 +2514,6 @@ namespace Mono.CSharp {
Block = block;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.Conditional) {
@ -2530,6 +2524,11 @@ namespace Mono.CSharp { @@ -2530,6 +2524,11 @@ namespace Mono.CSharp {
base.ApplyAttributeBuilder (a, ctor, cdata, pa);
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override bool Define ()
{
const Modifiers RequiredModifiers = Modifiers.PUBLIC | Modifiers.STATIC;

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

@ -35,11 +35,6 @@ namespace Mono.CSharp { @@ -35,11 +35,6 @@ namespace Mono.CSharp {
}
}
public static void Error_GlobalNamespaceRedefined (Report report, Location loc)
{
report.Error (1681, loc, "The global extern alias cannot be redefined");
}
public void RegisterNamespace (Namespace child)
{
if (child != this)
@ -583,9 +578,6 @@ namespace Mono.CSharp { @@ -583,9 +578,6 @@ namespace Mono.CSharp {
//
public class NamespaceContainer : IMemberContext, ITypesContainer
{
static readonly Namespace[] empty_namespaces = new Namespace[0];
static readonly string[] empty_using_list = new string[0];
Namespace ns;
readonly ModuleContainer module;
@ -596,18 +588,20 @@ namespace Mono.CSharp { @@ -596,18 +588,20 @@ namespace Mono.CSharp {
NamespaceContainer implicit_parent;
int symfile_id;
List<UsingNamespace> clauses;
// Used by parsed to check for parser errors
// Namespace using import block
List<NamespaceUsingAlias> using_aliases;
List<NamespaceUsing> using_clauses;
public bool DeclarationFound;
// End
bool resolved;
public readonly bool IsImplicit;
public readonly TypeContainer SlaveDeclSpace;
static readonly Namespace [] empty_namespaces = new Namespace [0];
static readonly string[] empty_using_list = new string[0];
Namespace[] namespace_using_table;
Dictionary<string, UsingAliasNamespace> aliases;
Namespace [] namespace_using_table;
public NamespaceContainer (MemberName name, ModuleContainer module, NamespaceContainer parent, CompilationSourceFile sourceFile)
{
@ -650,30 +644,89 @@ namespace Mono.CSharp { @@ -650,30 +644,89 @@ namespace Mono.CSharp {
}
}
public NamespaceContainer Parent {
get {
return parent;
}
}
public CompilationSourceFile SourceFile {
get {
return file;
}
}
public List<UsingNamespace> Usings {
public List<NamespaceUsing> Usings {
get {
return clauses;
return using_clauses;
}
}
#endregion
//
// Extracts the using alises and using clauses into a couple of
// arrays that might already have the same information; Used by the
// C# Eval mode.
//
public void Extract (List<NamespaceUsingAlias> out_using_aliases, List<NamespaceUsing> out_using_clauses)
{
if (using_aliases != null){
foreach (NamespaceUsingAlias uae in using_aliases){
bool replaced = false;
for (int i = 0; i < out_using_aliases.Count; i++){
NamespaceUsingAlias out_uea = (NamespaceUsingAlias) out_using_aliases [i];
if (out_uea.Alias == uae.Alias){
out_using_aliases [i] = uae;
replaced = true;
break;
}
}
if (!replaced)
out_using_aliases.Add (uae);
}
}
if (using_clauses != null){
foreach (NamespaceUsing ue in using_clauses){
bool found = false;
foreach (NamespaceUsing out_ue in out_using_clauses)
if (out_ue.Name == ue.Name){
found = true;
break;
}
if (!found)
out_using_clauses.Add (ue);
}
}
}
//
// According to section 16.3.1 (using-alias-directive), the namespace-or-type-name is
// resolved as if the immediately containing namespace body has no using-directives.
//
// Section 16.3.2 says that the same rule is applied when resolving the namespace-name
// in the using-namespace-directive.
//
// To implement these rules, the expressions in the using directives are resolved using
// the "doppelganger" (ghostly bodiless duplicate).
//
NamespaceContainer doppelganger;
NamespaceContainer Doppelganger {
get {
if (!IsImplicit && doppelganger == null) {
doppelganger = new NamespaceContainer (module, ImplicitParent, file, ns, true);
doppelganger.using_aliases = using_aliases;
}
return doppelganger;
}
}
public Namespace NS {
get { return ns; }
}
public NamespaceContainer Parent {
get { return parent; }
}
public NamespaceContainer ImplicitParent {
get {
if (parent == null)
@ -687,47 +740,78 @@ namespace Mono.CSharp { @@ -687,47 +740,78 @@ namespace Mono.CSharp {
}
}
public void AddUsing (UsingNamespace un)
/// <summary>
/// Records a new namespace for resolving name references
/// </summary>
public void AddUsing (MemberName name, Location loc)
{
if (DeclarationFound){
Compiler.Report.Error (1529, un.Location, "A using clause must precede all other namespace elements except extern alias declarations");
Compiler.Report.Error (1529, loc, "A using clause must precede all other namespace elements except extern alias declarations");
}
if (clauses == null)
clauses = new List<UsingNamespace> ();
clauses.Add (un);
if (using_clauses == null) {
using_clauses = new List<NamespaceUsing> ();
} else {
foreach (NamespaceUsing old_entry in using_clauses) {
if (name.Equals (old_entry.MemberName)) {
Compiler.Report.SymbolRelatedToPreviousError (old_entry.Location, old_entry.GetSignatureForError ());
Compiler.Report.Warning (105, 3, loc, "The using directive for `{0}' appeared previously in this namespace", name.GetSignatureForError ());
return;
}
}
}
resolved = false;
using_clauses.Add (new NamespaceUsing (name));
}
public void AddUsing (UsingAliasNamespace un)
public void AddUsingAlias (string alias, MemberName name, Location loc)
{
if (DeclarationFound){
Compiler.Report.Error (1529, un.Location, "A using clause must precede all other namespace elements except extern alias declarations");
Compiler.Report.Error (1529, loc, "A using clause must precede all other namespace elements except extern alias declarations");
}
AddAlias (un);
AddUsingAlias (new LocalUsingAliasEntry (alias, name, loc));
}
void AddAlias (UsingAliasNamespace un)
public void AddUsingExternalAlias (string alias, Location loc, Report Report)
{
if (clauses == null) {
clauses = new List<UsingNamespace> ();
} else {
foreach (var entry in clauses) {
var a = entry as UsingAliasNamespace;
if (a != null && a.Alias.Equals (un.Alias)) {
Compiler.Report.SymbolRelatedToPreviousError (a.Location, "");
Compiler.Report.Error (1537, un.Location,
"The using alias `{0}' appeared previously in this namespace", un.Alias.GetSignatureForError ());
bool not_first = using_clauses != null || DeclarationFound;
if (using_aliases != null && !not_first) {
foreach (NamespaceUsingAlias uae in using_aliases) {
if (uae is LocalUsingAliasEntry) {
not_first = true;
break;
}
}
}
clauses.Add (un);
if (not_first)
Report.Error (439, loc, "An extern alias declaration must precede all other elements");
if (alias == "global") {
Error_GlobalNamespaceRedefined (loc, Report);
return;
}
AddUsingAlias (new NamespaceUsingAlias (alias, loc));
}
void AddUsingAlias (NamespaceUsingAlias uae)
{
if (using_aliases == null) {
using_aliases = new List<NamespaceUsingAlias> ();
} else {
foreach (NamespaceUsingAlias entry in using_aliases) {
if (uae.Alias == entry.Alias) {
Compiler.Report.SymbolRelatedToPreviousError (uae.Location, uae.Alias);
Compiler.Report.Error (1537, entry.Location, "The using alias `{0}' appeared previously in this namespace",
entry.Alias);
return;
}
}
}
resolved = false;
using_aliases.Add (uae);
}
//
@ -737,7 +821,7 @@ namespace Mono.CSharp { @@ -737,7 +821,7 @@ namespace Mono.CSharp {
public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
{
List<MethodSpec> candidates = null;
foreach (Namespace n in namespace_using_table) {
foreach (Namespace n in GetUsingTable ()) {
var a = n.LookupExtensionMethod (this, extensionType, name, arity);
if (a == null)
continue;
@ -782,7 +866,7 @@ namespace Mono.CSharp { @@ -782,7 +866,7 @@ namespace Mono.CSharp {
IEnumerable<string> all = Enumerable.Empty<string> ();
for (NamespaceContainer curr_ns = this; curr_ns != null; curr_ns = curr_ns.ImplicitParent){
foreach (Namespace using_ns in namespace_using_table){
foreach (Namespace using_ns in GetUsingTable ()){
if (prefix.StartsWith (using_ns.Name)){
int ld = prefix.LastIndexOf ('.');
if (ld != -1){
@ -797,35 +881,18 @@ namespace Mono.CSharp { @@ -797,35 +881,18 @@ namespace Mono.CSharp {
return all.Distinct ().ToList ();
}
//
// Looks-up a alias named @name in this and surrounding namespace declarations
//
public FullNamedExpression LookupExternAlias (string name)
{
if (aliases == null)
return null;
UsingAliasNamespace uan;
if (aliases.TryGetValue (name, out uan) && uan is UsingExternAlias)
return uan.ResolvedExpression;
return null;
}
//
// Looks-up a alias named @name in this and surrounding namespace declarations
//
public FullNamedExpression LookupNamespaceAlias (string name)
{
for (NamespaceContainer n = this; n != null; n = n.ImplicitParent) {
if (n.aliases == null)
if (n.using_aliases == null)
continue;
UsingAliasNamespace uan;
if (n.aliases.TryGetValue (name, out uan))
return uan.ResolvedExpression;
foreach (NamespaceUsingAlias ue in n.using_aliases) {
if (ue.Alias == name)
return ue.Resolve (Doppelganger ?? this, Doppelganger == null);
}
}
return null;
@ -841,19 +908,26 @@ namespace Mono.CSharp { @@ -841,19 +908,26 @@ namespace Mono.CSharp {
//
// Check aliases.
//
if (aliases != null && arity == 0) {
UsingAliasNamespace uan;
if (aliases.TryGetValue (name, out uan)) {
if (fne != null) {
// TODO: Namespace has broken location
//Report.SymbolRelatedToPreviousError (fne.Location, null);
Compiler.Report.SymbolRelatedToPreviousError (uan.Location, null);
Compiler.Report.Error (576, loc,
"Namespace `{0}' contains a definition with same name as alias `{1}'",
GetSignatureForError (), name);
}
if (using_aliases != null && arity == 0) {
foreach (NamespaceUsingAlias ue in using_aliases) {
if (ue.Alias == name) {
if (fne != null) {
if (Doppelganger != null) {
if (mode == LookupMode.Normal) {
// TODO: Namespace has broken location
//Report.SymbolRelatedToPreviousError (fne.Location, null);
Compiler.Report.SymbolRelatedToPreviousError (ue.Location, null);
Compiler.Report.Error (576, loc,
"Namespace `{0}' contains a definition with same name as alias `{1}'",
GetSignatureForError (), name);
}
} else {
return fne;
}
}
return uan.ResolvedExpression;
return ue.Resolve (Doppelganger ?? this, Doppelganger == null);
}
}
}
@ -867,11 +941,9 @@ namespace Mono.CSharp { @@ -867,11 +941,9 @@ namespace Mono.CSharp {
// Check using entries.
//
FullNamedExpression match = null;
foreach (Namespace using_ns in namespace_using_table) {
//
foreach (Namespace using_ns in GetUsingTable ()) {
// A using directive imports only types contained in the namespace, it
// does not import any nested namespaces
//
fne = using_ns.LookupType (this, name, arity, mode, loc);
if (fne == null)
continue;
@ -911,20 +983,41 @@ namespace Mono.CSharp { @@ -911,20 +983,41 @@ namespace Mono.CSharp {
return match;
}
Namespace [] GetUsingTable ()
{
if (namespace_using_table != null)
return namespace_using_table;
if (using_clauses == null)
return empty_namespaces;
var list = new List<Namespace> (using_clauses.Count);
foreach (NamespaceUsing ue in using_clauses) {
Namespace using_ns = ue.Resolve (Doppelganger);
if (using_ns == null)
continue;
list.Add (using_ns);
}
if (Compiler.Settings.StatementMode)
return list.ToArray ();
namespace_using_table = list.ToArray ();
return namespace_using_table;
}
public int SymbolFileID {
get {
if (symfile_id == 0 && file.SourceFileEntry != null) {
int parent_id = parent == null ? 0 : parent.SymbolFileID;
string [] using_list = empty_using_list;
if (clauses != null) {
// TODO: Why is it needed, what to do with aliases
var ul = new List<string> ();
foreach (var c in clauses) {
ul.Add (c.NamespaceName.GetName ());
}
using_list = ul.ToArray ();
if (using_clauses != null) {
using_list = new string [using_clauses.Count];
for (int i = 0; i < using_clauses.Count; i++)
using_list [i] = ((NamespaceUsing) using_clauses [i]).MemberName.GetName ();
}
symfile_id = SymbolWriter.DefineNamespace (ns.Name, file.CompileUnitEntry, using_list, parent_id);
@ -943,6 +1036,11 @@ namespace Mono.CSharp { @@ -943,6 +1036,11 @@ namespace Mono.CSharp {
Console.WriteLine (" Try using -pkg:" + s);
}
public static void Error_GlobalNamespaceRedefined (Location loc, Report Report)
{
Report.Error (1681, loc, "The global extern alias cannot be redefined");
}
public static void Error_NamespaceNotFound (Location loc, string name, Report Report)
{
Report.Error (246, loc, "The type or namespace name `{0}' could not be found. Are you missing a using directive or an assembly reference?",
@ -971,76 +1069,29 @@ namespace Mono.CSharp { @@ -971,76 +1069,29 @@ namespace Mono.CSharp {
}
}
public void Define ()
/// <summary>
/// Used to validate that all the using clauses are correct
/// after we are finished parsing all the files.
/// </summary>
public void Resolve ()
{
if (resolved)
return;
// FIXME: Because we call Define from bottom not top
if (parent != null)
parent.Define ();
namespace_using_table = empty_namespaces;
resolved = true;
if (clauses != null) {
var list = new List<Namespace> (clauses.Count);
bool post_process_using_aliases = false;
for (int i = 0; i < clauses.Count; ++i) {
var entry = clauses[i];
if (entry.Alias != null) {
if (aliases == null)
aliases = new Dictionary<string, UsingAliasNamespace> ();
//
// Aliases are not available when resolving using section
// except extern aliases
//
if (entry is UsingExternAlias) {
entry.Define (this);
if (entry.ResolvedExpression != null)
aliases.Add (entry.Alias.Name, (UsingExternAlias) entry);
clauses.RemoveAt (i--);
} else {
post_process_using_aliases = true;
}
continue;
}
entry.Define (this);
Namespace using_ns = entry.ResolvedExpression as Namespace;
if (using_ns == null)
continue;
if (list.Contains (using_ns)) {
Compiler.Report.Warning (105, 3, entry.Location,
"The using directive for `{0}' appeared previously in this namespace", using_ns.GetSignatureForError ());
} else {
list.Add (using_ns);
}
}
namespace_using_table = list.ToArray ();
if (post_process_using_aliases) {
for (int i = 0; i < clauses.Count; ++i) {
var entry = clauses[i];
if (entry.Alias != null) {
entry.Define (this);
if (entry.ResolvedExpression != null) {
aliases.Add (entry.Alias.Name, (UsingAliasNamespace) entry);
}
if (using_aliases != null) {
foreach (NamespaceUsingAlias ue in using_aliases)
ue.Resolve (Doppelganger, Doppelganger == null);
}
clauses.RemoveAt (i--);
}
}
}
if (using_clauses != null) {
foreach (NamespaceUsing ue in using_clauses)
ue.Resolve (Doppelganger);
}
if (parent != null)
parent.Resolve ();
}
public string GetSignatureForError ()
@ -1067,7 +1118,7 @@ namespace Mono.CSharp { @@ -1067,7 +1118,7 @@ namespace Mono.CSharp {
}
public bool IsObsolete {
get { return false; }
get { return SlaveDeclSpace.IsObsolete; }
}
public bool IsUnsafe {
@ -1085,199 +1136,106 @@ namespace Mono.CSharp { @@ -1085,199 +1136,106 @@ namespace Mono.CSharp {
#endregion
}
public class UsingNamespace
public class NamespaceUsing
{
readonly MemberName name;
readonly Location loc;
protected FullNamedExpression resolved;
Namespace resolved;
public UsingNamespace (MemberName name, Location loc)
public NamespaceUsing (MemberName name)
{
this.name = name;
this.loc = loc;
}
#region Properties
public virtual MemberName Alias {
get {
return null;
}
}
public Location Location {
get {
return loc;
}
public string GetSignatureForError ()
{
return name.GetSignatureForError ();
}
public MemberName NamespaceName {
get {
return name;
}
public Location Location
{
get { return name.Location; }
}
public FullNamedExpression ResolvedExpression {
get {
return resolved;
}
public MemberName MemberName
{
get { return name; }
}
#endregion
public string GetSignatureForError ()
public string Name
{
return name.GetSignatureForError ();
get { return GetSignatureForError (); }
}
public virtual void Define (NamespaceContainer ctx)
public Namespace Resolve (IMemberContext rc)
{
resolved = name.GetTypeExpression ().ResolveAsTypeOrNamespace (ctx);
var ns = resolved as Namespace;
if (ns == null) {
if (resolved != null) {
ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (resolved.Type);
ctx.Module.Compiler.Report.Error (138, Location,
"`{0}' is a type not a namespace. A using namespace directive can only be applied to namespaces",
GetSignatureForError ());
}
if (resolved != null)
return resolved;
FullNamedExpression fne = name.GetTypeExpression ().ResolveAsTypeOrNamespace (rc);
if (fne == null)
return null;
resolved = fne as Namespace;
if (resolved == null) {
rc.Module.Compiler.Report.SymbolRelatedToPreviousError (fne.Type);
rc.Module.Compiler.Report.Error (138, Location,
"`{0}' is a type not a namespace. A using namespace directive can only be applied to namespaces",
GetSignatureForError ());
}
return resolved;
}
}
public class UsingExternAlias : UsingAliasNamespace
public class NamespaceUsingAlias
{
public UsingExternAlias (MemberName alias, Location loc)
: base (alias, null, loc)
public readonly string Alias;
public Location Location;
public NamespaceUsingAlias (string alias, Location loc)
{
this.Alias = alias;
this.Location = loc;
}
public override void Define (NamespaceContainer ctx)
public virtual FullNamedExpression Resolve (IMemberContext rc, bool local)
{
resolved = ctx.Module.GetRootNamespace (Alias.Name);
if (resolved == null) {
ctx.Module.Compiler.Report.Error (430, Location,
FullNamedExpression fne = rc.Module.GetRootNamespace (Alias);
if (fne == null) {
rc.Module.Compiler.Report.Error (430, Location,
"The extern alias `{0}' was not specified in -reference option",
Alias.Name);
Alias);
}
return fne;
}
}
public class UsingAliasNamespace : UsingNamespace
class LocalUsingAliasEntry : NamespaceUsingAlias
{
readonly MemberName alias;
FullNamedExpression resolved;
MemberName value;
struct AliasContext : IMemberContext
public LocalUsingAliasEntry (string alias, MemberName name, Location loc)
: base (alias, loc)
{
readonly NamespaceContainer ns;
public AliasContext (NamespaceContainer ns)
{
this.ns = ns;
}
public TypeSpec CurrentType {
get {
return null;
}
}
public TypeParameter[] CurrentTypeParameters {
get {
return null;
}
}
public MemberCore CurrentMemberDefinition {
get {
return null;
}
}
public bool IsObsolete {
get {
return false;
}
}
public bool IsUnsafe {
get {
throw new NotImplementedException ();
}
}
public bool IsStatic {
get {
throw new NotImplementedException ();
}
}
public ModuleContainer Module {
get {
return ns.Module;
}
}
this.value = name;
}
public string GetSignatureForError ()
{
throw new NotImplementedException ();
}
public override FullNamedExpression Resolve (IMemberContext rc, bool local)
{
if (resolved != null || value == null)
return resolved;
public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
{
if (local)
return null;
}
public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
var fne = ns.NS.LookupTypeOrNamespace (ns, name, arity, mode, loc);
if (fne != null)
return fne;
//
// Only extern aliases are allowed in this context
//
fne = ns.LookupExternAlias (name);
if (fne != null)
return fne;
if (ns.ImplicitParent != null)
return ns.ImplicitParent.LookupNamespaceOrType (name, arity, mode, loc);
resolved = value.GetTypeExpression ().ResolveAsTypeOrNamespace (rc);
if (resolved == null) {
value = null;
return null;
}
public FullNamedExpression LookupNamespaceAlias (string name)
{
return ns.LookupNamespaceAlias (name);
}
}
public UsingAliasNamespace (MemberName alias, MemberName ns, Location loc)
: base (ns, loc)
{
this.alias = alias;
}
public override MemberName Alias {
get {
return alias;
}
}
public override void Define (NamespaceContainer ctx)
{
//
// The namespace-or-type-name of a using-alias-directive is resolved as if
// the immediately containing compilation unit or namespace body had no
// using-directives. A using-alias-directive may however be affected
// by extern-alias-directives in the immediately containing compilation
// unit or namespace body
//
// We achieve that by introducing alias-context which redirect any local
// namespace or type resolve calls to parent namespace
//
resolved = NamespaceName.GetTypeExpression ().ResolveAsTypeOrNamespace (new AliasContext (ctx));
return resolved;
}
}
}

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

@ -1001,24 +1001,20 @@ namespace Mono.CSharp.Nullable @@ -1001,24 +1001,20 @@ namespace Mono.CSharp.Nullable
Expression left, right;
Unwrap unwrap;
public Expression Left {
get { return this.left; }
}
public Expression Right {
get { return this.right; }
}
public NullCoalescingOperator (Expression left, Expression right, Location loc)
{
this.left = left;
this.right = right;
this.loc = loc;
}
public Expression LeftExpression {
get {
return left;
}
}
public Expression Right {
get {
return right;
}
}
public override Expression CreateExpressionTree (ResolveContext ec)
{

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

@ -234,7 +234,10 @@ namespace Mono.CSharp { @@ -234,7 +234,10 @@ namespace Mono.CSharp {
TemporaryVariableReference expr_tree_variable;
HoistedVariable hoisted_variant;
public Modifier ParameterModifier { get { return modFlags; }}
public Expression DefaultExpression { get { return default_expr; }}
public Parameter (FullNamedExpression type, string name, Modifier mod, Attributes attrs, Location loc)
{
this.name = name;
@ -248,12 +251,6 @@ namespace Mono.CSharp { @@ -248,12 +251,6 @@ namespace Mono.CSharp {
#region Properties
public Expression DefaultExpression {
get {
return default_expr;
}
}
public DefaultParameterValueExpression DefaultValue {
get {
return default_expr as DefaultParameterValueExpression;
@ -282,12 +279,6 @@ namespace Mono.CSharp { @@ -282,12 +279,6 @@ namespace Mono.CSharp {
}
}
public Modifier ParameterModifier {
get {
return modFlags;
}
}
public TypeSpec Type {
get {
return parameter_type;
@ -1221,7 +1212,7 @@ namespace Mono.CSharp { @@ -1221,7 +1212,7 @@ namespace Mono.CSharp {
//
// Default parameter value expression. We need this wrapper to handle
// default parameter values of folded constants (e.g. indexer parameters).
// default parameter values of folded constants when for indexer parameters
// The expression is resolved only once but applied to two methods which
// both share reference to this expression and we ensure that resolving
// this expression always returns same instance

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

@ -733,12 +733,6 @@ namespace Mono.CSharp @@ -733,12 +733,6 @@ namespace Mono.CSharp
{
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
void CreateAutomaticProperty ()
{
// Create backing field
@ -763,6 +757,11 @@ namespace Mono.CSharp @@ -763,6 +757,11 @@ namespace Mono.CSharp
Set.Block.AddStatement (new StatementExpression (a));
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override bool Define ()
{
if (!base.Define ())
@ -858,11 +857,6 @@ namespace Mono.CSharp @@ -858,11 +857,6 @@ namespace Mono.CSharp
{
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override bool Define()
{
if (!base.Define ())
@ -877,6 +871,12 @@ namespace Mono.CSharp @@ -877,6 +871,12 @@ namespace Mono.CSharp
return attribute_targets;
}
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
/// <summary>
@ -999,12 +999,6 @@ namespace Mono.CSharp @@ -999,12 +999,6 @@ namespace Mono.CSharp
#region Properties
public List<FieldDeclarator> Declarators {
get {
return this.declarators;
}
}
bool HasBackingField {
get {
return !IsInterface && (ModFlags & Modifiers.ABSTRACT) == 0;
@ -1026,14 +1020,14 @@ namespace Mono.CSharp @@ -1026,14 +1020,14 @@ namespace Mono.CSharp
}
}
#endregion
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
public List<FieldDeclarator> Declarators {
get {
return this.declarators;
}
}
#endregion
public void AddDeclarator (FieldDeclarator declarator)
{
if (declarators == null)
@ -1111,6 +1105,11 @@ namespace Mono.CSharp @@ -1111,6 +1105,11 @@ namespace Mono.CSharp
return true;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
public abstract class Event : PropertyBasedMember
@ -1514,12 +1513,6 @@ namespace Mono.CSharp @@ -1514,12 +1513,6 @@ namespace Mono.CSharp
#endregion
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.IndexerName) {
@ -1541,6 +1534,11 @@ namespace Mono.CSharp @@ -1541,6 +1534,11 @@ namespace Mono.CSharp
return Parent.MemberCache.CheckExistingMembersOverloads (this, parameters);
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override bool Define ()
{
if (!base.Define ())

14
ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs

@ -442,7 +442,12 @@ namespace Mono.CSharp @@ -442,7 +442,12 @@ namespace Mono.CSharp
return assembly.GetType (compiler.BuiltinTypes.Object.FullName) != null;
}
public override Assembly LoadAssemblyFile (string assembly, bool isImplicitReference)
public override Assembly LoadAssemblyFile (string fileName)
{
return LoadAssemblyFile (fileName, false);
}
Assembly LoadAssemblyFile (string assembly, bool soft)
{
Assembly a = null;
@ -459,7 +464,7 @@ namespace Mono.CSharp @@ -459,7 +464,7 @@ namespace Mono.CSharp
a = Assembly.Load (ass);
}
} catch (FileNotFoundException) {
bool err = !isImplicitReference;
bool err = !soft;
foreach (string dir in paths) {
string full_path = Path.Combine (dir, assembly);
if (!assembly.EndsWith (".dll") && !assembly.EndsWith (".exe"))
@ -485,6 +490,11 @@ namespace Mono.CSharp @@ -485,6 +490,11 @@ namespace Mono.CSharp
return a;
}
public override Assembly LoadAssemblyDefault (string fileName)
{
return LoadAssemblyFile (fileName, true);
}
Module LoadModuleFile (AssemblyDefinitionDynamic assembly, string module)
{
string total_log = "";

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

@ -367,7 +367,7 @@ namespace Mono.CSharp @@ -367,7 +367,7 @@ namespace Mono.CSharp
public RootNamespace CreateRootNamespace (string alias)
{
if (alias == global_ns.Alias) {
RootNamespace.Error_GlobalNamespaceRedefined (Report, Location.Null);
NamespaceContainer.Error_GlobalNamespaceRedefined (Location.Null, Report);
return global_ns;
}

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

@ -154,11 +154,9 @@ namespace Mono.CSharp { @@ -154,11 +154,9 @@ namespace Mono.CSharp {
FalseStatement = false_statement;
loc = l;
}
public Expression Expr {
get {
return this.expr;
}
get { return this.expr; }
}
public override bool Resolve (BlockContext ec)
@ -641,11 +639,9 @@ namespace Mono.CSharp { @@ -641,11 +639,9 @@ namespace Mono.CSharp {
this.expr = expr;
loc = expr.Location;
}
public ExpressionStatement Expr {
get {
return this.expr;
}
get { return this.expr; }
}
protected override void CloneTo (CloneContext clonectx, Statement t)
@ -680,7 +676,7 @@ namespace Mono.CSharp { @@ -680,7 +676,7 @@ namespace Mono.CSharp {
this.expr = expr;
}
public Expression Expr {
public Expression Expression {
get {
return expr;
}
@ -783,30 +779,25 @@ namespace Mono.CSharp { @@ -783,30 +779,25 @@ namespace Mono.CSharp {
/// </summary>
public class Return : ExitStatement
{
Expression expr;
public Expression Expr { get; protected set; }
public Return (Expression expr, Location l)
{
this.expr = expr;
Expr = expr;
loc = l;
}
#region Properties
public Expression Expr {
public Expression Expression {
get {
return expr;
}
protected set {
expr = value;
return Expr;
}
}
#endregion
protected override bool DoResolve (BlockContext ec)
{
if (expr == null) {
if (Expr == null) {
if (ec.ReturnType.Kind == MemberKind.Void)
return true;
@ -820,7 +811,7 @@ namespace Mono.CSharp { @@ -820,7 +811,7 @@ namespace Mono.CSharp {
//
// Extra trick not to emit ret/leave inside awaiter body
//
expr = EmptyExpression.Null;
Expr = EmptyExpression.Null;
return true;
}
}
@ -836,7 +827,7 @@ namespace Mono.CSharp { @@ -836,7 +827,7 @@ namespace Mono.CSharp {
return false;
}
expr = expr.Resolve (ec);
Expr = Expr.Resolve (ec);
TypeSpec block_return_type = ec.ReturnType;
AnonymousExpression am = ec.CurrentAnonymousMethod;
@ -854,12 +845,12 @@ namespace Mono.CSharp { @@ -854,12 +845,12 @@ namespace Mono.CSharp {
var async_block = am as AsyncInitializer;
if (async_block != null) {
if (expr != null) {
if (Expr != null) {
var storey = (AsyncTaskStorey) am.Storey;
var async_type = storey.ReturnType;
if (async_type == null && async_block.ReturnTypeInference != null) {
async_block.ReturnTypeInference.AddCommonTypeBound (expr.Type);
async_block.ReturnTypeInference.AddCommonTypeBound (Expr.Type);
return true;
}
@ -880,20 +871,20 @@ namespace Mono.CSharp { @@ -880,20 +871,20 @@ namespace Mono.CSharp {
}
} else {
var l = am as AnonymousMethodBody;
if (l != null && l.ReturnTypeInference != null && expr != null) {
l.ReturnTypeInference.AddCommonTypeBound (expr.Type);
if (l != null && l.ReturnTypeInference != null && Expr != null) {
l.ReturnTypeInference.AddCommonTypeBound (Expr.Type);
return true;
}
}
}
if (expr == null)
if (Expr == null)
return false;
if (expr.Type != block_return_type) {
expr = Convert.ImplicitConversionRequired (ec, expr, block_return_type, loc);
if (Expr.Type != block_return_type) {
Expr = Convert.ImplicitConversionRequired (ec, Expr, block_return_type, loc);
if (expr == null) {
if (Expr == null) {
if (am != null && block_return_type == ec.ReturnType) {
ec.Report.Error (1662, loc,
"Cannot convert `{0}' to delegate type `{1}' because some of the return types in the block are not implicitly convertible to the delegate return type",
@ -908,8 +899,8 @@ namespace Mono.CSharp { @@ -908,8 +899,8 @@ namespace Mono.CSharp {
protected override void DoEmit (EmitContext ec)
{
if (expr != null) {
expr.Emit (ec);
if (Expr != null) {
Expr.Emit (ec);
var async_body = ec.CurrentAnonymousMethod as AsyncInitializer;
if (async_body != null) {
@ -945,10 +936,9 @@ namespace Mono.CSharp { @@ -945,10 +936,9 @@ namespace Mono.CSharp {
{
Return target = (Return) t;
// It's null for simple return;
if (expr != null)
target.expr = expr.Clone (clonectx);
if (Expr != null)
target.Expr = Expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -1145,11 +1135,9 @@ namespace Mono.CSharp { @@ -1145,11 +1135,9 @@ namespace Mono.CSharp {
expr = e;
loc = l;
}
public Expression Expr {
get {
return this.expr;
}
get { return this.expr; }
}
public override bool Resolve (BlockContext ec)
@ -1219,13 +1207,11 @@ namespace Mono.CSharp { @@ -1219,13 +1207,11 @@ namespace Mono.CSharp {
this.expr = expr;
loc = l;
}
public Expression Expr {
get {
return this.expr;
}
get { return this.expr; }
}
public override bool Resolve (BlockContext ec)
{
if (expr == null) {
@ -1886,7 +1872,6 @@ namespace Mono.CSharp { @@ -1886,7 +1872,6 @@ namespace Mono.CSharp {
public static string GetCompilerGeneratedName (Block block)
{
// HACK: Debugger depends on the name semantics
return "$locvar" + block.ParametersBlock.TemporaryLocalsCount++.ToString ("X");
}
@ -2003,7 +1988,7 @@ namespace Mono.CSharp { @@ -2003,7 +1988,7 @@ namespace Mono.CSharp {
int? resolving_init_idx;
Block original;
protected Block original;
#if DEBUG
static int id;
@ -2050,9 +2035,6 @@ namespace Mono.CSharp { @@ -2050,9 +2035,6 @@ namespace Mono.CSharp {
get {
return original;
}
protected set {
original = value;
}
}
public bool IsCompilerGenerated {
@ -2069,11 +2051,10 @@ namespace Mono.CSharp { @@ -2069,11 +2051,10 @@ namespace Mono.CSharp {
get { return (flags & Flags.Unsafe) != 0; }
set { flags |= Flags.Unsafe; }
}
public List<Statement> Statements {
get { return statements; }
get { return this.statements; }
}
#endregion
public Block CreateSwitchBlock (Location start)
@ -2347,7 +2328,6 @@ namespace Mono.CSharp { @@ -2347,7 +2328,6 @@ namespace Mono.CSharp {
foreach (Statement s in statements)
target.statements.Add (s.Clone (clonectx));
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -2712,7 +2692,7 @@ namespace Mono.CSharp { @@ -2712,7 +2692,7 @@ namespace Mono.CSharp {
// Overwrite original for comparison purposes when linking cross references
// between anonymous methods
//
Original = source;
original = source;
}
#region Properties
@ -2926,7 +2906,7 @@ namespace Mono.CSharp { @@ -2926,7 +2906,7 @@ namespace Mono.CSharp {
ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, StartLocation);
pb.EndLocation = EndLocation;
pb.statements = statements;
pb.Original = this;
pb.original = this;
var iterator = new Iterator (pb, method, host, iterator_type, is_enumerable);
am_storey = new IteratorStorey (iterator);
@ -2941,7 +2921,7 @@ namespace Mono.CSharp { @@ -2941,7 +2921,7 @@ namespace Mono.CSharp {
ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, StartLocation);
pb.EndLocation = EndLocation;
pb.statements = statements;
pb.Original = this;
pb.original = this;
var block_type = host.Module.Compiler.BuiltinTypes.Void;
var initializer = new AsyncInitializer (pb, host, block_type);
@ -4488,13 +4468,11 @@ namespace Mono.CSharp { @@ -4488,13 +4468,11 @@ namespace Mono.CSharp {
{
this.expr = expr;
}
public Expression Expr {
get {
return this.expr;
}
get { return this.expr; }
}
public override bool Resolve (BlockContext ec)
{
expr = expr.Resolve (ec);
@ -5173,12 +5151,6 @@ namespace Mono.CSharp { @@ -5173,12 +5151,6 @@ namespace Mono.CSharp {
this.fini = fini;
}
public Block Finallyblock {
get {
return fini;
}
}
public override bool Resolve (BlockContext ec)
{
bool ok = true;
@ -5230,20 +5202,23 @@ namespace Mono.CSharp { @@ -5230,20 +5202,23 @@ namespace Mono.CSharp {
public class TryCatch : ExceptionStatement
{
public Block Block;
List<Catch> clauses;
public List<Catch> Specific;
public Catch General;
readonly bool inside_try_finally;
public TryCatch (Block block, List<Catch> catch_clauses, Location l, bool inside_try_finally)
: base (l)
{
this.Block = block;
this.clauses = catch_clauses;
this.Specific = catch_clauses;
this.inside_try_finally = inside_try_finally;
}
public List<Catch> Clauses {
get {
return clauses;
if (catch_clauses != null) {
Catch c = catch_clauses [0];
if (c.IsGeneral) {
this.General = c;
catch_clauses.RemoveAt (0);
}
}
}
@ -5262,8 +5237,9 @@ namespace Mono.CSharp { @@ -5262,8 +5237,9 @@ namespace Mono.CSharp {
if (!Block.Resolve (ec))
ok = false;
for (int i = 0; i < clauses.Count; ++i) {
var c = clauses[i];
TypeSpec[] prev_catches = new TypeSpec [Specific.Count];
int last_index = 0;
foreach (Catch c in Specific){
ec.CurrentBranching.CreateSibling (c.Block, FlowBranching.SiblingType.Catch);
if (!c.Resolve (ec)) {
@ -5272,40 +5248,37 @@ namespace Mono.CSharp { @@ -5272,40 +5248,37 @@ namespace Mono.CSharp {
}
TypeSpec resolved_type = c.CatchType;
for (int ii = 0; ii < clauses.Count; ++ii) {
if (ii == i)
continue;
if (clauses[ii].IsGeneral) {
if (resolved_type.BuiltinType != BuiltinTypeSpec.Type.Exception)
continue;
if (!ec.Module.DeclaringAssembly.WrapNonExceptionThrows)
continue;
if (!ec.Module.PredefinedAttributes.RuntimeCompatibility.IsDefined)
continue;
for (int ii = 0; ii < last_index; ++ii) {
if (resolved_type == prev_catches[ii] || TypeSpec.IsBaseClass (resolved_type, prev_catches[ii], true)) {
ec.Report.Error (160, c.loc,
"A previous catch clause already catches all exceptions of this or a super type `{0}'",
TypeManager.CSharpName (prev_catches [ii]));
ok = false;
}
}
ec.Report.Warning (1058, 1, c.loc,
"A previous catch clause already catches all exceptions. All non-exceptions thrown will be wrapped in a `System.Runtime.CompilerServices.RuntimeWrappedException'");
prev_catches [last_index++] = resolved_type;
}
if (General != null) {
foreach (Catch c in Specific) {
if (c.CatchType.BuiltinType != BuiltinTypeSpec.Type.Exception)
continue;
}
if (ii >= i)
if (!ec.Module.DeclaringAssembly.WrapNonExceptionThrows)
continue;
var ct = clauses[ii].CatchType;
if (ct == null)
if (!ec.Module.PredefinedAttributes.RuntimeCompatibility.IsDefined)
continue;
if (resolved_type == ct || TypeSpec.IsBaseClass (resolved_type, ct, true)) {
ec.Report.Error (160, c.loc,
"A previous catch clause already catches all exceptions of this or a super type `{0}'",
ct.GetSignatureForError ());
ok = false;
}
ec.Report.Warning (1058, 1, c.loc,
"A previous catch clause already catches all exceptions. All non-exceptions thrown will be wrapped in a `System.Runtime.CompilerServices.RuntimeWrappedException'");
}
ec.CurrentBranching.CreateSibling (General.Block, FlowBranching.SiblingType.Catch);
if (!General.Resolve (ec))
ok = false;
}
ec.EndFlowBranching ();
@ -5320,9 +5293,12 @@ namespace Mono.CSharp { @@ -5320,9 +5293,12 @@ namespace Mono.CSharp {
Block.Emit (ec);
foreach (Catch c in clauses)
foreach (Catch c in Specific)
c.Emit (ec);
if (General != null)
General.Emit (ec);
if (!inside_try_finally)
ec.EndExceptionBlock ();
}
@ -5332,13 +5308,14 @@ namespace Mono.CSharp { @@ -5332,13 +5308,14 @@ namespace Mono.CSharp {
TryCatch target = (TryCatch) t;
target.Block = clonectx.LookupBlock (Block);
if (clauses != null){
target.clauses = new List<Catch> ();
foreach (Catch c in clauses)
target.clauses.Add ((Catch) c.Clone (clonectx));
if (General != null)
target.General = (Catch) General.Clone (clonectx);
if (Specific != null){
target.Specific = new List<Catch> ();
foreach (Catch c in Specific)
target.Specific.Add ((Catch) c.Clone (clonectx));
}
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -5491,7 +5468,7 @@ namespace Mono.CSharp { @@ -5491,7 +5468,7 @@ namespace Mono.CSharp {
declarators = null;
return stmt;
}
}
public override object Accept (StructuralVisitor visitor)
{
@ -5515,7 +5492,7 @@ namespace Mono.CSharp { @@ -5515,7 +5492,7 @@ namespace Mono.CSharp {
#region Properties
public Expression Expr {
public Expression Expression {
get {
return decl.Variable == null ? decl.Initializer : null;
}
@ -5594,7 +5571,6 @@ namespace Mono.CSharp { @@ -5594,7 +5571,6 @@ namespace Mono.CSharp {
target.decl = (VariableDeclaration) decl.Clone (clonectx);
target.stmt = stmt.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -6138,6 +6114,14 @@ namespace Mono.CSharp { @@ -6138,6 +6114,14 @@ namespace Mono.CSharp {
LocalVariable variable;
Expression expr;
Statement statement;
public Expression TypeExpr {
get { return this.type; }
}
public LocalVariable Variable {
get { return this.variable; }
}
public Foreach (Expression type, LocalVariable var, Expression expr, Statement stmt, Location l)
{
@ -6148,23 +6132,14 @@ namespace Mono.CSharp { @@ -6148,23 +6132,14 @@ namespace Mono.CSharp {
loc = l;
}
public Expression Expr {
get { return expr; }
}
public Statement Statement {
get { return statement; }
}
public Expression TypeExpression {
get { return type; }
}
public LocalVariable Variable {
get { return variable; }
public Expression Expr {
get { return this.expr; }
}
public override bool Resolve (BlockContext ec)
{
expr = expr.Resolve (ec);

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

@ -37,7 +37,7 @@ namespace Mono.CSharp { @@ -37,7 +37,7 @@ namespace Mono.CSharp {
return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode (obj);
}
}
#if !NET_4_0
public class Tuple<T1, T2> : IEquatable<Tuple<T1, T2>>
{
public Tuple (T1 item1, T2 item2)
@ -107,7 +107,6 @@ namespace Mono.CSharp { @@ -107,7 +107,6 @@ namespace Mono.CSharp {
return new Tuple<T1, T2, T3> (item1, item2, item3);
}
}
#endif
static class ArrayComparer
{

Loading…
Cancel
Save