Browse Source

Merged with mcs master.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
7a8e9d05c9
  1. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs
  2. 11
      ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  3. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs
  4. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/complete.cs
  5. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/constant.cs
  6. 14
      ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs
  7. 7320
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  8. 121
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  9. 11
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs
  10. 1
      ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs
  11. 11
      ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs
  12. 18
      ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
  13. 34
      ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs
  14. 90
      ICSharpCode.NRefactory.CSharp/Parser/mcs/flowanalysis.cs
  15. 25
      ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs
  16. 8
      ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs
  17. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/literal.cs
  18. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs
  19. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/rootcontext.cs
  20. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/roottypes.cs
  21. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  22. 71
      ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs
  23. 29
      ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs

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

@ -582,7 +582,7 @@ namespace Mono.CSharp @@ -582,7 +582,7 @@ namespace Mono.CSharp
public Field AddAwaiter (TypeSpec type, Location loc)
{
return AddCompilerGeneratedField ("$awaiter" + awaiters++.ToString ("X"), new TypeExpression (type, loc), true);
return AddCapturedVariable ("$awaiter" + awaiters++.ToString ("X"), type);
}
public Field AddCapturedLocalVariable (TypeSpec type)
@ -660,7 +660,6 @@ namespace Mono.CSharp @@ -660,7 +660,6 @@ namespace Mono.CSharp
}
builder = AddCompilerGeneratedField ("$builder", new TypeExpression (bt, Location));
builder.ModFlags |= Modifiers.READONLY;
if (!base.DoDefineMembers ())
return false;

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

@ -3,12 +3,13 @@ @@ -3,12 +3,13 @@
//
// Authors: Miguel de Icaza (miguel@gnu.org)
// Martin Baulig (martin@ximian.com)
// Marek Safar (marek.safar@seznam.cz)
// Marek Safar (marek.safar@gmail.com)
//
// Dual licensed under the terms of the MIT X11 or GNU GPL
//
// Copyright 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com)
// Copyright 2004-2008 Novell, Inc
// Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
//
using System;
@ -1241,7 +1242,7 @@ namespace Mono.CSharp @@ -1241,7 +1242,7 @@ namespace Mono.CSharp
if (iface_type == null)
continue;
if (!spec.AddInterface (iface_type))
if (!spec.AddInterfaceDefined (iface_type))
continue;
TypeBuilder.AddInterfaceImplementation (iface_type.GetMetaInfo ());
@ -1257,7 +1258,7 @@ namespace Mono.CSharp @@ -1257,7 +1258,7 @@ namespace Mono.CSharp
var base_ifaces = new List<TypeSpec> (iface_type.Interfaces);
for (int i = 0; i < base_ifaces.Count; ++i) {
var ii_iface_type = base_ifaces[i];
if (spec.AddInterface (ii_iface_type)) {
if (spec.AddInterfaceDefined (ii_iface_type)) {
TypeBuilder.AddInterfaceImplementation (ii_iface_type.GetMetaInfo ());
if (ii_iface_type.Interfaces != null)
@ -3143,13 +3144,13 @@ namespace Mono.CSharp @@ -3143,13 +3144,13 @@ namespace Mono.CSharp
if (OptAttributes == null || !OptAttributes.Contains (Module.PredefinedAttributes.Obsolete)) {
Report.SymbolRelatedToPreviousError (base_member);
Report.Warning (672, 1, Location, "Member `{0}' overrides obsolete member `{1}'. Add the Obsolete attribute to `{0}'",
GetSignatureForError (), TypeManager.GetFullNameSignature (base_member));
GetSignatureForError (), base_member.GetSignatureForError ());
}
} else {
if (OptAttributes != null && OptAttributes.Contains (Module.PredefinedAttributes.Obsolete)) {
Report.SymbolRelatedToPreviousError (base_member);
Report.Warning (809, 1, Location, "Obsolete member `{0}' overrides non-obsolete member `{1}'",
GetSignatureForError (), TypeManager.GetFullNameSignature (base_member));
GetSignatureForError (), base_member.GetSignatureForError ());
}
}

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

