Browse Source

Updated mcs.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
9f9a26b236
  1. 45
      ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs
  2. 43
      ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolWriter.cs
  3. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  4. 55
      ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs
  5. 9634
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  6. 24
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  7. 20
      ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs
  8. 73
      ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs
  9. 10
      ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
  10. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs
  11. 20
      ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs
  12. 92
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  13. 6
      ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAttribute.cs

45
ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs

@ -188,6 +188,20 @@ namespace Mono.CompilerServices.SymbolWriter @@ -188,6 +188,20 @@ namespace Mono.CompilerServices.SymbolWriter
public readonly bool IsHidden; // Obsolete is never used
#endregion
public sealed class LocationComparer : IComparer<LineNumberEntry>
{
public static readonly LocationComparer Default = new LocationComparer ();
public int Compare (LineNumberEntry l1, LineNumberEntry l2)
{
return l1.Row == l2.Row ?
l1.Offset.CompareTo (l2.Offset) :
l1.Row.CompareTo (l2.Row);
}
}
public static readonly LineNumberEntry Null = new LineNumberEntry (0, 0, 0);
public LineNumberEntry (int file, int row, int offset)
: this (file, row, offset, false)
{ }
@ -200,37 +214,6 @@ namespace Mono.CompilerServices.SymbolWriter @@ -200,37 +214,6 @@ namespace Mono.CompilerServices.SymbolWriter
this.IsHidden = is_hidden;
}
public static LineNumberEntry Null = new LineNumberEntry (0, 0, 0);
private class OffsetComparerClass : IComparer<LineNumberEntry>
{
public int Compare (LineNumberEntry l1, LineNumberEntry l2)
{
if (l1.Offset < l2.Offset)
return -1;
else if (l1.Offset > l2.Offset)
return 1;
else
return 0;
}
}
private class RowComparerClass : IComparer<LineNumberEntry>
{
public int Compare (LineNumberEntry l1, LineNumberEntry l2)
{
if (l1.Row < l2.Row)
return -1;
else if (l1.Row > l2.Row)
return 1;
else
return 0;
}
}
public static readonly IComparer<LineNumberEntry> OffsetComparer = new OffsetComparerClass ();
public static readonly IComparer<LineNumberEntry> RowComparer = new RowComparerClass ();
public override string ToString ()
{
return String.Format ("[Line {0}:{1}:{2}]", File, Row, Offset);

43
ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolWriter.cs

@ -251,6 +251,8 @@ namespace Mono.CompilerServices.SymbolWriter @@ -251,6 +251,8 @@ namespace Mono.CompilerServices.SymbolWriter
#else
Stack<CodeBlockEntry> _block_stack;
#endif
List<LineNumberEntry> method_lines;
string _real_name;
IMethodDef _method;
ICompileUnit _comp_unit;
@ -262,25 +264,33 @@ namespace Mono.CompilerServices.SymbolWriter @@ -262,25 +264,33 @@ namespace Mono.CompilerServices.SymbolWriter
this._comp_unit = comp_unit;
this._method = method;
this._ns_id = ns_id;
method_lines = new LineNumberEntry [32];
method_lines = new List<LineNumberEntry> ();
}
private LineNumberEntry [] method_lines;
private int method_lines_pos = 0;
public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column,
bool is_hidden)
public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, bool is_hidden)
{
if (method_lines_pos == method_lines.Length) {
LineNumberEntry [] tmp = method_lines;
method_lines = new LineNumberEntry [method_lines.Length * 2];
Array.Copy (tmp, method_lines, method_lines_pos);
int file_idx = file != null ? file.Index : 0;
var lne = new LineNumberEntry (file_idx, line, offset, is_hidden);
if (method_lines.Count > 0) {
var prev = method_lines[method_lines.Count - 1];
//
// Same offset cannot be used for multiple lines
//
if (prev.Offset == offset) {
//
// Use the new location because debugger will adjust
// the breakpoint to next line with sequence point
//
if (LineNumberEntry.LocationComparer.Default.Compare (lne, prev) > 0)
method_lines[method_lines.Count - 1] = lne;
return;
}
}
int file_idx = file != null ? file.Index : 0;
method_lines [method_lines_pos++] = new LineNumberEntry (
file_idx, line, offset, is_hidden);
method_lines.Add (lne);
}
public void StartBlock (CodeBlockEntry.Type type, int start_offset)
@ -392,12 +402,9 @@ namespace Mono.CompilerServices.SymbolWriter @@ -392,12 +402,9 @@ namespace Mono.CompilerServices.SymbolWriter
public void DefineMethod (MonoSymbolFile file)
{
LineNumberEntry[] lines = new LineNumberEntry [method_lines_pos];
Array.Copy (method_lines, lines, method_lines_pos);
MethodEntry entry = new MethodEntry (
file, _comp_unit.Entry, _method.Token, ScopeVariables,
Locals, lines, Blocks, _real_name, 0, //_method_flags,
Locals, method_lines.ToArray (), Blocks, _real_name, 0, //_method_flags,
_ns_id);
file.AddMethod (entry);

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

@ -53,6 +53,11 @@ namespace Mono.CSharp @@ -53,6 +53,11 @@ namespace Mono.CSharp
protected bool is_defined;
#if FULL_AST
// Any unattached attributes during parsing get added here.
public Attribute [] UnattachedAttributes;
#endif
public TypeContainer (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
: base (parent, name, attrs)
{
@ -1326,7 +1331,9 @@ namespace Mono.CSharp @@ -1326,7 +1331,9 @@ namespace Mono.CSharp
Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
member_name, cloned_params, null);
var block = new ToplevelBlock (Compiler, proxy_method.ParameterInfo, Location);
var block = new ToplevelBlock (Compiler, proxy_method.ParameterInfo, Location) {
IsCompilerGenerated = true
};
var mg = MethodGroupExpr.CreatePredefined (method, method.DeclaringType, Location);
mg.InstanceExpression = new BaseThis (method.DeclaringType, Location);

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

@ -330,17 +330,40 @@ namespace Mono.CSharp { @@ -330,17 +330,40 @@ namespace Mono.CSharp {
return TypeSpecComparer.Variant.IsEqual (expr_type, target_type) || expr_type.ImplementsInterface (target_type, true);
return target_type.BuiltinType == BuiltinTypeSpec.Type.Object || target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic;
}
//
// from the null literal to any reference-type.
//
if (expr_type == InternalType.NullLiteral) {
// Exlude internal compiler types
if (target_type.Kind == MemberKind.InternalCompilerType)
return target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic;
case MemberKind.InternalCompilerType:
//
// from the null literal to any reference-type.
//
if (expr_type == InternalType.NullLiteral) {
// Exlude internal compiler types
if (target_type.Kind == MemberKind.InternalCompilerType)
return target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic;
return TypeSpec.IsReferenceType (target_type);
}
//
// Implicit dynamic conversion
//
if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
switch (target_type.Kind) {
case MemberKind.ArrayType:
case MemberKind.Class:
case MemberKind.Delegate:
case MemberKind.Interface:
case MemberKind.TypeParameter:
return true;
}
// dynamic to __arglist
if (target_type == InternalType.Arglist)
return true;
return TypeSpec.IsReferenceType (target_type);
return false;
}
break;
}
return false;
@ -773,23 +796,17 @@ namespace Mono.CSharp { @@ -773,23 +796,17 @@ namespace Mono.CSharp {
return i.IsZeroInteger;
}
// Implicit dynamic conversion
//
// Implicit dynamic conversion for remaining value types. It should probably
// go somewhere else
//
if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
switch (target_type.Kind) {
case MemberKind.ArrayType:
case MemberKind.Class:
case MemberKind.Struct:
case MemberKind.Delegate:
case MemberKind.Enum:
case MemberKind.Interface:
case MemberKind.TypeParameter:
return true;
}
// dynamic to __arglist
if (target_type == InternalType.Arglist)
return true;
return false;
}

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

File diff suppressed because it is too large Load Diff

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

@ -614,6 +614,13 @@ namespace_or_type_declaration @@ -614,6 +614,13 @@ namespace_or_type_declaration
{
current_namespace.DeclarationFound = true;
}
| attribute_sections CLOSE_BRACE {
#if FULL_AST
current_namespace.UnattachedAttributes = ((List<Attribute>) $1).ToArray ();
#endif
report.Error (1518, lexer.Location, "Dangling attribute not attached to a type definition (class, delegate, enum, interface or struct). Unexpected symbol `{0}'");
lexer.putback ('}');
}
;
type_declaration
@ -908,6 +915,7 @@ class_member_declaration @@ -908,6 +915,7 @@ class_member_declaration
| constructor_declaration
| destructor_declaration
| type_declaration
| attributes_without_members
| error
{
report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration",
@ -2503,6 +2511,16 @@ event_accessor_block @@ -2503,6 +2511,16 @@ event_accessor_block
| block;
;
attributes_without_members
: attribute_sections CLOSE_BRACE {
#if FULL_AST
current_type.UnattachedAttributes = ((List<Attribute>) $1).ToArray ();
#endif
report.Error (1519, lexer.Location, "Attribute not attached to any member. Unexpected symbol `{0}' in class, struct, or interface member declaration. ");
lexer.putback ('}');
}
;
enum_declaration
: opt_attributes
opt_modifiers
@ -4176,11 +4194,11 @@ lambda_expression_body @@ -4176,11 +4194,11 @@ lambda_expression_body
lambda_expression_body_simple
: {
start_block (lexer.Location);
start_block (Location.Null);
}
expression_or_error // Have to close block when error occurs
{
Block b = end_block (lexer.Location);
Block b = end_block (Location.Null);
b.IsCompilerGenerated = true;
b.AddStatement (new ContextualReturn ((Expression) $2));
$$ = b;
@ -5561,7 +5579,7 @@ try_statement @@ -5561,7 +5579,7 @@ try_statement
}
| TRY block catch_clauses FINALLY block
{
$$ = new TryFinally (new TryCatch ((Block) $2, (List<Catch>) $3, GetLocation ($1), true), (Block) $5, GetLocation ($1));
$$ = new TryFinally (new TryCatch ((Block) $2, (List<Catch>) $3, Location.Null, true), (Block) $5, GetLocation ($1));
lbag.AddStatement ($$, GetLocation ($4));
}
| TRY block error

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

@ -10021,8 +10021,11 @@ namespace Mono.CSharp @@ -10021,8 +10021,11 @@ namespace Mono.CSharp
public override void EmitStatement (EmitContext ec)
{
foreach (ExpressionStatement e in initializers)
foreach (ExpressionStatement e in initializers) {
// TODO: need location region
ec.Mark (e.Location);
e.EmitStatement (ec);
}
}
}
@ -10299,7 +10302,7 @@ namespace Mono.CSharp @@ -10299,7 +10302,7 @@ namespace Mono.CSharp
bool error = false;
arguments = new Arguments (parameters.Count);
TypeExpression [] t_args = new TypeExpression [parameters.Count];
var t_args = new TypeSpec [parameters.Count];
for (int i = 0; i < parameters.Count; ++i) {
Expression e = parameters [i].Resolve (ec);
if (e == null) {
@ -10308,7 +10311,7 @@ namespace Mono.CSharp @@ -10308,7 +10311,7 @@ namespace Mono.CSharp
}
arguments.Add (new Argument (e));
t_args [i] = new TypeExpression (e.Type, e.Location);
t_args [i] = e.Type;
}
if (error)
@ -10318,8 +10321,15 @@ namespace Mono.CSharp @@ -10318,8 +10321,15 @@ namespace Mono.CSharp
if (anonymous_type == null)
return null;
RequestedType = new GenericTypeExpr (anonymous_type.Definition, new TypeArguments (t_args), loc);
return base.DoResolve (ec);
type = anonymous_type.Definition.MakeGenericType (ec.Module, t_args);
method = (MethodSpec) MemberCache.FindMember (type, MemberFilter.Constructor (null), BindingRestriction.DeclaredOnly);
eclass = ExprClass.Value;
return this;
}
public override void EmitStatement (EmitContext ec)
{
base.EmitStatement (ec);
}
public override object Accept (StructuralVisitor visitor)

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

@ -289,10 +289,23 @@ namespace Mono.CSharp @@ -289,10 +289,23 @@ namespace Mono.CSharp
}
}
public GetEnumeratorMethod (IteratorStorey host, FullNamedExpression returnType, MemberName name)
GetEnumeratorMethod (IteratorStorey host, FullNamedExpression returnType, MemberName name)
: base (host, null, returnType, Modifiers.DEBUGGER_HIDDEN, name)
{
Block.AddStatement (new GetEnumeratorStatement (host, this));
}
public static GetEnumeratorMethod Create (IteratorStorey host, FullNamedExpression returnType, MemberName name)
{
return Create (host, returnType, name, null);
}
public static GetEnumeratorMethod Create (IteratorStorey host, FullNamedExpression returnType, MemberName name, Statement statement)
{
var m = new GetEnumeratorMethod (host, returnType, name);
var stmt = statement ?? new GetEnumeratorStatement (host, m);
m.block.AddStatement (stmt);
m.block.IsCompilerGenerated = true;
return m;
}
}
@ -332,6 +345,7 @@ namespace Mono.CSharp @@ -332,6 +345,7 @@ namespace Mono.CSharp
host.Members.Add (this);
Block.AddStatement (new DisposeMethodStatement (host.Iterator));
Block.IsCompilerGenerated = true;
}
}
@ -479,25 +493,23 @@ namespace Mono.CSharp @@ -479,25 +493,23 @@ namespace Mono.CSharp
if (Iterator.IsEnumerable) {
FullNamedExpression explicit_iface = new TypeExpression (Compiler.BuiltinTypes.IEnumerable, Location);
var name = new MemberName ("GetEnumerator", null, explicit_iface, Location);
var name = new MemberName ("GetEnumerator", null, explicit_iface, Location.Null);
if (generic_enumerator_type != null) {
Method get_enumerator = new StateMachineMethod (this, null, enumerator_type, 0, name);
explicit_iface = new GenericTypeExpr (Module.PredefinedTypes.IEnumerableGeneric.Resolve (), generic_args, Location);
name = new MemberName ("GetEnumerator", null, explicit_iface, Location);
Method gget_enumerator = new GetEnumeratorMethod (this, generic_enumerator_type, name);
var gname = new MemberName ("GetEnumerator", null, explicit_iface, Location.Null);
Method gget_enumerator = GetEnumeratorMethod.Create (this, generic_enumerator_type, gname);
//
// Just call generic GetEnumerator implementation
//
get_enumerator.Block.AddStatement (
new Return (new Invocation (new DynamicMethodGroupExpr (gget_enumerator, Location), null), Location));
var stmt = new Return (new Invocation (new DynamicMethodGroupExpr (gget_enumerator, Location), null), Location);
Method get_enumerator = GetEnumeratorMethod.Create (this, enumerator_type, name, stmt);
Members.Add (get_enumerator);
Members.Add (gget_enumerator);
} else {
Members.Add (new GetEnumeratorMethod (this, enumerator_type, name));
Members.Add (GetEnumeratorMethod.Create (this, enumerator_type, name));
}
}
@ -519,11 +531,13 @@ namespace Mono.CSharp @@ -519,11 +531,13 @@ namespace Mono.CSharp
var name = new MemberName ("Current", null, explicit_iface, Location);
ToplevelBlock get_block = new ToplevelBlock (Compiler, Location);
ToplevelBlock get_block = new ToplevelBlock (Compiler, Location) {
IsCompilerGenerated = true
};
get_block.AddStatement (new Return (new DynamicFieldExpr (CurrentField, Location), Location));
Property current = new Property (this, type, Modifiers.DEBUGGER_HIDDEN, name, null);
current.Get = new Property.GetMethod (current, 0, null, Location);
Property current = new Property (this, type, Modifiers.DEBUGGER_HIDDEN | Modifiers.COMPILER_GENERATED, name, null);
current.Get = new Property.GetMethod (current, Modifiers.COMPILER_GENERATED, null, Location);
current.Get.Block = get_block;
Members.Add (current);
@ -533,12 +547,14 @@ namespace Mono.CSharp @@ -533,12 +547,14 @@ namespace Mono.CSharp
{
Method reset = new Method (
this, new TypeExpression (Compiler.BuiltinTypes.Void, Location),
Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN | Modifiers.COMPILER_GENERATED,
new MemberName ("Reset", Location),
ParametersCompiled.EmptyReadOnlyParameters, null);
Members.Add (reset);
reset.Block = new ToplevelBlock (Compiler, Location);
reset.Block = new ToplevelBlock (Compiler, Location) {
IsCompilerGenerated = true
};
TypeSpec ex_type = Module.PredefinedTypes.NotSupportedException.Resolve ();
if (ex_type == null)
@ -568,7 +584,7 @@ namespace Mono.CSharp @@ -568,7 +584,7 @@ namespace Mono.CSharp
name, ParametersCompiled.EmptyReadOnlyParameters, null)
{
this.expr = expr;
Block = new ToplevelBlock (host.Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location);
Block = new ToplevelBlock (host.Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
}
public override EmitContext CreateEmitContext (ILGenerator ig)
@ -715,7 +731,7 @@ namespace Mono.CSharp @@ -715,7 +731,7 @@ namespace Mono.CSharp
storey.Instance.Emit (ec);
}
void EmitMoveNext_NoResumePoints (EmitContext ec, Block original_block)
void EmitMoveNext_NoResumePoints (EmitContext ec)
{
ec.EmitThis ();
ec.Emit (OpCodes.Ldfld, storey.PC.Spec);
@ -729,9 +745,11 @@ namespace Mono.CSharp @@ -729,9 +745,11 @@ namespace Mono.CSharp
iterator_body_end = ec.DefineLabel ();
SymbolWriter.StartIteratorBody (ec);
original_block.Emit (ec);
SymbolWriter.EndIteratorBody (ec);
if (ec.EmitAccurateDebugInfo && ec.Mark (Block.Original.StartLocation)) {
ec.Emit (OpCodes.Nop);
}
block.Emit (ec);
ec.MarkLabel (iterator_body_end);
@ -751,7 +769,7 @@ namespace Mono.CSharp @@ -751,7 +769,7 @@ namespace Mono.CSharp
move_next_error = ec.DefineLabel ();
if (resume_points == null) {
EmitMoveNext_NoResumePoints (ec, block);
EmitMoveNext_NoResumePoints (ec);
return;
}
@ -785,22 +803,20 @@ namespace Mono.CSharp @@ -785,22 +803,20 @@ namespace Mono.CSharp
if (async_init != null)
ec.BeginExceptionBlock ();
SymbolWriter.StartIteratorDispatcher (ec);
ec.Emit (OpCodes.Ldloc, current_pc);
ec.Emit (OpCodes.Switch, labels);
ec.Emit (async_init != null ? OpCodes.Leave : OpCodes.Br, move_next_error);
SymbolWriter.EndIteratorDispatcher (ec);
ec.MarkLabel (labels[0]);
iterator_body_end = ec.DefineLabel ();
SymbolWriter.StartIteratorBody (ec);
block.Emit (ec);
SymbolWriter.EndIteratorBody (ec);
if (ec.EmitAccurateDebugInfo && ec.Mark (Block.Original.StartLocation)) {
ec.Emit (OpCodes.Nop);
}
SymbolWriter.StartIteratorDispatcher (ec);
block.Emit (ec);
ec.MarkLabel (iterator_body_end);
@ -820,6 +836,7 @@ namespace Mono.CSharp @@ -820,6 +836,7 @@ namespace Mono.CSharp
ec.EndExceptionBlock ();
}
ec.Mark (Block.Original.EndLocation);
ec.EmitThis ();
ec.EmitInt ((int) IteratorStorey.State.After);
ec.Emit (OpCodes.Stfld, storey.PC.Spec);
@ -839,8 +856,6 @@ namespace Mono.CSharp @@ -839,8 +856,6 @@ namespace Mono.CSharp
ec.EmitInt (1);
ec.Emit (OpCodes.Ret);
}
SymbolWriter.EndIteratorDispatcher (ec);
}
protected virtual void EmitMoveNextEpilogue (EmitContext ec)

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

