Browse Source

[Parser] Merged mcs.

newNRvisualizers
Mike Krüger 13 years ago
parent
commit
8c8e6cf52b
  1. 12
      ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  2. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs
  3. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs
  4. 19
      ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs
  5. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs
  6. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs
  7. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
  8. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs
  9. 74
      ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs
  10. 18
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  11. 7
      ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs

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

@ -315,7 +315,7 @@ namespace Mono.CSharp { @@ -315,7 +315,7 @@ namespace Mono.CSharp {
}
var hoisted = localVariable.HoistedVariant;
if (hoisted != null && hoisted.Storey != this && hoisted.Storey.Kind == MemberKind.Struct) {
if (hoisted != null && hoisted.Storey != this && hoisted.Storey is StateMachine) {
// TODO: It's too late the field is defined in HoistedLocalVariable ctor
hoisted.Storey.hoisted_locals.Remove (hoisted);
hoisted = null;
@ -331,7 +331,7 @@ namespace Mono.CSharp { @@ -331,7 +331,7 @@ namespace Mono.CSharp {
hoisted_locals.Add (hoisted);
}
if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit)
if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoisted.Storey is StateMachine))
hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);
}
@ -343,7 +343,7 @@ namespace Mono.CSharp { @@ -343,7 +343,7 @@ namespace Mono.CSharp {
var hoisted = parameterInfo.Parameter.HoistedVariant;
if (parameterInfo.Block.StateMachine is AsyncTaskStorey) {
if (parameterInfo.Block.StateMachine != null) {
//
// Another storey in same block exists but state machine does not
// have parameter captured. We need to add it there as well to
@ -365,7 +365,7 @@ namespace Mono.CSharp { @@ -365,7 +365,7 @@ namespace Mono.CSharp {
// Lift captured parameter from value type storey to reference type one. Otherwise
// any side effects would be done on a copy
//
if (hoisted != null && hoisted.Storey != this && hoisted.Storey.Kind == MemberKind.Struct) {
if (hoisted != null && hoisted.Storey != this && hoisted.Storey is StateMachine) {
if (hoisted_local_params == null)
hoisted_local_params = new List<HoistedParameter> ();
@ -488,7 +488,7 @@ namespace Mono.CSharp { @@ -488,7 +488,7 @@ namespace Mono.CSharp {
// When the current context is async (or iterator) lift local storey
// instantiation to the currect storey
//
if (ec.CurrentAnonymousMethod is StateMachineInitializer) {
if (ec.CurrentAnonymousMethod is StateMachineInitializer && (block.HasYield || block.HasAwait)) {
//
// Unfortunately, normal capture mechanism could not be used because we are
// too late in the pipeline and standart assign cannot be used either due to
@ -702,7 +702,7 @@ namespace Mono.CSharp { @@ -702,7 +702,7 @@ namespace Mono.CSharp {
public override void Emit (EmitContext ec)
{
ResolveContext rc = new ResolveContext (ec.MemberContext);
Expression e = hv.GetFieldExpression (ec).CreateExpressionTree (rc);
Expression e = hv.GetFieldExpression (ec).CreateExpressionTree (rc, false);
// This should never fail
e = e.Resolve (rc);
if (e != null)

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

@ -1337,8 +1337,7 @@ namespace Mono.CSharp { @@ -1337,8 +1337,7 @@ namespace Mono.CSharp {
try {
c = c.ConvertImplicitly (target_type);
} catch {
Console.WriteLine ("Conversion error happened in line {0}", loc);
throw;
throw new InternalErrorException ("Conversion error", loc);
}
if (c != null)
return c;

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

@ -1816,13 +1816,10 @@ namespace Mono.CSharp @@ -1816,13 +1816,10 @@ namespace Mono.CSharp
public void putback (int c)
{
if (putback_char != -1){
Console.WriteLine ("Col: " + col);
Console.WriteLine ("Row: " + line);
Console.WriteLine ("Name: " + current_source.Name);
Console.WriteLine ("Current [{0}] putting back [{1}] ", putback_char, c);
throw new Exception ("This should not happen putback on putback");
if (putback_char != -1) {
throw new InternalErrorException (string.Format ("Secondary putback [{0}] putting back [{1}] is not allowed", (char)putback_char, (char) c), Location);
}
if (c == '\n' || col == 0) {
// It won't happen though.
line--;

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

@ -2401,7 +2401,7 @@ namespace Mono.CSharp { @@ -2401,7 +2401,7 @@ namespace Mono.CSharp {
} else {
break;
}
} else if (me is MethodGroupExpr) {
} else if (me is MethodGroupExpr || me is PropertyExpr || me is IndexerExpr) {
// Leave it to overload resolution to report correct error
} else {
// TODO: rc.Report.SymbolRelatedToPreviousError ()
@ -5238,14 +5238,25 @@ namespace Mono.CSharp { @@ -5238,14 +5238,25 @@ namespace Mono.CSharp {
public override Expression CreateExpressionTree (ResolveContext ec)
{
return CreateExpressionTree (ec, true);
}
public Expression CreateExpressionTree (ResolveContext ec, bool convertInstance)
{
Arguments args;
Expression instance;
if (InstanceExpression == null) {
instance = new NullLiteral (loc);
} else {
} else if (convertInstance) {
instance = InstanceExpression.CreateExpressionTree (ec);
} else {
args = new Arguments (1);
args.Add (new Argument (InstanceExpression));
instance = CreateExpressionFactoryCall (ec, "Constant", args);
}
Arguments args = Arguments.CreateForExpressionTree (ec, null,
args = Arguments.CreateForExpressionTree (ec, null,
instance,
CreateTypeOfExpression ());
@ -6067,7 +6078,7 @@ namespace Mono.CSharp { @@ -6067,7 +6078,7 @@ namespace Mono.CSharp {
GetSignatureForError ());
} else {
rc.Report.SymbolRelatedToPreviousError (best_candidate.Set);
ErrorIsInaccesible (rc, best_candidate.Set.GetSignatureForError (), loc);
ErrorIsInaccesible (rc, best_candidate.GetSignatureForError (), loc);
}
}

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

@ -9870,7 +9870,7 @@ namespace Mono.CSharp @@ -9870,7 +9870,7 @@ namespace Mono.CSharp
}
}
public CollectionElementInitializer(Expression argument)
public CollectionElementInitializer (Expression argument)
: base (null, new Arguments (1))
{
IsSingle = true;
@ -9878,7 +9878,7 @@ namespace Mono.CSharp @@ -9878,7 +9878,7 @@ namespace Mono.CSharp
this.loc = argument.Location;
}
public CollectionElementInitializer(List<Expression> arguments, Location loc)
public CollectionElementInitializer (List<Expression> arguments, Location loc)
: base (null, new Arguments (arguments.Count))
{
IsSingle = false;

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

@ -972,7 +972,9 @@ namespace Mono.CSharp @@ -972,7 +972,9 @@ namespace Mono.CSharp
method.Block.IsCompilerGenerated = true;
method.Block.AddStatement (new TryFinallyBlockProxyStatement (this, block));
storey.AddMember (method);
// Cannot it add to storey because it'd be emitted before nested
// anonoymous methods which could capture shared variable
return method;
}

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

@ -1432,8 +1432,7 @@ namespace Mono.CSharp { @@ -1432,8 +1432,7 @@ namespace Mono.CSharp {
base_ctor = ConstructorLookup (ec, type, ref argument_list, loc);
}
// TODO MemberCache: Does it work for inflated types ?
if (base_ctor == caller_builder.Spec){
if (base_ctor.MemberDefinition == caller_builder.Spec.MemberDefinition) {
ec.Report.Error (516, loc, "Constructor `{0}' cannot call itself",
caller_builder.GetSignatureForError ());
}

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

@ -170,12 +170,6 @@ namespace Mono.CSharp { @@ -170,12 +170,6 @@ namespace Mono.CSharp {
extra_information.Add (msg);
}
public bool CheckWarningCode (string code, Location loc)
{
Warning (1691, 1, loc, "`{0}' is not a valid warning number", code);
return false;
}
public bool CheckWarningCode (int code, Location loc)
{
if (AllWarningsHashSet == null)
@ -184,7 +178,8 @@ namespace Mono.CSharp { @@ -184,7 +178,8 @@ namespace Mono.CSharp {
if (AllWarningsHashSet.Contains (code))
return true;
return CheckWarningCode (code.ToString (), loc);
Warning (1691, 1, loc, "`{0}' is not a valid warning number", code);
return false;
}
public void ExtraInformation (Location loc, string msg)

74
ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs

@ -565,36 +565,22 @@ namespace Mono.CSharp { @@ -565,36 +565,22 @@ namespace Mono.CSharp {
source_file_index.Add (path, unit.Index);
}
void AddWarningAsError (string warningId, CompilerSettings settings)
public bool ProcessWarningsList (string text, Action<int> action)
{
int id;
try {
id = int.Parse (warningId);
} catch {
report.CheckWarningCode (warningId, Location.Null);
return;
}
if (!report.CheckWarningCode (id, Location.Null))
return;
settings.AddWarningAsError (id);
}
bool valid = true;
foreach (string wid in text.Split (numeric_value_separator)) {
int id;
if (!int.TryParse (wid, NumberStyles.AllowLeadingWhite, CultureInfo.InvariantCulture, out id)) {
report.Error (1904, "`{0}' is not a valid warning number", wid);
valid = false;
continue;
}
void RemoveWarningAsError (string warningId, CompilerSettings settings)
{
int id;
try {
id = int.Parse (warningId);
} catch {
report.CheckWarningCode (warningId, Location.Null);
return;
if (report.CheckWarningCode (id, Location.Null))
action (id);
}
if (!report.CheckWarningCode (id, Location.Null))
return;
settings.AddWarningOnly (id);
return valid;
}
void Error_RequiresArgument (string option)
@ -997,8 +983,8 @@ namespace Mono.CSharp { @@ -997,8 +983,8 @@ namespace Mono.CSharp {
settings.WarningsAreErrors = true;
parser_settings.WarningsAreErrors = true;
} else {
foreach (string wid in value.Split (numeric_value_separator))
AddWarningAsError (wid, settings);
if (!ProcessWarningsList (value, v => settings.AddWarningAsError (v)))
return ParseResult.Error;
}
return ParseResult.Success;
@ -1006,12 +992,13 @@ namespace Mono.CSharp { @@ -1006,12 +992,13 @@ namespace Mono.CSharp {
if (value.Length == 0) {
settings.WarningsAreErrors = false;
} else {
foreach (string wid in value.Split (numeric_value_separator))
RemoveWarningAsError (wid, settings);
if (!ProcessWarningsList (value, v => settings.AddWarningOnly (v)))
return ParseResult.Error;
}
return ParseResult.Success;
case "/warn":
case "/w":
if (value.Length == 0) {
Error_RequiresArgument (option);
return ParseResult.Error;
@ -1021,28 +1008,15 @@ namespace Mono.CSharp { @@ -1021,28 +1008,15 @@ namespace Mono.CSharp {
return ParseResult.Success;
case "/nowarn":
if (value.Length == 0) {
Error_RequiresArgument (option);
return ParseResult.Error;
}
if (value.Length == 0) {
Error_RequiresArgument (option);
return ParseResult.Error;
}
var warns = value.Split (numeric_value_separator);
foreach (string wc in warns) {
try {
if (wc.Trim ().Length == 0)
continue;
if (!ProcessWarningsList (value, v => settings.SetIgnoreWarning (v)))
return ParseResult.Error;
int warn = Int32.Parse (wc);
if (warn < 1) {
throw new ArgumentOutOfRangeException ("warn");
}
settings.SetIgnoreWarning (warn);
} catch {
report.Error (1904, "`{0}' is not a valid warning number", wc);
return ParseResult.Error;
}
}
return ParseResult.Success;
return ParseResult.Success;
case "/noconfig":
settings.LoadDefaultReferences = false;

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

@ -950,10 +950,9 @@ namespace Mono.CSharp { @@ -950,10 +950,9 @@ namespace Mono.CSharp {
async_return.EmitAssign (ec);
ec.EmitEpilogue ();
ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, async_body.BodyEnd);
}
ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, async_body.BodyEnd);
return;
}
@ -2462,15 +2461,6 @@ namespace Mono.CSharp { @@ -2462,15 +2461,6 @@ namespace Mono.CSharp {
if (ec.CurrentAnonymousMethod is StateMachineInitializer && ParametersBlock.Original == ec.CurrentAnonymousMethod.Block.Original)
return ec.CurrentAnonymousMethod.Storey;
//
// When referencing a variable inside iterator where all
// variables will be captured anyway we don't need to create
// another storey context
//
if (ParametersBlock.StateMachine is IteratorStorey) {
return ParametersBlock.StateMachine;
}
if (am_storey == null) {
MemberBase mc = ec.MemberContext as MemberBase;
@ -4539,6 +4529,12 @@ namespace Mono.CSharp { @@ -4539,6 +4529,12 @@ namespace Mono.CSharp {
ec.MarkLabel (start_finally);
if (finally_host != null) {
finally_host.Define ();
finally_host.Emit ();
// Now it's safe to add, to close it properly and emit sequence points
finally_host.Parent.AddMember (finally_host);
var ce = new CallEmitter ();
ce.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc);
ce.EmitPredefined (ec, finally_host.Spec, new Arguments (0));

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

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
//
using System;
using System.Diagnostics;
namespace Mono.CSharp
{
@ -18,7 +19,7 @@ namespace Mono.CSharp @@ -18,7 +19,7 @@ namespace Mono.CSharp
{
public virtual void Visit (MemberCore member)
{
Console.WriteLine ("unknown member type: " + member.GetType ());
Debug.Fail ("unknown member type: " + member.GetType ());
}
public virtual void Visit (ModuleContainer mc)
@ -125,7 +126,7 @@ namespace Mono.CSharp @@ -125,7 +126,7 @@ namespace Mono.CSharp
public virtual object Visit (Statement stmt)
{
Console.WriteLine ("unknown statement:" + stmt);
Debug.Fail ("unknown statement:" + stmt);
return null;
}
@ -309,7 +310,7 @@ namespace Mono.CSharp @@ -309,7 +310,7 @@ namespace Mono.CSharp
public virtual object Visit (Expression expression)
{
Console.WriteLine ("Visit unknown expression:" + expression);
Debug.Fail ("Visit unknown expression:" + expression);
return null;
}

Loading…
Cancel
Save