@ -958,7 +958,7 @@ namespace Mono.CSharp @@ -958,7 +958,7 @@ namespace Mono.CSharp
//
// Push the instance expression
//
if ((instance_type.IsStruct && (callOpcode == OpCodes.Callvirt || (callOpcode == OpCodes.Call && declaringType == instance_type))) ||
if ((instance_type.IsStruct && (callOpcode == OpCodes.Callvirt || (callOpcode == OpCodes.Call && declaringType.IsStruct))) ||
instance_type.IsGenericParameter || declaringType.IsNullableType) {
//
// If the expression implements IMemoryLocation, then

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

@ -120,7 +120,7 @@ namespace Mono.CSharp { @@ -120,7 +120,7 @@ namespace Mono.CSharp {
TypeSpec expr_type = expr_resolved.Type;
if (expr_type.IsPointer || expr_type.Kind == MemberKind.Void || expr_type == InternalType.NullLiteral || expr_type == InternalType.AnonymousMethod) {
Unary.Error_OperatorCannotBeApplied (ec, loc, ".", expr_type);
expr_resolved.Error_OperatorCannotBeApplied (ec, loc, ".", expr_type);
return null;
}

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

@ -274,7 +274,7 @@ namespace Mono.CSharp { @@ -274,7 +274,7 @@ namespace Mono.CSharp {
return this;
Constant c;
if (TypeManager.IsEnumType (target_type)) {
if (target_type.IsEnum) {
c = TryReduce (ec, EnumSpec.GetUnderlyingType (target_type));
if (c == null)
return null;

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

@ -1259,7 +1259,7 @@ namespace Mono.CSharp { @@ -1259,7 +1259,7 @@ namespace Mono.CSharp {
static Expression ImplicitConversionStandard (ResolveContext ec, Expression expr, TypeSpec target_type, Location loc, bool explicit_cast)
{
if (expr.eclass == ExprClass.MethodGroup){
if (!TypeManager.IsDelegateType (target_type)){
if (!target_type.IsDelegate){
return null;
}
@ -1334,7 +1334,7 @@ namespace Mono.CSharp { @@ -1334,7 +1334,7 @@ namespace Mono.CSharp {
if (e != null)
return e;
if (expr is IntegralConstant && TypeManager.IsEnumType (target_type)){
if (expr is IntegralConstant && target_type.IsEnum){
var i = (IntegralConstant) expr;
//
// LAMESPEC: csc allows any constant like 0 values to be converted, including const float f = 0.0
@ -1871,7 +1871,7 @@ namespace Mono.CSharp { @@ -1871,7 +1871,7 @@ namespace Mono.CSharp {
//
// From System delegate to any delegate-type
//
if (source_type.BuiltinType == BuiltinTypeSpec.Type.Delegate && TypeManager.IsDelegateType (target_type))
if (source_type.BuiltinType == BuiltinTypeSpec.Type.Delegate && target_type.IsDelegate)
return source == null ? EmptyExpression.Null : new ClassCast (source, target_type);
//
@ -1931,8 +1931,8 @@ namespace Mono.CSharp { @@ -1931,8 +1931,8 @@ namespace Mono.CSharp {
if (ne != null)
return ne;
if (TypeManager.IsEnumType (expr_type)) {
TypeSpec real_target = TypeManager.IsEnumType (target_type) ? EnumSpec.GetUnderlyingType (target_type) : target_type;
if (expr_type.IsEnum) {
TypeSpec real_target = target_type.IsEnum ? EnumSpec.GetUnderlyingType (target_type) : target_type;
Expression underlying = EmptyCast.Create (expr, EnumSpec.GetUnderlyingType (expr_type));
if (underlying.Type == real_target)
ne = underlying;
@ -1952,14 +1952,14 @@ namespace Mono.CSharp { @@ -1952,14 +1952,14 @@ namespace Mono.CSharp {
return ne != null ? EmptyCast.Create (ne, target_type) : null;
}
if (TypeManager.IsEnumType (target_type)) {
if (target_type.IsEnum) {
//
// System.Enum can be unboxed to any enum-type
//
if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Enum)
return new UnboxCast (expr, target_type);
TypeSpec real_target = TypeManager.IsEnumType (target_type) ? EnumSpec.GetUnderlyingType (target_type) : target_type;
TypeSpec real_target = target_type.IsEnum ? EnumSpec.GetUnderlyingType (target_type) : target_type;
if (expr_type == real_target)
return EmptyCast.Create (expr, target_type);

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

File diff suppressed because it is too large Load Diff

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

@ -75,6 +75,8 @@ namespace Mono.CSharp @@ -75,6 +75,8 @@ namespace Mono.CSharp
ParametersCompiled current_local_parameters;
bool parsing_anonymous_method;
bool async_block;
///
/// An out-of-band stack.
@ -885,7 +887,7 @@ named_attribute_argument @@ -885,7 +887,7 @@ named_attribute_argument
;
named_argument
: IDENTIFIER COLON opt_named_modifier expression
: identifier_inside_body COLON opt_named_modifier expression
{
if (lang_version <= LanguageVersion.V_3)
FeatureIsNotAvailable (GetLocation ($1), "named argument");
@ -1254,14 +1256,14 @@ method_declaration @@ -1254,14 +1256,14 @@ method_declaration
// Add it early in the case of body being eof for full ast
Method m = (Method) $1;
lexer.async_block = (m.ModFlags & Modifiers.ASYNC) != 0;
async_block = (m.ModFlags & Modifiers.ASYNC) != 0;
current_container.AddMethod (m);
}
method_body
{
Method method = (Method) $1;
method.Block = (ToplevelBlock) $3;
lexer.async_block = false;
async_block = false;
if (method.Block == null) {
lbag.AppendToMember (method, savedLocation); // semicolon
@ -3709,13 +3711,13 @@ typeof_type_expression @@ -3709,13 +3711,13 @@ typeof_type_expression
;
unbound_type_name
: IDENTIFIER generic_dimension
: identifier_inside_body generic_dimension
{
var lt = (Tokenizer.LocatedToken) $1;
$$ = new SimpleName (lt.Value, (int) $2, lt.Location);
}
| qualified_alias_member IDENTIFIER generic_dimension
| qualified_alias_member identifier_inside_body generic_dimension
{
var lt1 = (Tokenizer.LocatedToken) $1;
var lt2 = (Tokenizer.LocatedToken) $2;
@ -3723,7 +3725,7 @@ unbound_type_name @@ -3723,7 +3725,7 @@ unbound_type_name
$$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (int) $3, lt1.Location);
lbag.AddLocation ($$, GetLocation ($2));
}
| unbound_type_name DOT IDENTIFIER
| unbound_type_name DOT identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $3;
@ -3731,7 +3733,7 @@ unbound_type_name @@ -3731,7 +3733,7 @@ unbound_type_name
DotLocation = GetLocation ($2)
};
}
| unbound_type_name DOT IDENTIFIER generic_dimension
| unbound_type_name DOT identifier_inside_body generic_dimension
{
var lt = (Tokenizer.LocatedToken) $3;
@ -3739,7 +3741,7 @@ unbound_type_name @@ -3739,7 +3741,7 @@ unbound_type_name
DotLocation = GetLocation ($2)
};
}
| namespace_or_type_name DOT IDENTIFIER generic_dimension
| namespace_or_type_name DOT identifier_inside_body generic_dimension
{
var te = ((MemberName) $1).GetTypeExpression ();
if (te.HasTypeArguments)
@ -3878,22 +3880,20 @@ unary_expression @@ -3878,22 +3880,20 @@ unary_expression
{
$$ = new Unary (Unary.Operator.OnesComplement, (Expression) $2, GetLocation ($1));
}
| cast_expression
| await_expression
;
cast_expression
: OPEN_PARENS_CAST type CLOSE_PARENS prefixed_unary_expression
| OPEN_PARENS_CAST type CLOSE_PARENS prefixed_unary_expression
{
$$ = new Cast ((FullNamedExpression) $2, (Expression) $4, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($3));
}
;
await_expression
: AWAIT unary_expression
| AWAIT prefixed_unary_expression
{
current_block.ParametersBlock.IsAsync = true;
if (!async_block) {
report.Error (1992, GetLocation ($1),
"The `await' operator can only be used when its containing method or lambda expression is marked with the `async' modifier");
} else {
current_block.ParametersBlock.IsAsync = true;
}
$$ = new Await ((Expression) $2, GetLocation ($1));
}
;
@ -4092,8 +4092,13 @@ conditional_expression @@ -4092,8 +4092,13 @@ conditional_expression
}
;
expression_recover
: expression
| error { $$ = new NullLiteral (GetLocation ($1)); }
;
assignment_expression
: prefixed_unary_expression ASSIGN expression
: prefixed_unary_expression ASSIGN expression_recover
{
$$ = new SimpleAssign ((Expression) $1, (Expression) $3, GetLocation ($2));
}
@ -4173,13 +4178,13 @@ lambda_parameter_list @@ -4173,13 +4178,13 @@ lambda_parameter_list
;
lambda_parameter
: parameter_modifier parameter_type IDENTIFIER
: parameter_modifier parameter_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $3;
$$ = new Parameter ((FullNamedExpression) $2, lt.Value, (Parameter.Modifier) $1, null, lt.Location);
}
| parameter_type IDENTIFIER
| parameter_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $2;
@ -4240,7 +4245,7 @@ lambda_expression @@ -4240,7 +4245,7 @@ lambda_expression
$$ = end_anonymous ((ParametersBlock) $4);
lbag.AddLocation ($$, GetLocation ($2));
}
| ASYNC IDENTIFIER ARROW
| ASYNC identifier_inside_body ARROW
{
var lt = (Tokenizer.LocatedToken) $2;
Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
@ -4800,7 +4805,7 @@ empty_statement @@ -4800,7 +4805,7 @@ empty_statement
;
labeled_statement
: IDENTIFIER COLON
: identifier_inside_body COLON
{
var lt = (Tokenizer.LocatedToken) $1;
LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location);
@ -4908,8 +4913,19 @@ pointer_star @@ -4908,8 +4913,19 @@ pointer_star
}
;
identifier_inside_body
: IDENTIFIER
| AWAIT
{
if (async_block) {
report.Error (4003, GetLocation ($1), "`await' cannot be used as an identifier within an async method or lambda expression");
$$ = Tokenizer.LocatedToken.Create ("await", GetLocation ($1));
}
}
;
block_variable_declaration
: variable_type IDENTIFIER
: variable_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $2;
var li = new LocalVariable (current_block, lt.Value, lt.Location);
@ -4922,7 +4938,7 @@ block_variable_declaration @@ -4922,7 +4938,7 @@ block_variable_declaration
current_variable = null;
lbag.AppendTo ($$, GetLocation ($6));
}
| CONST variable_type IDENTIFIER
| CONST variable_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $3;
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location);
@ -4981,7 +4997,7 @@ variable_declarators @@ -4981,7 +4997,7 @@ variable_declarators
;
variable_declarator
: COMMA IDENTIFIER
: COMMA identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $2;
var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location);
@ -4990,7 +5006,7 @@ variable_declarator @@ -4990,7 +5006,7 @@ variable_declarator
current_block.AddLocalName (li);
lbag.AddLocation (d, GetLocation ($1));
}
| COMMA IDENTIFIER ASSIGN block_variable_initializer
| COMMA identifier_inside_body ASSIGN block_variable_initializer
{
var lt = (Tokenizer.LocatedToken) $2;
var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location);
@ -5024,7 +5040,7 @@ const_declarators @@ -5024,7 +5040,7 @@ const_declarators
;
const_declarator
: COMMA IDENTIFIER ASSIGN constant_initializer_expr
: COMMA identifier_inside_body ASSIGN constant_initializer_expr
{
var lt = (Tokenizer.LocatedToken) $2;
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location);
@ -5277,7 +5293,7 @@ opt_for_initializer @@ -5277,7 +5293,7 @@ opt_for_initializer
;
for_initializer
: variable_type IDENTIFIER
: variable_type identifier_inside_body
{
var lt = (Tokenizer.LocatedToken) $2;
var li = new LocalVariable (current_block, lt.Value, lt.Location);
@ -5329,7 +5345,7 @@ foreach_statement @@ -5329,7 +5345,7 @@ foreach_statement
report.Error (230, GetLocation ($1), "Type and identifier are both required in a foreach statement");
$$ = null;
}
| FOREACH open_parens_any type IDENTIFIER IN expression CLOSE_PARENS
| FOREACH open_parens_any type identifier_inside_body IN expression CLOSE_PARENS
{
start_block (GetLocation ($2));
current_block.IsCompilerGenerated = true;
@ -5377,7 +5393,7 @@ continue_statement @@ -5377,7 +5393,7 @@ continue_statement
;
goto_statement
: GOTO IDENTIFIER SEMICOLON
: GOTO identifier_inside_body SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $2;
$$ = new Goto (lt.Value, GetLocation ($1));
@ -5412,7 +5428,7 @@ throw_statement @@ -5412,7 +5428,7 @@ throw_statement
;
yield_statement
: IDENTIFIER RETURN opt_expression SEMICOLON
: identifier_inside_body RETURN opt_expression SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $1;
string s = lt.Value;
@ -5428,7 +5444,7 @@ yield_statement @@ -5428,7 +5444,7 @@ yield_statement
$$ = new Yield ((Expression) $3, lt.Location);
lbag.AddStatement ($$, GetLocation ($2), GetLocation ($4));
}
| IDENTIFIER BREAK SEMICOLON
| identifier_inside_body BREAK SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $1;
string s = lt.Value;
@ -5499,7 +5515,7 @@ catch_clauses @@ -5499,7 +5515,7 @@ catch_clauses
opt_identifier
: /* empty */
| IDENTIFIER
| identifier_inside_body
;
catch_clause
@ -5575,7 +5591,7 @@ lock_statement @@ -5575,7 +5591,7 @@ lock_statement
;
fixed_statement
: FIXED open_parens_any variable_type IDENTIFIER
: FIXED open_parens_any variable_type identifier_inside_body
{
start_block (GetLocation ($2));
@ -5603,7 +5619,7 @@ fixed_statement @@ -5603,7 +5619,7 @@ fixed_statement
;
using_statement
: USING open_parens_any variable_type IDENTIFIER
: USING open_parens_any variable_type identifier_inside_body
{
start_block (GetLocation ($2));
@ -5695,7 +5711,7 @@ query_expression @@ -5695,7 +5711,7 @@ query_expression
;
first_from_clause
: FROM_FIRST IDENTIFIER IN expression
: FROM_FIRST identifier_inside_body IN expression
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
@ -5703,7 +5719,7 @@ first_from_clause @@ -5703,7 +5719,7 @@ first_from_clause
var rv = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1)));
}
| FROM_FIRST type IDENTIFIER IN expression
| FROM_FIRST type identifier_inside_body IN expression
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
@ -5718,7 +5734,7 @@ first_from_clause @@ -5718,7 +5734,7 @@ first_from_clause
;
nested_from_clause
: FROM IDENTIFIER IN expression
: FROM identifier_inside_body IN expression
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
@ -5726,7 +5742,7 @@ nested_from_clause @@ -5726,7 +5742,7 @@ nested_from_clause
var rv = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1)));
}
| FROM type IDENTIFIER IN expression
| FROM type identifier_inside_body IN expression
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
@ -5741,7 +5757,7 @@ nested_from_clause @@ -5741,7 +5757,7 @@ nested_from_clause
;
from_clause
: FROM IDENTIFIER IN
: FROM identifier_inside_body IN
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
}
@ -5756,7 +5772,7 @@ from_clause @@ -5756,7 +5772,7 @@ from_clause
((Linq.QueryBlock)current_block).AddRangeVariable (sn);
}
| FROM type IDENTIFIER IN
| FROM type identifier_inside_body IN
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
}
@ -5860,7 +5876,7 @@ query_body_clause @@ -5860,7 +5876,7 @@ query_body_clause
;
let_clause
: LET IDENTIFIER ASSIGN
: LET identifier_inside_body ASSIGN
{
current_block = new Linq.QueryBlock (current_block, lexer.Location);
}
@ -5893,7 +5909,7 @@ where_clause @@ -5893,7 +5909,7 @@ where_clause
;
join_clause
: JOIN IDENTIFIER IN
: JOIN identifier_inside_body IN
{
if (linq_clause_blocks == null)
linq_clause_blocks = new Stack<Linq.QueryBlock> ();
@ -5955,7 +5971,7 @@ join_clause @@ -5955,7 +5971,7 @@ join_clause
current_block = block.Parent;
((Linq.QueryBlock)current_block).AddRangeVariable (into);
}
| JOIN type IDENTIFIER IN
| JOIN type identifier_inside_body IN
{
if (linq_clause_blocks == null)
linq_clause_blocks = new Stack<Linq.QueryBlock> ();
@ -6023,7 +6039,7 @@ join_clause @@ -6023,7 +6039,7 @@ join_clause
opt_join_into
: /* empty */
| INTO IDENTIFIER
| INTO identifier_inside_body
{
$$ = $2;
}
@ -6112,7 +6128,7 @@ then_by @@ -6112,7 +6128,7 @@ then_by
opt_query_continuation
: /* empty */
| INTO IDENTIFIER
| INTO identifier_inside_body
{
// query continuation block is not linked with query block but with block
// before. This means each query can use same range variable names for
@ -6651,7 +6667,7 @@ void start_anonymous (bool isLambda, ParametersCompiled parameters, bool isAsync @@ -6651,7 +6667,7 @@ void start_anonymous (bool isLambda, ParametersCompiled parameters, bool isAsync
oob_stack.Push (current_anonymous_method);
oob_stack.Push (current_local_parameters);
oob_stack.Push (current_variable);
oob_stack.Push (lexer.async_block);
oob_stack.Push (async_block);
current_local_parameters = parameters;
if (isLambda) {
@ -6666,7 +6682,7 @@ void start_anonymous (bool isLambda, ParametersCompiled parameters, bool isAsync @@ -6666,7 +6682,7 @@ void start_anonymous (bool isLambda, ParametersCompiled parameters, bool isAsync
current_anonymous_method = new AnonymousMethodExpression (isAsync, loc);
}
lexer.async_block = isAsync;
async_block = isAsync;
// Force the next block to be created as a ToplevelBlock
parsing_anonymous_method = true;
}
@ -6682,7 +6698,7 @@ AnonymousMethodExpression end_anonymous (ParametersBlock anon_block) @@ -6682,7 +6698,7 @@ AnonymousMethodExpression end_anonymous (ParametersBlock anon_block)
current_anonymous_method.Block = anon_block;
retval = current_anonymous_method;
lexer.async_block = (bool) oob_stack.Pop ();
async_block = (bool) oob_stack.Pop ();
current_variable = (BlockVariableDeclaration) oob_stack.Pop ();
current_local_parameters = (ParametersCompiled) oob_stack.Pop ();
current_anonymous_method = (AnonymousMethodExpression) oob_stack.Pop ();
@ -6901,8 +6917,6 @@ static string GetTokenName (int token) @@ -6901,8 +6917,6 @@ static string GetTokenName (int token)
return "add";
case Token.ASYNC:
return "async";
case Token.AWAIT:
return "await";
case Token.BASE:
return "base";
case Token.BREAK:
@ -7164,6 +7178,7 @@ static string GetTokenName (int token) @@ -7164,6 +7178,7 @@ static string GetTokenName (int token)
case Token.LITERAL:
return "value";
case Token.IDENTIFIER:
case Token.AWAIT:
return "identifier";
case Token.EOF:

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

@ -85,6 +85,11 @@ namespace Mono.CSharp @@ -85,6 +85,11 @@ namespace Mono.CSharp
return Create (null, row, column);
}
public static LocatedToken Create (string value, Location loc)
{
return Create (value, loc.Row, loc.Column);
}
public static LocatedToken Create (string value, int row, int column)
{
//
@ -207,8 +212,6 @@ namespace Mono.CSharp @@ -207,8 +212,6 @@ namespace Mono.CSharp
public bool parsing_modifiers;
public bool async_block;
//
// The special characters to inject on streams to run the unit parser
// in the special expression mode. Using private characters from
@ -830,7 +833,7 @@ namespace Mono.CSharp @@ -830,7 +833,7 @@ namespace Mono.CSharp
break;
case Token.AWAIT:
if (!async_block)
if (parsing_block == 0)
res = -1;
break;
@ -2878,7 +2881,7 @@ namespace Mono.CSharp @@ -2878,7 +2881,7 @@ namespace Mono.CSharp
if (id_builder [0] >= '_' && !quoted) {
int keyword = GetKeyword (id_builder, pos);
if (keyword != -1) {
val = LocatedToken.Create (null, ref_line, column);
val = LocatedToken.Create (keyword == Token.AWAIT ? "await" : null, ref_line, column);
return keyword;
}
}

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

@ -27,7 +27,6 @@ using IKVM.Reflection.Emit; @@ -27,7 +27,6 @@ using IKVM.Reflection.Emit;
#else
using System.Reflection;
using System.Reflection.Emit;
//using Mono.Collections.Generic;
#endif
namespace Mono.CSharp {

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

@ -742,6 +742,12 @@ namespace Mono.CSharp { @@ -742,6 +742,12 @@ namespace Mono.CSharp {
throw new NotImplementedException ();
}
public virtual void Error_OperatorCannotBeApplied (ResolveContext rc, Location loc, string oper, TypeSpec t)
{
rc.Report.Error (23, loc, "The `{0}' operator cannot be applied to operand of type `{1}'",
oper, t.GetSignatureForError ());
}
protected void Error_PointerInsideExpressionTree (ResolveContext ec)
{
ec.Report.Error (1944, loc, "An expression tree cannot contain an unsafe pointer operation");
@ -2991,11 +2997,12 @@ namespace Mono.CSharp { @@ -2991,11 +2997,12 @@ namespace Mono.CSharp {
if (InstanceExpression is IMemoryLocation) {
((IMemoryLocation) InstanceExpression).AddressOf (ec, AddressOp.Load);
} else {
// Cannot release the temporary variable when its address
// is required to be on stack for any parent
LocalTemporary t = new LocalTemporary (instance_type);
InstanceExpression.Emit (ec);
t.Store (ec);
t.AddressOf (ec, AddressOp.Store);
t.Release (ec);
}
} else {
InstanceExpression.Emit (ec);
@ -5092,7 +5099,7 @@ namespace Mono.CSharp { @@ -5092,7 +5099,7 @@ namespace Mono.CSharp {
public override string GetSignatureForError ()
{
return TypeManager.GetFullNameSignature (spec);
return spec.GetSignatureForError ();
}
public bool IsMarshalByRefAccess (ResolveContext rc)

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

@ -55,7 +55,9 @@ namespace Mono.CSharp @@ -55,7 +55,9 @@ namespace Mono.CSharp
static object evaluator_lock = new object ();
static volatile bool invoking;
#if !STATIC
static int count;
#endif
static Thread invoke_thread;
readonly Dictionary<string, Tuple<FieldSpec, FieldInfo>> fields;
@ -134,6 +136,11 @@ namespace Mono.CSharp @@ -134,6 +136,11 @@ namespace Mono.CSharp
/// </summary>
public bool DescribeTypeExpressions;
/// <summary>
/// Whether the evaluator will use terse syntax, and the semicolons at the end are optional
/// </summary>
public bool Terse = true;
/// <summary>
/// The base class for the classes that host the user generated code
/// </summary>
@ -200,7 +207,7 @@ namespace Mono.CSharp @@ -200,7 +207,7 @@ namespace Mono.CSharp
/// compiled parameter will be set to the delegate
/// that can be invoked to execute the code.
///
/// </remarks>
/// </remarks>
public string Compile (string input, out CompiledMethod compiled)
{
if (input == null || input.Length == 0){
@ -218,6 +225,10 @@ namespace Mono.CSharp @@ -218,6 +225,10 @@ namespace Mono.CSharp
bool partial_input;
CSharpParser parser = ParseString (ParseMode.Silent, input, out partial_input);
if (parser == null && Terse && partial_input){
bool ignore;
parser = ParseString (ParseMode.Silent, input + ";", out ignore);
}
if (parser == null){
compiled = null;
if (partial_input)
@ -604,11 +615,12 @@ namespace Mono.CSharp @@ -604,11 +615,12 @@ namespace Mono.CSharp
CompiledMethod CompileBlock (Class host, Undo undo, Report Report)
{
string current_debug_name = "eval-" + count + ".dll";
++count;
#if STATIC
throw new NotSupportedException ();
#else
string current_debug_name = "eval-" + count + ".dll";
++count;
AssemblyDefinitionDynamic assembly;
AssemblyBuilderAccess access;

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

@ -324,7 +324,7 @@ namespace Mono.CSharp @@ -324,7 +324,7 @@ namespace Mono.CSharp
//
// E operator ~(E x);
//
if (Oper == Operator.OnesComplement && TypeManager.IsEnumType (expr_type))
if (Oper == Operator.OnesComplement && expr_type.IsEnum)
return ResolveEnumOperator (ec, expr, predefined);
return ResolveUserType (ec, expr, predefined);
@ -565,12 +565,6 @@ namespace Mono.CSharp @@ -565,12 +565,6 @@ namespace Mono.CSharp
Expr.EmitSideEffect (ec);
}
public static void Error_OperatorCannotBeApplied (ResolveContext ec, Location loc, string oper, TypeSpec t)
{
ec.Report.Error (23, loc, "The `{0}' operator cannot be applied to operand of type `{1}'",
oper, TypeManager.CSharpName (t));
}
//
// Converts operator to System.Linq.Expressions.ExpressionType enum name
//
@ -1201,7 +1195,7 @@ namespace Mono.CSharp @@ -1201,7 +1195,7 @@ namespace Mono.CSharp
source = operation;
if (source == null) {
Unary.Error_OperatorCannotBeApplied (ec, loc, Operator.GetName (user_op), type);
expr.Error_OperatorCannotBeApplied (ec, loc, Operator.GetName (user_op), type);
return null;
}
@ -2319,7 +2313,7 @@ namespace Mono.CSharp @@ -2319,7 +2313,7 @@ namespace Mono.CSharp
public static void Error_OperatorCannotBeApplied (ResolveContext ec, Expression left, Expression right, string oper, Location loc)
{
if (left.Type == InternalType.FakeInternalType || right.Type == InternalType.FakeInternalType)
if (left.Type == InternalType.ErrorType || right.Type == InternalType.ErrorType)
return;
string l, r;
@ -2652,7 +2646,7 @@ namespace Mono.CSharp @@ -2652,7 +2646,7 @@ namespace Mono.CSharp
case Operator.LessThanOrEqual:
case Operator.GreaterThan:
case Operator.GreaterThanOrEqual:
if (TypeManager.IsEnumType (left.Type))
if (left.Type.IsEnum)
return left;
if (left.IsZeroInteger)
@ -2669,7 +2663,7 @@ namespace Mono.CSharp @@ -2669,7 +2663,7 @@ namespace Mono.CSharp
case Operator.Modulus:
case Operator.LeftShift:
case Operator.RightShift:
if (TypeManager.IsEnumType (right.Type) || TypeManager.IsEnumType (left.Type))
if (right.Type.IsEnum || left.Type.IsEnum)
break;
return left;
}
@ -2926,7 +2920,7 @@ namespace Mono.CSharp @@ -2926,7 +2920,7 @@ namespace Mono.CSharp
Constant rc = right as Constant;
// The conversion rules are ignored in enum context but why
if (!ec.HasSet (ResolveContext.Options.EnumScope) && lc != null && rc != null && (TypeManager.IsEnumType (left.Type) || TypeManager.IsEnumType (right.Type))) {
if (!ec.HasSet (ResolveContext.Options.EnumScope) && lc != null && rc != null && (left.Type.IsEnum || right.Type.IsEnum)) {
lc = EnumLiftUp (ec, lc, rc, loc);
if (lc != null)
rc = EnumLiftUp (ec, rc, lc, loc);
@ -5309,7 +5303,7 @@ namespace Mono.CSharp @@ -5309,7 +5303,7 @@ namespace Mono.CSharp
Expression invoke = null;
if (mg == null) {
if (expr_type != null && TypeManager.IsDelegateType (expr_type)) {
if (expr_type != null && expr_type.IsDelegate) {
invoke = new DelegateInvocation (member_expr, arguments, loc);
invoke = invoke.Resolve (ec);
if (invoke == null || !dynamic_arg)
@ -5649,7 +5643,7 @@ namespace Mono.CSharp @@ -5649,7 +5643,7 @@ namespace Mono.CSharp
return ReducedExpression.Create (c, this);
}
if (TypeManager.IsDelegateType (type)) {
if (type.IsDelegate) {
return (new NewDelegate (type, arguments, loc)).Resolve (ec);
}
@ -6365,7 +6359,7 @@ namespace Mono.CSharp @@ -6365,7 +6359,7 @@ namespace Mono.CSharp
int count = array_data.Count;
TypeSpec element_type = array_element_type;
if (TypeManager.IsEnumType (element_type))
if (element_type.IsEnum)
element_type = EnumSpec.GetUnderlyingType (element_type);
factor = BuiltinTypeSpec.GetSize (element_type);
@ -7629,7 +7623,7 @@ namespace Mono.CSharp @@ -7629,7 +7623,7 @@ namespace Mono.CSharp
if (type_queried == null)
return null;
if (TypeManager.IsEnumType (type_queried))
if (type_queried.IsEnum)
type_queried = EnumSpec.GetUnderlyingType (type_queried);
int size_of = BuiltinTypeSpec.GetSize (type_queried);
@ -7858,7 +7852,7 @@ namespace Mono.CSharp @@ -7858,7 +7852,7 @@ namespace Mono.CSharp
if (type == InternalType.NullLiteral && rc.IsRuntimeBinder)
rc.Report.Error (Report.RuntimeErrorId, loc, "Cannot perform member binding on `null' value");
else
Unary.Error_OperatorCannotBeApplied (rc, loc, ".", type);
expr.Error_OperatorCannotBeApplied (rc, loc, ".", type);
}
public static bool IsValidDotExpression (TypeSpec type)
@ -9168,7 +9162,7 @@ namespace Mono.CSharp @@ -9168,7 +9162,7 @@ namespace Mono.CSharp
public static readonly ErrorExpression Instance = new ErrorExpression ();
private ErrorExpression ()
: base (InternalType.FakeInternalType)
: base (InternalType.ErrorType)
{
}
@ -9185,6 +9179,10 @@ namespace Mono.CSharp @@ -9185,6 +9179,10 @@ namespace Mono.CSharp
public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl)
{
}
public override void Error_OperatorCannotBeApplied (ResolveContext rc, Location loc, string oper, TypeSpec t)
{
}
}
public class UserCast : Expression {

90
ICSharpCode.NRefactory.CSharp/Parser/mcs/flowanalysis.cs

@ -1346,7 +1346,6 @@ namespace Mono.CSharp @@ -1346,7 +1346,6 @@ namespace Mono.CSharp
// </summary>
public readonly bool IsParameter;
readonly VariableInfo Parent;
VariableInfo[] sub_info;
bool is_ever_assigned;
@ -1370,7 +1369,6 @@ namespace Mono.CSharp @@ -1370,7 +1369,6 @@ namespace Mono.CSharp
this.Name = parent.Name;
this.TypeInfo = type;
this.Offset = parent.Offset + type.Offset;
this.Parent = parent;
this.Length = type.TotalLength;
this.IsParameter = parent.IsParameter;
@ -1416,28 +1414,30 @@ namespace Mono.CSharp @@ -1416,28 +1414,30 @@ namespace Mono.CSharp
if (vector [Offset])
return true;
// FIXME: Fix SetFieldAssigned to set the whole range like SetAssigned below. Then, get rid of this stanza
for (VariableInfo parent = Parent; parent != null; parent = parent.Parent) {
if (vector [parent.Offset]) {
// 'parent' is assigned, but someone forgot to note that all its components are assigned too
parent.SetAssigned (vector);
return true;
}
}
// Return unless this is a struct.
// Unless this is a struct
if (!TypeInfo.IsStruct)
return false;
// Ok, so each field must be assigned.
for (int i = 0; i < TypeInfo.Length; i++) {
if (!vector [Offset + i + 1])
//
// Following case cannot be handled fully by SetStructFieldAssigned
// because we may encounter following case
//
// struct A { B b }
// struct B { int value; }
//
// setting a.b.value is propagated only to B's vector and not upwards to possible parents
//
//
// Each field must be assigned
//
for (int i = Offset + 1; i <= TypeInfo.Length + Offset; i++) {
if (!vector[i])
return false;
}
// Ok, now check all fields which are structs.
for (int i = 0; i < sub_info.Length; i++) {
VariableInfo sinfo = sub_info [i];
VariableInfo sinfo = sub_info[i];
if (sinfo == null)
continue;
@ -1446,26 +1446,9 @@ namespace Mono.CSharp @@ -1446,26 +1446,9 @@ namespace Mono.CSharp
}
vector [Offset] = true;
is_ever_assigned = true;
return true;
}
public void SetAssigned (ResolveContext ec)
{
if (ec.DoFlowAnalysis)
ec.CurrentBranching.SetAssigned (this);
}
public void SetAssigned (MyBitVector vector)
{
if (Length == 1)
vector [Offset] = true;
else
vector.SetRange (Offset, Length);
is_ever_assigned = true;
}
public bool IsStructFieldAssigned (ResolveContext ec, string name)
{
return !ec.DoFlowAnalysis || ec.CurrentBranching.IsStructFieldAssigned (this, name);
@ -1487,15 +1470,54 @@ namespace Mono.CSharp @@ -1487,15 +1470,54 @@ namespace Mono.CSharp
ec.CurrentBranching.SetFieldAssigned (this, name);
}
public void SetAssigned (ResolveContext ec)
{
if (ec.DoFlowAnalysis)
ec.CurrentBranching.SetAssigned (this);
}
public void SetAssigned (MyBitVector vector)
{
if (Length == 1)
vector[Offset] = true;
else
vector.SetRange (Offset, Length);
is_ever_assigned = true;
}
public void SetStructFieldAssigned (MyBitVector vector, string field_name)
{
if (vector[Offset])
return;
int field_idx = TypeInfo.GetFieldIndex (field_name);
if (field_idx == 0)
return;
vector [Offset + field_idx] = true;
var complex_field = TypeInfo.GetStructField (field_name);
if (complex_field != null) {
vector.SetRange (complex_field.Offset, complex_field.TotalLength);
} else {
vector[Offset + field_idx] = true;
}
is_ever_assigned = true;
//
// Each field must be assigned
//
for (int i = Offset + 1; i <= TypeInfo.Length + Offset; i++) {
if (!vector[i])
return;
}
//
// Set master struct flag to assigned when all tested struct
// fields have been assigned
//
vector[Offset] = true;
}
public VariableInfo GetStructFieldInfo (string fieldName)

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

@ -1785,6 +1785,16 @@ namespace Mono.CSharp { @@ -1785,6 +1785,16 @@ namespace Mono.CSharp {
BaseType = inflator.Inflate (open_type.BaseType);
}
} else if ((state & StateFlags.PendingBaseTypeInflate) != 0) {
//
// It can happen when resolving base type without being defined
// which is not allowed to happen and will always lead to an error
//
// class B { class N {} }
// class A<T> : A<B.N> {}
//
if (open_type.BaseType == null)
return;
BaseType = inflator.Inflate (open_type.BaseType);
state &= ~StateFlags.PendingBaseTypeInflate;
}
@ -2690,7 +2700,7 @@ namespace Mono.CSharp { @@ -2690,7 +2700,7 @@ namespace Mono.CSharp {
// Align params arguments
TypeSpec t_i = methodParameters [i >= methodParameters.Length ? methodParameters.Length - 1: i];
if (!TypeManager.IsDelegateType (t_i)) {
if (!t_i.IsDelegate) {
if (!t_i.IsExpressionTreeType)
continue;
@ -2920,7 +2930,7 @@ namespace Mono.CSharp { @@ -2920,7 +2930,7 @@ namespace Mono.CSharp {
for (int i = 0; i < methodParameters.Length; ++i) {
TypeSpec t = methodParameters[i];
if (!TypeManager.IsDelegateType (t)) {
if (!t.IsDelegate) {
if (!t.IsExpressionTreeType)
continue;
@ -3127,6 +3137,13 @@ namespace Mono.CSharp { @@ -3127,6 +3137,13 @@ namespace Mono.CSharp {
return gt.GetDefinition ().MakeGenericType (context, inflated_targs);
}
var ac = parameter as ArrayContainer;
if (ac != null) {
var inflated = InflateGenericArgument (context, ac.Element);
if (inflated != ac.Element)
return ArrayContainer.MakeType (context.Module, inflated);
}
return parameter;
}
@ -3143,7 +3160,7 @@ namespace Mono.CSharp { @@ -3143,7 +3160,7 @@ namespace Mono.CSharp {
if (IsFixed (returnType))
return false;
} else if (TypeManager.IsGenericType (returnType)) {
if (TypeManager.IsDelegateType (returnType)) {
if (returnType.IsDelegate) {
invoke = Delegate.GetInvokeMethod (returnType);
return IsReturnTypeNonDependent (ec, invoke, invoke.ReturnType);
}
@ -3347,7 +3364,7 @@ namespace Mono.CSharp { @@ -3347,7 +3364,7 @@ namespace Mono.CSharp {
// then a lower-bound inference is made from U for Tb.
//
if (e is MethodGroupExpr) {
if (!TypeManager.IsDelegateType (t)) {
if (!t.IsDelegate) {
if (!t.IsExpressionTreeType)
return 0;

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

@ -1888,7 +1888,13 @@ namespace Mono.CSharp @@ -1888,7 +1888,13 @@ namespace Mono.CSharp
if ((t.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate && importer.IgnorePrivateMembers)
continue;
imported = importer.CreateNestedType (t, declaringType);
try {
imported = importer.CreateNestedType (t, declaringType);
} catch (Exception e) {
throw new InternalErrorException (e, "Could not import nested type `{0}' from `{1}'",
t.FullName, declaringType.MemberDefinition.DeclaringAssembly.FullName);
}
cache.AddMemberImported (imported);
}

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

@ -126,7 +126,7 @@ namespace Mono.CSharp @@ -126,7 +126,7 @@ namespace Mono.CSharp
//
// The 0 literal can be converted to an enum value
//
if (Value == 0 && TypeManager.IsEnumType (type)) {
if (Value == 0 && type.IsEnum) {
Constant c = ConvertImplicitly (EnumSpec.GetUnderlyingType (type));
if (c == null)
return null;

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

@ -1275,7 +1275,7 @@ namespace Mono.CSharp @@ -1275,7 +1275,7 @@ namespace Mono.CSharp
if (!base.Define ())
return false;
if (!TypeManager.IsDelegateType (MemberType)) {
if (!MemberType.IsDelegate) {
Report.Error (66, Location, "`{0}': event must be of a delegate type", GetSignatureForError ());
}

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

@ -30,7 +30,7 @@ namespace Mono.CSharp { @@ -30,7 +30,7 @@ namespace Mono.CSharp {
V_5 = 5,
Future = 100,
Default = LanguageVersion.V_4,
Default = LanguageVersion.V_5,
}
public enum RuntimeVersion

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

@ -399,8 +399,13 @@ namespace Mono.CSharp @@ -399,8 +399,13 @@ namespace Mono.CSharp
public new void Define ()
{
foreach (TypeContainer tc in types)
tc.DefineType ();
foreach (TypeContainer tc in types) {
try {
tc.DefineType ();
} catch (Exception e) {
throw new InternalErrorException (tc, e);
}
}
foreach (TypeContainer tc in types)
tc.ResolveTypeParameters ();

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

@ -3613,7 +3613,7 @@ namespace Mono.CSharp { @@ -3613,7 +3613,7 @@ namespace Mono.CSharp {
{
Label lbl_default = default_target;
if (labels.Count > 0) {
if (labels != null && labels.Count > 0) {
List<LabelsRange> ranges;
if (string_labels != null) {
// We have done all hard work for string already
@ -3645,7 +3645,7 @@ namespace Mono.CSharp { @@ -3645,7 +3645,7 @@ namespace Mono.CSharp {
ranges.Sort ();
}
TypeSpec compare_type = TypeManager.IsEnumType (SwitchType) ? EnumSpec.GetUnderlyingType (SwitchType) : SwitchType;
TypeSpec compare_type = SwitchType.IsEnum ? EnumSpec.GetUnderlyingType (SwitchType) : SwitchType;
for (int range_index = ranges.Count - 1; range_index >= 0; --range_index) {
LabelsRange kb = ranges[range_index];

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

@ -379,14 +379,9 @@ namespace Mono.CSharp @@ -379,14 +379,9 @@ namespace Mono.CSharp
MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncVoidMethodBuilder.TypeSpec));
AsyncTaskMethodBuilderGenericSetResult = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric,
MemberFilter.Method ("SetResult", 0,
new ParametersImported (
new[] {
new ParameterData (null, Parameter.Modifier.NONE)
},
new[] {
new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null)
}, false), btypes.Void));
"SetResult", MemberKind.Method, () => new TypeSpec[] {
types.AsyncTaskMethodBuilderGeneric.TypeSpec.MemberDefinition.TypeParameters[0]
});
AsyncTaskMethodBuilderGenericSetException = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric,
MemberFilter.Method ("SetException", 0,
@ -701,8 +696,8 @@ namespace Mono.CSharp @@ -701,8 +696,8 @@ namespace Mono.CSharp
T member;
TypeSpec declaring_type;
readonly PredefinedType declaring_type_predefined;
readonly PredefinedType[] parameters_predefined;
MemberFilter filter;
readonly Func<TypeSpec[]> filter_builder;
public PredefinedMember (ModuleContainer module, PredefinedType type, MemberFilter filter)
{
@ -726,7 +721,24 @@ namespace Mono.CSharp @@ -726,7 +721,24 @@ namespace Mono.CSharp
public PredefinedMember (ModuleContainer module, PredefinedType type, string name, MemberKind kind, params PredefinedType[] types)
: this (module, type, new MemberFilter (name, 0, kind, null, null))
{
parameters_predefined = types;
filter_builder = () => {
var ptypes = new TypeSpec[types.Length];
for (int i = 0; i < ptypes.Length; ++i) {
var p = types[i];
if (!p.Define ())
return null;
ptypes[i] = p.TypeSpec;
}
return ptypes;
};
}
public PredefinedMember (ModuleContainer module, PredefinedType type, string name, MemberKind kind, Func<TypeSpec[]> typesBuilder)
: this (module, type, new MemberFilter (name, 0, kind, null, null))
{
filter_builder = typesBuilder;
}
public PredefinedMember (ModuleContainer module, BuiltinTypeSpec type, string name, params TypeSpec[] types)
@ -746,20 +758,14 @@ namespace Mono.CSharp @@ -746,20 +758,14 @@ namespace Mono.CSharp
declaring_type = declaring_type_predefined.TypeSpec;
}
if (parameters_predefined != null) {
TypeSpec[] types = new TypeSpec [parameters_predefined.Length];
for (int i = 0; i < types.Length; ++i) {
var p = parameters_predefined [i];
if (!p.Define ())
return null;
types[i] = p.TypeSpec;
}
if (filter_builder != null) {
var types = filter_builder ();
if (filter.Kind == MemberKind.Field)
filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind, null, types [0]);
else
filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind, ParametersCompiled.CreateFullyResolved (types), filter.MemberType);
filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind,
ParametersCompiled.CreateFullyResolved (types), filter.MemberType);
}
member = MemberCache.FindMember (declaring_type, filter, BindingRestriction.DeclaredOnly) as T;
@ -785,16 +791,9 @@ namespace Mono.CSharp @@ -785,16 +791,9 @@ namespace Mono.CSharp
return null;
}
if (parameters_predefined != null) {
TypeSpec[] types = new TypeSpec[parameters_predefined.Length];
for (int i = 0; i < types.Length; ++i) {
var p = parameters_predefined[i];
types[i] = p.Resolve ();
if (types[i] == null)
return null;
}
filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind, ParametersCompiled.CreateFullyResolved (types), filter.MemberType);
if (filter_builder != null) {
filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind,
ParametersCompiled.CreateFullyResolved (filter_builder ()), filter.MemberType);
}
string method_args = null;
@ -843,18 +842,6 @@ namespace Mono.CSharp @@ -843,18 +842,6 @@ namespace Mono.CSharp
return mb.GetSignatureForError ();
}
// Obsolete
public static bool IsDelegateType (TypeSpec t)
{
return t.IsDelegate;
}
// Obsolete
public static bool IsEnumType (TypeSpec t)
{
return t.IsEnum;
}
//
// Whether a type is unmanaged. This is used by the unsafe code (25.2)
//

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

@ -340,6 +340,34 @@ namespace Mono.CSharp @@ -340,6 +340,34 @@ namespace Mono.CSharp
return false;
}
//
// Special version used during type definition
//
public bool AddInterfaceDefined (TypeSpec iface)
{
if (!AddInterface (iface))
return false;
//
// We can get into a situation where a type is inflated before
// its interfaces are resoved. Consider this situation
//
// class A<T> : X<A<int>>, IFoo {}
//
// When resolving base class of X`1 we inflate context type A`1
// All this happens before we even hit IFoo resolve. Without
// additional expansion any inside usage of A<T> would miss IFoo
// interface because it comes from early inflated TypeSpec
//
if (inflated_instances != null) {
foreach (var inflated in inflated_instances) {
inflated.Value.AddInterface (iface);
}
}
return true;
}
public AttributeUsageAttribute GetAttributeUsage (PredefinedAttribute pa)
{
if (Kind != MemberKind.Class)
@ -1247,6 +1275,7 @@ namespace Mono.CSharp @@ -1247,6 +1275,7 @@ namespace Mono.CSharp
public static readonly InternalType NullLiteral = new InternalType ("null");
public static readonly InternalType FakeInternalType = new InternalType ("<fake$type>");
public static readonly InternalType Namespace = new InternalType ("<namespace>");
public static readonly InternalType ErrorType = new InternalType ("<error>");
readonly string name;

Loading…
Cancel
Save