@ -2167,15 +2167,19 @@ namespace Mono.CSharp { @@ -2167,15 +2167,19 @@ namespace Mono.CSharp {
MethodGroupExpr method_expr = MethodGroupExpr.CreatePredefined (base_dtor, base_type, Location);
method_expr.InstanceExpression = new BaseThis (base_type, Location);
var try_block = new ExplicitBlock (block, block.StartLocation, block.EndLocation);
var finaly_block = new ExplicitBlock (block, Location, Location);
var try_block = new ExplicitBlock (block, block.StartLocation, block.EndLocation) {
IsCompilerGenerated = true
};
var finaly_block = new ExplicitBlock (block, Location, Location) {
IsCompilerGenerated = true
};
//
// 0-size arguments to avoid CS0250 error
// TODO: Should use AddScopeStatement or something else which emits correct
// debugger scope
//
finaly_block.AddStatement (new StatementExpression (new Invocation (method_expr, new Arguments (0))));
finaly_block.AddStatement (new StatementExpression (new Invocation (method_expr, new Arguments (0)), Location.Null));
var tf = new TryFinally (try_block, finaly_block, Location);
block.WrapIntoDestructor (tf, try_block);

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

@ -725,6 +725,9 @@ namespace Mono.CSharp { @@ -725,6 +725,9 @@ namespace Mono.CSharp {
Dictionary<string, UsingAliasNamespace> aliases;
public readonly MemberName RealMemberName;
#if FULL_AST
Attribute [] UnattachedAttributes;
#endif
public NamespaceContainer (MemberName name, NamespaceContainer parent)
: base (parent, name, null, MemberKind.Namespace)
{

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

@ -749,15 +749,19 @@ namespace Mono.CSharp @@ -749,15 +749,19 @@ namespace Mono.CSharp
if ((field.ModFlags & Modifiers.STATIC) == 0)
fe.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);
// Create get block
Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location);
Return r = new Return (fe, Location);
//
// Create get block but we careful with location to
// emit only single sequence point per accessor. This allow
// to set a breakpoint on it even with no user code
//
Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
Return r = new Return (fe, Get.Location);
Get.Block.AddStatement (r);
// Create set block
Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location);
Assign a = new SimpleAssign (fe, new SimpleName ("value", Location));
Set.Block.AddStatement (new StatementExpression (a));
Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location.Null);
Assign a = new SimpleAssign (fe, new SimpleName ("value", Location.Null), Location.Null);
Set.Block.AddStatement (new StatementExpression (a, Set.Location));
}
public override bool Define ()
@ -893,7 +897,9 @@ namespace Mono.CSharp @@ -893,7 +897,9 @@ namespace Mono.CSharp
public override void Emit (TypeDefinition parent)
{
if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0) {
block = new ToplevelBlock (Compiler, ParameterInfo, Location);
block = new ToplevelBlock (Compiler, ParameterInfo, Location) {
IsCompilerGenerated = true
};
FabricateBodyStatement ();
}

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

