Browse Source

Updated mcs.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
19c344c55c
  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. 9900
      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.PosArguments != null) {
foreach (var arg in attr.PosArguments) {
if (attr.PositionalArguments != null) {
foreach (var arg in attr.PositionalArguments) {
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.Expression.Accept (this) as Expression;
var expr = statementErrorExpression.Expr.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.Specific != null) {
foreach (Catch ctch in tryCatchStatement.Specific) {
if (tryCatchStatement.Clauses != null) {
foreach (Catch ctch in tryCatchStatement.Clauses) {
result.AddChild (ConvertCatch (ctch), TryCatchStatement.CatchClauseRole);
}
}
if (tryCatchStatement.General != null)
/* if (tryCatchStatement. != 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.Expression != null)
result.AddChild ((AstNode)usingStatement.Expression.Accept (this), UsingStatement.ResourceAcquisitionRole);
if (usingStatement.Expr != null)
result.AddChild ((AstNode)usingStatement.Expr.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.TypeExpr != null)
result.AddChild (ConvertToType (foreachStatement.TypeExpr), ForeachStatement.Roles.Type);
if (foreachStatement.TypeExpression != null)
result.AddChild (ConvertToType (foreachStatement.TypeExpression), 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.Left.Accept (this), BinaryOperatorExpression.LeftRole);
result.AddChild ((Expression)nullCoalescingOperator.LeftExpression.Accept (this), BinaryOperatorExpression.LeftRole);
result.AddChild (new CSharpTokenNode (Convert (nullCoalescingOperator.Location), 2), BinaryOperatorExpression.OperatorRole);
result.AddChild ((Expression)nullCoalescingOperator.Right.Accept (this), BinaryOperatorExpression.RightRole);
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.Expression != null)
result.AddChild ((Expression)invocationExpression.Expression.Accept (this), InvocationExpression.Roles.TargetExpression);
if (invocationExpression.Exp != null)
result.AddChild ((Expression)invocationExpression.Exp.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.QueriedType), TypeOfExpression.Roles.Type);
result.AddChild (ConvertToType (sizeOfExpression.TypeExpression), 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,9 +885,8 @@ namespace Mono.CSharp { @@ -885,9 +885,8 @@ namespace Mono.CSharp {
public ParametersBlock Block;
public AnonymousMethodExpression (bool isAsync, Location loc)
public AnonymousMethodExpression (Location loc)
{
this.IsAsync = isAsync;
this.loc = loc;
this.compatibles = new Dictionary<TypeSpec, Expression> ();
}

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

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

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

@ -418,6 +418,11 @@ namespace Mono.CSharp { @@ -418,6 +418,11 @@ 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
@ -653,6 +658,12 @@ namespace Mono.CSharp { @@ -653,6 +658,12 @@ namespace Mono.CSharp {
this.left = left;
}
public Binary.Operator Operator {
get {
return op;
}
}
protected override Expression DoResolve (ResolveContext ec)
{
right = right.Resolve (ec);
@ -811,10 +822,10 @@ namespace Mono.CSharp { @@ -811,10 +822,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,6 +40,12 @@ namespace Mono.CSharp @@ -40,6 +40,12 @@ 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,8 +89,7 @@ namespace Mono.CSharp { @@ -89,8 +89,7 @@ namespace Mono.CSharp {
public AttributeTargets Target;
readonly ATypeNameExpression expression;
public Arguments PosArguments;
public Arguments NamedArguments;
Arguments pos_args, named_args;
bool resolve_error;
bool arg_resolved;
@ -118,8 +117,8 @@ namespace Mono.CSharp { @@ -118,8 +117,8 @@ namespace Mono.CSharp {
{
this.expression = expr;
if (args != null) {
PosArguments = args[0];
NamedArguments = args[1];
pos_args = args[0];
named_args = args[1];
}
this.loc = loc;
ExplicitTarget = target;
@ -132,6 +131,24 @@ namespace Mono.CSharp { @@ -132,6 +131,24 @@ 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";
@ -147,7 +164,7 @@ namespace Mono.CSharp { @@ -147,7 +164,7 @@ namespace Mono.CSharp {
}
if (NamedArguments == null)
NamedArguments = new Arguments (1);
named_args = 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));
@ -156,8 +173,8 @@ namespace Mono.CSharp { @@ -156,8 +173,8 @@ namespace Mono.CSharp {
public Attribute Clone ()
{
Attribute a = new Attribute (ExplicitTarget, expression, null, loc, nameEscaped);
a.PosArguments = PosArguments;
a.NamedArguments = NamedArguments;
a.pos_args = pos_args;
a.named_args = NamedArguments;
return a;
}
@ -432,14 +449,14 @@ namespace Mono.CSharp { @@ -432,14 +449,14 @@ namespace Mono.CSharp {
MethodSpec ctor;
// Try if the attribute is simple and has been resolved before
if (PosArguments != null || !context.Module.AttributeConstructorCache.TryGetValue (Type, out ctor)) {
if (pos_args != null || !context.Module.AttributeConstructorCache.TryGetValue (Type, out ctor)) {
rc = CreateResolveContext ();
ctor = ResolveConstructor (rc);
if (ctor == null) {
return null;
}
if (PosArguments == null && ctor.Parameters.IsEmpty)
if (pos_args == null && ctor.Parameters.IsEmpty)
context.Module.AttributeConstructorCache.Add (Type, ctor);
}
@ -468,16 +485,16 @@ namespace Mono.CSharp { @@ -468,16 +485,16 @@ namespace Mono.CSharp {
MethodSpec ResolveConstructor (ResolveContext ec)
{
if (PosArguments != null) {
if (pos_args != null) {
bool dynamic;
PosArguments.Resolve (ec, out dynamic);
pos_args.Resolve (ec, out dynamic);
if (dynamic) {
Error_AttributeArgumentIsDynamic (ec.MemberContext, loc);
return null;
}
}
return Expression.ConstructorLookup (ec, Type, ref PosArguments, loc);
return Expression.ConstructorLookup (ec, Type, ref pos_args, loc);
}
bool ResolveNamedArguments (ResolveContext ec)
@ -637,7 +654,7 @@ namespace Mono.CSharp { @@ -637,7 +654,7 @@ namespace Mono.CSharp {
if (resolve_error)
return DefaultUsageAttribute;
AttributeUsageAttribute usage_attribute = new AttributeUsageAttribute ((AttributeTargets)((Constant) PosArguments [0].Expr).GetValue ());
AttributeUsageAttribute usage_attribute = new AttributeUsageAttribute ((AttributeTargets) ((Constant) pos_args[0].Expr).GetValue ());
var field = GetNamedValue ("AllowMultiple") as BoolConstant;
if (field != null)
@ -660,10 +677,10 @@ namespace Mono.CSharp { @@ -660,10 +677,10 @@ namespace Mono.CSharp {
// But because a lot of attribute class code must be rewritten will be better to wait...
Resolve ();
if (resolve_error || PosArguments.Count != 1 || !(PosArguments [0].Expr is Constant))
if (resolve_error || pos_args.Count != 1 || !(pos_args[0].Expr is Constant))
return null;
return ((Constant) PosArguments [0].Expr).GetValue () as string;
return ((Constant) pos_args[0].Expr).GetValue () as string;
}
/// <summary>
@ -679,7 +696,7 @@ namespace Mono.CSharp { @@ -679,7 +696,7 @@ namespace Mono.CSharp {
if (resolve_error)
return null;
return ((Constant) PosArguments[0].Expr).GetValue () as string;
return ((Constant) pos_args[0].Expr).GetValue () as string;
}
/// <summary>
@ -701,14 +718,14 @@ namespace Mono.CSharp { @@ -701,14 +718,14 @@ namespace Mono.CSharp {
if (resolve_error)
return null;
if (PosArguments == null)
if (pos_args == null)
return new ObsoleteAttribute ();
string msg = ((Constant) PosArguments[0].Expr).GetValue () as string;
if (PosArguments.Count == 1)
string msg = ((Constant) pos_args[0].Expr).GetValue () as string;
if (pos_args.Count == 1)
return new ObsoleteAttribute (msg);
return new ObsoleteAttribute (msg, ((BoolConstant) PosArguments[1].Expr).Value);
return new ObsoleteAttribute (msg, ((BoolConstant) pos_args[1].Expr).Value);
}
/// <summary>
@ -726,7 +743,7 @@ namespace Mono.CSharp { @@ -726,7 +743,7 @@ namespace Mono.CSharp {
if (resolve_error)
return false;
return ((BoolConstant) PosArguments[0].Expr).Value;
return ((BoolConstant) pos_args[0].Expr).Value;
}
public TypeSpec GetCoClassAttributeValue ()
@ -812,7 +829,7 @@ namespace Mono.CSharp { @@ -812,7 +829,7 @@ namespace Mono.CSharp {
System.Security.Permissions.SecurityAction GetSecurityActionValue ()
{
return (SecurityAction) ((Constant) PosArguments[0].Expr).GetValue ();
return (SecurityAction) ((Constant) pos_args[0].Expr).GetValue ();
}
/// <summary>
@ -822,9 +839,9 @@ namespace Mono.CSharp { @@ -822,9 +839,9 @@ namespace Mono.CSharp {
public void ExtractSecurityPermissionSet (MethodSpec ctor, ref SecurityType permissions)
{
#if STATIC
object[] values = new object [PosArguments.Count];
object[] values = new object[pos_args.Count];
for (int i = 0; i < values.Length; ++i)
values [i] = ((Constant) PosArguments [i].Expr).GetValue ();
values[i] = ((Constant) pos_args[i].Expr).GetValue ();
PropertyInfo[] prop;
object[] prop_values;
@ -865,7 +882,7 @@ namespace Mono.CSharp { @@ -865,7 +882,7 @@ namespace Mono.CSharp {
public CharSet GetCharSetValue ()
{
return (CharSet)System.Enum.Parse (typeof (CharSet), ((Constant) PosArguments [0].Expr).GetValue ().ToString ());
return (CharSet) System.Enum.Parse (typeof (CharSet), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
}
public bool HasField (string fieldName)
@ -887,8 +904,8 @@ namespace Mono.CSharp { @@ -887,8 +904,8 @@ namespace Mono.CSharp {
public bool IsInternalCall ()
{
MethodImplOptions options = 0;
if (PosArguments.Count == 1) {
options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), ((Constant) PosArguments[0].Expr).GetValue ().ToString ());
if (pos_args.Count == 1) {
options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
} else if (HasField ("Value")) {
var named = GetNamedValue ("Value");
options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), named.GetValue ().ToString ());
@ -902,19 +919,19 @@ namespace Mono.CSharp { @@ -902,19 +919,19 @@ namespace Mono.CSharp {
//
public bool IsExplicitLayoutKind ()
{
if (PosArguments == null || PosArguments.Count != 1)
if (pos_args == null || pos_args.Count != 1)
return false;
var value = (LayoutKind) System.Enum.Parse (typeof (LayoutKind), ((Constant) PosArguments[0].Expr).GetValue ().ToString ());
var value = (LayoutKind) System.Enum.Parse (typeof (LayoutKind), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
return value == LayoutKind.Explicit;
}
public Expression GetParameterDefaultValue ()
{
if (PosArguments == null)
if (pos_args == null)
return null;
return PosArguments[0].Expr;
return pos_args[0].Expr;
}
public override bool Equals (object obj)
@ -951,16 +968,16 @@ namespace Mono.CSharp { @@ -951,16 +968,16 @@ namespace Mono.CSharp {
}
byte[] cdata;
if (PosArguments == null && named_values == null) {
if (pos_args == null && named_values == null) {
cdata = AttributeEncoder.Empty;
} else {
AttributeEncoder encoder = new AttributeEncoder ();
if (PosArguments != null) {
if (pos_args != null) {
var param_types = ctor.Parameters.Types;
for (int j = 0; j < PosArguments.Count; ++j) {
for (int j = 0; j < pos_args.Count; ++j) {
var pt = param_types[j];
var arg_expr = PosArguments[j].Expr;
var arg_expr = pos_args[j].Expr;
if (j == 0) {
if ((Type == predefined.IndexerName || Type == predefined.Conditional) && arg_expr is Constant) {
string v = ((Constant) arg_expr).GetValue () as string;
@ -984,15 +1001,15 @@ namespace Mono.CSharp { @@ -984,15 +1001,15 @@ namespace Mono.CSharp {
"System.AttributeUsage");
}
} else if (Type == predefined.MarshalAs) {
if (PosArguments.Count == 1) {
var u_type = (UnmanagedType) System.Enum.Parse (typeof (UnmanagedType), ((Constant) PosArguments[0].Expr).GetValue ().ToString ());
if (pos_args.Count == 1) {
var u_type = (UnmanagedType) System.Enum.Parse (typeof (UnmanagedType), ((Constant) pos_args[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 (PosArguments.Count == 1 && PosArguments[0].Expr is Constant) {
var value = ((Constant) PosArguments[0].Expr).GetValue () as string;
if (pos_args.Count == 1 && pos_args[0].Expr is Constant) {
var value = ((Constant) pos_args[0].Expr).GetValue () as string;
if (string.IsNullOrEmpty (value))
Error_AttributeEmitError ("DllName cannot be empty");
}
@ -1055,8 +1072,8 @@ namespace Mono.CSharp { @@ -1055,8 +1072,8 @@ namespace Mono.CSharp {
// Here we are testing attribute arguments for array usage (error 3016)
if (Owner.IsClsComplianceRequired ()) {
if (PosArguments != null)
PosArguments.CheckArrayAsAttribute (context.Module.Compiler);
if (pos_args != null)
pos_args.CheckArrayAsAttribute (context.Module.Compiler);
if (NamedArguments == null)
return;
@ -1067,10 +1084,10 @@ namespace Mono.CSharp { @@ -1067,10 +1084,10 @@ namespace Mono.CSharp {
private Expression GetValue ()
{
if (PosArguments == null || PosArguments.Count < 1)
if (pos_args == null || pos_args.Count < 1)
return null;
return PosArguments [0].Expr;
return pos_args[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;
protected FullNamedExpression base_type_expr; // TODO: It's temporary variable
FullNamedExpression base_type_expr; // TODO: It's temporary variable
protected TypeSpec[] iface_exprs;
protected List<FullNamedExpression> type_bases;
@ -256,6 +256,12 @@ namespace Mono.CSharp @@ -256,6 +256,12 @@ namespace Mono.CSharp
#region Properties
public List<FullNamedExpression> BaseTypeExpressions {
get {
return type_bases;
}
}
public override TypeSpec CurrentType {
get {
if (current_type == null) {
@ -332,7 +338,7 @@ namespace Mono.CSharp @@ -332,7 +338,7 @@ namespace Mono.CSharp
{
visitor.Visit (this);
}
public bool AddMember (MemberCore symbol)
{
return AddToContainer (symbol, symbol.MemberName.Basename);
@ -1366,9 +1372,13 @@ namespace Mono.CSharp @@ -1366,9 +1372,13 @@ namespace Mono.CSharp
type_defined = true;
// TODO: Driver resolves only first level of namespace, do the rest here for now
if (IsTopLevel && (ModFlags & Modifiers.COMPILER_GENERATED) == 0) {
NamespaceEntry.Resolve ();
// Nested type share same namespace
if (IsTopLevel && !IsCompilerGenerated) {
NamespaceEntry.Define ();
if (partial_parts != null) {
foreach (var part in partial_parts)
part.NamespaceEntry.Define ();
}
}
if (!DefineBaseTypes ()) {

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

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

@ -47,7 +47,6 @@ namespace Mono.CSharp { @@ -47,7 +47,6 @@ namespace Mono.CSharp {
bool is_double_colon;
public bool IsDoubleColon { get { return is_double_colon; } }
#if FULL_AST
public Location DotLocation {
@ -124,6 +123,12 @@ namespace Mono.CSharp { @@ -124,6 +123,12 @@ 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,6 +81,13 @@ namespace Mono.CSharp { @@ -81,6 +81,13 @@ 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.Resolve ();
source_file.NamespaceContainer.Define ();
}
tr.Stop (TimeReporter.TimerType.UsingResolve);

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

@ -4418,7 +4418,10 @@ namespace Mono.CSharp { @@ -4418,7 +4418,10 @@ namespace Mono.CSharp {
var ac_p = p as ArrayContainer;
if (ac_p != null) {
var ac_q = ((ArrayContainer) q);
var ac_q = q as ArrayContainer;
if (ac_q == null)
return null;
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,6 +373,7 @@ namespace Mono.CSharp @@ -373,6 +373,7 @@ 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);
@ -768,12 +769,17 @@ namespace Mono.CSharp @@ -768,12 +769,17 @@ namespace Mono.CSharp
return sb.ToString ();
}
internal ICollection<string> GetUsingList ()
internal List<string> GetUsingList ()
{
var res = new List<string> ();
foreach (var ue in source_file.NamespaceContainer.Usings)
res.Add (ue.Name);
foreach (var ue in source_file.NamespaceContainer.Usings) {
if (ue.Alias != null)
continue;
res.Add (ue.NamespaceName.Name);
}
return res;
}
@ -814,7 +820,7 @@ namespace Mono.CSharp @@ -814,7 +820,7 @@ namespace Mono.CSharp
public void LoadAssembly (string file)
{
var loader = new DynamicLoader (importer, ctx);
var assembly = loader.LoadAssemblyFile (file);
var assembly = loader.LoadAssemblyFile (file, false);
if (assembly == null)
return;

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

@ -801,18 +801,18 @@ namespace Mono.CSharp @@ -801,18 +801,18 @@ namespace Mono.CSharp
LocalTemporary temporary;
bool prepared;
public Expression Expr {
get {
return expr;
}
}
public Indirection (Expression expr, Location l)
{
this.expr = expr;
loc = l;
}
public Expression Expr {
get {
return expr;
}
}
public bool IsFixed {
get { return true; }
}
@ -1017,6 +1017,13 @@ namespace Mono.CSharp @@ -1017,6 +1017,13 @@ 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;
@ -1029,13 +1036,6 @@ namespace Mono.CSharp @@ -1029,13 +1036,6 @@ 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,6 +1283,7 @@ namespace Mono.CSharp @@ -1283,6 +1283,7 @@ namespace Mono.CSharp
target.expr = expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -1371,6 +1372,10 @@ namespace Mono.CSharp @@ -1371,6 +1372,10 @@ namespace Mono.CSharp
{
}
protected override string OperatorName {
get { return "is"; }
}
public override Expression CreateExpressionTree (ResolveContext ec)
{
Arguments args = Arguments.CreateForExpressionTree (ec, null,
@ -1545,10 +1550,6 @@ namespace Mono.CSharp @@ -1545,10 +1550,6 @@ namespace Mono.CSharp
return this;
}
protected override string OperatorName {
get { return "is"; }
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -1566,6 +1567,10 @@ namespace Mono.CSharp @@ -1566,6 +1567,10 @@ namespace Mono.CSharp
{
}
protected override string OperatorName {
get { return "as"; }
}
public override Expression CreateExpressionTree (ResolveContext ec)
{
Arguments args = Arguments.CreateForExpressionTree (ec, null,
@ -1644,14 +1649,10 @@ namespace Mono.CSharp @@ -1644,14 +1649,10 @@ namespace Mono.CSharp
return null;
}
protected override string OperatorName {
get { return "as"; }
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
//
@ -1753,13 +1754,6 @@ namespace Mono.CSharp @@ -1753,13 +1754,6 @@ namespace Mono.CSharp
public class DefaultValueExpression : Expression
{
Expression expr;
public Expression Expr {
get {
return this.expr;
}
}
public DefaultValueExpression (Expression expr, Location loc)
{
@ -1767,6 +1761,12 @@ namespace Mono.CSharp @@ -1767,6 +1761,12 @@ namespace Mono.CSharp
this.loc = loc;
}
public Expression Expr {
get {
return this.expr;
}
}
public override bool IsSideEffectFree {
get {
return true;
@ -2225,11 +2225,15 @@ namespace Mono.CSharp @@ -2225,11 +2225,15 @@ 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
@ -5235,7 +5239,7 @@ namespace Mono.CSharp @@ -5235,7 +5239,7 @@ namespace Mono.CSharp
}
}
public Expression Expression {
public Expression Exp {
get {
return expr;
}
@ -5490,6 +5494,7 @@ namespace Mono.CSharp @@ -5490,6 +5494,7 @@ 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);
@ -5541,6 +5546,12 @@ namespace Mono.CSharp @@ -5541,6 +5546,12 @@ namespace Mono.CSharp
}
}
public Expression TypeExpression {
get {
return RequestedType;
}
}
#endregion
/// <summary>
@ -5933,6 +5944,12 @@ namespace Mono.CSharp @@ -5933,6 +5944,12 @@ namespace Mono.CSharp
get { return elements.Count; }
}
public List<Expression> Elements {
get {
return elements;
}
}
public Expression this [int index] {
get {
return elements [index];
@ -5947,12 +5964,6 @@ namespace Mono.CSharp @@ -5947,12 +5964,6 @@ namespace Mono.CSharp
variable = value;
}
}
public List<Expression> Elements {
get {
return this.elements;
}
}
#endregion
public void Add (Expression expr)
@ -6044,24 +6055,16 @@ namespace Mono.CSharp @@ -6044,24 +6055,16 @@ 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)
{
@ -6099,6 +6102,24 @@ namespace Mono.CSharp @@ -6099,6 +6102,24 @@ 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) {
@ -6179,7 +6200,7 @@ namespace Mono.CSharp @@ -6179,7 +6200,7 @@ namespace Mono.CSharp
++const_initializers_count;
}
} else {
// only_constant_initializers = false;
only_constant_initializers = false;
}
array_data.Add (element);
@ -6284,7 +6305,7 @@ namespace Mono.CSharp @@ -6284,7 +6305,7 @@ namespace Mono.CSharp
protected bool ResolveInitializers (ResolveContext ec)
{
// only_constant_initializers = true;
only_constant_initializers = true;
if (arguments != null) {
bool res = true;
@ -7124,8 +7145,8 @@ namespace Mono.CSharp @@ -7124,8 +7145,8 @@ namespace Mono.CSharp
/// </summary>
public class Arglist : Expression
{
public Arguments Arguments { get; private set; }
Arguments arguments;
public Arglist (Location loc)
: this (null, loc)
{
@ -7133,18 +7154,24 @@ namespace Mono.CSharp @@ -7133,18 +7154,24 @@ 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;
}
@ -7165,9 +7192,9 @@ namespace Mono.CSharp @@ -7165,9 +7192,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;
@ -7175,17 +7202,18 @@ namespace Mono.CSharp @@ -7175,17 +7202,18 @@ 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);
@ -7207,6 +7235,12 @@ namespace Mono.CSharp @@ -7207,6 +7235,12 @@ namespace Mono.CSharp
this.loc = loc;
}
public FullNamedExpression TypeExpression {
get {
return texpr;
}
}
public override bool ContainsEmitWithAwait ()
{
return false;
@ -7597,12 +7631,12 @@ namespace Mono.CSharp @@ -7597,12 +7631,12 @@ namespace Mono.CSharp
/// Implements the sizeof expression
/// </summary>
public class SizeOf : Expression {
public readonly Expression QueriedType;
readonly Expression texpr;
TypeSpec type_queried;
public SizeOf (Expression queried_type, Location l)
{
this.QueriedType = queried_type;
this.texpr = queried_type;
loc = l;
}
@ -7612,6 +7646,12 @@ namespace Mono.CSharp @@ -7612,6 +7646,12 @@ namespace Mono.CSharp
}
}
public Expression TypeExpression {
get {
return texpr;
}
}
public override bool ContainsEmitWithAwait ()
{
return false;
@ -7625,7 +7665,7 @@ namespace Mono.CSharp @@ -7625,7 +7665,7 @@ namespace Mono.CSharp
protected override Expression DoResolve (ResolveContext ec)
{
type_queried = QueriedType.ResolveAsType (ec);
type_queried = texpr.ResolveAsType (ec);
if (type_queried == null)
return null;
@ -7693,6 +7733,12 @@ namespace Mono.CSharp @@ -7693,6 +7733,12 @@ namespace Mono.CSharp
this.alias = alias;
}
public string Alias {
get {
return alias;
}
}
public override FullNamedExpression ResolveAsTypeOrNamespace (IMemberContext ec)
{
if (alias == GlobalAlias) {
@ -7707,19 +7753,8 @@ namespace Mono.CSharp @@ -7707,19 +7753,8 @@ namespace Mono.CSharp
ec.Module.Compiler.Report.Error (432, loc, "Alias `{0}' not found", alias);
return null;
}
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;
return base.ResolveAsTypeOrNamespace (ec);
}
protected override Expression DoResolve (ResolveContext ec)
@ -7727,13 +7762,6 @@ namespace Mono.CSharp @@ -7727,13 +7762,6 @@ 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;
@ -7746,6 +7774,14 @@ namespace Mono.CSharp @@ -7746,6 +7774,14 @@ 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);
}
@ -8105,6 +8141,14 @@ namespace Mono.CSharp @@ -8105,6 +8141,14 @@ 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);
@ -8265,6 +8309,7 @@ namespace Mono.CSharp @@ -8265,6 +8309,7 @@ namespace Mono.CSharp
target.Expr = Expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -8329,6 +8374,7 @@ namespace Mono.CSharp @@ -8329,6 +8374,7 @@ namespace Mono.CSharp
target.Expr = Expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -9539,15 +9585,7 @@ namespace Mono.CSharp @@ -9539,15 +9585,7 @@ 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;
@ -9555,6 +9593,18 @@ namespace Mono.CSharp @@ -9555,6 +9593,18 @@ 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;
@ -10033,18 +10083,18 @@ namespace Mono.CSharp @@ -10033,18 +10083,18 @@ namespace Mono.CSharp
CollectionOrObjectInitializers initializers;
IMemoryLocation instance;
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;
}
public CollectionOrObjectInitializers Initializers {
get {
return initializers;
}
}
protected override void CloneTo (CloneContext clonectx, Expression t)
{
base.CloneTo (clonectx, t);
@ -10155,10 +10205,6 @@ namespace Mono.CSharp @@ -10155,10 +10205,6 @@ 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)
{
@ -10166,6 +10212,12 @@ namespace Mono.CSharp @@ -10166,6 +10212,12 @@ 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,6 +94,12 @@ namespace Mono.CSharp { @@ -94,6 +94,12 @@ namespace Mono.CSharp {
#region Properties
public List<FullNamedExpression> TypeExpressions {
get {
return constraints;
}
}
public Location Location {
get {
return loc;
@ -385,6 +391,12 @@ namespace Mono.CSharp { @@ -385,6 +391,12 @@ namespace Mono.CSharp {
}
}
public Constraints Constraints {
get {
return constraints;
}
}
public IAssemblyDefinition DeclaringAssembly {
get {
return Module.DeclaringAssembly;
@ -440,12 +452,6 @@ namespace Mono.CSharp { @@ -440,12 +452,6 @@ namespace Mono.CSharp {
}
}
public Constraints Constraints {
get {
return this.constraints;
}
}
#endregion
//
@ -1911,6 +1917,12 @@ namespace Mono.CSharp { @@ -1911,6 +1917,12 @@ 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,13 +24,8 @@ namespace Mono.CSharp { @@ -24,13 +24,8 @@ 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)
: this (false, loc)
: base (loc)
{
}

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

@ -287,6 +287,12 @@ namespace Mono.CSharp.Linq @@ -287,6 +287,12 @@ namespace Mono.CSharp.Linq
this.identifier = identifier;
}
public RangeVariable Identifier {
get {
return identifier;
}
}
public FullNamedExpression IdentifierType { get; set; }
protected Invocation CreateCastExpression (Expression lSide)
@ -476,6 +482,12 @@ namespace Mono.CSharp.Linq @@ -476,6 +482,12 @@ 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);
@ -519,6 +531,13 @@ namespace Mono.CSharp.Linq @@ -519,6 +531,13 @@ 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;
@ -530,13 +549,6 @@ namespace Mono.CSharp.Linq @@ -530,13 +549,6 @@ 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,8 +95,13 @@ namespace Mono.CSharp @@ -95,8 +95,13 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class CharLiteral : CharConstant, ILiteralConstant
@ -111,8 +116,13 @@ namespace Mono.CSharp @@ -111,8 +116,13 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class IntLiteral : IntConstant, ILiteralConstant
@ -143,8 +153,13 @@ namespace Mono.CSharp @@ -143,8 +153,13 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class UIntLiteral : UIntConstant, ILiteralConstant
@ -159,8 +174,13 @@ namespace Mono.CSharp @@ -159,8 +174,13 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class LongLiteral : LongConstant, ILiteralConstant
@ -175,8 +195,13 @@ namespace Mono.CSharp @@ -175,8 +195,13 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class ULongLiteral : ULongConstant, ILiteralConstant
@ -191,8 +216,13 @@ namespace Mono.CSharp @@ -191,8 +216,13 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class FloatLiteral : FloatConstant, ILiteralConstant
@ -207,8 +237,13 @@ namespace Mono.CSharp @@ -207,8 +237,13 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class DoubleLiteral : DoubleConstant, ILiteralConstant
@ -245,8 +280,13 @@ namespace Mono.CSharp @@ -245,8 +280,13 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class DecimalLiteral : DecimalConstant, ILiteralConstant
@ -261,8 +301,13 @@ namespace Mono.CSharp @@ -261,8 +301,13 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class StringLiteral : StringConstant, ILiteralConstant
@ -277,7 +322,12 @@ namespace Mono.CSharp @@ -277,7 +322,12 @@ namespace Mono.CSharp
}
#if FULL_AST
char[] ILiteralConstant.ParsedValue { get; set; }
public char[] ParsedValue { get; set; }
#endif
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
}

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

@ -899,6 +899,11 @@ namespace Mono.CSharp { @@ -899,6 +899,11 @@ 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)
{
@ -1175,11 +1180,6 @@ namespace Mono.CSharp { @@ -1175,11 +1180,6 @@ namespace Mono.CSharp {
return true;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
//
// Creates the type
//
@ -1569,6 +1569,11 @@ namespace Mono.CSharp { @@ -1569,6 +1569,11 @@ 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 ()) {
@ -1614,11 +1619,6 @@ namespace Mono.CSharp { @@ -1614,11 +1619,6 @@ namespace Mono.CSharp {
return true;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
//
// Creates the ConstructorBuilder
//
@ -2155,6 +2155,11 @@ namespace Mono.CSharp { @@ -2155,6 +2155,11 @@ 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) {
@ -2164,10 +2169,6 @@ namespace Mono.CSharp { @@ -2164,10 +2169,6 @@ namespace Mono.CSharp {
base.ApplyAttributeBuilder (a, ctor, cdata, pa);
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
protected override bool CheckBase ()
{
@ -2514,6 +2515,11 @@ namespace Mono.CSharp { @@ -2514,6 +2515,11 @@ 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) {
@ -2524,11 +2530,6 @@ namespace Mono.CSharp { @@ -2524,11 +2530,6 @@ 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,6 +35,11 @@ namespace Mono.CSharp { @@ -35,6 +35,11 @@ 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)
@ -578,6 +583,9 @@ namespace Mono.CSharp { @@ -578,6 +583,9 @@ 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;
@ -588,20 +596,18 @@ namespace Mono.CSharp { @@ -588,20 +596,18 @@ namespace Mono.CSharp {
NamespaceContainer implicit_parent;
int symfile_id;
// Namespace using import block
List<NamespaceUsingAlias> using_aliases;
List<NamespaceUsing> using_clauses;
List<UsingNamespace> clauses;
// Used by parsed to check for parser errors
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;
Namespace[] namespace_using_table;
Dictionary<string, UsingAliasNamespace> aliases;
public NamespaceContainer (MemberName name, ModuleContainer module, NamespaceContainer parent, CompilationSourceFile sourceFile)
{
@ -644,89 +650,30 @@ namespace Mono.CSharp { @@ -644,89 +650,30 @@ namespace Mono.CSharp {
}
}
public CompilationSourceFile SourceFile {
public NamespaceContainer Parent {
get {
return file;
return parent;
}
}
public List<NamespaceUsing> Usings {
public CompilationSourceFile SourceFile {
get {
return using_clauses;
return file;
}
}
#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 {
public List<UsingNamespace> Usings {
get {
if (!IsImplicit && doppelganger == null) {
doppelganger = new NamespaceContainer (module, ImplicitParent, file, ns, true);
doppelganger.using_aliases = using_aliases;
}
return doppelganger;
return clauses;
}
}
#endregion
public Namespace NS {
get { return ns; }
}
public NamespaceContainer Parent {
get { return parent; }
}
public NamespaceContainer ImplicitParent {
get {
if (parent == null)
@ -740,78 +687,47 @@ namespace Mono.CSharp { @@ -740,78 +687,47 @@ namespace Mono.CSharp {
}
}
/// <summary>
/// Records a new namespace for resolving name references
/// </summary>
public void AddUsing (MemberName name, Location loc)
public void AddUsing (UsingNamespace un)
{
if (DeclarationFound){
Compiler.Report.Error (1529, loc, "A using clause must precede all other namespace elements except extern alias declarations");
Compiler.Report.Error (1529, un.Location, "A using clause must precede all other namespace elements except extern alias declarations");
}
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;
}
}
}
if (clauses == null)
clauses = new List<UsingNamespace> ();
using_clauses.Add (new NamespaceUsing (name));
}
clauses.Add (un);
public void AddUsingAlias (string alias, MemberName name, Location loc)
{
if (DeclarationFound){
Compiler.Report.Error (1529, loc, "A using clause must precede all other namespace elements except extern alias declarations");
}
AddUsingAlias (new LocalUsingAliasEntry (alias, name, loc));
resolved = false;
}
public void AddUsingExternalAlias (string alias, Location loc, Report Report)
public void AddUsing (UsingAliasNamespace un)
{
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;
}
}
}
if (not_first)
Report.Error (439, loc, "An extern alias declaration must precede all other elements");
if (alias == "global") {
Error_GlobalNamespaceRedefined (loc, Report);
return;
if (DeclarationFound){
Compiler.Report.Error (1529, un.Location, "A using clause must precede all other namespace elements except extern alias declarations");
}
AddUsingAlias (new NamespaceUsingAlias (alias, loc));
AddAlias (un);
}
void AddUsingAlias (NamespaceUsingAlias uae)
void AddAlias (UsingAliasNamespace un)
{
if (using_aliases == null) {
using_aliases = new List<NamespaceUsingAlias> ();
if (clauses == null) {
clauses = new List<UsingNamespace> ();
} 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;
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 ());
}
}
}
using_aliases.Add (uae);
clauses.Add (un);
resolved = false;
}
//
@ -821,7 +737,7 @@ namespace Mono.CSharp { @@ -821,7 +737,7 @@ namespace Mono.CSharp {
public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
{
List<MethodSpec> candidates = null;
foreach (Namespace n in GetUsingTable ()) {
foreach (Namespace n in namespace_using_table) {
var a = n.LookupExtensionMethod (this, extensionType, name, arity);
if (a == null)
continue;
@ -866,7 +782,7 @@ namespace Mono.CSharp { @@ -866,7 +782,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 GetUsingTable ()){
foreach (Namespace using_ns in namespace_using_table){
if (prefix.StartsWith (using_ns.Name)){
int ld = prefix.LastIndexOf ('.');
if (ld != -1){
@ -881,18 +797,35 @@ namespace Mono.CSharp { @@ -881,18 +797,35 @@ 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.using_aliases == null)
if (n.aliases == null)
continue;
foreach (NamespaceUsingAlias ue in n.using_aliases) {
if (ue.Alias == name)
return ue.Resolve (Doppelganger ?? this, Doppelganger == null);
}
UsingAliasNamespace uan;
if (n.aliases.TryGetValue (name, out uan))
return uan.ResolvedExpression;
}
return null;
@ -908,26 +841,19 @@ namespace Mono.CSharp { @@ -908,26 +841,19 @@ namespace Mono.CSharp {
//
// Check aliases.
//
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 ue.Resolve (Doppelganger ?? this, Doppelganger == null);
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);
}
return uan.ResolvedExpression;
}
}
@ -941,9 +867,11 @@ namespace Mono.CSharp { @@ -941,9 +867,11 @@ namespace Mono.CSharp {
// Check using entries.
//
FullNamedExpression match = null;
foreach (Namespace using_ns in GetUsingTable ()) {
foreach (Namespace using_ns in namespace_using_table) {
//
// 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;
@ -983,41 +911,20 @@ namespace Mono.CSharp { @@ -983,41 +911,20 @@ 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 (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 ();
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 ();
}
symfile_id = SymbolWriter.DefineNamespace (ns.Name, file.CompileUnitEntry, using_list, parent_id);
@ -1036,11 +943,6 @@ namespace Mono.CSharp { @@ -1036,11 +943,6 @@ 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?",
@ -1069,29 +971,76 @@ namespace Mono.CSharp { @@ -1069,29 +971,76 @@ namespace Mono.CSharp {
}
}
/// <summary>
/// Used to validate that all the using clauses are correct
/// after we are finished parsing all the files.
/// </summary>
public void Resolve ()
public void Define ()
{
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 (using_aliases != null) {
foreach (NamespaceUsingAlias ue in using_aliases)
ue.Resolve (Doppelganger, Doppelganger == null);
}
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;
}
if (using_clauses != null) {
foreach (NamespaceUsing ue in using_clauses)
ue.Resolve (Doppelganger);
}
continue;
}
if (parent != null)
parent.Resolve ();
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);
}
clauses.RemoveAt (i--);
}
}
}
}
}
public string GetSignatureForError ()
@ -1118,7 +1067,7 @@ namespace Mono.CSharp { @@ -1118,7 +1067,7 @@ namespace Mono.CSharp {
}
public bool IsObsolete {
get { return SlaveDeclSpace.IsObsolete; }
get { return false; }
}
public bool IsUnsafe {
@ -1136,106 +1085,199 @@ namespace Mono.CSharp { @@ -1136,106 +1085,199 @@ namespace Mono.CSharp {
#endregion
}
public class NamespaceUsing
public class UsingNamespace
{
readonly MemberName name;
Namespace resolved;
readonly Location loc;
protected FullNamedExpression resolved;
public NamespaceUsing (MemberName name)
public UsingNamespace (MemberName name, Location loc)
{
this.name = name;
this.loc = loc;
}
public string GetSignatureForError ()
{
return name.GetSignatureForError ();
}
#region Properties
public Location Location
{
get { return name.Location; }
public virtual MemberName Alias {
get {
return null;
}
}
public MemberName MemberName
{
get { return name; }
public Location Location {
get {
return loc;
}
}
public string Name
{
get { return GetSignatureForError (); }
public MemberName NamespaceName {
get {
return name;
}
}
public Namespace Resolve (IMemberContext rc)
{
if (resolved != null)
public FullNamedExpression ResolvedExpression {
get {
return resolved;
}
}
FullNamedExpression fne = name.GetTypeExpression ().ResolveAsTypeOrNamespace (rc);
if (fne == null)
return null;
#endregion
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 ());
public string GetSignatureForError ()
{
return name.GetSignatureForError ();
}
public virtual void Define (NamespaceContainer ctx)
{
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 ());
}
}
return resolved;
}
}
public class NamespaceUsingAlias
public class UsingExternAlias : UsingAliasNamespace
{
public readonly string Alias;
public Location Location;
public NamespaceUsingAlias (string alias, Location loc)
public UsingExternAlias (MemberName alias, Location loc)
: base (alias, null, loc)
{
this.Alias = alias;
this.Location = loc;
}
public virtual FullNamedExpression Resolve (IMemberContext rc, bool local)
public override void Define (NamespaceContainer ctx)
{
FullNamedExpression fne = rc.Module.GetRootNamespace (Alias);
if (fne == null) {
rc.Module.Compiler.Report.Error (430, Location,
resolved = ctx.Module.GetRootNamespace (Alias.Name);
if (resolved == null) {
ctx.Module.Compiler.Report.Error (430, Location,
"The extern alias `{0}' was not specified in -reference option",
Alias);
Alias.Name);
}
return fne;
}
}
class LocalUsingAliasEntry : NamespaceUsingAlias
public class UsingAliasNamespace : UsingNamespace
{
FullNamedExpression resolved;
MemberName value;
readonly MemberName alias;
public LocalUsingAliasEntry (string alias, MemberName name, Location loc)
: base (alias, loc)
struct AliasContext : IMemberContext
{
this.value = name;
}
readonly NamespaceContainer ns;
public override FullNamedExpression Resolve (IMemberContext rc, bool local)
{
if (resolved != null || value == null)
return resolved;
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;
}
}
public string GetSignatureForError ()
{
throw new NotImplementedException ();
}
if (local)
public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
{
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;
}
return resolved;
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));
}
}
}

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

@ -1001,20 +1001,24 @@ namespace Mono.CSharp.Nullable @@ -1001,20 +1001,24 @@ 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,10 +234,7 @@ namespace Mono.CSharp { @@ -234,10 +234,7 @@ 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;
@ -251,6 +248,12 @@ namespace Mono.CSharp { @@ -251,6 +248,12 @@ namespace Mono.CSharp {
#region Properties
public Expression DefaultExpression {
get {
return default_expr;
}
}
public DefaultParameterValueExpression DefaultValue {
get {
return default_expr as DefaultParameterValueExpression;
@ -279,6 +282,12 @@ namespace Mono.CSharp { @@ -279,6 +282,12 @@ namespace Mono.CSharp {
}
}
public Modifier ParameterModifier {
get {
return modFlags;
}
}
public TypeSpec Type {
get {
return parameter_type;
@ -1212,7 +1221,7 @@ namespace Mono.CSharp { @@ -1212,7 +1221,7 @@ namespace Mono.CSharp {
//
// Default parameter value expression. We need this wrapper to handle
// default parameter values of folded constants when for indexer parameters
// default parameter values of folded constants (e.g. 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,6 +733,12 @@ namespace Mono.CSharp @@ -733,6 +733,12 @@ namespace Mono.CSharp
{
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
void CreateAutomaticProperty ()
{
// Create backing field
@ -757,11 +763,6 @@ namespace Mono.CSharp @@ -757,11 +763,6 @@ 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 ())
@ -857,6 +858,11 @@ namespace Mono.CSharp @@ -857,6 +858,11 @@ namespace Mono.CSharp
{
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override bool Define()
{
if (!base.Define ())
@ -871,12 +877,6 @@ namespace Mono.CSharp @@ -871,12 +877,6 @@ namespace Mono.CSharp
return attribute_targets;
}
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
/// <summary>
@ -999,6 +999,12 @@ namespace Mono.CSharp @@ -999,6 +999,12 @@ namespace Mono.CSharp
#region Properties
public List<FieldDeclarator> Declarators {
get {
return this.declarators;
}
}
bool HasBackingField {
get {
return !IsInterface && (ModFlags & Modifiers.ABSTRACT) == 0;
@ -1020,14 +1026,14 @@ namespace Mono.CSharp @@ -1020,14 +1026,14 @@ namespace Mono.CSharp
}
}
public List<FieldDeclarator> Declarators {
get {
return this.declarators;
}
}
#endregion
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public void AddDeclarator (FieldDeclarator declarator)
{
if (declarators == null)
@ -1105,11 +1111,6 @@ namespace Mono.CSharp @@ -1105,11 +1111,6 @@ namespace Mono.CSharp
return true;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
public abstract class Event : PropertyBasedMember
@ -1513,6 +1514,12 @@ namespace Mono.CSharp @@ -1513,6 +1514,12 @@ 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) {
@ -1534,11 +1541,6 @@ namespace Mono.CSharp @@ -1534,11 +1541,6 @@ 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,12 +442,7 @@ namespace Mono.CSharp @@ -442,12 +442,7 @@ namespace Mono.CSharp
return assembly.GetType (compiler.BuiltinTypes.Object.FullName) != null;
}
public override Assembly LoadAssemblyFile (string fileName)
{
return LoadAssemblyFile (fileName, false);
}
Assembly LoadAssemblyFile (string assembly, bool soft)
public override Assembly LoadAssemblyFile (string assembly, bool isImplicitReference)
{
Assembly a = null;
@ -464,7 +459,7 @@ namespace Mono.CSharp @@ -464,7 +459,7 @@ namespace Mono.CSharp
a = Assembly.Load (ass);
}
} catch (FileNotFoundException) {
bool err = !soft;
bool err = !isImplicitReference;
foreach (string dir in paths) {
string full_path = Path.Combine (dir, assembly);
if (!assembly.EndsWith (".dll") && !assembly.EndsWith (".exe"))
@ -490,11 +485,6 @@ namespace Mono.CSharp @@ -490,11 +485,6 @@ 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) {
NamespaceContainer.Error_GlobalNamespaceRedefined (Location.Null, Report);
RootNamespace.Error_GlobalNamespaceRedefined (Report, Location.Null);
return global_ns;
}

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

@ -154,9 +154,11 @@ namespace Mono.CSharp { @@ -154,9 +154,11 @@ 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)
@ -639,9 +641,11 @@ namespace Mono.CSharp { @@ -639,9 +641,11 @@ 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)
@ -676,7 +680,7 @@ namespace Mono.CSharp { @@ -676,7 +680,7 @@ namespace Mono.CSharp {
this.expr = expr;
}
public Expression Expression {
public Expression Expr {
get {
return expr;
}
@ -779,25 +783,30 @@ namespace Mono.CSharp { @@ -779,25 +783,30 @@ namespace Mono.CSharp {
/// </summary>
public class Return : ExitStatement
{
public Expression Expr { get; protected set; }
Expression expr;
public Return (Expression expr, Location l)
{
Expr = expr;
this.expr = expr;
loc = l;
}
#region Properties
public Expression Expression {
public Expression Expr {
get {
return Expr;
return expr;
}
protected set {
expr = value;
}
}
#endregion
protected override bool DoResolve (BlockContext ec)
{
if (Expr == null) {
if (expr == null) {
if (ec.ReturnType.Kind == MemberKind.Void)
return true;
@ -811,7 +820,7 @@ namespace Mono.CSharp { @@ -811,7 +820,7 @@ namespace Mono.CSharp {
//
// Extra trick not to emit ret/leave inside awaiter body
//
Expr = EmptyExpression.Null;
expr = EmptyExpression.Null;
return true;
}
}
@ -827,7 +836,7 @@ namespace Mono.CSharp { @@ -827,7 +836,7 @@ namespace Mono.CSharp {
return false;
}
Expr = Expr.Resolve (ec);
expr = expr.Resolve (ec);
TypeSpec block_return_type = ec.ReturnType;
AnonymousExpression am = ec.CurrentAnonymousMethod;
@ -845,12 +854,12 @@ namespace Mono.CSharp { @@ -845,12 +854,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;
}
@ -871,20 +880,20 @@ namespace Mono.CSharp { @@ -871,20 +880,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",
@ -899,8 +908,8 @@ namespace Mono.CSharp { @@ -899,8 +908,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) {
@ -936,9 +945,10 @@ namespace Mono.CSharp { @@ -936,9 +945,10 @@ 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);
@ -1135,9 +1145,11 @@ namespace Mono.CSharp { @@ -1135,9 +1145,11 @@ namespace Mono.CSharp {
expr = e;
loc = l;
}
public Expression Expr {
get { return this.expr; }
get {
return this.expr;
}
}
public override bool Resolve (BlockContext ec)
@ -1207,11 +1219,13 @@ namespace Mono.CSharp { @@ -1207,11 +1219,13 @@ 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) {
@ -1872,6 +1886,7 @@ namespace Mono.CSharp { @@ -1872,6 +1886,7 @@ namespace Mono.CSharp {
public static string GetCompilerGeneratedName (Block block)
{
// HACK: Debugger depends on the name semantics
return "$locvar" + block.ParametersBlock.TemporaryLocalsCount++.ToString ("X");
}
@ -1988,7 +2003,7 @@ namespace Mono.CSharp { @@ -1988,7 +2003,7 @@ namespace Mono.CSharp {
int? resolving_init_idx;
protected Block original;
Block original;
#if DEBUG
static int id;
@ -2035,6 +2050,9 @@ namespace Mono.CSharp { @@ -2035,6 +2050,9 @@ namespace Mono.CSharp {
get {
return original;
}
protected set {
original = value;
}
}
public bool IsCompilerGenerated {
@ -2051,10 +2069,11 @@ namespace Mono.CSharp { @@ -2051,10 +2069,11 @@ namespace Mono.CSharp {
get { return (flags & Flags.Unsafe) != 0; }
set { flags |= Flags.Unsafe; }
}
public List<Statement> Statements {
get { return this.statements; }
get { return statements; }
}
#endregion
public Block CreateSwitchBlock (Location start)
@ -2328,6 +2347,7 @@ namespace Mono.CSharp { @@ -2328,6 +2347,7 @@ namespace Mono.CSharp {
foreach (Statement s in statements)
target.statements.Add (s.Clone (clonectx));
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -2692,7 +2712,7 @@ namespace Mono.CSharp { @@ -2692,7 +2712,7 @@ namespace Mono.CSharp {
// Overwrite original for comparison purposes when linking cross references
// between anonymous methods
//
original = source;
Original = source;
}
#region Properties
@ -2906,7 +2926,7 @@ namespace Mono.CSharp { @@ -2906,7 +2926,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);
@ -2921,7 +2941,7 @@ namespace Mono.CSharp { @@ -2921,7 +2941,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);
@ -4468,11 +4488,13 @@ namespace Mono.CSharp { @@ -4468,11 +4488,13 @@ 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);
@ -5151,6 +5173,12 @@ namespace Mono.CSharp { @@ -5151,6 +5173,12 @@ namespace Mono.CSharp {
this.fini = fini;
}
public Block Finallyblock {
get {
return fini;
}
}
public override bool Resolve (BlockContext ec)
{
bool ok = true;
@ -5202,23 +5230,20 @@ namespace Mono.CSharp { @@ -5202,23 +5230,20 @@ namespace Mono.CSharp {
public class TryCatch : ExceptionStatement
{
public Block Block;
public List<Catch> Specific;
public Catch General;
List<Catch> clauses;
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.Specific = catch_clauses;
this.clauses = catch_clauses;
this.inside_try_finally = inside_try_finally;
if (catch_clauses != null) {
Catch c = catch_clauses [0];
if (c.IsGeneral) {
this.General = c;
catch_clauses.RemoveAt (0);
}
}
public List<Catch> Clauses {
get {
return clauses;
}
}
@ -5237,9 +5262,8 @@ namespace Mono.CSharp { @@ -5237,9 +5262,8 @@ namespace Mono.CSharp {
if (!Block.Resolve (ec))
ok = false;
TypeSpec[] prev_catches = new TypeSpec [Specific.Count];
int last_index = 0;
foreach (Catch c in Specific){
for (int i = 0; i < clauses.Count; ++i) {
var c = clauses[i];
ec.CurrentBranching.CreateSibling (c.Block, FlowBranching.SiblingType.Catch);
if (!c.Resolve (ec)) {
@ -5248,37 +5272,40 @@ namespace Mono.CSharp { @@ -5248,37 +5272,40 @@ namespace Mono.CSharp {
}
TypeSpec resolved_type = c.CatchType;
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;
}
}
for (int ii = 0; ii < clauses.Count; ++ii) {
if (ii == i)
continue;
prev_catches [last_index++] = resolved_type;
}
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;
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'");
if (General != null) {
foreach (Catch c in Specific) {
if (c.CatchType.BuiltinType != BuiltinTypeSpec.Type.Exception)
continue;
}
if (!ec.Module.DeclaringAssembly.WrapNonExceptionThrows)
if (ii >= i)
continue;
if (!ec.Module.PredefinedAttributes.RuntimeCompatibility.IsDefined)
var ct = clauses[ii].CatchType;
if (ct == null)
continue;
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'");
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.CurrentBranching.CreateSibling (General.Block, FlowBranching.SiblingType.Catch);
if (!General.Resolve (ec))
ok = false;
}
ec.EndFlowBranching ();
@ -5293,12 +5320,9 @@ namespace Mono.CSharp { @@ -5293,12 +5320,9 @@ namespace Mono.CSharp {
Block.Emit (ec);
foreach (Catch c in Specific)
foreach (Catch c in clauses)
c.Emit (ec);
if (General != null)
General.Emit (ec);
if (!inside_try_finally)
ec.EndExceptionBlock ();
}
@ -5308,14 +5332,13 @@ namespace Mono.CSharp { @@ -5308,14 +5332,13 @@ namespace Mono.CSharp {
TryCatch target = (TryCatch) t;
target.Block = clonectx.LookupBlock (Block);
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));
if (clauses != null){
target.clauses = new List<Catch> ();
foreach (Catch c in clauses)
target.clauses.Add ((Catch) c.Clone (clonectx));
}
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -5468,7 +5491,7 @@ namespace Mono.CSharp { @@ -5468,7 +5491,7 @@ namespace Mono.CSharp {
declarators = null;
return stmt;
}
}
public override object Accept (StructuralVisitor visitor)
{
@ -5492,7 +5515,7 @@ namespace Mono.CSharp { @@ -5492,7 +5515,7 @@ namespace Mono.CSharp {
#region Properties
public Expression Expression {
public Expression Expr {
get {
return decl.Variable == null ? decl.Initializer : null;
}
@ -5571,6 +5594,7 @@ namespace Mono.CSharp { @@ -5571,6 +5594,7 @@ namespace Mono.CSharp {
target.decl = (VariableDeclaration) decl.Clone (clonectx);
target.stmt = stmt.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -6114,14 +6138,6 @@ namespace Mono.CSharp { @@ -6114,14 +6138,6 @@ 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)
{
@ -6132,14 +6148,23 @@ namespace Mono.CSharp { @@ -6132,14 +6148,23 @@ namespace Mono.CSharp {
loc = l;
}
public Expression Expr {
get { return expr; }
}
public Statement Statement {
get { return statement; }
}
public Expression Expr {
get { return this.expr; }
public Expression TypeExpression {
get { return type; }
}
public LocalVariable Variable {
get { return variable; }
}
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,6 +107,7 @@ namespace Mono.CSharp { @@ -107,6 +107,7 @@ namespace Mono.CSharp {
return new Tuple<T1, T2, T3> (item1, item2, item3);
}
}
#endif
static class ArrayComparer
{

Loading…
Cancel
Save