@ -327,17 +327,21 @@ namespace Mono.CSharp { @@ -327,17 +327,21 @@ namespace Mono.CSharp {
EmbeddedStatement.Emit (ec);
ec.MarkLabel (ec.LoopBegin);
// Mark start of while condition
ec.Mark (expr.Location);
//
// Dead code elimination
//
if (expr is Constant){
if (expr is Constant) {
bool res = !((Constant) expr).IsDefaultValue;
expr.EmitSideEffect (ec);
if (res)
ec.Emit (OpCodes.Br, loop);
} else
ec.Emit (OpCodes.Br, loop);
} else {
expr.EmitBranchable (ec, loop, true);
}
ec.MarkLabel (ec.LoopEnd);
@ -427,9 +431,13 @@ namespace Mono.CSharp { @@ -427,9 +431,13 @@ namespace Mono.CSharp {
//
// Inform whether we are infinite or not
//
if (expr is Constant){
if (expr is Constant) {
// expr is 'true', since the 'empty' case above handles the 'false' case
ec.MarkLabel (ec.LoopBegin);
if (ec.EmitAccurateDebugInfo)
ec.Emit (OpCodes.Nop);
expr.EmitSideEffect (ec);
Statement.Emit (ec);
ec.Emit (OpCodes.Br, ec.LoopBegin);
@ -448,8 +456,8 @@ namespace Mono.CSharp { @@ -448,8 +456,8 @@ namespace Mono.CSharp {
Statement.Emit (ec);
ec.MarkLabel (ec.LoopBegin);
ec.Mark (loc);
ec.Mark (expr.Location);
expr.EmitBranchable (ec, while_loop, true);
ec.MarkLabel (ec.LoopEnd);
@ -459,11 +467,6 @@ namespace Mono.CSharp { @@ -459,11 +467,6 @@ namespace Mono.CSharp {
ec.LoopEnd = old_end;
}
public override void Emit (EmitContext ec)
{
DoEmit (ec);
}
protected override void CloneTo (CloneContext clonectx, Statement t)
{
While target = (While) t;
@ -592,7 +595,9 @@ namespace Mono.CSharp { @@ -592,7 +595,9 @@ namespace Mono.CSharp {
// If test is null, there is no test, and we are just
// an infinite loop
//
if (Condition != null){
if (Condition != null) {
ec.Mark (Condition.Location);
//
// The Resolve code already catches the case for
// Test == Constant (false) so we know that
@ -1853,7 +1858,7 @@ namespace Mono.CSharp { @@ -1853,7 +1858,7 @@ namespace Mono.CSharp {
// All fixed variabled are pinned, a slot has to be alocated
//
builder = ec.DeclareLocal (Type, IsFixed);
if (SymbolWriter.HasSymbolWriter)
if (!ec.HasSet (BuilderContext.Options.OmitDebugInfo) && (flags & Flags.CompilerGenerated) == 0)
ec.DefineLocalVariable (name, builder);
}
@ -2057,6 +2062,9 @@ namespace Mono.CSharp { @@ -2057,6 +2062,9 @@ namespace Mono.CSharp {
get {
return (flags & Flags.HasRet) != 0;
}
set {
flags = value ? flags | Flags.HasRet : flags & ~Flags.HasRet;
}
}
public Block Original {
@ -2453,7 +2461,7 @@ namespace Mono.CSharp { @@ -2453,7 +2461,7 @@ namespace Mono.CSharp {
if (scope_initializers != null)
EmitScopeInitializers (ec);
if (ec.EmitAccurateDebugInfo && ec.Mark (StartLocation)) {
if (ec.EmitAccurateDebugInfo && !IsCompilerGenerated && ec.Mark (StartLocation)) {
ec.Emit (OpCodes.Nop);
}
@ -2469,7 +2477,7 @@ namespace Mono.CSharp { @@ -2469,7 +2477,7 @@ namespace Mono.CSharp {
if (emit_debug_info)
ec.EndScope ();
if (ec.EmitAccurateDebugInfo && !HasUnreachableClosingBrace && ec.Mark (EndLocation)) {
if (ec.EmitAccurateDebugInfo && !HasUnreachableClosingBrace && !IsCompilerGenerated && ec.Mark (EndLocation)) {
ec.Emit (OpCodes.Nop);
}
}
@ -2942,8 +2950,7 @@ namespace Mono.CSharp { @@ -2942,8 +2950,7 @@ namespace Mono.CSharp {
public void WrapIntoIterator (IMethodData method, TypeDefinition host, TypeSpec iterator_type, bool is_enumerable)
{
ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, StartLocation);
pb.EndLocation = EndLocation;
ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
pb.statements = statements;
pb.Original = this;
@ -2953,6 +2960,7 @@ namespace Mono.CSharp { @@ -2953,6 +2960,7 @@ namespace Mono.CSharp {
statements = new List<Statement> (1);
AddStatement (new Return (iterator, iterator.Location));
flags &= ~Flags.YieldBlock;
IsCompilerGenerated = true;
}
public void WrapIntoAsyncTask (IMemberContext context, TypeDefinition host, TypeSpec returnType)
@ -4078,7 +4086,10 @@ namespace Mono.CSharp { @@ -4078,7 +4086,10 @@ namespace Mono.CSharp {
}
}
simple_stmt = new If (cond, s.Block, simple_stmt, loc);
//
// Compiler generated, hide from symbol file
//
simple_stmt = new If (cond, s.Block, simple_stmt, Location.Null);
}
// It's null for empty switch
@ -4166,7 +4177,9 @@ namespace Mono.CSharp { @@ -4166,7 +4177,9 @@ namespace Mono.CSharp {
// Check if string dictionary is initialized and initialize
//
switch_cache_field.EmitBranchable (ec, l_initialized, true);
string_dictionary.EmitStatement (ec);
using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
string_dictionary.EmitStatement (ec);
}
ec.MarkLabel (l_initialized);
LocalTemporary string_switch_variable = new LocalTemporary (ec.BuiltinTypes.Int);
@ -4210,6 +4223,9 @@ namespace Mono.CSharp { @@ -4210,6 +4223,9 @@ namespace Mono.CSharp {
protected override void DoEmit (EmitContext ec)
{
// Workaround broken flow-analysis
block.HasUnreachableClosingBrace = true;
//
// Needed to emit anonymous storey initialization
// Otherwise it does not contain any statements for now
@ -5117,17 +5133,13 @@ namespace Mono.CSharp { @@ -5117,17 +5133,13 @@ namespace Mono.CSharp {
//
if (li.HoistedVariant != null) {
LocalTemporary lt = new LocalTemporary (li.Type);
SymbolWriter.OpenCompilerGeneratedBlock (ec);
lt.Store (ec);
SymbolWriter.CloseCompilerGeneratedBlock (ec);
// switch to assigning from the temporary variable and not from top of the stack
assign.UpdateSource (lt);
}
} else {
SymbolWriter.OpenCompilerGeneratedBlock (ec);
ec.Emit (OpCodes.Pop);
SymbolWriter.CloseCompilerGeneratedBlock (ec);
}
Block.Emit (ec);
@ -5152,8 +5164,11 @@ namespace Mono.CSharp { @@ -5152,8 +5164,11 @@ namespace Mono.CSharp {
if (li.Type.IsGenericParameter)
source = new UnboxCast (source, li.Type);
assign = new CompilerAssign (new LocalVariableReference (li, loc), source, loc);
Block.AddScopeStatement (new StatementExpression (assign));
//
// Uses Location.Null to hide from symbol file
//
assign = new CompilerAssign (new LocalVariableReference (li, Location.Null), source, Location.Null);
Block.AddScopeStatement (new StatementExpression (assign, Location.Null));
}
}
@ -5479,7 +5494,10 @@ namespace Mono.CSharp { @@ -5479,7 +5494,10 @@ namespace Mono.CSharp {
new Cast (new TypeExpression (idt, loc), lvr, loc).Resolve (bc) :
lvr;
Statement dispose = new StatementExpression (new Invocation (dispose_mg, null));
//
// Hide it from symbol file via null location
//
Statement dispose = new StatementExpression (new Invocation (dispose_mg, null), Location.Null);
// Add conditional call when disposing possible null variable
if (!type.IsStruct || type.IsNullableType)
@ -5546,6 +5564,14 @@ namespace Mono.CSharp { @@ -5546,6 +5564,14 @@ namespace Mono.CSharp {
#endregion
public override void Emit (EmitContext ec)
{
//
// Don't emit sequence point it will be set on variable declaration
//
DoEmit (ec);
}
protected override void EmitTryBodyPrepare (EmitContext ec)
{
decl.Emit (ec);
@ -5998,7 +6024,7 @@ namespace Mono.CSharp { @@ -5998,7 +6024,7 @@ namespace Mono.CSharp {
return null;
}
return MethodGroupExpr.CreatePredefined (ms, enumerator.ReturnType, loc);
return MethodGroupExpr.CreatePredefined (ms, enumerator.ReturnType, expr.Location);
}
PropertySpec ResolveCurrent (ResolveContext rc, MethodSpec enumerator)
@ -6077,7 +6103,7 @@ namespace Mono.CSharp { @@ -6077,7 +6103,7 @@ namespace Mono.CSharp {
var init = new Invocation (get_enumerator_mg, null);
statement = new While (new BooleanExpression (new Invocation (move_next_mg, null)),
new Body (variable.Type, variable, current_pe, statement, loc), loc);
new Body (variable.Type, variable, current_pe, statement, variable.Location), Location.Null);
var enum_type = enumerator_variable.Type;
@ -6089,23 +6115,23 @@ namespace Mono.CSharp { @@ -6089,23 +6115,23 @@ namespace Mono.CSharp {
//
// Runtime Dispose check
//
var vd = new RuntimeDispose (enumerator_variable.LocalInfo, loc);
var vd = new RuntimeDispose (enumerator_variable.LocalInfo, Location.Null);
vd.Initializer = init;
statement = new Using (vd, statement, loc);
statement = new Using (vd, statement, Location.Null);
} else {
//
// No Dispose call needed
//
this.init = new SimpleAssign (enumerator_variable, init);
this.init = new SimpleAssign (enumerator_variable, init, Location.Null);
this.init.Resolve (ec);
}
} else {
//
// Static Dispose check
//
var vd = new Using.VariableDeclaration (enumerator_variable.LocalInfo, loc);
var vd = new Using.VariableDeclaration (enumerator_variable.LocalInfo, Location.Null);
vd.Initializer = init;
statement = new Using (vd, statement, loc);
statement = new Using (vd, statement, Location.Null);
}
return statement.Resolve (ec);
@ -6126,7 +6152,7 @@ namespace Mono.CSharp { @@ -6126,7 +6152,7 @@ namespace Mono.CSharp {
bool OverloadResolver.IErrorHandler.AmbiguousCandidates (ResolveContext ec, MemberSpec best, MemberSpec ambiguous)
{
ec.Report.SymbolRelatedToPreviousError (best);
ec.Report.Warning (278, 2, loc,
ec.Report.Warning (278, 2, expr.Location,
"`{0}' contains ambiguous implementation of `{1}' pattern. Method `{2}' is ambiguous with method `{3}'",
expr.Type.GetSignatureForError (), "enumerable",
best.GetSignatureForError (), ambiguous.GetSignatureForError ());

6
ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAttribute.cs

@ -51,8 +51,7 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -51,8 +51,7 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
this.namedCtorArguments = namedCtorArguments ?? EmptyList<KeyValuePair<string, IConstantValue>>.Instance;
this.namedArguments = namedArguments ?? EmptyList<KeyValuePair<string, IConstantValue>>.Instance;
}
public DomRegion Region {
public DomRegion Region {
get { return region; }
}
@ -157,7 +156,7 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -157,7 +156,7 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
} else {
namedArgs = new List<KeyValuePair<IMember, ResolveResult>>();
foreach (var pair in unresolved.namedArguments) {
IMember member = attributeType.GetMembers(m => (m.EntityType == EntityType.Field || m.EntityType == EntityType.Property) && m.Name == pair.Key).FirstOrDefault();
IMember member = attributeType.GetMembers(m => (m.EntityType == EntityType.Fidyj.keld || m.EntityType == EntityType.Property) && m.Name == pair.Key).FirstOrDefault();
if (member != null) {
ResolveResult val = pair.Value.Resolve(context);
namedArgs.Add(new KeyValuePair<IMember, ResolveResult>(member, val));
@ -259,3 +258,4 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -259,3 +258,4 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
}
*/
}
MarshalByRefObject ^äp
Loading…
Cancel
Save