Browse Source

Squashed 'NRefactory/' changes from 858d4cc..b374e40

b374e40 Don't insert space in front of brace if the brace is the first token in the line.
9f809bc Use IOutputFormatter.StartNode() instead of OutputStarted event.
f30ceb5 Set version number to 5.0.0.4.
8d5b268 Fixed completion bug.
d2f2feb Remove the thread-local cache; it seems to cause massive memory leaks.
cfe807a Fix "find references" for method group conversions in delegate creation expressions "new Action(MyMethod)"
5f8dcf4 Implement 'ToMemberReference()' and 'InterfaceImplementations' on specialized members.
33b57d5 Fixed IMember.ToMemberReference() for explicit interface implementations.
9859dce Improve ResolveAtLocation.
a7245af Fixed finding references to method group conversions.
194b334 Add FindReferencesConsistencyCheck.
d0bd4fa Merge changes from SharpDevelop 'newNR' branch into NRefactory main repository.
311df2b CSharpAstResolver: add cancellation support
17a8d43 Fixed completion bug.
3b682d4 Fixed code completion bug.
e2bf1e4 Worked on unattached attribute handling.
b0332c6 Added IsInside methods to the AstNode.
e5217c2 Fixed bug in 'BetterConversion' implementation - converting to Func<> delegates is better than converting to Action<> delegates.
c6ecab1 Implemented support for InternalsVisibleToAttribute.
cb84ada Fixed parsing undocumented expressions.
46254b3 Add support for resolving "operator true".
862e950 When the specified reflection name is not assembly-qualified, ReflectionHelper.ParseReflectionName() will now produce an ITypeReference that looks in all referenced assemblies (not just in CurrentAssembly).
77ea4da Report more types of invalid equality comparisons as errors. Mark an anonymous function conversion as invalid if there are compiler errors in the implicitly typed lambda.
bb822e9 Allow using AstType.ToTypeReference().Resolve(compilation.TypeResolveContext) - this will now resolve in the global namespace. Fixed increment operator on System.Char.
27a91cc Fixed bug in protected member logic.
6b45af2 Fixed "UsingStatementTests.UsingStatementWithMultipleVariableDeclaration".
f3541d4 Fixed accessing protected members through type parameters.
9f5f18e Fixed resolving "condition ? byte : 0".
7971ad2 Check IType.Kind instead of using SpecialType.X.Equals().
c20807e Fixed return type of members of generic enums.
67d1912 Fixed bug in reachability analysis when lambda/anonymous method contains a condition or switch statement.
1a7ca15 Allow conversion of anonymous method with unreachable endpoint to Func<T>.
822fda7 Handle T[] -> T* and string -> char* conversions in fixed statement initializers.
0f2b0c3 Fixed lambda type inference in delegate creation expressions. ("new Func<int, int>(a => a)")
aa2e97f When copying type parameters into inner classes, re-use the same ITypeParameter instance.
57a5934 Revert "Fixed type system converter case reported from "erik-kallen"."
006d18a Resolve at location can now give back the AstNode.
6054ed4 Added unattached attributes to the AST.
426ce5d Removed some ignore attributes.
9f9a26b Updated mcs.
c4dfb27 Fixed type system converter case reported from "erik-kallen".
8efd32e Don't crash when trying to decode invalid attribute/secdecl blobs.
5ff4462 NRefactory 5: do not throw exceptions if there's no cecil reference for entity
fb0c292 Fix icsharpcode/NRefactory#13 - Indexer accessors do not get correct parameters.
5c9dfb9 Fixed IUnresolvedTypeDefinition.Resolve() and IAssembly.GetTypeDefinition(IUnresolvedTypeDefinition) to always retrieve the correct version of the type definition for the compilation, even if the IUnresolvedTypeDefinition is a different version. The two methods now return UnknownType/null if the IUnresolvedTypeDefinition does not belong to the assembly.
c5c5192 Add documentation to methods for creating type references that describe the expected ITypeResolveContext for resolving those type references.
6d7abd9 Use AstType.ToTypeReference() instead of TypeSystemConvertVisitor.ConvertType().
13ac45e Add AstType.ToTypeReference() method.
c5c1337 Add failing unit test for using-statement with multiple variable declarations.
79b8b00 Fix bug in output type inference for explicitly typed lambdas.
cdfa794 Add some ToString() overrides for easier debugging
e441980 Fixed parsing "bool.TrueString".
d44077a Add CSharpAstResolver.GetResolverStateAfter() and fixed an issue with the scanning logic in ResolveVisitor.
dce53cb Fixed code completion bug.
20b9420 Took out error message.
3d21a80 Fixed the ResolveVisitor scanning logic and several related issues.
a3ff017 When a simple-name refers to an instance field in the current class, set TargetResult=new ThisResolveResult().
4d20ce3 Fix build.
b400314 Add MethodGroupResolveResult.GetEligibleExtensionMethods() method.
5838210 Fixed parser exception.
510d58a Fixed parameter test case.
440bc4f Fixed assertion error.
8b32926 Fixed const field access.
802cd23 Fixed "assertion problem". Failed code was: -------------------------------- using System; using System.Collections.Generic; namespace MyApp { public interface ISubject<T> { } public class Test<T,TRight,TLeft> { public void Foo (IObserver<T> observer) { var rightSubs = new List<ISubject<TRight>> (); var rightVals = new List<TRight> (); Observer.Create<TLeft> (v => { ISubject<TRight> rsub = new ReplaySubject<TRight> (); foreach (var r }, () => sub.OnCompleted ()); } } } ------------------------------------
e7833ba Added some more naming contexts.
3a4eeb4 Merged with monodevelop engine.
d88c793 Fixed bug in RemoveBackingStore context action.
e7ee62f Fixed resolve at location for object create expressions.
9a96b02 Fixed using context/ added unit test for try ... catch case.
22f7e30 Take correct type for override completion.
f931cf0 Added some null checks. Mcs can now parse much more "invalid" expressions & statements.
2cfed41 Fixed primitive type keywords.
7df3367 Guard against storing the resolve result for variable name token twice in foreach statement.
bd39c22 Removed some debug messages.
4e801c8 Fixed tuple parameter index.
1dab608 Added some null checks.
335fe94 Updated mcs.
6a85f2a Fixed AST builder.
c33bc0f Fixed assembly attribute location. The fix isn't very clean - but the structure is built that way, would be cleaner if it would be represented as Container.
764b8a3 Added unit tests for context actions.
e6df8e7 Added unit tests for SplitDeclarationAndAssignment context action.
1d8918c Fixed unit tests.
baa2096 Fixed hardcoded path.
93bea6d Fixed failing unit test.
96a5e7c Merge branch 'master' of github.com:icsharpcode/NRefactory
ef53445 [GtkDemo] Close application when closing main window.
9286461 Adjusting SharpDevelop to new type system (unresolved/resolved split).
3b4abcc Fixed ast node script positions.
7958965 Implemented some missing functions in refactoring context.
1737920 Added some unit tests.
72258ae Implemented type parameter type completion.
33e0c0e Fixed FindReferences on attributes.
a126210 Improved anonymous type context.
179d90a Added some null checks. Not sure if they're needed.
12b9542 Fixed other LINQ case.
ddc245e Fixed "LINQ" context unit tests.
f788f91 Ignore AssemblyInfo in RoundtripTest.
9fea0d0 Implemented eligibility check for extension methods.
7431897 Implemented 'partial' completion.
45fb111 Fixed anonymous type null reference exception.
e0d4232 Added unit test for "as" expression context.
9129087 Fixed type expected context.
574994c Updated/merged mcs.
e492e80 Merge branch 'master' of github.com:icsharpcode/NRefactory
75a4266 Merge NRefactory '90c0758bb07a651cbf7f7c78cb2bbfd282306c34' into SharpDevelop newNR branch.
90c0758 Update roundtrip test.
f201168 Fixed resolving LINQ queries that involve transparent identifiers.
418f709 Fixed resolving NamedExpressions in anonymous type creation expressions.
7779508 Fixed lifting for built-in relational operators.
040b841 Fixed resolving equality and relational operators on nullable types.
b803d85 Do not report invalid conversion from int to void for this code:
dac8c0f Implement CSharpAstResolver.GetExpectedType() and CSharpAstResolver.GetConversion().
70e62f4 Fixed DefaultMemberReference for methods with parameters.
d9fe4a3 Worked on merging mcs.
bd58ea7 Merged with mcs.
dba7b47 Fixed operators show up in completion list.
f92742b Removed double "default" item in switch context.
6a9564d Added member provider to give the completion engine more context from outside.
578bb6c Fixed parsing of switch statements.
a33b320 Fixed failing unit test.
b5c90d6 Added unit test for "Finalizer" method not shown.
b09fd7f Find references tries now to detect delegate usages of methods. TODO: Overload resolution.
bf12c00 Add protected virtual Clone() method to CSharpProjectContent.
453aac3 Ensure that IMember.InterfaceImplementations does not contain nulls if there were resolve errors.
1c46d7d Added unit test for category sorting.
01233b4 Fixed comparison of completion categories.
3a62505 Added location bounds check.
7befa59 Fixed for context completion.
25faa21 Removed some debug messages / fixed possible null ref.
eb5f257 Fixed constructor this/base unit test.
d5ead16 Fixed unit tests with leading dots & integer at eol.
4917151 Updated mcs.
3b95e5a Fixed IsExplicitInterfaceImplementation. Implemented IMember.InterfaceImplementations for explicitly implemented members.
5d81799 Fixed some tests broken by the mcs update.
a8cd94e Updated mcs.
2d49624 Ignored failing tests.
54168d5 Add nuspec. Changed project settings to produce xml-doc and debug symbols in release configuration.
0fd4f5b Rename unresolved InterfaceImplementations to ExplicitInterfaceImplementations.
06f96bf Remove IAccessor and use IMethod instead.
3c6cbee Add IMember.UnresolvedMember property.
7dda083 Added name context test suite.
5377104 Added named argument context.
850776f Fixed completion test case.
b5da9b1 Fixed some unit tests.
f8eed16 Worked on completion engine API.
e6877e9 Fixed completion unit test.
942b4f7 Move ConversionResoleResult to ICSharpCode.NRefactory.Semantics. Boxing conversion for attribute arguments is now used consistently in C# type system and Cecil-loaded type system.
812c1dc Added LINQ where test.
e9903ad Revert "Updated mcs."
19c344c Updated mcs.
bfafe8b Fixed handling of constants in OverloadResolution.GetArgumentsWithConversions(). This fixes IAttribute.PositionalArguments when implicit numeric conversions are involved.
44b1c40 Remove some dead code.
9af3c04 Fixed resolving compound assignment operators.
5218417 Improved completion of enums.
0ff96ea Fixed IndentBlocks bug.
f68f990 Fixed indent break statement formatting.
0a71c80 Fixed some more array initializer context bugs.
0017621 Fixed array initializer completion case.
ef04ca0 Added flag for new completion.
0ba844e Fixed type parameter completion bug.
d66eb1d Added new completion test case + bugfix.
d5677e5 Added parameter context tests.
b7c1490 Fixed completion case.
3a15d36 Fixed some code completion unit tests.
969223a Added a method to get all extension methods on a specified type.
d78d5f1 Fixed "type too fast" issue in code completion.
f763631 Merge NRefactory 7063203 into SharpDevelop repository.
24f8ae0 Add GetNewOffset() method to TextChangeEventArgs.
dc98bef Add IsDeleted and Equals() implementation to IDocumentLine.
43a8429 Disable resolver logging.

git-subtree-dir: NRefactory
git-subtree-split: b374e407589060b38af9156ff050dc7109c57bc6
pull/314/merge
Daniel Grunwald 13 years ago
parent
commit
07ba466934
  1. 20
      ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs
  2. 91
      ICSharpCode.NRefactory.CSharp/Analysis/ReachabilityAnalysis.cs
  3. 32
      ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs
  4. 33
      ICSharpCode.NRefactory.CSharp/Ast/AstNodeCollection.cs
  5. 60
      ICSharpCode.NRefactory.CSharp/Ast/AstType.cs
  6. 17
      ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs
  7. 34
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/AssignmentExpression.cs
  8. 15
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs
  9. 23
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/ParenthesizedExpression.cs
  10. 24
      ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs
  11. 56
      ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs
  12. 21
      ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs
  13. 1
      ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/AttributedNode.cs
  14. 4
      ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ConstructorDeclaration.cs
  15. 19
      ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs
  16. 636
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
  17. 315
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs
  18. 97
      ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs
  19. 20
      ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs
  20. 1
      ICSharpCode.NRefactory.CSharp/Completion/ICompletionDataFactory.cs
  21. 40
      ICSharpCode.NRefactory.CSharp/Completion/IMemberProvider.cs
  22. 3
      ICSharpCode.NRefactory.CSharp/Completion/IParameterCompletionDataFactory.cs
  23. 9
      ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs
  24. 18
      ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj
  25. 38
      ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs
  26. 10
      ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs
  27. 20
      ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs
  28. 792
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  29. 43
      ICSharpCode.NRefactory.CSharp/Parser/mcs/AssemblyInfo.cs
  30. 34100
      ICSharpCode.NRefactory.CSharp/Parser/mcs/ChangeLog
  31. 126
      ICSharpCode.NRefactory.CSharp/Parser/mcs/Makefile
  32. 22
      ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs
  33. 54
      ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs
  34. 46
      ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolWriter.cs
  35. 38
      ICSharpCode.NRefactory.CSharp/Parser/mcs/NOTES
  36. 26
      ICSharpCode.NRefactory.CSharp/Parser/mcs/OPTIMIZE
  37. 239
      ICSharpCode.NRefactory.CSharp/Parser/mcs/OTODO
  38. 66
      ICSharpCode.NRefactory.CSharp/Parser/mcs/PLAN
  39. 72
      ICSharpCode.NRefactory.CSharp/Parser/mcs/README
  40. 223
      ICSharpCode.NRefactory.CSharp/Parser/mcs/TODO
  41. 224
      ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  42. 29
      ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
  43. 28
      ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs
  44. 18
      ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs
  45. 103
      ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs
  46. 2132
      ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  47. 39
      ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs
  48. 116
      ICSharpCode.NRefactory.CSharp/Parser/mcs/compiler.doc
  49. 22
      ICSharpCode.NRefactory.CSharp/Parser/mcs/complete.cs
  50. 6
      ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs
  51. 17
      ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs
  52. 55
      ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs
  53. 9825
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  54. 701
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  55. 334
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs
  56. 661
      ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs
  57. 40
      ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs
  58. 154
      ICSharpCode.NRefactory.CSharp/Parser/mcs/dmcs.csproj
  59. 6
      ICSharpCode.NRefactory.CSharp/Parser/mcs/dmcs.exe.config
  60. 55
      ICSharpCode.NRefactory.CSharp/Parser/mcs/dmcs.exe.sources
  61. 20
      ICSharpCode.NRefactory.CSharp/Parser/mcs/dmcs.sln
  62. 59
      ICSharpCode.NRefactory.CSharp/Parser/mcs/doc-bootstrap.cs
  63. 37
      ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs
  64. 125
      ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs
  65. 33
      ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs
  66. 135
      ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs
  67. 30
      ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs
  68. 126
      ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
  69. 334
      ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs
  70. 30
      ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs
  71. 27
      ICSharpCode.NRefactory.CSharp/Parser/mcs/flowanalysis.cs
  72. 344
      ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs
  73. 111
      ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.csproj
  74. 14
      ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.exe.config
  75. 56
      ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.exe.sources
  76. 20
      ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.sln
  77. 23
      ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.userprefs
  78. 29
      ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs2.csproj
  79. 0
      ICSharpCode.NRefactory.CSharp/Parser/mcs/hosting.cs
  80. 131
      ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs
  81. 7
      ICSharpCode.NRefactory.CSharp/Parser/mcs/lambda.cs
  82. 24
      ICSharpCode.NRefactory.CSharp/Parser/mcs/lambda.todo
  83. 28
      ICSharpCode.NRefactory.CSharp/Parser/mcs/linq.cs
  84. 70
      ICSharpCode.NRefactory.CSharp/Parser/mcs/literal.cs
  85. 410
      ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs
  86. 43
      ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs
  87. 344
      ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
  88. 241
      ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs
  89. 1134
      ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs
  90. 20
      ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs
  91. 19
      ICSharpCode.NRefactory.CSharp/Parser/mcs/parameter.cs
  92. 12
      ICSharpCode.NRefactory.CSharp/Parser/mcs/pending.cs
  93. 185
      ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs
  94. 14
      ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs
  95. 168
      ICSharpCode.NRefactory.CSharp/Parser/mcs/repl.txt
  96. 135
      ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs
  97. 170
      ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs
  98. 53
      ICSharpCode.NRefactory.CSharp/Parser/mcs/smcs.exe.sources
  99. 384
      ICSharpCode.NRefactory.CSharp/Parser/mcs/smcs.exe.sources-xml
  100. 472
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  101. Some files were not shown because too many files have changed in this diff Show More

20
ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs

@ -21,9 +21,10 @@ using System.Collections.Generic; @@ -21,9 +21,10 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.NRefactory.CSharp.Analysis
@ -156,7 +157,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -156,7 +157,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
}
Statement rootStatement;
CSharpAstResolver resolver;
CSharpTypeResolveContext typeResolveContext;
Func<AstNode, CancellationToken, ResolveResult> resolver;
List<ControlFlowNode> nodes;
Dictionary<string, ControlFlowNode> labels;
List<ControlFlowNode> gotoStatements;
@ -164,6 +166,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -164,6 +166,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
public IList<ControlFlowNode> BuildControlFlowGraph(Statement statement, CancellationToken cancellationToken = default(CancellationToken))
{
if (statement == null)
throw new ArgumentNullException("statement");
CSharpResolver r = new CSharpResolver(MinimalCorlib.Instance.CreateCompilation());
return BuildControlFlowGraph(statement, new CSharpAstResolver(r, statement), cancellationToken);
}
@ -174,7 +178,11 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -174,7 +178,11 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
throw new ArgumentNullException("statement");
if (resolver == null)
throw new ArgumentNullException("resolver");
return BuildControlFlowGraph(statement, resolver.Resolve, resolver.TypeResolveContext, cancellationToken);
}
internal IList<ControlFlowNode> BuildControlFlowGraph(Statement statement, Func<AstNode, CancellationToken, ResolveResult> resolver, CSharpTypeResolveContext typeResolveContext, CancellationToken cancellationToken)
{
NodeCreationVisitor nodeCreationVisitor = new NodeCreationVisitor();
nodeCreationVisitor.builder = this;
try {
@ -183,6 +191,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -183,6 +191,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
this.gotoStatements = new List<ControlFlowNode>();
this.rootStatement = statement;
this.resolver = resolver;
this.typeResolveContext = typeResolveContext;
this.cancellationToken = cancellationToken;
ControlFlowNode entryPoint = CreateStartNode(statement);
@ -205,6 +214,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -205,6 +214,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
this.gotoStatements = null;
this.rootStatement = null;
this.resolver = null;
this.typeResolveContext = null;
this.cancellationToken = CancellationToken.None;
}
}
@ -288,7 +298,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -288,7 +298,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
if (!(expr is PrimitiveExpression || expr is NullReferenceExpression))
return null;
}
return resolver.Resolve(expr, cancellationToken);
return resolver(expr, cancellationToken);
}
/// <summary>
@ -308,7 +318,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -308,7 +318,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
{
if (c1 == null || c2 == null || !c1.IsCompileTimeConstant || !c2.IsCompileTimeConstant)
return false;
CSharpResolver r = new CSharpResolver(resolver.TypeResolveContext);
CSharpResolver r = new CSharpResolver(typeResolveContext);
ResolveResult c = r.ResolveBinaryOperator(BinaryOperatorType.Equality, c1, c2);
return c.IsCompileTimeConstant && (c.ConstantValue as bool?) == true;
}

91
ICSharpCode.NRefactory.CSharp/Analysis/ReachabilityAnalysis.cs

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Threading;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.Semantics;
namespace ICSharpCode.NRefactory.CSharp.Analysis
{
/// <summary>
/// Statement reachability analysis.
/// </summary>
public sealed class ReachabilityAnalysis
{
HashSet<Statement> reachableStatements = new HashSet<Statement>();
HashSet<Statement> reachableEndPoints = new HashSet<Statement>();
HashSet<ControlFlowNode> visitedNodes = new HashSet<ControlFlowNode>();
Stack<ControlFlowNode> stack = new Stack<ControlFlowNode>();
private ReachabilityAnalysis() {}
public static ReachabilityAnalysis Create(Statement statement, CSharpAstResolver resolver = null, CancellationToken cancellationToken = default(CancellationToken))
{
var cfgBuilder = new ControlFlowGraphBuilder();
var cfg = cfgBuilder.BuildControlFlowGraph(statement, resolver, cancellationToken);
return Create(cfg, cancellationToken);
}
internal static ReachabilityAnalysis Create(Statement statement, Func<AstNode, CancellationToken, ResolveResult> resolver, CSharpTypeResolveContext typeResolveContext, CancellationToken cancellationToken)
{
var cfgBuilder = new ControlFlowGraphBuilder();
var cfg = cfgBuilder.BuildControlFlowGraph(statement, resolver, typeResolveContext, cancellationToken);
return Create(cfg, cancellationToken);
}
public static ReachabilityAnalysis Create(IList<ControlFlowNode> controlFlowGraph, CancellationToken cancellationToken = default(CancellationToken))
{
if (controlFlowGraph == null)
throw new ArgumentNullException("controlFlowGraph");
ReachabilityAnalysis ra = new ReachabilityAnalysis();
ra.stack.Push(controlFlowGraph[0]);
while (ra.stack.Count > 0) {
cancellationToken.ThrowIfCancellationRequested();
ra.MarkReachable(ra.stack.Pop());
}
ra.stack = null;
ra.visitedNodes = null;
return ra;
}
void MarkReachable(ControlFlowNode node)
{
if (node.PreviousStatement != null)
reachableEndPoints.Add(node.PreviousStatement);
if (node.NextStatement != null)
reachableStatements.Add(node.NextStatement);
foreach (var edge in node.Outgoing) {
if (visitedNodes.Add(edge.To))
stack.Push(edge.To);
}
}
public bool IsReachable(Statement statement)
{
return reachableStatements.Contains(statement);
}
public bool IsEndpointReachable(Statement statement)
{
return reachableEndPoints.Contains(statement);
}
}
}

32
ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs

@ -135,6 +135,34 @@ namespace ICSharpCode.NRefactory.CSharp @@ -135,6 +135,34 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
/// <summary>
/// Returns true, if the given coordinates are in the node.
/// </summary>
public bool IsInside (TextLocation location)
{
return StartLocation <= location && location <= EndLocation;
}
/// <summary>
/// Returns true, if the given coordinates (line, column) are in the node.
/// </summary>
public bool IsInside(int line, int column)
{
return IsInside(new TextLocation (line, column));
}
/// <summary>
/// Gets the region from StartLocation to EndLocation for this node.
/// The file name of the region is set based on the parent CompilationUnit's file name.
/// If this node is not connected to a whole compilation, the file name will be null.
/// </summary>
public ICSharpCode.NRefactory.TypeSystem.DomRegion GetRegion()
{
var cu = (this.Ancestors.LastOrDefault() ?? this) as CompilationUnit;
string fileName = (cu != null ? cu.FileName : null);
return new ICSharpCode.NRefactory.TypeSystem.DomRegion(fileName, this.StartLocation, this.EndLocation);
}
public AstNode Parent {
get { return parent; }
}
@ -537,7 +565,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -537,7 +565,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
/// <summary>
/// Gets the node specified by T at location. This is useful for getting a specific node from the tree. For example searching
/// Gets the node specified by T at location. This is useful for getting a specific node from the tree. For example searching
/// the current method declaration.
/// </summary>
public T GetNodeAt<T> (TextLocation location) where T : AstNode
@ -579,7 +607,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -579,7 +607,7 @@ namespace ICSharpCode.NRefactory.CSharp
yield return node;
} else {
if (node.EndLocation <= start) {
next = node.NextSibling;
next = node.NextSibling;
} else {
next = node.FirstChild;
}

33
ICSharpCode.NRefactory.CSharp/Ast/AstNodeCollection.cs

@ -85,12 +85,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -85,12 +85,16 @@ namespace ICSharpCode.NRefactory.CSharp
if (nodes != null)
nodes = nodes.ToList();
Clear();
foreach (T node in nodes)
Add(node);
if (nodes != null) {
foreach (T node in nodes)
Add(node);
}
}
public void MoveTo(ICollection<T> targetCollection)
{
if (targetCollection == null)
throw new ArgumentNullException("targetCollection");
foreach (T node in this) {
node.Remove();
targetCollection.Add(node);
@ -124,6 +128,31 @@ namespace ICSharpCode.NRefactory.CSharp @@ -124,6 +128,31 @@ namespace ICSharpCode.NRefactory.CSharp
item.Remove();
}
/// <summary>
/// Returns the first element for which the predicate returns true,
/// or the null node (AstNode with IsNull=true) if no such object is found.
/// </summary>
public T FirstOrNullObject(Func<T, bool> predicate = null)
{
foreach (T item in this)
if (predicate == null || predicate(item))
return item;
return role.NullObject;
}
/// <summary>
/// Returns the last element for which the predicate returns true,
/// or the null node (AstNode with IsNull=true) if no such object is found.
/// </summary>
public T LastOrNullObject(Func<T, bool> predicate = null)
{
T result = role.NullObject;
foreach (T item in this)
if (predicate == null || predicate(item))
result = item;
return result;
}
bool ICollection<T>.IsReadOnly {
get { return false; }
}

60
ICSharpCode.NRefactory.CSharp/Ast/AstType.cs

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp
@ -47,6 +48,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -47,6 +48,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return other == null || other.IsNull;
}
public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode)
{
return SpecialType.UnknownType;
}
}
#endregion
@ -74,6 +80,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -74,6 +80,11 @@ namespace ICSharpCode.NRefactory.CSharp
return visitor.VisitPatternPlaceholder(this, child, data);
}
public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode)
{
throw new NotSupportedException();
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
@ -95,6 +106,18 @@ namespace ICSharpCode.NRefactory.CSharp @@ -95,6 +106,18 @@ namespace ICSharpCode.NRefactory.CSharp
return (AstType)base.Clone();
}
/// <summary>
/// Create an ITypeReference for this AstType.
/// </summary>
/// <remarks>
/// The resulting type reference will read the context information from the
/// <see cref="ITypeResolveContext"/>:
/// For resolving type parameters, the CurrentTypeDefinition/CurrentMember is used.
/// For resolving simple names, the current namespace and usings from the CurrentUsingScope
/// (on CSharpTypeResolveContext only) is used.
/// </remarks>
public abstract ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type);
/// <summary>
/// Creates a pointer type from this type by nesting it in a <see cref="ComposedType"/>.
/// If this type already is a pointer type, this method just increases the PointerRank of the existing pointer type.
@ -153,42 +176,5 @@ namespace ICSharpCode.NRefactory.CSharp @@ -153,42 +176,5 @@ namespace ICSharpCode.NRefactory.CSharp
{
return new TypeReferenceExpression { Type = this }.Invoke(methodName, typeArguments, arguments);
}
public static AstType Create(Type type)
{
switch (Type.GetTypeCode(type)) {
case TypeCode.Object:
return new PrimitiveType("object");
case TypeCode.Boolean:
return new PrimitiveType("bool");
case TypeCode.Char:
return new PrimitiveType("char");
case TypeCode.SByte:
return new PrimitiveType("sbyte");
case TypeCode.Byte:
return new PrimitiveType("byte");
case TypeCode.Int16:
return new PrimitiveType("short");
case TypeCode.UInt16:
return new PrimitiveType("ushort");
case TypeCode.Int32:
return new PrimitiveType("int");
case TypeCode.UInt32:
return new PrimitiveType("uint");
case TypeCode.Int64:
return new PrimitiveType("long");
case TypeCode.UInt64:
return new PrimitiveType("ulong");
case TypeCode.Single:
return new PrimitiveType("float");
case TypeCode.Double:
return new PrimitiveType("double");
case TypeCode.Decimal:
return new PrimitiveType("decimal");
case TypeCode.String:
return new PrimitiveType("string");
}
return new SimpleType(type.FullName); // TODO: implement this correctly
}
}
}

17
ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs

@ -27,6 +27,7 @@ using System; @@ -27,6 +27,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp
{
@ -114,6 +115,22 @@ namespace ICSharpCode.NRefactory.CSharp @@ -114,6 +115,22 @@ namespace ICSharpCode.NRefactory.CSharp
InsertChildBefore(this.ArraySpecifiers.FirstOrDefault(), new ArraySpecifier(dimensions), ArraySpecifierRole);
return this;
}
public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type)
{
ITypeReference t = this.BaseType.ToTypeReference(lookupMode);
if (this.HasNullableSpecifier) {
t = NullableType.Create(t);
}
int pointerRank = this.PointerRank;
for (int i = 0; i < pointerRank; i++) {
t = new PointerTypeReference(t);
}
foreach (var a in this.ArraySpecifiers.Reverse()) {
t = new ArrayTypeReference(t, a.Dimensions);
}
return t;
}
}
/// <summary>

34
ICSharpCode.NRefactory.CSharp/Ast/Expressions/AssignmentExpression.cs

@ -117,6 +117,40 @@ namespace ICSharpCode.NRefactory.CSharp @@ -117,6 +117,40 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
/// <summary>
/// Gets the binary operator for the specified compound assignment operator.
/// Returns null if 'op' is not a compound assignment.
/// </summary>
public static BinaryOperatorType? GetCorrespondingBinaryOperator(AssignmentOperatorType op)
{
switch (op) {
case AssignmentOperatorType.Assign:
return null;
case AssignmentOperatorType.Add:
return BinaryOperatorType.Add;
case AssignmentOperatorType.Subtract:
return BinaryOperatorType.Subtract;
case AssignmentOperatorType.Multiply:
return BinaryOperatorType.Multiply;
case AssignmentOperatorType.Divide:
return BinaryOperatorType.Divide;
case AssignmentOperatorType.Modulus:
return BinaryOperatorType.Modulus;
case AssignmentOperatorType.ShiftLeft:
return BinaryOperatorType.ShiftLeft;
case AssignmentOperatorType.ShiftRight:
return BinaryOperatorType.ShiftRight;
case AssignmentOperatorType.BitwiseAnd:
return BinaryOperatorType.BitwiseAnd;
case AssignmentOperatorType.BitwiseOr:
return BinaryOperatorType.BitwiseOr;
case AssignmentOperatorType.ExclusiveOr:
return BinaryOperatorType.ExclusiveOr;
default:
throw new NotSupportedException("Invalid value for AssignmentOperatorType");
}
}
public static ExpressionType GetLinqNodeType(AssignmentOperatorType op, bool checkForOverflow)
{
switch (op) {

15
ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs

@ -202,30 +202,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -202,30 +202,15 @@ namespace ICSharpCode.NRefactory.CSharp
return new CastExpression { Type = type, Expression = this };
}
public CastExpression CastTo(Type type)
{
return new CastExpression { Type = AstType.Create(type), Expression = this };
}
public AsExpression CastAs(AstType type)
{
return new AsExpression { Type = type, Expression = this };
}
public AsExpression CastAs(Type type)
{
return new AsExpression { Type = AstType.Create(type), Expression = this };
}
public IsExpression IsType(AstType type)
{
return new IsExpression { Type = type, Expression = this };
}
public IsExpression IsType(Type type)
{
return new IsExpression { Type = AstType.Create(type), Expression = this };
}
#endregion
}
}

23
ICSharpCode.NRefactory.CSharp/Ast/Expressions/ParenthesizedExpression.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
//
// ParenthesizedExpression.cs
//
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@ -63,5 +63,26 @@ namespace ICSharpCode.NRefactory.CSharp @@ -63,5 +63,26 @@ namespace ICSharpCode.NRefactory.CSharp
ParenthesizedExpression o = other as ParenthesizedExpression;
return o != null && this.Expression.DoMatch(o.Expression, match);
}
/// <summary>
/// Gets whether the expression acts like a parenthesized expression,
/// i.e. whether information about the expected type (for lambda type inference) flows
/// into the inner expression.
/// </summary>
/// <returns>Returns true for ParenthesizedExpression, CheckedExpression or UncheckedExpression; false otherwise.</returns>
public static bool ActsAsParenthesizedExpression(AstNode expression)
{
return expression is ParenthesizedExpression || expression is CheckedExpression || expression is UncheckedExpression;
}
/// <summary>
/// Unpacks the given expression if it is a ParenthesizedExpression, CheckedExpression or UncheckedExpression.
/// </summary>
public static Expression UnpackParenthesizedExpression(Expression expr)
{
while (ActsAsParenthesizedExpression(expr))
expr = expr.GetChildByRole(ParenthesizedExpression.Roles.Expression);
return expr;
}
}
}

24
ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs

@ -28,6 +28,8 @@ using System; @@ -28,6 +28,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp
{
@ -114,6 +116,28 @@ namespace ICSharpCode.NRefactory.CSharp @@ -114,6 +116,28 @@ namespace ICSharpCode.NRefactory.CSharp
}
return b.ToString();
}
public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type)
{
TypeOrNamespaceReference t;
if (this.IsDoubleColon) {
SimpleType st = this.Target as SimpleType;
if (st != null) {
t = new AliasNamespaceReference(st.Identifier);
} else {
t = null;
}
} else {
t = this.Target.ToTypeReference(lookupMode) as TypeOrNamespaceReference;
}
if (t == null)
return SpecialType.UnknownType;
var typeArguments = new List<ITypeReference>();
foreach (var ta in this.TypeArguments) {
typeArguments.Add(ta.ToTypeReference(lookupMode));
}
return new MemberTypeOrNamespaceReference(t, this.MemberName, typeArguments);
}
}
}

56
ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs

@ -26,6 +26,9 @@ @@ -26,6 +26,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.NRefactory.CSharp
{
@ -34,6 +37,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -34,6 +37,10 @@ namespace ICSharpCode.NRefactory.CSharp
public string Keyword { get; set; }
public TextLocation Location { get; set; }
public KnownTypeCode KnownTypeCode {
get { return GetTypeCodeForPrimitiveType(this.Keyword); }
}
public PrimitiveType()
{
}
@ -83,6 +90,55 @@ namespace ICSharpCode.NRefactory.CSharp @@ -83,6 +90,55 @@ namespace ICSharpCode.NRefactory.CSharp
{
return Keyword ?? base.ToString();
}
public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type)
{
KnownTypeCode typeCode = GetTypeCodeForPrimitiveType(this.Keyword);
if (typeCode == KnownTypeCode.None)
return new UnknownType(null, this.Keyword);
else
return KnownTypeReference.Get(typeCode);
}
public static KnownTypeCode GetTypeCodeForPrimitiveType(string keyword)
{
switch (keyword) {
case "string":
return KnownTypeCode.String;
case "int":
return KnownTypeCode.Int32;
case "uint":
return KnownTypeCode.UInt32;
case "object":
return KnownTypeCode.Object;
case "bool":
return KnownTypeCode.Boolean;
case "sbyte":
return KnownTypeCode.SByte;
case "byte":
return KnownTypeCode.Byte;
case "short":
return KnownTypeCode.Int16;
case "ushort":
return KnownTypeCode.UInt16;
case "long":
return KnownTypeCode.Int64;
case "ulong":
return KnownTypeCode.UInt64;
case "float":
return KnownTypeCode.Single;
case "double":
return KnownTypeCode.Double;
case "decimal":
return KnownTypeCode.Decimal;
case "char":
return KnownTypeCode.Char;
case "void":
return KnownTypeCode.Void;
default:
return KnownTypeCode.None;
}
}
}
}

21
ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs

@ -28,6 +28,9 @@ using System; @@ -28,6 +28,9 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp
{
@ -53,6 +56,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,6 +56,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return other == null || other.IsNull;
}
public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode)
{
return SpecialType.UnknownType;
}
}
#endregion
@ -130,6 +138,19 @@ namespace ICSharpCode.NRefactory.CSharp @@ -130,6 +138,19 @@ namespace ICSharpCode.NRefactory.CSharp
}
return b.ToString();
}
public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type)
{
var typeArguments = new List<ITypeReference>();
foreach (var ta in this.TypeArguments) {
typeArguments.Add(ta.ToTypeReference(lookupMode));
}
if (typeArguments.Count == 0 && string.IsNullOrEmpty(this.Identifier)) {
// empty SimpleType is used for typeof(List<>).
return SpecialType.UnboundTypeArgument;
}
return new SimpleTypeOrNamespaceReference(this.Identifier, typeArguments, lookupMode);
}
}
}

1
ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/AttributedNode.cs

@ -25,6 +25,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -25,6 +25,7 @@ namespace ICSharpCode.NRefactory.CSharp
public abstract class AttributedNode : AstNode
{
public static readonly Role<AttributeSection> AttributeRole = new Role<AttributeSection>("Attribute");
public static readonly Role<AttributeSection> UnattachedAttributeRole = new Role<AttributeSection>("UnattachedAttribute");
public static readonly Role<CSharpModifierToken> ModifierRole = new Role<CSharpModifierToken>("Modifier");
public AstNodeCollection<AttributeSection> Attributes {

4
ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ConstructorDeclaration.cs

@ -57,6 +57,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,6 +57,10 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public CSharpTokenNode ColonToken {
get { return GetChildByRole (Roles.Colon); }
}
public ConstructorInitializer Initializer {
get { return GetChildByRole (InitializerRole); }
set { SetChildByRole( InitializerRole, value); }

19
ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs

@ -87,7 +87,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -87,7 +87,7 @@ namespace ICSharpCode.NRefactory.CSharp
return null;
}
public ICompilation CreateCompilation()
public virtual ICompilation CreateCompilation()
{
var solutionSnapshot = new DefaultSolutionSnapshot();
ICompilation compilation = new SimpleCompilation(solutionSnapshot, this, assemblyReferences);
@ -95,28 +95,33 @@ namespace ICSharpCode.NRefactory.CSharp @@ -95,28 +95,33 @@ namespace ICSharpCode.NRefactory.CSharp
return compilation;
}
public ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot)
public virtual ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot)
{
return new SimpleCompilation(solutionSnapshot, this, assemblyReferences);
}
protected virtual CSharpProjectContent Clone()
{
return new CSharpProjectContent(this);
}
public IProjectContent SetAssemblyName(string newAssemblyName)
{
CSharpProjectContent pc = new CSharpProjectContent(this);
CSharpProjectContent pc = Clone();
pc.assemblyName = newAssemblyName;
return pc;
}
public IProjectContent AddAssemblyReferences(IEnumerable<IAssemblyReference> references)
{
CSharpProjectContent pc = new CSharpProjectContent(this);
CSharpProjectContent pc = Clone();
pc.assemblyReferences.AddRange(references);
return pc;
}
public IProjectContent RemoveAssemblyReferences(IEnumerable<IAssemblyReference> references)
{
CSharpProjectContent pc = new CSharpProjectContent(this);
CSharpProjectContent pc = Clone();
pc.assemblyReferences.RemoveAll(r => references.Contains(r));
return pc;
}
@ -129,7 +134,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -129,7 +134,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (!Platform.FileNameComparer.Equals(oldFile.FileName, newFile.FileName))
throw new ArgumentException("When both oldFile and newFile are specified, they must use the same file name.");
}
CSharpProjectContent pc = new CSharpProjectContent(this);
CSharpProjectContent pc = Clone();
if (newFile == null)
pc.parsedFiles.Remove(oldFile.FileName);
else
@ -139,7 +144,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -139,7 +144,7 @@ namespace ICSharpCode.NRefactory.CSharp
public IProjectContent UpdateProjectContent(IEnumerable<IParsedFile> oldFiles, IEnumerable<IParsedFile> newFiles)
{
CSharpProjectContent pc = new CSharpProjectContent(this);
CSharpProjectContent pc = Clone();
if (oldFiles != null) {
foreach (var oldFile in oldFiles) {
pc.parsedFiles.Remove(oldFile.FileName);

636
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs

File diff suppressed because it is too large Load Diff

315
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// CSharpCompletionEngineBase.cs
//
// Author:
@ -23,7 +23,6 @@ @@ -23,7 +23,6 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
@ -50,15 +49,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -50,15 +49,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
protected IUnresolvedMember currentMember;
#region Input properties
public CSharpTypeResolveContext ctx { get; set; }
public CSharpTypeResolveContext ctx { get; private set; }
public CompilationUnit Unit { get; set; }
public CompilationUnit Unit { get; private set; }
public CSharpParsedFile CSharpParsedFile { get; set; }
public CSharpParsedFile CSharpParsedFile { get; private set; }
public IProjectContent ProjectContent { get; set; }
public IProjectContent ProjectContent { get; private set; }
ICompilation compilation;
protected ICompilation Compilation {
get {
if (compilation == null)
@ -66,27 +66,39 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -66,27 +66,39 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
return compilation;
}
}
#endregion
protected CSharpCompletionEngineBase (IProjectContent content, CSharpTypeResolveContext ctx, CompilationUnit unit, CSharpParsedFile parsedFile)
{
if (content == null)
throw new ArgumentNullException ("content");
if (ctx == null)
throw new ArgumentNullException ("ctx");
if (unit == null)
throw new ArgumentNullException ("unit");
if (parsedFile == null)
throw new ArgumentNullException ("parsedFile");
this.ProjectContent = content;
this.ctx = ctx;
this.Unit = unit;
this.CSharpParsedFile = parsedFile;
}
public IMemberProvider MemberProvider {
get;
set;
}
protected void SetOffset (int offset)
{
Reset ();
this.offset = offset;
this.location = document.GetLocation (offset);
this.currentType = CSharpParsedFile.GetInnermostTypeDefinition (location);
this.currentMember = null;
if (this.currentType != null) {
foreach (var member in currentType.Members) {
if (member.Region.Begin < location && (currentMember == null || currentMember.Region.Begin < member.Region.Begin))
currentMember = member;
}
}
var stack = GetBracketStack (GetMemberTextToCaret ().Item1);
if (stack.Count == 0)
currentMember = null;
var provider = MemberProvider ?? new DefaultMemberProvider (this);
provider.GetCurrentMembers (offset, out currentType, out currentMember);
}
#region Context helper methods
@ -180,55 +192,113 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -180,55 +192,113 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
var expr = Unit.GetNodeAt<PrimitiveExpression> (loc.Line, loc.Column);
return expr != null && expr.Value is string;
}
#endregion
protected CSharpResolver GetState ()
{
return new CSharpResolver (ctx);
/*var state = new CSharpResolver (ctx);
state.CurrentMember = currentMember;
state.CurrentTypeDefinition = currentType;
state.CurrentUsingScope = CSharpParsedFile.GetUsingScope (location);
if (state.CurrentMember != null) {
var node = Unit.GetNodeAt (location);
if (node == null)
return state;
var navigator = new NodeListResolveVisitorNavigator (new[] { node });
var visitor = new ResolveVisitor (state, CSharpParsedFile, navigator);
Unit.AcceptVisitor (visitor, null);
try {
var newState = visitor.GetResolverStateBefore (node);
if (newState != null)
state = newState;
} catch (Exception) {
}
}
return state;*/
}
#endregion
#region Basic parsing/resolving functions
Stack<Tuple<char, int>> GetBracketStack (string memberText)
{
var bracketStack = new Stack<Tuple<char, int>> ();
bool isInString = false, isInChar = false;
bool isInLineComment = false, isInBlockComment = false;
bool inSingleComment = false, inString = false, inVerbatimString = false, inChar = false, inMultiLineComment = false;
for (int pos = 0; pos < memberText.Length; pos++) {
char ch = memberText [pos];
for (int i = 0; i < memberText.Length; i++) {
char ch = memberText [i];
char nextCh = i + 1 < memberText.Length ? memberText [i + 1] : '\0';
switch (ch) {
case '(':
case '[':
case '{':
if (!isInString && !isInChar && !isInLineComment && !isInBlockComment)
bracketStack.Push (Tuple.Create (ch, pos));
if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment)
break;
bracketStack.Push (Tuple.Create (ch, i));
break;
case ')':
case ']':
case '}':
if (!isInString && !isInChar && !isInLineComment && !isInBlockComment)
if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment)
break;
if (bracketStack.Count > 0)
bracketStack.Pop ();
break;
case '\r':
case '\n':
isInLineComment = false;
break;
case '/':
if (isInBlockComment) {
if (pos > 0 && memberText [pos - 1] == '*')
isInBlockComment = false;
} else if (!isInString && !isInChar && pos + 1 < memberText.Length) {
char nextChar = memberText [pos + 1];
if (nextChar == '/')
isInLineComment = true;
if (!isInLineComment && nextChar == '*')
isInBlockComment = true;
if (inString || inChar || inVerbatimString)
break;
if (nextCh == '/') {
i++;
inSingleComment = true;
}
if (nextCh == '*')
inMultiLineComment = true;
break;
case '*':
if (inString || inChar || inVerbatimString || inSingleComment)
break;
if (nextCh == '/') {
i++;
inMultiLineComment = false;
}
break;
case '@':
if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment)
break;
if (nextCh == '"') {
i++;
inVerbatimString = true;
}
break;
case '\n':
case '\r':
inSingleComment = false;
inString = false;
inChar = false;
break;
case '\\':
if (inString || inChar)
i++;
break;
case '"':
if (!(isInChar || isInLineComment || isInBlockComment))
isInString = !isInString;
if (inSingleComment || inMultiLineComment || inChar)
break;
if (inVerbatimString) {
if (nextCh == '"') {
i++;
break;
}
inVerbatimString = false;
break;
}
inString = !inString;
break;
case '\'':
if (!(isInString || isInLineComment || isInBlockComment))
isInChar = !isInChar;
if (inSingleComment || inMultiLineComment || inString || inVerbatimString)
break;
inChar = !inChar;
break;
default :
break;
@ -293,7 +363,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -293,7 +363,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
}
}
protected CompilationUnit ParseStub (string continuation, bool appendSemicolon = true)
protected CompilationUnit ParseStub (string continuation, bool appendSemicolon = true, string afterContinuation = null)
{
var mt = GetMemberTextToCaret ();
if (mt == null)
@ -318,23 +388,25 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -318,23 +388,25 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
wrapper.Append (memberText);
wrapper.Append (continuation);
AppendMissingClosingBrackets (wrapper, memberText, appendSemicolon);
wrapper.Append (afterContinuation);
if (wrapInClass)
wrapper.Append ('}');
TextLocation memberLocation;
if (currentMember != null && currentType.Kind != TypeKind.Enum) {
if (currentMember != null && currentType != null && currentType.Kind != TypeKind.Enum) {
memberLocation = currentMember.Region.Begin;
} else if (currentType != null) {
memberLocation = currentType.Region.Begin;
} else {
memberLocation = new TextLocation (1, 1);
}
using (var stream = new System.IO.StringReader (wrapper.ToString ())) {
try {
var parser = new CSharpParser ();
return parser.Parse (stream, "stub.cs" , wrapInClass ? memberLocation.Line - 2 : 0);
} catch (Exception){
return parser.Parse (stream, "stub.cs", wrapInClass ? memberLocation.Line - 2 : 0);
} catch (Exception) {
Console.WriteLine ("------");
Console.WriteLine (wrapper);
throw;
@ -352,7 +424,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -352,7 +424,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
protected Tuple<string, bool> GetMemberTextToCaret ()
{
int startOffset;
if (currentMember != null && currentType.Kind != TypeKind.Enum) {
if (currentMember != null && currentType != null && currentType.Kind != TypeKind.Enum) {
startOffset = document.GetOffset (currentMember.Region.BeginLine, currentMember.Region.BeginColumn);
} else if (currentType != null) {
startOffset = document.GetOffset (currentType.Region.BeginLine, currentType.Region.BeginColumn);
@ -386,7 +458,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -386,7 +458,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
return Tuple.Create (CSharpParsedFile, (AstNode)attr, Unit);
}
}
if (currentMember == null && currentType == null) {
return null;
}
@ -394,13 +465,21 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -394,13 +465,21 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin;
var mref = baseUnit.GetNodeAt (location.Line, location.Column - 1, n => n is InvocationExpression || n is ObjectCreateExpression);
AstNode expr;
AstNode expr = null;
if (mref is InvocationExpression) {
expr = ((InvocationExpression)mref).Target;
} else if (mref is ObjectCreateExpression) {
expr = mref;
} else {
return null;
baseUnit = ParseStub (")};", false);
mref = baseUnit.GetNodeAt (location.Line, location.Column - 1, n => n is InvocationExpression || n is ObjectCreateExpression);
if (mref is InvocationExpression) {
expr = ((InvocationExpression)mref).Target;
} else if (mref is ObjectCreateExpression) {
expr = mref;
}
if (expr == null)
return null;
}
var member = Unit.GetNodeAt<AttributedNode> (memberLocation);
var member2 = baseUnit.GetNodeAt<AttributedNode> (memberLocation);
@ -426,14 +505,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -426,14 +505,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
// var newContent = ProjectContent.UpdateProjectContent (CSharpParsedFile, file);
var csResolver = new CSharpResolver (ctx);
var navigator = new NodeListResolveVisitorNavigator (new[] { resolveNode });
var visitor = new ResolveVisitor (csResolver, CSharpParsedFile, navigator);
var csResolver = new CSharpAstResolver(new CSharpResolver (ctx), unit, CSharpParsedFile);
visitor.Scan (unit);
var state = visitor.GetResolverStateBefore (resolveNode);
var result = visitor.GetResolveResult (resolveNode);
var result = csResolver.Resolve (resolveNode);
var state = csResolver.GetResolverStateBefore (resolveNode);
return Tuple.Create (result, state);
}
@ -444,5 +519,127 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -444,5 +519,127 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
}
#endregion
class DefaultMemberProvider : IMemberProvider
{
CSharpCompletionEngineBase engine;
public DefaultMemberProvider (CSharpCompletionEngineBase engine)
{
this.engine = engine;
}
public void GetCurrentMembers (int offset, out IUnresolvedTypeDefinition currentType, out IUnresolvedMember currentMember)
{
var document = engine.document;
var location = engine.location;
currentType = null;
foreach (var type in engine.CSharpParsedFile.TopLevelTypeDefinitions) {
if (type.Region.Begin < location)
currentType = type;
}
currentType = FindInnerType (currentType, location);
// location is beyond last reported end region, now we need to check, if the end region changed
if (currentType != null && currentType.Region.End < location) {
if (!IsInsideType (currentType, location))
currentType = null;
}
currentMember = null;
if (currentType != null) {
foreach (var member in currentType.Members) {
if (member.Region.Begin < location && (currentMember == null || currentMember.Region.Begin < member.Region.Begin))
currentMember = member;
}
}
// location is beyond last reported end region, now we need to check, if the end region changed
// NOTE: Enums are a special case, there the "last" field needs to be treated as current member
if (currentMember != null && currentMember.Region.End < location && currentType.Kind != TypeKind.Enum) {
if (!IsInsideType (currentMember, location))
currentMember = null;
}
var stack = engine.GetBracketStack (engine.GetMemberTextToCaret ().Item1);
if (stack.Count == 0)
currentMember = null;
}
IUnresolvedTypeDefinition FindInnerType (IUnresolvedTypeDefinition parent, TextLocation location)
{
if (parent == null)
return null;
var currentType = parent;
foreach (var type in parent.NestedTypes) {
if (type.Region.Begin < location && location < type.Region.End)
currentType = FindInnerType (type, location);
}
return currentType;
}
bool IsInsideType (IUnresolvedEntity currentType, TextLocation location)
{
var document = engine.document;
int startOffset = document.GetOffset (currentType.Region.Begin);
int endOffset = document.GetOffset (location);
bool foundEndBracket = false;
var bracketStack = new Stack<char> ();
bool isInString = false, isInChar = false;
bool isInLineComment = false, isInBlockComment = false;
for (int i = startOffset; i < endOffset; i++) {
char ch = document.GetCharAt (i);
switch (ch) {
case '(':
case '[':
case '{':
if (!isInString && !isInChar && !isInLineComment && !isInBlockComment)
bracketStack.Push (ch);
break;
case ')':
case ']':
case '}':
if (!isInString && !isInChar && !isInLineComment && !isInBlockComment)
if (bracketStack.Count > 0)
bracketStack.Pop ();
break;
case '\r':
case '\n':
isInLineComment = false;
break;
case '/':
if (isInBlockComment) {
if (i > 0 && document.GetCharAt (i - 1) == '*')
isInBlockComment = false;
} else if (!isInString && !isInChar && i + 1 < document.TextLength) {
char nextChar = document.GetCharAt (i + 1);
if (nextChar == '/')
isInLineComment = true;
if (!isInLineComment && nextChar == '*')
isInBlockComment = true;
}
break;
case '"':
if (!(isInChar || isInLineComment || isInBlockComment))
isInString = !isInString;
break;
case '\'':
if (!(isInString || isInLineComment || isInBlockComment))
isInChar = !isInChar;
break;
default :
break;
}
}
return bracketStack.Any (t => t == '{');
}
}
}
}

97
ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs

@ -38,8 +38,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -38,8 +38,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
{
internal IParameterCompletionDataFactory factory;
public CSharpParameterCompletionEngine (IDocument document, IParameterCompletionDataFactory factory)
public CSharpParameterCompletionEngine (IDocument document, IParameterCompletionDataFactory factory, IProjectContent content, CSharpTypeResolveContext ctx, CompilationUnit unit, CSharpParsedFile parsedFile) : base (content, ctx, unit, parsedFile)
{
if (document == null)
throw new ArgumentNullException ("document");
if (factory == null)
throw new ArgumentNullException ("factory");
this.document = document;
this.factory = factory;
}
@ -49,11 +53,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -49,11 +53,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
CompilationUnit baseUnit;
if (currentMember == null && currentType == null)
return null;
if (Unit == null)
return null;
baseUnit = ParseStub ("x] = a[1");
var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin;
var mref = baseUnit.GetNodeAt (location, n => n is IndexerExpression);
Print (baseUnit);
AstNode expr;
if (mref is IndexerExpression) {
expr = ((IndexerExpression)mref).Target;
@ -63,6 +68,30 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -63,6 +68,30 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
var member = Unit.GetNodeAt<AttributedNode> (memberLocation);
var member2 = baseUnit.GetNodeAt<AttributedNode> (memberLocation);
if (member == null || member2 == null)
return null;
member2.Remove ();
member.ReplaceWith (member2);
var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName);
Unit.AcceptVisitor (tsvisitor, null);
return Tuple.Create (tsvisitor.ParsedFile, (AstNode)expr, Unit);
}
public Tuple<CSharpParsedFile, AstNode, CompilationUnit> GetTypeBeforeCursor ()
{
CompilationUnit baseUnit;
if (currentMember == null && currentType == null)
return null;
if (Unit == null)
return null;
baseUnit = ParseStub ("x> a");
var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin;
var expr = baseUnit.GetNodeAt<AstType> (location.Line, location.Column + 1); // '>' position
var member = Unit.GetNodeAt<AttributedNode> (memberLocation);
var member2 = baseUnit.GetNodeAt<AttributedNode> (memberLocation);
if (member == null || member2 == null)
return null;
member2.Remove ();
member.ReplaceWith (member2);
var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName);
@ -81,13 +110,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -81,13 +110,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (IsInsideCommentOrString ())
return null;
var invoke = GetInvocationBeforeCursor (true) ?? GetIndexerBeforeCursor ();
if (invoke == null)
return null;
ResolveResult resolveResult;
switch (completionChar) {
case '(':
var invoke = GetInvocationBeforeCursor (true) ?? GetIndexerBeforeCursor ();
if (invoke == null)
return null;
if (invoke.Item2 is ObjectCreateExpression) {
var createType = ResolveExpression (invoke.Item1, ((ObjectCreateExpression)invoke.Item2).Type, invoke.Item3);
return factory.CreateConstructorProvider (createType.Item1.Type);
@ -127,6 +156,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -127,6 +156,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
// }
break;
case ',':
invoke = GetInvocationBeforeCursor (true) ?? GetIndexerBeforeCursor ();
if (invoke == null) {
invoke = GetTypeBeforeCursor ();
if (invoke !=null) {
var typeExpression = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3);
if (typeExpression == null || typeExpression.Item1 == null || typeExpression.Item1.IsError)
return null;
return factory.CreateTypeParameterDataProvider (CollectAllTypes (typeExpression.Item1.Type));
}
return null;
}
if (invoke.Item2 is ObjectCreateExpression) {
var createType = ResolveExpression (invoke.Item1, ((ObjectCreateExpression)invoke.Item2).Type, invoke.Item3);
return factory.CreateConstructorProvider (createType.Item1.Type);
@ -157,12 +198,19 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -157,12 +198,19 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (resolveResult != null)
return factory.CreateIndexerParameterDataProvider (resolveResult.Type, invoke.Item2);
break;
// case '<':
// if (string.IsNullOrEmpty (result.Expression))
// return null;
// return new NRefactoryTemplateParameterDataProvider (textEditorData, resolver, GetUsedNamespaces (), result, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset));
case '<':
invoke = GetTypeBeforeCursor ();
if (invoke == null)
return null;
var tExpr = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3);
if (tExpr == null || tExpr.Item1 == null || tExpr.Item1.IsError)
return null;
return factory.CreateTypeParameterDataProvider (CollectAllTypes (tExpr.Item1.Type));
case '[':
invoke = GetIndexerBeforeCursor ();
if (invoke == null)
return null;
var indexerExpression = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3);
if (indexerExpression == null || indexerExpression.Item1 == null || indexerExpression.Item1.IsError)
return null;
@ -171,6 +219,24 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -171,6 +219,24 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
return null;
}
IEnumerable<IType> CollectAllTypes (IType baseType)
{
var state = GetState ();
for (var n = state.CurrentUsingScope; n != null; n = n.Parent) {
foreach (var u in n.Usings) {
foreach (var type in u.Types) {
if (type.TypeParameterCount > 0 && type.Name == baseType.Name)
yield return type;
}
}
foreach (var type in n.Namespace.Types) {
if (type.TypeParameterCount > 0 && type.Name == baseType.Name)
yield return type;
}
}
}
List<string> GetUsedNamespaces ()
{
var scope = CSharpParsedFile.GetUsingScope (location);
@ -194,7 +260,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -194,7 +260,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
{
SetOffset (triggerOffset);
var text = GetMemberTextToCaret ();
if (text.Item1.EndsWith ("("))
if (text.Item1.EndsWith ("(") || text.Item1.EndsWith ("<"))
return 0;
var parameter = new Stack<int> ();
@ -216,6 +282,17 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -216,6 +282,17 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (parameter.Count > 0)
parameter.Pop ();
break;
case '<':
if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment)
break;
parameter.Push (0);
break;
case '>':
if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment)
break;
if (parameter.Count > 0)
parameter.Pop ();
break;
case ',':
if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment)
break;

20
ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs

@ -27,6 +27,7 @@ using System; @@ -27,6 +27,7 @@ using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.Completion;
using ICSharpCode.NRefactory.TypeSystem;
using System.Linq;
namespace ICSharpCode.NRefactory.CSharp.Completion
{
@ -203,31 +204,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -203,31 +204,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
{
this.Type = type;
}
public override int CompareTo (CompletionCategory other)
{
var compareCategory = other as TypeCompletionCategory;
if (compareCategory == null)
return 1;
return -1;
if (Type.ReflectionName == compareCategory.Type.ReflectionName)
return 0;
// System.Object is always the smallest
if (Type.ReflectionName == "System.Object")
if (Type.GetAllBaseTypes ().Any (t => t.ReflectionName == compareCategory.Type.ReflectionName))
return -1;
if (compareCategory.Type.ReflectionName == "System.Object")
return 1;
/* if (Type.GetProjectContent () != null) {
if (Type.GetProjectContent ().GetInheritanceTree (Type).Any (t => t != null && t.DecoratedFullName == compareCategory.Type.DecoratedFullName))
return 1;
return -1;
}
// source project dom == null - try to make the opposite comparison
if (compareCategory.Type.GetProjectContent () != null && compareCategory.Type.GetProjectContent ().GetInheritanceTree (Type).Any (t => t != null && t.DecoratedFullName == Type.DecoratedFullName))
return -1;*/
return 1;
}
}

1
ICSharpCode.NRefactory.CSharp/Completion/ICompletionDataFactory.cs

@ -63,6 +63,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -63,6 +63,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
ICompletionData CreateEventCreationCompletionData (string varName, IType delegateType, IEvent evt, string parameterDefinition, IUnresolvedMember currentMember, IUnresolvedTypeDefinition currentType);
ICompletionData CreateNewOverrideCompletionData (int declarationBegin, IUnresolvedTypeDefinition type, IMember m);
ICompletionData CreateNewPartialCompletionData (int declarationBegin, IUnresolvedTypeDefinition type, IUnresolvedMember m);
IEnumerable<ICompletionData> CreateCodeTemplateCompletionData ();

40
ICSharpCode.NRefactory.CSharp/Completion/IMemberProvider.cs

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
//
// IMemberProvider.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using System.Linq;
namespace ICSharpCode.NRefactory.CSharp.Completion
{
public interface IMemberProvider
{
void GetCurrentMembers (int offset, out IUnresolvedTypeDefinition currentType, out IUnresolvedMember currentMember);
}
}

3
ICSharpCode.NRefactory.CSharp/Completion/IParameterCompletionDataFactory.cs

@ -27,6 +27,7 @@ using System; @@ -27,6 +27,7 @@ using System;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.Completion;
using ICSharpCode.NRefactory.CSharp.Resolver;
using System.Collections.Generic;
namespace ICSharpCode.NRefactory.CSharp.Completion
{
@ -41,6 +42,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -41,6 +42,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
IParameterDataProvider CreateDelegateDataProvider (IType type);
IParameterDataProvider CreateIndexerParameterDataProvider (IType type, AstNode resolvedNode);
IParameterDataProvider CreateTypeParameterDataProvider (IEnumerable<IType> types);
}
}

9
ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs

@ -873,7 +873,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -873,7 +873,8 @@ namespace ICSharpCode.NRefactory.CSharp
nextStatementIndent = " ";
}
}
if (!(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement ||
if (policy.IndentBlocks &&
!(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement ||
policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement))
curIndent.Level++;
object result = isBlock ? base.VisitBlockStatement ((BlockStatement)node, null) : node.AcceptVisitor (this, null);
@ -1158,6 +1159,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1158,6 +1159,12 @@ namespace ICSharpCode.NRefactory.CSharp
curIndent.Level++;
foreach (var stmt in switchSection.Statements) {
if (stmt is BreakStatement && !policy.IndentBreakStatements && policy.IndentCaseBody) {
curIndent.Level--;
stmt.AcceptVisitor (this, null);
curIndent.Level++;
continue;
}
stmt.AcceptVisitor (this, null);
}
if (policy.IndentCaseBody)

18
ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{53DCA265-3C3C-42F9-B647-F72BA678122B}</ProjectGuid>
@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.NRefactory.CSharp</RootNamespace>
<AssemblyName>ICSharpCode.NRefactory.CSharp</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
@ -18,6 +19,8 @@ @@ -18,6 +19,8 @@
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<DocumentationFile>..\ICSharpCode.NRefactory\bin\$(Configuration)\ICSharpCode.NRefactory.CSharp.xml</DocumentationFile>
<NoWarn>1591,1587,1570</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -37,7 +40,7 @@ @@ -37,7 +40,7 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\ICSharpCode.NRefactory\bin\Release\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<DebugType>PdbOnly</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE;FULL_AST</DefineConstants>
@ -55,6 +58,7 @@ @@ -55,6 +58,7 @@
<ItemGroup>
<Compile Include="Analysis\ControlFlow.cs" />
<Compile Include="Analysis\DefiniteAssignmentAnalysis.cs" />
<Compile Include="Analysis\ReachabilityAnalysis.cs" />
<Compile Include="Ast\AstNode.cs" />
<Compile Include="Ast\AstNodeCollection.cs" />
<Compile Include="Ast\AstType.cs" />
@ -195,7 +199,6 @@ @@ -195,7 +199,6 @@
<Compile Include="Parser\mcs\cs-tokenizer.cs" />
<Compile Include="Parser\mcs\decl.cs" />
<Compile Include="Parser\mcs\delegate.cs" />
<Compile Include="Parser\mcs\doc-bootstrap.cs" />
<Compile Include="Parser\mcs\doc.cs" />
<Compile Include="Parser\mcs\driver.cs" />
<Compile Include="Parser\mcs\dynamic.cs" />
@ -206,7 +209,6 @@ @@ -206,7 +209,6 @@
<Compile Include="Parser\mcs\field.cs" />
<Compile Include="Parser\mcs\flowanalysis.cs" />
<Compile Include="Parser\mcs\generic.cs" />
<Compile Include="Parser\mcs\hosting.cs" />
<Compile Include="Parser\mcs\import.cs" />
<Compile Include="Parser\mcs\iterators.cs" />
<Compile Include="Parser\mcs\lambda.cs" />
@ -227,8 +229,6 @@ @@ -227,8 +229,6 @@
<Compile Include="Parser\mcs\property.cs" />
<Compile Include="Parser\mcs\reflection.cs" />
<Compile Include="Parser\mcs\report.cs" />
<Compile Include="Parser\mcs\rootcontext.cs" />
<Compile Include="Parser\mcs\roottypes.cs" />
<Compile Include="Parser\mcs\statement.cs" />
<Compile Include="Parser\mcs\support.cs" />
<Compile Include="Parser\mcs\symbolwriter.cs" />
@ -271,7 +271,6 @@ @@ -271,7 +271,6 @@
<Compile Include="Refactoring\TextReplaceAction.cs" />
<Compile Include="Refactoring\TypeSystemAstBuilder.cs" />
<Compile Include="Resolver\CompositeResolveVisitorNavigator.cs" />
<Compile Include="Resolver\ConversionResolveResult.cs" />
<Compile Include="Resolver\Conversions.cs" />
<Compile Include="Resolver\CSharpAstResolver.cs" />
<Compile Include="Resolver\CSharpInvocationResolveResult.cs" />
@ -291,10 +290,10 @@ @@ -291,10 +290,10 @@
<Compile Include="Resolver\OverloadResolutionErrors.cs" />
<Compile Include="Resolver\ResolveAtLocation.cs" />
<Compile Include="Resolver\ResolveVisitor.cs" />
<Compile Include="Resolver\SimpleNameLookupMode.cs" />
<Compile Include="Resolver\TypeInference.cs" />
<Compile Include="Completion\ICompletionDataFactory.cs" />
<Compile Include="Completion\IParameterCompletionDataFactory.cs" />
<Compile Include="SimpleNameLookupMode.cs" />
<Compile Include="TypeSystem\AliasNamespaceReference.cs" />
<Compile Include="TypeSystem\AttributeTypeReference.cs" />
<Compile Include="TypeSystem\ConstantValues.cs" />
@ -316,6 +315,9 @@ @@ -316,6 +315,9 @@
<Compile Include="Completion\CSharpCompletionEngine.cs" />
<Compile Include="Completion\CSharpCompletionEngineBase.cs" />
<Compile Include="Completion\CSharpParameterCompletionEngine.cs" />
<Compile Include="Completion\IMemberProvider.cs" />
<Compile Include="Parser\mcs\module.cs" />
<Compile Include="Parser\mcs\settings.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">

38
ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs

@ -77,38 +77,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -77,38 +77,6 @@ namespace ICSharpCode.NRefactory.CSharp
}
#region StartNode/EndNode
public event EventHandler<AstNodeEventArgs> OutputStarted;
protected virtual void OnOutputStarted (AstNodeEventArgs e)
{
EventHandler<AstNodeEventArgs> handler = this.OutputStarted;
if (handler != null)
handler (this, e);
}
public event EventHandler<AstNodeEventArgs> OutputFinished;
protected virtual void OnOutputFinished (AstNodeEventArgs e)
{
EventHandler<AstNodeEventArgs> handler = this.OutputFinished;
if (handler != null)
handler (this, e);
}
[Serializable]
public sealed class AstNodeEventArgs : EventArgs
{
public AstNode AstNode {
get;
private set;
}
public AstNodeEventArgs (AstNode node)
{
this.AstNode = node;
}
}
void StartNode (AstNode node)
{
// Ensure that nodes are visited in the proper nested order.
@ -118,7 +86,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -118,7 +86,6 @@ namespace ICSharpCode.NRefactory.CSharp
WriteSpecialsUpToNode (node);
containerStack.Push (node);
positionStack.Push (node.FirstChild);
OnOutputStarted (new AstNodeEventArgs (node));
formatter.StartNode (node);
}
@ -129,7 +96,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -129,7 +96,6 @@ namespace ICSharpCode.NRefactory.CSharp
Debug.Assert (pos == null || pos.Parent == node);
WriteSpecials (pos, null);
containerStack.Pop ();
OnOutputFinished (new AstNodeEventArgs (node));
formatter.EndNode (node);
return null;
}
@ -200,7 +166,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -200,7 +166,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// Writes a comma.
/// </summary>
/// <param name="nextNode">The next node after the comma.</param>
/// <param name="noSpacesAfterComma">When set prevents printing a space after comma.</param>
/// <param name="noSpaceAfterComma">When set prevents printing a space after comma.</param>
void Comma (AstNode nextNode, bool noSpaceAfterComma = false)
{
WriteSpecialsUpToRole (AstNode.Roles.Comma, nextNode);
@ -2486,6 +2452,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2486,6 +2452,8 @@ namespace ICSharpCode.NRefactory.CSharp
VisitNamedNode((NamedNode)childNode, data);
} else if (childNode is OptionalNode) {
VisitOptionalNode((OptionalNode)childNode, data);
} else if (childNode is Repeat) {
VisitRepeat((Repeat)childNode, data);
} else {
WritePrimitiveValue(childNode);
}

10
ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs

@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// Converts a compilation unit to CodeDom.
/// </summary>
/// <param name="compilationUnit">The input compilation unit.</param>
/// <param name="context">Type resolve context, used for resolving type references.</param>
/// <param name="compilation">The current compilation.</param>
/// <param name="parsedFile">CSharpParsedFile, used for resolving.</param>
/// <returns>Converted CodeCompileUnit</returns>
/// <remarks>
@ -75,8 +75,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -75,8 +75,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// Converts a C# AST node to CodeDom.
/// </summary>
/// <param name="node">The input node.</param>
/// <param name="resolveVisitor">The resolve visitor.
/// The visitor must be already initialized for the file containing the given node (Scan must be called).</param>
/// <param name="resolver">The AST resolver.</param>
/// <returns>The node converted into CodeDom</returns>
/// <remarks>
/// This conversion process requires a resolver because it needs to distinguish field/property/event references etc.
@ -1233,13 +1232,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1233,13 +1232,12 @@ namespace ICSharpCode.NRefactory.CSharp
CodeObject IAstVisitor<object, CodeObject>.VisitPrimitiveType(PrimitiveType primitiveType, object data)
{
string keyword = primitiveType.Keyword;
KnownTypeCode typeCode = TypeSystemConvertVisitor.GetTypeCodeForPrimitiveType(keyword);
KnownTypeCode typeCode = primitiveType.KnownTypeCode;
if (typeCode != KnownTypeCode.None) {
KnownTypeReference ktr = KnownTypeReference.Get(typeCode);
return new CodeTypeReference(ktr.Namespace + "." + ktr.Name);
}
return new CodeTypeReference(keyword);
return new CodeTypeReference(primitiveType.Keyword);
}
CodeObject IAstVisitor<object, CodeObject>.VisitComment (Comment comment, object data)

20
ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs

@ -29,6 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -29,6 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp
readonly TextWriter textWriter;
int indentation;
bool needsIndent = true;
bool isAtStartOfLine = true;
public int Indentation {
get {
@ -53,18 +54,21 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,18 +54,21 @@ namespace ICSharpCode.NRefactory.CSharp
{
WriteIndentation();
textWriter.Write(ident);
isAtStartOfLine = false;
}
public void WriteKeyword(string keyword)
{
WriteIndentation();
textWriter.Write(keyword);
isAtStartOfLine = false;
}
public void WriteToken(string token)
{
WriteIndentation();
textWriter.Write(token);
isAtStartOfLine = false;
}
public void Space()
@ -75,7 +79,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -75,7 +79,6 @@ namespace ICSharpCode.NRefactory.CSharp
public void OpenBrace(BraceStyle style)
{
bool isAtStartOfLine = needsIndent;
switch (style) {
case BraceStyle.DoNotChange:
case BraceStyle.EndOfLine:
@ -125,16 +128,19 @@ namespace ICSharpCode.NRefactory.CSharp @@ -125,16 +128,19 @@ namespace ICSharpCode.NRefactory.CSharp
Unindent();
WriteIndentation();
textWriter.Write('}');
isAtStartOfLine = false;
break;
case BraceStyle.NextLineShifted:
WriteIndentation();
textWriter.Write('}');
isAtStartOfLine = false;
Unindent();
break;
case BraceStyle.NextLineShifted2:
Unindent();
WriteIndentation();
textWriter.Write('}');
isAtStartOfLine = false;
Unindent();
break;
default:
@ -142,7 +148,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -142,7 +148,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
void WriteIndentation()
protected void WriteIndentation()
{
if (needsIndent) {
needsIndent = false;
@ -156,6 +162,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -156,6 +162,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
textWriter.WriteLine();
needsIndent = true;
isAtStartOfLine = true;
}
public void Indent()
@ -176,16 +183,19 @@ namespace ICSharpCode.NRefactory.CSharp @@ -176,16 +183,19 @@ namespace ICSharpCode.NRefactory.CSharp
textWriter.Write("//");
textWriter.WriteLine(content);
needsIndent = true;
isAtStartOfLine = true;
break;
case CommentType.MultiLine:
textWriter.Write("/*");
textWriter.Write(content);
textWriter.Write("*/");
isAtStartOfLine = false;
break;
case CommentType.Documentation:
textWriter.Write("///");
textWriter.WriteLine(content);
needsIndent = true;
isAtStartOfLine = true;
break;
default:
textWriter.Write(content);
@ -196,7 +206,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -196,7 +206,7 @@ namespace ICSharpCode.NRefactory.CSharp
public void WritePreProcessorDirective(PreProcessorDirectiveType type, string argument)
{
// pre-processor directive must start on its own line
if (!needsIndent)
if (!isAtStartOfLine)
NewLine();
WriteIndentation();
textWriter.Write('#');
@ -210,6 +220,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -210,6 +220,10 @@ namespace ICSharpCode.NRefactory.CSharp
public virtual void StartNode(AstNode node)
{
// Write out the indentation, so that overrides of this method
// can rely use the current output length to identify the position of the node
// in the output.
WriteIndentation();
}
public virtual void EndNode(AstNode node)

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

File diff suppressed because it is too large Load Diff

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

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
//
// AssemblyInfo.cs
//
// Author:
// Marek Safar (marek.safar@gmail.com)
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle ("Mono C# Compiler")]
[assembly: AssemblyProduct ("Mono C# Compiler")]
[assembly: AssemblyCopyright ("2001 - 2009 Novell, Inc.")]
[assembly: AssemblyCompany ("Novell, Inc.")]
[assembly: AssemblyCulture ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyVersion ("1.0")]
[assembly: AssemblyFileVersion ("1.0")]
[assembly: AssemblyDescription ("Mono C# Compiler")]

34100
ICSharpCode.NRefactory.CSharp/Parser/mcs/ChangeLog

File diff suppressed because it is too large Load Diff

126
ICSharpCode.NRefactory.CSharp/Parser/mcs/Makefile

@ -1,126 +0,0 @@ @@ -1,126 +0,0 @@
thisdir := mcs
SUBDIRS :=
include ../build/rules.make
EXTRA_DISTFILES = \
*mcs.csproj \
compiler.doc \
*mcs.sln \
*cs-parser.jay \
*.sources \
NOTES \
TODO \
*mcs.exe.config
COMPILER_NAME = gmcs
ifeq (net_2_0, $(PROFILE))
INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/gmcs.exe
endif
ifeq (moonlight_bootstrap, $(PROFILE))
INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/gmcs.exe
endif
ifeq (2.1, $(FRAMEWORK_VERSION))
LOCAL_MCS_FLAGS += -d:SMCS_SOURCE
COMPILER_NAME = smcs
endif
ifeq (4.0, $(FRAMEWORK_VERSION))
COMPILER_NAME = dmcs
endif
PROGRAM = $(topdir)/class/lib/$(PROFILE)/$(COMPILER_NAME).exe
BUILT_SOURCES = cs-parser.cs
PROGRAM_COMPILE = $(BOOT_COMPILE)
CLEAN_FILES += y.output
%-parser.cs: %-parser.jay $(topdir)/jay/skeleton.cs
$(topdir)/jay/jay -cvt < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
KEEP_OUTPUT_FILE_COPY = yes
include ../build/executable.make
csproj-local:
config_file=`basename $(PROGRAM) .exe`-$(PROFILE).input; \
echo $(thisdir):$$config_file >> $(topdir)/../mono/msvc/scripts/order; \
(echo $(is_boot); \
echo $(BOOTSTRAP_MCS); \
echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
echo $(PROGRAM); \
echo $(BUILT_SOURCES); \
echo $(PROGRAM); \
echo $(response)) > $(topdir)/../mono/msvc/scripts/inputs/$$config_file
#
# Below this line we have local targets used for testing and development
#
# Testing targets
TIME = time
# This used to be called test, but that conflicts with the global
# recursive target.
btest: mcs2.exe mcs3.exe
ls -l mcs2.exe mcs3.exe
mcs2.exe: $(PROGRAM)
$(TIME) $(RUNTIME) $(RUNTIME_FLAGS) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
mcs3.exe: mcs2.exe
$(TIME) $(RUNTIME) $(RUNTIME_FLAGS) ./mcs2.exe $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
wc:
wc -l $(BUILT_SOURCES) `cat $(sourcefile)`
ctest:
rm -f mcs2.exe mcs3.exe
$(MAKE) USE_MCS_FLAGS="-d:NET_1_1 -d:ONLY_1_1" btest
# we need this because bash tries to use its own crappy timer
FRIENDLY_TIME = $(shell which time) -f'%U seconds'
do-time : $(PROGRAM)
@ echo -n "Run 1: "
@ rm -f mcs2.exe
@ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs2.exe > /dev/null || (echo FAILED; exit 1)
@ echo -n "Run 2: "
@ rm -f mcs3.exe
@ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs3.exe > /dev/null || (echo FAILED; exit 1)
@ $(MAKE) do-corlib
do-corlib:
@ echo -n "corlib: "
@ rm -f ../class/lib/mscorlib.dll
@ cd ../class/corlib ; $(MAKE) BOOTSTRAP_MCS='$(FRIENDLY_TIME) mono $$(topdir)/class/lib/$(PROFILE)/mcs.exe' > /dev/null || (echo FAILED; exit 1)
PROFILER=default
do-gettext:
xgettext --keyword='Report.Error:3' --keyword='Report.Error:2' --keyword='Report.Warning:3' --keyword='Report.Warning:2' -o mcs.po --language='C#' `cat gmcs.exe.sources | grep -v /`
profile : $(PROGRAM)
$(RUNTIME) $(RUNTIME_FLAGS) --profile=$(PROFILER) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:mcs2.exe $(BUILT_SOURCES) @$(response)
#
# quick hack target, to quickly develop the gmcs compiler
# Update manually.
q: cs-parser.cs qh
echo 'System.Console.WriteLine ("Hello");' | mono csharp.exe
echo -e 'using System;\nConsole.WriteLine ("hello");' | mono csharp.exe
echo -e '"foo" == "bar";' | mono csharp.exe
echo -e 'var a = 1;\na + 2;' | mono csharp.exe
echo -e 'int j;\nj = 1;' | mono csharp.exe
echo -e 'var a = new int[]{1,2,3};\nfrom x in a select x;' | mono csharp.exe
echo -e 'var a = from f in System.IO.Directory.GetFiles ("/tmp") where f == "passwd" select f;' | mono csharp.exe

22
ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs

@ -156,7 +156,6 @@ namespace Mono.CompilerServices.SymbolWriter @@ -156,7 +156,6 @@ namespace Mono.CompilerServices.SymbolWriter
List<MethodEntry> methods = new List<MethodEntry> ();
List<SourceFileEntry> sources = new List<SourceFileEntry> ();
List<CompileUnitEntry> comp_units = new List<CompileUnitEntry> ();
Dictionary<Type, int> type_hash = new Dictionary<Type, int> ();
Dictionary<int, AnonymousScopeEntry> anonymous_scopes;
OffsetTable ot;
@ -187,17 +186,6 @@ namespace Mono.CompilerServices.SymbolWriter @@ -187,17 +186,6 @@ namespace Mono.CompilerServices.SymbolWriter
return comp_units.Count;
}
internal int DefineType (Type type)
{
int index;
if (type_hash.TryGetValue (type, out index))
return index;
index = ++last_type_index;
type_hash.Add (type, index);
return index;
}
internal void AddMethod (MethodEntry entry)
{
methods.Add (entry);
@ -285,7 +273,7 @@ namespace Mono.CompilerServices.SymbolWriter @@ -285,7 +273,7 @@ namespace Mono.CompilerServices.SymbolWriter
//
methods.Sort ();
for (int i = 0; i < methods.Count; i++)
((MethodEntry) methods [i]).Index = i + 1;
methods [i].Index = i + 1;
//
// Write data sections.
@ -304,7 +292,7 @@ namespace Mono.CompilerServices.SymbolWriter @@ -304,7 +292,7 @@ namespace Mono.CompilerServices.SymbolWriter
//
ot.MethodTableOffset = (int) bw.BaseStream.Position;
for (int i = 0; i < methods.Count; i++) {
MethodEntry entry = (MethodEntry) methods [i];
MethodEntry entry = methods [i];
entry.Write (bw);
}
ot.MethodTableSize = (int) bw.BaseStream.Position - ot.MethodTableOffset;
@ -314,7 +302,7 @@ namespace Mono.CompilerServices.SymbolWriter @@ -314,7 +302,7 @@ namespace Mono.CompilerServices.SymbolWriter
//
ot.SourceTableOffset = (int) bw.BaseStream.Position;
for (int i = 0; i < sources.Count; i++) {
SourceFileEntry source = (SourceFileEntry) sources [i];
SourceFileEntry source = sources [i];
source.Write (bw);
}
ot.SourceTableSize = (int) bw.BaseStream.Position - ot.SourceTableOffset;
@ -324,7 +312,7 @@ namespace Mono.CompilerServices.SymbolWriter @@ -324,7 +312,7 @@ namespace Mono.CompilerServices.SymbolWriter
//
ot.CompileUnitTableOffset = (int) bw.BaseStream.Position;
for (int i = 0; i < comp_units.Count; i++) {
CompileUnitEntry unit = (CompileUnitEntry) comp_units [i];
CompileUnitEntry unit = comp_units [i];
unit.Write (bw);
}
ot.CompileUnitTableSize = (int) bw.BaseStream.Position - ot.CompileUnitTableOffset;
@ -633,7 +621,7 @@ namespace Mono.CompilerServices.SymbolWriter @@ -633,7 +621,7 @@ namespace Mono.CompilerServices.SymbolWriter
lock (this) {
read_methods ();
return (MethodEntry) method_list [index - 1];
return method_list [index - 1];
}
}

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

@ -185,9 +185,23 @@ namespace Mono.CompilerServices.SymbolWriter @@ -185,9 +185,23 @@ namespace Mono.CompilerServices.SymbolWriter
public readonly int Row;
public readonly int File;
public readonly int Offset;
public readonly bool IsHidden;
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);
@ -568,6 +551,7 @@ namespace Mono.CompilerServices.SymbolWriter @@ -568,6 +551,7 @@ namespace Mono.CompilerServices.SymbolWriter
}
}
[Obsolete]
public int DefineNamespace (string name, string[] using_clauses, int parent)
{
if (!creating)
@ -700,6 +684,12 @@ namespace Mono.CompilerServices.SymbolWriter @@ -700,6 +684,12 @@ namespace Mono.CompilerServices.SymbolWriter
this.hash = checksum;
}
public byte[] Checksum {
get {
return hash;
}
}
internal void WriteData (MyBinaryWriter bw)
{
DataOffset = (int) bw.BaseStream.Position;

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

@ -153,6 +153,7 @@ namespace Mono.CompilerServices.SymbolWriter @@ -153,6 +153,7 @@ namespace Mono.CompilerServices.SymbolWriter
return entry;
}
[Obsolete]
public int DefineNamespace (string name, CompileUnitEntry unit,
string[] using_clauses, int parent)
{
@ -250,6 +251,8 @@ namespace Mono.CompilerServices.SymbolWriter @@ -250,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;
@ -261,25 +264,33 @@ namespace Mono.CompilerServices.SymbolWriter @@ -261,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)
@ -370,10 +381,12 @@ namespace Mono.CompilerServices.SymbolWriter @@ -370,10 +381,12 @@ namespace Mono.CompilerServices.SymbolWriter
new ScopeVariable (scope, index));
}
[Obsolete]
public string RealMethodName {
get { return _real_name; }
}
[Obsolete ("It has no meaning")]
public void SetRealMethodName (string name)
{
_real_name = name;
@ -389,12 +402,9 @@ namespace Mono.CompilerServices.SymbolWriter @@ -389,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, RealMethodName, 0, //_method_flags,
Locals, method_lines.ToArray (), Blocks, _real_name, 0, //_method_flags,
_ns_id);
file.AddMethod (entry);

38
ICSharpCode.NRefactory.CSharp/Parser/mcs/NOTES

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
* Notes on improving error handling in MCS
(from Axel Schreiner <ats@cs.rit.edu>)
I included the 'recover' example with C# as well. Currently the package
is at <http://www.cs.rit.edu/~ats/projects/jay/>. I did change some
names and the embedding that the user does somewhat, i.e., it is not
directly compatible with what you did.
Here is the important part about error recovery. To make the typical
iterations bullet-proof, code them as follows:
opt : // null
| opt WORD { yyErrorFlag = 0; }
| opt error
seq : WORD
| seq WORD { yyErrorFlag = 0; }
| error
| seq error
list : WORD
| list ',' WORD { yyErrorFlag = 0; }
| error
| list error
| list error WORD { yyErrorFlag = 0; }
| list ',' error
i.e., throw in 'error' wherever a token can be. 'yyErrorFlag' need not
be set to zero, but if it is done this way, second errors are caught
earlier. This may introduce s/r conflicts, but they tend to be harmless.
In your case -- the comment concerning error recovery at the beginning
of your compiler jay file -- just adding 'error' to the different
global things won't work. Your example will already have started to
advance in one of the rules and 'error' is then not in the lookahead of
wherever the parse then is. You need to put 'error' into the iteration
above those global things.

26
ICSharpCode.NRefactory.CSharp/Parser/mcs/OPTIMIZE

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
This document describes all code optimalizations performed by Mono C# compiler
when optimalizations are enabled via /optimize+ option.
Optimalizations:
* Instance field initializer to default value
---------------------------------------------
Code to optimize:
class C
{
enum E
{
Test
}
int i = 0; // Field will not be redundantly assigned
int i2 = new int (); // This will be also completely optimized out
E e = E.Test; // Even this will go out.
}

239
ICSharpCode.NRefactory.CSharp/Parser/mcs/OTODO

@ -1,239 +0,0 @@ @@ -1,239 +0,0 @@
---- This is a list of old tasks, just here for historical value ----
Open question:
Create a toplevel block for anonymous methods?
Anonymous Methods
-----------------
Plan:
* Resolve anonymous methods before.
* Each time a Local matches, if the mode is `InAnonymous', flag
the VariableInfo for `proxying'.
* During Resolve track the depth required for local variables.
* Before Emit, create proxy classes with proper depth.
* Emit.
Notes on memory allocation
--------------------------
Outdated:
A run of the AllocationProfile shows that the compiler allocates roughly
30 megabytes of strings. From those, 20 megabytes come from
LookupType.
See the notes on current_container problems below on memory usage.
LookupTypeReflection:
---------------------
With something like `System.Object', LookupTypeReflection will be called
twice: once to find out that `System' is not a type and once
for System.Object.
This is required because System.Reflection requires that the type/nested types are
not separated by a dot but by a plus sign.
A nested class would be My+Class (My being the toplevel, Class the nested one).
It is interesting to look at the most called lookups when bootstrapping MCS:
647 LTR: ArrayList
713 LTR: System.Globalization
822 LTR: System.Object+Expression
904 LTR: Mono.CSharp.ArrayList
976 LTR: System.Runtime.CompilerServices
999 LTR: Type
1118 LTR: System.Runtime
1208 LTR: Mono.CSharp.Type
1373 LTR: Mono.Languages
1599 LTR: System.Diagnostics
2036 LTR: System.Text
2302 LTR: System.Reflection.Emit
2515 LTR: System.Collections
4527 LTR: System.Reflection
22273 LTR: Mono.CSharp
24245 LTR: System
27005 LTR: Mono
Analysis:
The top 9 lookups are done for things which are not types.
Mono.CSharp.Type happens to be a common lookup: the class Type
used heavily in the compiler in the default namespace.
RED FLAG:
Then `Type' is looked up alone a lot of the time, this happens
in parameter declarations and am not entirely sure that this is
correct (FindType will pass to LookupInterfaceOrClass a the current_type.FullName,
which for some reason is null!). This seems to be a problem with a lost
piece of context during FindType.
System.Object is also used a lot as a toplevel class, and we assume it will
have children, we should just shortcut this.
A cache:
Adding a cache and adding a catch for `System.Object' to flag that it wont be the
root of a hierarchy reduced the MCS bootstrap time from 10.22 seconds to 8.90 seconds.
This cache is currently enabled with SIMPLE_SPEEDUP in typemanager.cs. Memory consumption
went down from 74 megs to 65 megs with this change.
Major tasks:
------------
Pinned and volatile require type modifiers that can not be encoded
with Reflection.Emit.
* Revisit
Primary-expression, as it has now been split into
non-array-creation-expression and array-creation-expression.
* Emit `pinned' for pinned local variables.
Both `modreq' and pinned will require special hacks in the compiler.
* Make sure that we are pinning the right variable
* local_variable_declaration
Not sure that this grammar is correct, we might have to
resolve this during semantic analysis.
* Optimizations
In Indexers and Properties, probably support an EmitWithDup
That emits the code to call Get and then leaves a this pointer
in the stack, so that later a Store can be emitted using that
this pointer (consider Property++ or Indexer++)
* Use of local temporary in UnaryMutator
We should get rid of the Localtemporary there for some cases
This turns out to be very complex, at least for the post-version,
because this case:
a = i++
To produce optimal code, it is necessary for UnaryMutator to know
that it is being assigned to a variable (the way the stack is laid
out using dup requires the store to happen inside UnaryMutator).
* Interface indexers
I have not figured out why the Microsoft version puts an
`instance' attribute, and I am not generating this `instance' attribute.
Explanation: The reason for the `instance' attribute on
indexers is that indexers only apply to instances
* Check for Final when overriding, if the parent is Final, then we cant
allow an override.
Implement base indexer access.
current_container/current_namespace and the DeclSpace
-----------------------------------------------------
We are storing fully qualified names in the DeclSpace instead of the node,
this is because `current_namespace' (Namepsace) is not a DeclSpace like
`current_container'.
The reason for storing the full names today is this:
namespace X {
class Y {
}
}
namespace A {
class Y {
}
}
The problem is that we only use the namespace stack to track the "prefix"
for typecontainers, but they are not typecontainers themselves, so we have
to use fully qualified names, because both A.X and A.Y would be entered
in the toplevel type container. If we use the short names, there would be
a name clash.
To fix this problem, we have to make namespaces DeclSpaces.
The full size, contrasted with the size that could be stored is:
corlib:
Size of strings held: 368901
Size of strings short: 147863
System:
Size of strings held: 212677
Size of strings short: 97521
System.XML:
Size of strings held: 128055
Size of strings short: 35782
System.Data:
Size of strings held: 117896
Size of strings short: 36153
System.Web:
Size of strings held: 194527
Size of strings short: 58064
System.Windows.Forms:
Size of strings held: 220495
Size of strings short: 64923
The use of DottedName
---------------------
We could probably use a different system to represent names, like this:
class Name {
string simplename;
Name parent;
}
So `System.ComponentModel' becomes:
x: (System, null)
y: (ComponentModel, x)
The problem is that we would still need to construct the name to pass to
GetType.
This has been now implemented, its called "QualifiedIdentifier"
TODO:
1. Create a "partial" emit context for each TypeContainer..
2. EmitContext should be partially constructed. No IL Generator.
interface_type review.
parameter_array, line 952: `note: must be a single dimension array type'. Validate this
Instance idea
-------------
It would be nice to have things that can be "instances" to have an
EmitInstance method (this would default to nothing).
The idea is to be able to use efficiently the instance data on stack
manipulations, as opposed to the current scheme, where we basically have
a few special cases.
* `yield' is no longer a keyword, it only has special
meaning before a return or break keywords.
* Study side effects with assign
* Study TemporaryStorage/LocalStorage -> Merge/rename

66
ICSharpCode.NRefactory.CSharp/Parser/mcs/PLAN

@ -1,66 +0,0 @@ @@ -1,66 +0,0 @@
Clean Up
--------
Move MapVariable from CodeGen into Block?
Improve test:
Necesitamos que a-capture8.cs pruebe si la asignacion funciona o no.
Audit:
Al emitir instancias de variables
(EmitCaptureVariableInstance) parece ser que el loop de iteracion:
while (si.ScopeBlock.ID != li.Block.ID)
está mas actulizado que el codigo similar para parámetros, es posible
que sea bitrot de parámetros o que en los parámetros usamos otra estrategia
(lo segundo es más razonable).
Iteradores:
En algún lugar no pongo el `FieldBuilder' a un valor con los
iteradores, ver expression.cs: 3616, local_info.FieldBuilder es nulo.
Parameters:
a-parameter4.cs falla por que no se liga el método anónimo
anidado con el padre.
Cleanup:
CaptureContext cc = ContextForParameter (ec.CurrentBlock.Toplevel, name);
if (cc != this){
cc.EmitParameter (ec, name);
return;
}
That should be a static method, and call the instance method
in the right CaptureContext, instead of having the CaptureContext
compute that itself.
MakePinned is gone:
Need to audit the code now that use DeclareLocal, and that this uses
a differnent code path than the main mcs.
Need to fix the order in which types are closed: currently we are not
compatible with the MS requirement that the parent has to be created
before the children are.
Tests and pending features:
Switch statement is broken (because it uses ILGenerator during
the Resolve phase, which with the `anonymous' branch is no longer
the case: so we have to delay the creation of labels until they
are needed, during the Emit phase).
Validation:
For testing, set ec.IG == null during resolve, restore value
for emit.
Currently it is commented out: there is a bug in the
statement.cs changes (see the old-statement.cs, the compiler
fails during bootstrap)

72
ICSharpCode.NRefactory.CSharp/Parser/mcs/README

@ -1,72 +0,0 @@ @@ -1,72 +0,0 @@
Completion support
==================
Supported:
a.<TAB> to complete members of type `a'
a<TAB> for types and namespaces
a.W<TAB>
a<TAB> for local variables
Unsupported:
delegate { FOO.<TAB>
using statement autocompletion
These are the sources to the Mono C# compiler
---------------------------------------------
Read the mcs/docs/compiler.txt for an overview of the compiler.
Testing the Compiler
--------------------
You might want to use the `make btest' in this directory to
have the compiler bootstrap itself, this is the basic regression
test.
Before commiting changes to MCS, make sure that all the tests
in `mcs/tests' pass, and all the tests in 'mcs/errors' have the
expected result, type:
cd mcs # The top-level 'mcs' directory
make compiler-tests
If you want to test the installed compiler, you can run:
cd mcs # The top-level 'mcs' directory
make test-installed-compiler
Full Bootstrap
==============
To finally ensure the state of the compiler, it is ideal to do
a full bootstrap, to do this, do:
cd mcs
make clean;
make
make install
That installs the compiler and assemblies compiled by the new compiler.
Then, repeat that step again:
make clean
make
If things work, the compiler has not added a new regression
while building the mscorlib and the compiler itself.
Tests
=====
When bugs are fixed, new tests must be added to the
`mcs/tests' directory to excercise the problem and to guarantee
that we keep the compiler in a good state.
When an error is reported, it should be added to mcs/errors.
We try to make the errors numbers be the same as the ones in
Microsoft C#, if this is not possible, allocate a negative error
number, and list it in mcs/errors/errors.txt

223
ICSharpCode.NRefactory.CSharp/Parser/mcs/TODO

@ -1,223 +0,0 @@ @@ -1,223 +0,0 @@
===========================================
* Value Parameter
I believe that `Value Parameter' might have been introduced
after C# 1.0, also notice than in the treatment of Value Parameter
the parameters are defined in four categories:
Section 9.3 in the latest spec.
Large project:
--------------
New
---
It would be nice to optimize the case of:
Method (new ValueType ())
So that no temporary is created, and we only use a newobj call
that remains on the stack, as opposed to ldloca, initobj, ldloc
call.
NEW NOTES:
----------
ImplicitStandardConversionExists and ImplicitStandardConversion
should always be the same, but there are a few diverging lines that
must be studied:
if (expr_type == target_type && !(expr is NullLiteral))
return expr;
vs:
if (expr_type == target_type)
return true;
****************************************************************************************
*
* The information on the rest of this file is mostly outdated, and its kept here for
* historical reasons
*
****************************************************************************************
Error Reporting:
----------------
* Make yyerror show a nice syntax error, instead of the current mess.
Optimization ideas
------------------
Currently when we build a type cache, it contains private members,
internal members, and internal protected members; We should trim
these out, as it shows up on the profile.
We create too many Arraylists; When we know the size, we should create
an array;
During parsing we use arraylists to accumulate data, like this:
thing:
thing_list
: thing { $$ =new ArrayList (); $$.Add ($1); }
| thing_list thing { ArrayList a = $1; a.Add ($2); $$ = a; }
We probably could start using "Pairs" there:
thing_list
: thing { $$ = new Pair ($1, null); }
| thing_list thing { Pair p = $1; $$ = new Pair ($2, $1); }
EmitContext.ResolveTypeTree
---------------------------
We should investigate its usage. The problem is that by default
this will be set when calling FindType, that triggers a more expensive
lookup.
I believe we should pass the current EmitContext (which has this turned off
by default) to ResolveType/REsolveTypeExpr and then have the routines that
need ResolveType to pass null as the emit context.
DeclareLocal audit
------------------
DeclareLocal is used in various statements. The audit should be done
in two steps:
* Identify all the declare locals.
* Identify its uses.
* Find if we can make wrapper functions for all of them.
Then we can move DeclareLocal into a helper class.
This is required to fix foreach in iterators.
Ideas:
------
Instead of the hack that *knows* about System.Object not having any children classes,
we should just make it simple for a probe to know that there is no need for it.
Dead Code Elimination bugs:
---------------------------
I should also resolve all the children expressions in Switch, Fixed, Using.
Major tasks:
------------
Properties and 17.6.3: Finish it.
readonly variables and ref/out
BUGS
----
* Break/Continue statements
A finally block should reset the InLoop/LoopBegin/LoopEnd, as
they are logically outside the scope of the loop.
* Break/continue part 2.
They should transfer control to the finally block if inside a try/catch
block.
*
> // CSC sets beforefieldinit
> class X {
> // .cctor will be generated by compiler
> public static readonly object O = new System.Object ();
> public static void Main () {}
> }
>
PENDING TASKS
-------------
* Merge test 89 and test-34
* Code cleanup
The information when registering a method in InternalParameters
is duplicated, you can always get the types from the InternalParameters
* Emit modreq for volatiles
Handle modreq from public apis.
* Merge tree.cs, rootcontext.cs
OPTIMIZATIONS
-------------
* User Defined Conversions is doing way too many calls to do union sets that are not needed
* Add test case for destructors
* Places that use `Ldelema' are basically places where I will be
initializing a value type. I could apply an optimization to
disable the implicit local temporary from being created (by using
the method in New).
* Dropping TypeContainer as an argument to EmitContext
My theory is that I can get rid of the TypeBuilder completely from
the EmitContext, and have typecasts where it is used (from
DeclSpace to where it matters).
The only pending problem is that the code that implements Aliases
is on TypeContainer, and probably should go in DeclSpace.
* Tests
Write tests for the various reference conversions. We have
test for all the numeric conversions.
* Optimizations: variable allocation.
When local variables of a type are required, we should request
the variable and later release it when we are done, so that
the same local variable slot can be reused later on.
* Add a cache for the various GetArrayMethod operations.
* MakeUnionSet Callers
If the types are the same, there is no need to compute the unionset,
we can just use the list from one of the types.
* Factor the lookup code for class declarations an interfaces
(interface.cs:GetInterfaceByName)
RECOMMENDATIONS
---------------
* Use of lexer.Location in the parser
Currently we do:
TOKEN nt TERMINAL nt TERMINAL nt3 {
$$ = new Blah ($2, $4, $6, lexer.Location);
}
This is bad, because the lexer.Location is for the last item in `nt3'
We need to change that to use this pattern:
TOKEN { oob_stack.Push (lexer.Location) } nt TERMINAL nt TERMINAL nt3 {
$$ = new Blah ($3, $5, $7, (Location) oob_stack.Pop ());
}
Notice how numbering of the arguments changes as the
{ oob_stack.Push (lexer.Location) } takes a "slot" in the productions.

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

@ -16,6 +16,7 @@ using System.Collections.Generic; @@ -16,6 +16,7 @@ using System.Collections.Generic;
#if STATIC
using IKVM.Reflection;
using IKVM.Reflection.Emit;
using System.Diagnostics;
#else
using System.Reflection;
using System.Reflection.Emit;
@ -26,7 +27,7 @@ namespace Mono.CSharp { @@ -26,7 +27,7 @@ namespace Mono.CSharp {
public abstract class CompilerGeneratedClass : Class
{
protected CompilerGeneratedClass (TypeContainer parent, MemberName name, Modifiers mod)
: base (parent.NamespaceEntry, parent, name, mod | Modifiers.COMPILER_GENERATED, null)
: base (parent, name, mod | Modifiers.COMPILER_GENERATED, null)
{
}
@ -36,15 +37,18 @@ namespace Mono.CSharp { @@ -36,15 +37,18 @@ namespace Mono.CSharp {
throw new InternalErrorException ("Helper class already defined!");
}
protected static MemberName MakeMemberName (MemberBase host, string name, int unique_id, TypeParameter[] tparams, Location loc)
protected static MemberName MakeMemberName (MemberBase host, string name, int unique_id, TypeParameters tparams, Location loc)
{
string host_name = host == null ? null : host.Name;
string host_name = host == null ? null : host is InterfaceMemberBase ? ((InterfaceMemberBase)host).GetFullName (host.MemberName) : host.MemberName.Name;
string tname = MakeName (host_name, "c", name, unique_id);
TypeArguments args = null;
TypeParameters args = null;
if (tparams != null) {
args = new TypeArguments ();
foreach (TypeParameter tparam in tparams)
args.Add (new TypeParameterName (tparam.Name, null, loc));
args = new TypeParameters (tparams.Count);
// Type parameters will be filled later when we have TypeContainer
// instance, for now we need only correct arity to create valid name
for (int i = 0; i < tparams.Count; ++i)
args.Add ((TypeParameter) null);
}
return new MemberName (tname, args, loc);
@ -81,16 +85,17 @@ namespace Mono.CSharp { @@ -81,16 +85,17 @@ namespace Mono.CSharp {
protected TypeParameterMutator mutator;
public HoistedStoreyClass (TypeContainer parent, MemberName name, TypeParameter[] tparams, Modifiers mod)
public HoistedStoreyClass (TypeDefinition parent, MemberName name, TypeParameters tparams, Modifiers mod)
: base (parent, name, mod | Modifiers.PRIVATE)
{
if (tparams != null) {
type_params = new TypeParameter[tparams.Length];
var src = new TypeParameterSpec[tparams.Length];
var dst = new TypeParameterSpec[tparams.Length];
var type_params = name.TypeParameters;
var src = new TypeParameterSpec[tparams.Count];
var dst = new TypeParameterSpec[tparams.Count];
for (int i = 0; i < type_params.Length; ++i) {
type_params[i] = tparams[i].CreateHoistedCopy (this, spec);
for (int i = 0; i < tparams.Count; ++i) {
type_params[i] = tparams[i].CreateHoistedCopy (spec);
src[i] = tparams[i].Type;
dst[i] = type_params[i].Type;
@ -99,7 +104,7 @@ namespace Mono.CSharp { @@ -99,7 +104,7 @@ namespace Mono.CSharp {
// A copy is not enough, inflate any type parameter constraints
// using a new type parameters
var inflator = new TypeParameterInflator (this, null, src, dst);
for (int i = 0; i < type_params.Length; ++i) {
for (int i = 0; i < tparams.Count; ++i) {
src[i].InflateConstraints (inflator, dst[i]);
}
@ -122,7 +127,7 @@ namespace Mono.CSharp { @@ -122,7 +127,7 @@ namespace Mono.CSharp {
public HoistedStoreyClass GetGenericStorey ()
{
DeclSpace storey = this;
TypeContainer storey = this;
while (storey != null && storey.CurrentTypeParameters == null)
storey = storey.Parent;
@ -178,7 +183,6 @@ namespace Mono.CSharp { @@ -178,7 +183,6 @@ namespace Mono.CSharp {
// Unique storey ID
public readonly int ID;
static int unique_id;
public readonly Block OriginalSourceBlock;
@ -196,12 +200,12 @@ namespace Mono.CSharp { @@ -196,12 +200,12 @@ namespace Mono.CSharp {
// Local variable which holds this storey instance
public Expression Instance;
public AnonymousMethodStorey (Block block, TypeContainer parent, MemberBase host, TypeParameter[] tparams, string name)
: base (parent, MakeMemberName (host, name, unique_id, tparams, block.StartLocation),
public AnonymousMethodStorey (Block block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name)
: base (parent, MakeMemberName (host, name, parent.Module.CounterAnonymousContainers, tparams, block.StartLocation),
tparams, Modifiers.SEALED)
{
OriginalSourceBlock = block;
ID = unique_id++;
ID = parent.Module.CounterAnonymousContainers++;
}
public void AddCapturedThisField (EmitContext ec)
@ -226,7 +230,7 @@ namespace Mono.CSharp { @@ -226,7 +230,7 @@ namespace Mono.CSharp {
CheckMembersDefined ();
FullNamedExpression field_type = new TypeExpression (type, Location);
if (!IsGeneric)
if (!spec.IsGenericOrParentIsGeneric)
return AddCompilerGeneratedField (name, field_type);
const Modifiers mod = Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED;
@ -323,8 +327,8 @@ namespace Mono.CSharp { @@ -323,8 +327,8 @@ namespace Mono.CSharp {
// Use current method type parameter (MVAR) for top level storey only. All
// nested storeys use class type parameter (VAR)
//
TypeParameter[] tparams = ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.Storey != null ?
ec.CurrentAnonymousMethod.Storey.TypeParameters :
var tparams = ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.Storey != null ?
ec.CurrentAnonymousMethod.Storey.CurrentTypeParameters :
ec.CurrentTypeParameters;
TypeArguments targs = new TypeArguments ();
@ -333,7 +337,7 @@ namespace Mono.CSharp { @@ -333,7 +337,7 @@ namespace Mono.CSharp {
// Use type parameter name instead of resolved type parameter
// specification to resolve to correctly nested type parameters
//
for (int i = 0; i < tparams.Length; ++i)
for (int i = 0; i < tparams.Count; ++i)
targs.Add (new SimpleName (tparams [i].Name, Location)); // new TypeParameterExpr (tparams[i], Location));
storey_type_expr = new GenericTypeExpr (Definition, targs, Location);
@ -347,19 +351,18 @@ namespace Mono.CSharp { @@ -347,19 +351,18 @@ namespace Mono.CSharp {
public void SetNestedStoryParent (AnonymousMethodStorey parentStorey)
{
Parent = parentStorey;
type_params = null;
spec.IsGeneric = false;
spec.DeclaringType = parentStorey.CurrentType;
MemberName.TypeArguments = null;
MemberName.TypeParameters = null;
}
protected override bool DoResolveTypeParameters ()
{
// Although any storey can have type parameters they are all clones of method type
// parameters therefore have to mutate MVAR references in any of cloned constraints
if (type_params != null) {
for (int i = 0; i < type_params.Length; ++i) {
var spec = type_params[i].Type;
if (CurrentTypeParameters != null) {
for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
var spec = CurrentTypeParameters[i].Type;
spec.BaseType = mutator.Mutate (spec.BaseType);
if (spec.InterfacesDefined != null) {
var mutated = new TypeSpec[spec.InterfacesDefined.Length];
@ -493,8 +496,10 @@ namespace Mono.CSharp { @@ -493,8 +496,10 @@ namespace Mono.CSharp {
}
}
public override void EmitType ()
public override void Emit ()
{
base.Emit ();
SymbolWriter.DefineAnonymousScope (ID);
if (hoisted_this != null)
@ -515,8 +520,6 @@ namespace Mono.CSharp { @@ -515,8 +520,6 @@ namespace Mono.CSharp {
SymbolWriter.DefineCapturedScope (ID, sf.Storey.ID, sf.Field.Name);
}
}
base.EmitType ();
}
//
@ -593,11 +596,6 @@ namespace Mono.CSharp { @@ -593,11 +596,6 @@ namespace Mono.CSharp {
public IList<ExplicitBlock> ReferencesFromChildrenBlock {
get { return children_references; }
}
public static void Reset ()
{
unique_id = 0;
}
}
public abstract class HoistedVariable
@ -714,7 +712,7 @@ namespace Mono.CSharp { @@ -714,7 +712,7 @@ namespace Mono.CSharp {
}
if (inner_access == null) {
if (field.Parent.IsGeneric) {
if (field.Parent.IsGenericOrParentIsGeneric) {
var fs = MemberCache.GetMember (field.Parent.CurrentType, field.Spec);
inner_access = new FieldExpr (fs, field.Location);
} else {
@ -885,9 +883,8 @@ namespace Mono.CSharp { @@ -885,9 +883,8 @@ namespace Mono.CSharp {
public ParametersBlock Block;
public AnonymousMethodExpression (bool isAsync, Location loc)
public AnonymousMethodExpression (Location loc)
{
this.IsAsync = isAsync;
this.loc = loc;
this.compatibles = new Dictionary<TypeSpec, Expression> ();
}
@ -911,10 +908,10 @@ namespace Mono.CSharp { @@ -911,10 +908,10 @@ namespace Mono.CSharp {
return Block.Parameters;
}
}
public bool IsAsync {
get;
private set;
internal set;
}
#endregion
@ -1042,16 +1039,10 @@ namespace Mono.CSharp { @@ -1042,16 +1039,10 @@ namespace Mono.CSharp {
return false;
for (int i = 0; i < Parameters.Count; ++i) {
TypeSpec itype = d_params.Types [i];
if (!TypeManager.IsGenericParameter (itype)) {
if (!TypeManager.HasElementType (itype))
continue;
if (!TypeManager.IsGenericParameter (TypeManager.GetElementType (itype)))
continue;
}
type_inference.ExactInference (Parameters.Types [i], itype);
if (type_inference.ExactInference (Parameters.Types[i], d_params.Types[i]) == 0)
return false;
}
return true;
}
@ -1069,7 +1060,7 @@ namespace Mono.CSharp { @@ -1069,7 +1060,7 @@ namespace Mono.CSharp {
var body = CompatibleMethodBody (ec, tic, InternalType.Arglist, delegate_type);
if (body != null) {
if (Block.IsAsync) {
AsyncInitializer.Create (ec, body.Block, body.Parameters, ec.CurrentMemberDefinition.Parent, null, loc);
AsyncInitializer.Create (ec, body.Block, body.Parameters, ec.CurrentMemberDefinition.Parent.PartialContainer, null, loc);
}
am = body.Compatible (ec, body);
@ -1163,7 +1154,7 @@ namespace Mono.CSharp { @@ -1163,7 +1154,7 @@ namespace Mono.CSharp {
GetSignatureForError (), type.GetSignatureForError ());
}
AsyncInitializer.Create (ec, body.Block, body.Parameters, ec.CurrentMemberDefinition.Parent, rt, loc);
AsyncInitializer.Create (ec, body.Block, body.Parameters, ec.CurrentMemberDefinition.Parent.PartialContainer, rt, loc);
}
am = body.Compatible (ec);
@ -1321,20 +1312,18 @@ namespace Mono.CSharp { @@ -1321,20 +1312,18 @@ namespace Mono.CSharp {
{
public readonly AnonymousExpression AnonymousMethod;
public readonly AnonymousMethodStorey Storey;
readonly string RealName;
public AnonymousMethodMethod (DeclSpace parent, AnonymousExpression am, AnonymousMethodStorey storey,
GenericMethod generic, TypeExpr return_type,
Modifiers mod, string real_name, MemberName name,
public AnonymousMethodMethod (TypeDefinition parent, AnonymousExpression am, AnonymousMethodStorey storey,
TypeExpr return_type,
Modifiers mod, MemberName name,
ParametersCompiled parameters)
: base (parent, generic, return_type, mod | Modifiers.COMPILER_GENERATED,
: base (parent, return_type, mod | Modifiers.COMPILER_GENERATED,
name, parameters, null)
{
this.AnonymousMethod = am;
this.Storey = storey;
this.RealName = real_name;
Parent.PartialContainer.AddMethod (this);
Parent.PartialContainer.Members.Add (this);
Block = new ToplevelBlock (am.block, parameters);
}
@ -1376,11 +1365,6 @@ namespace Mono.CSharp { @@ -1376,11 +1365,6 @@ namespace Mono.CSharp {
base.Emit ();
}
public override void EmitExtraSymbolInfo (SourceMethod source)
{
source.SetRealMethodName (RealName);
}
}
protected ParametersBlock block;
@ -1493,8 +1477,6 @@ namespace Mono.CSharp { @@ -1493,8 +1477,6 @@ namespace Mono.CSharp {
string block_name;
TypeInferenceContext return_inference;
static int unique_id;
public AnonymousMethodBody (ParametersCompiled parameters,
ParametersBlock block, TypeSpec return_type, TypeSpec delegate_type,
Location loc)
@ -1580,37 +1562,28 @@ namespace Mono.CSharp { @@ -1580,37 +1562,28 @@ namespace Mono.CSharp {
modifiers = Modifiers.STATIC | Modifiers.PRIVATE;
}
TypeContainer parent = storey != null ? storey : ec.CurrentTypeDefinition.Parent.PartialContainer;
var parent = storey != null ? storey : ec.CurrentTypeDefinition.Parent.PartialContainer;
MemberCore mc = ec.MemberContext as MemberCore;
string name = CompilerGeneratedClass.MakeName (parent != storey ? block_name : null,
"m", null, unique_id++);
"m", null, ec.Module.CounterAnonymousMethods++);
MemberName member_name;
GenericMethod generic_method;
if (storey == null && mc.MemberName.TypeArguments != null) {
member_name = new MemberName (name, mc.MemberName.TypeArguments.Clone (), Location);
if (storey == null && ec.CurrentTypeParameters != null) {
var hoisted_tparams = ec.CurrentTypeParameters;
var type_params = new TypeParameter[hoisted_tparams.Length];
for (int i = 0; i < type_params.Length; ++i) {
type_params[i] = hoisted_tparams[i].CreateHoistedCopy (parent, null);
var type_params = new TypeParameters (hoisted_tparams.Count);
for (int i = 0; i < hoisted_tparams.Count; ++i) {
type_params.Add (hoisted_tparams[i].CreateHoistedCopy (null));
}
generic_method = new GenericMethod (parent.NamespaceEntry, parent, member_name, type_params,
new TypeExpression (ReturnType, Location), parameters);
member_name = new MemberName (name, type_params, Location);
} else {
member_name = new MemberName (name, Location);
generic_method = null;
}
string real_name = String.Format (
"{0}~{1}{2}", mc.GetSignatureForError (), GetSignatureForError (),
parameters.GetSignatureForError ());
return new AnonymousMethodMethod (parent,
this, storey, generic_method, new TypeExpression (ReturnType, Location), modifiers,
real_name, member_name, parameters);
this, storey, new TypeExpression (ReturnType, Location), modifiers,
member_name, parameters);
}
protected override Expression DoResolve (ResolveContext ec)
@ -1643,8 +1616,8 @@ namespace Mono.CSharp { @@ -1643,8 +1616,8 @@ namespace Mono.CSharp {
// Creates a field cache to store delegate instance if it's not generic
//
if (!method.MemberName.IsGeneric) {
TypeContainer parent = method.Parent.PartialContainer;
int id = parent.Fields == null ? 0 : parent.Fields.Count;
var parent = method.Parent.PartialContainer;
int id = parent.AnonymousMethodsCounter++;
var cache_type = storey != null && storey.Mutator != null ? storey.Mutator.Mutate (type) : type;
am_cache = new Field (parent, new TypeExpression (cache_type, loc),
@ -1753,11 +1726,6 @@ namespace Mono.CSharp { @@ -1753,11 +1726,6 @@ namespace Mono.CSharp {
{
return TypeManager.CSharpName (type);
}
public static void Reset ()
{
unique_id = 0;
}
}
//
@ -1765,33 +1733,31 @@ namespace Mono.CSharp { @@ -1765,33 +1733,31 @@ namespace Mono.CSharp {
//
public class AnonymousTypeClass : CompilerGeneratedClass
{
static int types_counter;
public const string ClassNamePrefix = "<>__AnonType";
public const string SignatureForError = "anonymous type";
readonly IList<AnonymousTypeParameter> parameters;
private AnonymousTypeClass (TypeContainer parent, MemberName name, IList<AnonymousTypeParameter> parameters, Location loc)
: base (parent, name, (parent.Module.Evaluator != null ? Modifiers.PUBLIC : 0) | Modifiers.SEALED)
private AnonymousTypeClass (ModuleContainer parent, MemberName name, IList<AnonymousTypeParameter> parameters, Location loc)
: base (parent, name, (parent.Evaluator != null ? Modifiers.PUBLIC : 0) | Modifiers.SEALED)
{
this.parameters = parameters;
}
public static AnonymousTypeClass Create (TypeContainer parent, IList<AnonymousTypeParameter> parameters, Location loc)
{
string name = ClassNamePrefix + types_counter++;
string name = ClassNamePrefix + parent.Module.CounterAnonymousTypes++;
ParametersCompiled all_parameters;
TypeParameterName[] t_params;
TypeParameters tparams = null;
SimpleName[] t_args;
if (parameters.Count == 0) {
all_parameters = ParametersCompiled.EmptyReadOnlyParameters;
t_params = new TypeParameterName[0];
t_args = null;
} else {
t_args = new SimpleName[parameters.Count];
t_params = new TypeParameterName[parameters.Count];
tparams = new TypeParameters ();
Parameter[] ctor_params = new Parameter[parameters.Count];
for (int i = 0; i < parameters.Count; ++i) {
AnonymousTypeParameter p = parameters[i];
@ -1808,7 +1774,7 @@ namespace Mono.CSharp { @@ -1808,7 +1774,7 @@ namespace Mono.CSharp {
}
t_args[i] = new SimpleName ("<" + p.Name + ">__T", p.Location);
t_params[i] = new TypeParameterName (t_args[i].Name, null, p.Location);
tparams.Add (new TypeParameter (i, new MemberName (t_args[i].Name, p.Location), null, null, Variance.None));
ctor_params[i] = new Parameter (t_args[i], p.Name, Parameter.Modifier.NONE, null, p.Location);
}
@ -1819,14 +1785,10 @@ namespace Mono.CSharp { @@ -1819,14 +1785,10 @@ namespace Mono.CSharp {
// Create generic anonymous type host with generic arguments
// named upon properties names
//
AnonymousTypeClass a_type = new AnonymousTypeClass (parent.NamespaceEntry.SlaveDeclSpace,
new MemberName (name, new TypeArguments (t_params), loc), parameters, loc);
if (parameters.Count > 0)
a_type.SetParameterInfo (null);
AnonymousTypeClass a_type = new AnonymousTypeClass (parent.Module, new MemberName (name, tparams, loc), parameters, loc);
Constructor c = new Constructor (a_type, name, Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
null, all_parameters, null, loc);
null, all_parameters, loc);
c.Block = new ToplevelBlock (parent.Module.Compiler, c.ParameterInfo, loc);
//
@ -1856,7 +1818,7 @@ namespace Mono.CSharp { @@ -1856,7 +1818,7 @@ namespace Mono.CSharp {
new MemberName (p.Name, p.Location), null);
prop.Get = new Property.GetMethod (prop, 0, null, p.Location);
prop.Get.Block = get_block;
a_type.AddProperty (prop);
a_type.AddMember (prop);
}
if (error)
@ -1866,30 +1828,6 @@ namespace Mono.CSharp { @@ -1866,30 +1828,6 @@ namespace Mono.CSharp {
return a_type;
}
public static void Reset ()
{
types_counter = 0;
}
protected override bool AddToContainer (MemberCore symbol, string name)
{
MemberCore mc = GetDefinition (name);
if (mc == null) {
defined_names.Add (name, symbol);
return true;
}
// A conflict between anonymous type members will be reported
if (symbol is TypeParameter) {
Report.SymbolRelatedToPreviousError (symbol);
return false;
}
// Ignore other conflicts
return true;
}
protected override bool DoDefineMembers ()
{
if (!base.DoDefineMembers ())
@ -1900,23 +1838,24 @@ namespace Mono.CSharp { @@ -1900,23 +1838,24 @@ namespace Mono.CSharp {
var equals_parameters = ParametersCompiled.CreateFullyResolved (
new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc), Compiler.BuiltinTypes.Object);
Method equals = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
Method equals = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Equals", loc),
equals_parameters, null);
equals_parameters[0].Resolve (equals, 0);
Method tostring = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.String, loc),
Method tostring = new Method (this, new TypeExpression (Compiler.BuiltinTypes.String, loc),
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("ToString", loc),
Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);
ToplevelBlock equals_block = new ToplevelBlock (Compiler, equals.ParameterInfo, loc);
TypeExpr current_type;
if (type_params != null) {
if (CurrentTypeParameters != null) {
var targs = new TypeArguments ();
foreach (var type_param in type_params)
targs.Add (new TypeParameterExpr (type_param, type_param.Location));
for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
targs.Add (new TypeParameterExpr (CurrentTypeParameters[i], Location));
}
current_type = new GenericTypeExpr (Definition, targs, loc);
} else {
@ -1935,7 +1874,7 @@ namespace Mono.CSharp { @@ -1935,7 +1874,7 @@ namespace Mono.CSharp {
Expression rs_hashcode = new IntConstant (Compiler.BuiltinTypes, -2128831035, loc);
for (int i = 0; i < parameters.Count; ++i) {
var p = parameters [i];
var f = Fields [i];
var f = (Field) Members [i * 2];
MemberAccess equality_comparer = new MemberAccess (new MemberAccess (
system_collections_generic, "EqualityComparer",
@ -2012,12 +1951,12 @@ namespace Mono.CSharp { @@ -2012,12 +1951,12 @@ namespace Mono.CSharp {
equals.Block = equals_block;
equals.Define ();
AddMethod (equals);
Members.Add (equals);
//
// GetHashCode () override
//
Method hashcode = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.Int, loc),
Method hashcode = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Int, loc),
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN,
new MemberName ("GetHashCode", loc),
Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);
@ -2066,7 +2005,7 @@ namespace Mono.CSharp { @@ -2066,7 +2005,7 @@ namespace Mono.CSharp {
hashcode_block.AddStatement (new Return (hash_variable, loc));
hashcode.Block = hashcode_top;
hashcode.Define ();
AddMethod (hashcode);
Members.Add (hashcode);
//
// ToString () override
@ -2076,7 +2015,7 @@ namespace Mono.CSharp { @@ -2076,7 +2015,7 @@ namespace Mono.CSharp {
tostring_block.AddStatement (new Return (string_concat, loc));
tostring.Block = tostring_block;
tostring.Define ();
AddMethod (tostring);
Members.Add (tostring);
return true;
}
@ -2086,6 +2025,11 @@ namespace Mono.CSharp { @@ -2086,6 +2025,11 @@ namespace Mono.CSharp {
return SignatureForError;
}
public override CompilationSourceFile GetCompilationSourceFile ()
{
return null;
}
public IList<AnonymousTypeParameter> Parameters {
get {
return parameters;

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

@ -437,8 +437,8 @@ namespace Mono.CSharp @@ -437,8 +437,8 @@ namespace Mono.CSharp
{
if (Compiler.Settings.Target == Target.Module) {
module_target_attrs = new AssemblyAttributesPlaceholder (module, name);
module_target_attrs.CreateType ();
module_target_attrs.DefineType ();
module_target_attrs.CreateContainer ();
module_target_attrs.DefineContainer ();
module_target_attrs.Define ();
module.AddCompilerGeneratedClass (module_target_attrs);
} else if (added_modules != null) {
@ -448,16 +448,11 @@ namespace Mono.CSharp @@ -448,16 +448,11 @@ namespace Mono.CSharp
if (Compiler.Settings.GenerateDebugInfo) {
symbol_writer = new MonoSymbolWriter (file_name);
// Register all source files with symbol writer
foreach (var source in Compiler.SourceFiles) {
source.DefineSymbolInfo (symbol_writer);
}
// TODO: global variables
SymbolWriter.symwriter = symbol_writer;
}
module.Emit ();
module.EmitContainer ();
if (module.HasExtensionMethod) {
var pa = module.PredefinedAttributes.Extension;
@ -484,12 +479,7 @@ namespace Mono.CSharp @@ -484,12 +479,7 @@ namespace Mono.CSharp
Builder.__AddDeclarativeSecurity (entry);
}
#else
var args = new PermissionSet[3];
#pragma warning disable 618
declarative_security.TryGetValue (SecurityAction.RequestMinimum, out args[0]);
declarative_security.TryGetValue (SecurityAction.RequestOptional, out args[1]);
declarative_security.TryGetValue (SecurityAction.RequestRefuse, out args[2]);
builder_extra.AddPermissionRequests (args);
throw new NotSupportedException ("Assembly-level security");
#endif
}
@ -1090,8 +1080,7 @@ namespace Mono.CSharp @@ -1090,8 +1080,7 @@ namespace Mono.CSharp
public abstract bool HasObjectType (T assembly);
protected abstract string[] GetDefaultReferences ();
public abstract T LoadAssemblyFile (string fileName);
public abstract T LoadAssemblyDefault (string assembly);
public abstract T LoadAssemblyFile (string fileName, bool isImplicitReference);
public abstract void LoadReferences (ModuleContainer module);
protected void Error_FileNotFound (string fileName)
@ -1128,14 +1117,14 @@ namespace Mono.CSharp @@ -1128,14 +1117,14 @@ namespace Mono.CSharp
// Load mscorlib.dll as the first
//
if (module.Compiler.Settings.StdLib) {
corlib_assembly = LoadAssemblyDefault ("mscorlib.dll");
corlib_assembly = LoadAssemblyFile ("mscorlib.dll", true);
} else {
corlib_assembly = default (T);
}
T a;
foreach (string r in module.Compiler.Settings.AssemblyReferences) {
a = LoadAssemblyFile (r);
a = LoadAssemblyFile (r, false);
if (a == null || EqualityComparer<T>.Default.Equals (a, corlib_assembly))
continue;
@ -1153,7 +1142,7 @@ namespace Mono.CSharp @@ -1153,7 +1142,7 @@ namespace Mono.CSharp
}
foreach (var entry in module.Compiler.Settings.AssemblyReferencesAliases) {
a = LoadAssemblyFile (entry.Item2);
a = LoadAssemblyFile (entry.Item2, false);
if (a == null)
continue;
@ -1166,7 +1155,7 @@ namespace Mono.CSharp @@ -1166,7 +1155,7 @@ namespace Mono.CSharp
if (compiler.Settings.LoadDefaultReferences) {
foreach (string r in GetDefaultReferences ()) {
a = LoadAssemblyDefault (r);
a = LoadAssemblyFile (r, true);
if (a == null)
continue;

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

@ -357,7 +357,7 @@ namespace Mono.CSharp { @@ -357,7 +357,7 @@ namespace Mono.CSharp {
return this;
}
#if NET_4_0
#if NET_4_0 || MONODROID
public override System.Linq.Expressions.Expression MakeExpression (BuilderContext ctx)
{
var tassign = target as IDynamicAssign;
@ -418,6 +418,11 @@ namespace Mono.CSharp { @@ -418,6 +418,11 @@ namespace Mono.CSharp {
_target.target = target.Clone (clonectx);
_target.source = source.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
public class SimpleAssign : Assign
@ -560,7 +565,18 @@ namespace Mono.CSharp { @@ -560,7 +565,18 @@ namespace Mono.CSharp {
{
if (resolved == null)
return;
//
// Emit sequence symbol info even if we are in compiler generated
// block to allow debugging filed initializers when constructor is
// compiler generated
//
if (ec.HasSet (BuilderContext.Options.OmitDebugInfo)) {
using (ec.With (BuilderContext.Options.OmitDebugInfo, false)) {
ec.Mark (loc);
}
}
if (resolved != this)
resolved.EmitStatement (ec);
else
@ -653,6 +669,12 @@ namespace Mono.CSharp { @@ -653,6 +669,12 @@ namespace Mono.CSharp {
this.left = left;
}
public Binary.Operator Operator {
get {
return op;
}
}
protected override Expression DoResolve (ResolveContext ec)
{
right = right.Resolve (ec);
@ -811,10 +833,10 @@ namespace Mono.CSharp { @@ -811,10 +833,10 @@ namespace Mono.CSharp {
ctarget.right = ctarget.source = source.Clone (clonectx);
ctarget.target = target.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
}

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

@ -40,6 +40,12 @@ namespace Mono.CSharp @@ -40,6 +40,12 @@ namespace Mono.CSharp
this.loc = loc;
}
public Expression Expr {
get {
return expr;
}
}
protected override void CloneTo (CloneContext clonectx, Expression target)
{
var t = (Await) target;
@ -393,7 +399,7 @@ namespace Mono.CSharp @@ -393,7 +399,7 @@ namespace Mono.CSharp
{
TypeInferenceContext return_inference;
public AsyncInitializer (ParametersBlock block, TypeContainer host, TypeSpec returnType)
public AsyncInitializer (ParametersBlock block, TypeDefinition host, TypeSpec returnType)
: base (block, host, returnType)
{
}
@ -426,7 +432,7 @@ namespace Mono.CSharp @@ -426,7 +432,7 @@ namespace Mono.CSharp
#endregion
public static void Create (IMemberContext context, ParametersBlock block, ParametersCompiled parameters, TypeContainer host, TypeSpec returnType, Location loc)
public static void Create (IMemberContext context, ParametersBlock block, ParametersCompiled parameters, TypeDefinition host, TypeSpec returnType, Location loc)
{
for (int i = 0; i < parameters.Count; i++) {
Parameter p = parameters[i];
@ -537,7 +543,7 @@ namespace Mono.CSharp @@ -537,7 +543,7 @@ namespace Mono.CSharp
TypeSpec action;
public AsyncTaskStorey (IMemberContext context, AsyncInitializer initializer, TypeSpec type)
: base (initializer.OriginalBlock, initializer.Host,context.CurrentMemberDefinition as MemberBase, context.CurrentTypeParameters, "async")
: base (initializer.OriginalBlock, initializer.Host, context.CurrentMemberDefinition as MemberBase, context.CurrentTypeParameters, "async")
{
return_type = type;
}
@ -669,10 +675,12 @@ namespace Mono.CSharp @@ -669,10 +675,12 @@ namespace Mono.CSharp
builder = AddCompilerGeneratedField ("$builder", new TypeExpression (bt, Location));
var ctor = DefineDefaultConstructor (false);
if (!base.DoDefineMembers ())
return false;
var block = instance_constructors[0].Block;
Block block = ctor.Block;
var mg = MethodGroupExpr.CreatePredefined (builder_factory, bt, Location);
block.AddStatement (
@ -777,7 +785,7 @@ namespace Mono.CSharp @@ -777,7 +785,7 @@ namespace Mono.CSharp
class StackField : Field
{
public StackField (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name)
public StackField (TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name)
: base (parent, type, mod, name, null)
{
}

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

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

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

File diff suppressed because it is too large Load Diff

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

@ -89,6 +89,13 @@ namespace Mono.CSharp @@ -89,6 +89,13 @@ namespace Mono.CSharp
if (rc.Module.Compiler.Settings.Checked)
flags |= Options.CheckedScope;
if (SymbolWriter.HasSymbolWriter) {
if (!rc.Module.Compiler.Settings.Optimize)
flags |= Options.AccurateDebugInfo;
} else {
flags |= Options.OmitDebugInfo;
}
#if STATIC
ig.__CleverExceptionBlockAssistance ();
#endif
@ -112,14 +119,20 @@ namespace Mono.CSharp @@ -112,14 +119,20 @@ namespace Mono.CSharp
get { return member_context.CurrentType; }
}
public TypeParameter[] CurrentTypeParameters {
get { return member_context.CurrentTypeParameters; }
public TypeParameters CurrentTypeParameters {
get { return member_context.CurrentTypeParameters; }
}
public MemberCore CurrentTypeDefinition {
get { return member_context.CurrentMemberDefinition; }
}
public bool EmitAccurateDebugInfo {
get {
return (flags & Options.AccurateDebugInfo) != 0;
}
}
public bool HasReturnLabel {
get {
return return_label.HasValue;
@ -188,12 +201,19 @@ namespace Mono.CSharp @@ -188,12 +201,19 @@ namespace Mono.CSharp
/// This is called immediately before emitting an IL opcode to tell the symbol
/// writer to which source line this opcode belongs.
/// </summary>
public void Mark (Location loc)
public bool Mark (Location loc)
{
if (!SymbolWriter.HasSymbolWriter || HasSet (Options.OmitDebugInfo) || loc.IsNull)
return;
if ((flags & Options.OmitDebugInfo) != 0)
return false;
if (loc.IsNull)
return false;
if (loc.SourceFile.IsHiddenLocation (loc))
return false;
SymbolWriter.MarkSequencePoint (ig, loc);
return true;
}
public void DefineLocalVariable (string name, LocalBuilder builder)
@ -238,12 +258,11 @@ namespace Mono.CSharp @@ -238,12 +258,11 @@ namespace Mono.CSharp
{
if (dynamic_site_container == null) {
var mc = member_context.CurrentMemberDefinition as MemberBase;
dynamic_site_container = new DynamicSiteClass (CurrentTypeDefinition.Parent.PartialContainer, mc, CurrentTypeParameters);
dynamic_site_container = new DynamicSiteClass (CurrentTypeDefinition.Parent.PartialContainer, mc, member_context.CurrentTypeParameters);
CurrentTypeDefinition.Module.AddCompilerGeneratedClass (dynamic_site_container);
dynamic_site_container.CreateType ();
dynamic_site_container.DefineType ();
dynamic_site_container.ResolveTypeParameters ();
dynamic_site_container.CreateContainer ();
dynamic_site_container.DefineContainer ();
dynamic_site_container.Define ();
var inflator = new TypeParameterInflator (Module, CurrentType, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes);
@ -866,7 +885,7 @@ namespace Mono.CSharp @@ -866,7 +885,7 @@ namespace Mono.CSharp
public void Emit (EmitContext ec, MethodSpec method, Arguments Arguments, Location loc)
{
// Speed up the check by not doing it on not allowed targets
if (method.ReturnType.Kind == MemberKind.Void && method.IsConditionallyExcluded (ec.Module.Compiler, loc))
if (method.ReturnType.Kind == MemberKind.Void && method.IsConditionallyExcluded (ec.MemberContext, loc))
return;
EmitPredefined (ec, method, Arguments);

116
ICSharpCode.NRefactory.CSharp/Parser/mcs/compiler.doc

@ -1,116 +0,0 @@ @@ -1,116 +0,0 @@
Compiler operation
The compiler has a number of phases:
* Parsing.
Initially the compiler parses all the source files and keeps a
parsed representation in memory. Very syntax error checking
is performed at this point.
The compiler stores the information in classes whose names
represent the language construct, for example, the "if"
construct is stored in an `If' class. A class is stored in a
`Class'.
* The TypeManager
The TypeManager loads all the assemblies that were referenced
by the programmer. The CLR type system is used as our
repository for types defined as well.
So the same interface that is used to query the types,
properties and flags about system types is the same interface
that we use for our types.
As we work our way through the code generation and semantic
analysis, new types are entered into the Type system through
the use of System.Reflection.Emit. The TypeManager will
lookup types on both the user defined types and on the system
defined ones.
So special care has to be used. The order in which we
proceeed from here is important.
* Base class resolution and type definition.
Once the parsing has happened, the compiler resolves the
inheritance tree for interfaces. This is done recursively
and we catch recursive interface definitions here.
After this is done, we continue on with classes. Classes have
can have an optional "parent" inherit from or the implicit
System.Object class (for normal builds, builds with /nostdlib
will allow you to compile class System.Object with no parent).
At this point we do some error checking and verify that the
inherits/implements section of a class is correct (since we
have previously built the interface inheritance).
By the time we are done, all classes, structs and interfaces
have been created using System.Reflection.Emit and registered
with the Type Manager.
This allows us to define fields and resolve argument names for
methods, properties, indexers and events.
* Field generation
Fields are generated next, we go through all the type
containers (classes and structs) and enter the fields into
their types.
* Method, Properties, Indexers and events definitions
Now all the methods, constructors, properties, indexers and
events are entered. They are only `defined' using
System.Reflection.Emit. No code generation will happen until
everything has been entered into System.Reflection.Emit.
This is important because to actually generate code we need to
know everything about the environment in which the code is
being generated.
* Code Generation
At this point all the definitions have been entered into the
type manager through System.Reflection.Emit. We can now use
System.Reflection to query all the information about the
types.
Your normal semantic analysis and code generation phase lives
here.
* Statements
Most of the statements are handled in the codegen.cs file.
* Expressions
* Error reporting
Always use `Report::Error' or `Report::Warning' methods of Report
class. The actual Report instance is available via local context.
An expression error reporting has to be done during Resolve phase,
except when it's Emit specific (very rare).
Error reporting should try to use the same codes that the
Microsoft compiler uses (if only so we can track which errors
we handle and which ones we dont).
If there is an error which is specific to MSC, use negative
numbers, and register the number in mcs/errors/errors.txt
Try to write a test case for any error that you run into the
code of the compiler if there is none already.
Put your test case in a file called csNNNN.cs in the
mcs/errors directory, and have the first two lines be:
// csNNNN.cs: This is the error message
// Line: XXX
// Compiler options: an optional compiler options
Where `XXX' is the line where the error ocurrs. We will later
use this as a regression test suite for catching errors in the
compiler.

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

@ -78,11 +78,9 @@ namespace Mono.CSharp { @@ -78,11 +78,9 @@ namespace Mono.CSharp {
{
var results = new List<string> ();
AppendResults (results, Prefix, ec.Module.Evaluator.GetVarNames ());
AppendResults (results, Prefix, ec.CurrentMemberDefinition.Parent.NamespaceEntry.CompletionGetTypesStartingWith (Prefix));
AppendResults (results, Prefix, ec.Module.Evaluator.GetUsingList ());
throw new CompletionResult (Prefix, results.ToArray ());
ec.CurrentMemberDefinition.GetCompletionStartingWith (Prefix, results);
throw new CompletionResult (Prefix, results.Distinct ().Select (l => l.Substring (Prefix.Length)).ToArray ());
}
protected override void CloneTo (CloneContext clonectx, Expression t)
@ -140,17 +138,9 @@ namespace Mono.CSharp { @@ -140,17 +138,9 @@ namespace Mono.CSharp {
else
namespaced_partial = nexpr.Name + "." + partial_name;
#if false
Console.WriteLine ("Workign with: namespaced partial {0}", namespaced_partial);
foreach (var x in ec.TypeContainer.NamespaceEntry.CompletionGetTypesStartingWith (ec.TypeContainer, namespaced_partial)){
Console.WriteLine (" {0}", x);
}
#endif
CompletionSimpleName.AppendResults (
results,
partial_name,
ec.CurrentMemberDefinition.Parent.NamespaceEntry.CompletionGetTypesStartingWith (namespaced_partial));
ec.CurrentMemberDefinition.GetCompletionStartingWith (namespaced_partial, results);
if (partial_name != null)
results = results.Select (l => l.Substring (partial_name.Length)).ToList ();
} else {
var r = MemberCache.GetCompletitionMembers (ec, expr_type, partial_name).Select (l => l.Name);
AppendResults (results, partial_name, r);

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

@ -26,7 +26,7 @@ namespace Mono.CSharp { @@ -26,7 +26,7 @@ namespace Mono.CSharp {
Modifiers.INTERNAL |
Modifiers.PRIVATE;
public Const (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
public Const (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, AllowedModifiers, name, attrs)
{
ModFlags |= Modifiers.STATIC;
@ -63,12 +63,12 @@ namespace Mono.CSharp { @@ -63,12 +63,12 @@ namespace Mono.CSharp {
if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
int index = Parent.PartialContainer.Constants.IndexOf (this);
foreach (var d in declarators) {
var c = new Const (Parent, t, ModFlags & ~Modifiers.STATIC, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
c.initializer = d.Initializer;
((ConstInitializer) c.initializer).Name = d.Name.Value;
Parent.PartialContainer.Constants.Insert (++index, c);
c.Define ();
Parent.PartialContainer.Members.Add (c);
}
}

17
ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs

@ -37,7 +37,7 @@ namespace Mono.CSharp @@ -37,7 +37,7 @@ namespace Mono.CSharp
//
// A scope type parameters either VAR or MVAR
//
TypeParameter[] CurrentTypeParameters { get; }
TypeParameters CurrentTypeParameters { get; }
//
// A member definition of the context. For partial types definition use
@ -393,7 +393,7 @@ namespace Mono.CSharp @@ -393,7 +393,7 @@ namespace Mono.CSharp
get { return MemberContext.CurrentType; }
}
public TypeParameter[] CurrentTypeParameters {
public TypeParameters CurrentTypeParameters {
get { return MemberContext.CurrentTypeParameters; }
}
@ -586,10 +586,10 @@ namespace Mono.CSharp @@ -586,10 +586,10 @@ namespace Mono.CSharp
Dictionary<string, SourceFile> all_source_files;
public CompilerContext (CompilerSettings settings, Report report)
public CompilerContext (CompilerSettings settings, ReportPrinter reportPrinter)
{
this.settings = settings;
this.report = report;
this.report = new Report (this, reportPrinter);
this.builtin_types = new BuiltinTypes ();
this.TimeReporter = DisabledTimeReporter;
}
@ -620,7 +620,7 @@ namespace Mono.CSharp @@ -620,7 +620,7 @@ namespace Mono.CSharp
}
}
public List<CompilationSourceFile> SourceFiles {
public List<SourceFile> SourceFiles {
get {
return settings.SourceFiles;
}
@ -646,7 +646,7 @@ namespace Mono.CSharp @@ -646,7 +646,7 @@ namespace Mono.CSharp
string path;
if (!Path.IsPathRooted (name)) {
string root = Path.GetDirectoryName (comp_unit.FullPathName);
string root = Path.GetDirectoryName (comp_unit.SourceFile.FullPathName);
path = Path.Combine (root, name);
} else
path = name;
@ -655,7 +655,8 @@ namespace Mono.CSharp @@ -655,7 +655,8 @@ namespace Mono.CSharp
if (all_source_files.TryGetValue (path, out retval))
return retval;
retval = Location.AddFile (name, path);
retval = new SourceFile (name, path, all_source_files.Count + 1);
Location.AddFile (retval);
all_source_files.Add (path, retval);
return retval;
}
@ -681,6 +682,8 @@ namespace Mono.CSharp @@ -681,6 +682,8 @@ namespace Mono.CSharp
/// </summary>
CheckedScope = 1 << 0,
AccurateDebugInfo = 1 << 1,
OmitDebugInfo = 1 << 2,
ConstructorScope = 1 << 3,

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;
}

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

@ -73,7 +73,8 @@ namespace Mono.CSharp @@ -73,7 +73,8 @@ namespace Mono.CSharp
{
int row, column;
string value;
static LocatedToken[] buffer;
static LocatedToken[] buffer = new LocatedToken[0];
static int pos;
private LocatedToken ()
@ -129,8 +130,10 @@ namespace Mono.CSharp @@ -129,8 +130,10 @@ namespace Mono.CSharp
public static void Initialize ()
{
if (buffer == null)
buffer = new LocatedToken [10000];
#if !FULL_AST
if (buffer.Length == 0)
buffer = new LocatedToken [15000];
#endif
pos = 0;
}
@ -158,23 +161,24 @@ namespace Mono.CSharp @@ -158,23 +161,24 @@ namespace Mono.CSharp
Error = 9,
Warning = 10,
Pragma = 11 | CustomArgumentsParsing,
Line = 12,
Line = 12 | CustomArgumentsParsing,
CustomArgumentsParsing = 1 << 10,
RequiresArgument = 1 << 11
}
SeekableStreamReader reader;
SourceFile ref_name;
CompilationSourceFile file_name;
CompilerContext context;
bool hidden = false;
readonly SeekableStreamReader reader;
readonly CompilationSourceFile source_file;
readonly CompilerContext context;
SourceFile current_source;
Location hidden_block_start;
int ref_line = 1;
int line = 1;
int col = 0;
int previous_col;
int current_token;
int tab_size;
readonly int tab_size;
bool handle_get_set = false;
bool handle_remove_add = false;
bool handle_where = false;
@ -263,7 +267,7 @@ namespace Mono.CSharp @@ -263,7 +267,7 @@ namespace Mono.CSharp
//
static readonly KeywordEntry<int>[][] keywords;
static readonly KeywordEntry<PreprocessorDirective>[][] keywords_preprocessor;
static readonly Dictionary<string, object> keyword_strings; // TODO: HashSet
static readonly HashSet<string> keyword_strings;
static readonly NumberStyles styles;
static readonly NumberFormatInfo csharp_format_info;
@ -272,6 +276,9 @@ namespace Mono.CSharp @@ -272,6 +276,9 @@ namespace Mono.CSharp
static readonly char[] pragma_warning_disable = "disable".ToCharArray ();
static readonly char[] pragma_warning_restore = "restore".ToCharArray ();
static readonly char[] pragma_checksum = "checksum".ToCharArray ();
static readonly char[] line_hidden = "hidden".ToCharArray ();
static readonly char[] line_default = "default".ToCharArray ();
static readonly char[] simple_whitespaces = new char[] { ' ', '\t' };
bool startsLine = true;
internal SpecialsBag sbag;
@ -295,12 +302,7 @@ namespace Mono.CSharp @@ -295,12 +302,7 @@ namespace Mono.CSharp
get { return handle_typeof; }
set { handle_typeof = value; }
}
public int TabSize {
get { return tab_size; }
set { tab_size = value; }
}
public XmlCommentState doc_state {
get { return xml_doc_state; }
set {
@ -324,7 +326,7 @@ namespace Mono.CSharp @@ -324,7 +326,7 @@ namespace Mono.CSharp
escaped_identifiers.Add (loc);
}
public bool IsEscapedIdentifier (MemberName name)
public bool IsEscapedIdentifier (ATypeNameExpression name)
{
return escaped_identifiers != null && escaped_identifiers.Contains (name.Location);
}
@ -348,14 +350,27 @@ namespace Mono.CSharp @@ -348,14 +350,27 @@ namespace Mono.CSharp
//
Stack<int> ifstack;
static System.Text.StringBuilder string_builder;
const int max_id_size = 512;
static readonly char[] id_builder = new char [max_id_size];
public static Dictionary<char[], string>[] identifiers = new Dictionary<char[], string>[max_id_size + 1];
const int max_number_size = 512;
static char[] number_builder = new char [max_number_size];
#if FULL_AST
readonly char [] id_builder = new char [max_id_size];
Dictionary<char[], string>[] identifiers = new Dictionary<char[], string>[max_id_size + 1];
char [] number_builder = new char [max_number_size];
int number_pos;
char[] value_builder = new char[256];
#else
static readonly char [] id_builder = new char [max_id_size];
static Dictionary<char[], string>[] identifiers = new Dictionary<char[], string>[max_id_size + 1];
static char [] number_builder = new char [max_number_size];
static int number_pos;
static char[] value_builder = new char[256];
#endif
public int Line {
get {
@ -377,7 +392,7 @@ namespace Mono.CSharp @@ -377,7 +392,7 @@ namespace Mono.CSharp
public int line;
public int ref_line;
public int col;
public bool hidden;
public Location hidden;
public int putback_char;
public int previous_col;
public Stack<int> ifstack;
@ -391,7 +406,7 @@ namespace Mono.CSharp @@ -391,7 +406,7 @@ namespace Mono.CSharp
line = t.line;
ref_line = t.ref_line;
col = t.col;
hidden = t.hidden;
hidden = t.hidden_block_start;
putback_char = t.putback_char;
previous_col = t.previous_col;
if (t.ifstack != null && t.ifstack.Count != 0) {
@ -407,24 +422,22 @@ namespace Mono.CSharp @@ -407,24 +422,22 @@ namespace Mono.CSharp
}
}
public Tokenizer (SeekableStreamReader input, CompilationSourceFile file, CompilerContext ctx)
public Tokenizer (SeekableStreamReader input, CompilationSourceFile file)
{
this.ref_name = file;
this.file_name = file;
this.context = ctx;
this.source_file = file;
this.context = file.Compiler;
this.current_source = file.SourceFile;
reader = input;
putback_char = -1;
xml_comment_buffer = new StringBuilder ();
doc_processing = ctx.Settings.DocumentationFile != null;
doc_processing = context.Settings.DocumentationFile != null;
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
tab_size = 4;
else
tab_size = 8;
tab_size = context.Settings.TabSize;
Mono.CSharp.Location.Push (file, file);
Mono.CSharp.Location.Push (current_source);
}
public void PushPosition ()
@ -440,7 +453,7 @@ namespace Mono.CSharp @@ -440,7 +453,7 @@ namespace Mono.CSharp
ref_line = p.ref_line;
line = p.line;
col = p.col;
hidden = p.hidden;
hidden_block_start = p.hidden;
putback_char = p.putback_char;
previous_col = p.previous_col;
ifstack = p.ifstack;
@ -457,7 +470,7 @@ namespace Mono.CSharp @@ -457,7 +470,7 @@ namespace Mono.CSharp
static void AddKeyword (string kw, int token)
{
keyword_strings.Add (kw, null);
keyword_strings.Add (kw);
AddKeyword (keywords, kw, token);
}
@ -493,7 +506,7 @@ namespace Mono.CSharp @@ -493,7 +506,7 @@ namespace Mono.CSharp
//
static Tokenizer ()
{
keyword_strings = new Dictionary<string, object> ();
keyword_strings = new HashSet<string> ();
// 11 is the length of the longest keyword for now
keywords = new KeywordEntry<int>[11][];
@ -621,8 +634,6 @@ namespace Mono.CSharp @@ -621,8 +634,6 @@ namespace Mono.CSharp
csharp_format_info = NumberFormatInfo.InvariantInfo;
styles = NumberStyles.Float;
string_builder = new System.Text.StringBuilder ();
}
int GetKeyword (char[] id, int id_len)
@ -872,7 +883,7 @@ namespace Mono.CSharp @@ -872,7 +883,7 @@ namespace Mono.CSharp
public Location Location {
get {
return new Location (ref_line, hidden ? -1 : col);
return new Location (ref_line, col);
}
}
@ -900,7 +911,7 @@ namespace Mono.CSharp @@ -900,7 +911,7 @@ namespace Mono.CSharp
public static bool IsKeyword (string s)
{
return keyword_strings.ContainsKey (s);
return keyword_strings.Contains (s);
}
//
@ -1511,9 +1522,16 @@ namespace Mono.CSharp @@ -1511,9 +1522,16 @@ namespace Mono.CSharp
#if FULL_AST
int read_start = reader.Position - 1;
if (c == '.') {
//
// Caller did peek_char
//
--read_start;
}
#endif
number_pos = 0;
var loc = Location;
bool hasLeadingDot = c == '.';
if (c >= '0' && c <= '9'){
if (c == '0'){
@ -1545,7 +1563,6 @@ namespace Mono.CSharp @@ -1545,7 +1563,6 @@ namespace Mono.CSharp
putback ('.');
number_pos--;
val = res = adjust_int (-1, loc);
#if FULL_AST
res.ParsedValue = reader.ReadChars (read_start, reader.Position - 1);
#endif
@ -1595,9 +1612,11 @@ namespace Mono.CSharp @@ -1595,9 +1612,11 @@ namespace Mono.CSharp
}
val = res;
#if FULL_AST
res.ParsedValue = reader.ReadChars (read_start, reader.Position - (type == TypeCode.Empty ? 1 : 0));
var chars = reader.ReadChars (read_start, reader.Position - (type == TypeCode.Empty && c > 0 ? 1 : 0));
if (chars[chars.Length - 1] == '\r')
Array.Resize (ref chars, chars.Length - 1);
res.ParsedValue = chars;
#endif
return Token.LITERAL;
@ -1772,12 +1791,12 @@ namespace Mono.CSharp @@ -1772,12 +1791,12 @@ namespace Mono.CSharp
return reader.Peek ();
}
void putback (int c)
public void putback (int c)
{
if (putback_char != -1){
Console.WriteLine ("Col: " + col);
Console.WriteLine ("Row: " + line);
Console.WriteLine ("Name: " + ref_name.Name);
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");
}
@ -1938,44 +1957,120 @@ namespace Mono.CSharp @@ -1938,44 +1957,120 @@ namespace Mono.CSharp
//
// Handles the #line directive
//
bool PreProcessLine (string arg)
bool PreProcessLine ()
{
if (arg.Length == 0)
return false;
Location loc = Location;
int c;
int length = TokenizePreprocessorIdentifier (out c);
if (length == line_default.Length) {
if (!IsTokenIdentifierEqual (line_default))
return false;
current_source = source_file.SourceFile;
if (!hidden_block_start.IsNull) {
current_source.RegisterHiddenScope (hidden_block_start, loc);
hidden_block_start = Location.Null;
}
if (arg == "default"){
ref_line = line;
ref_name = file_name;
hidden = false;
Location.Push (file_name, ref_name);
Location.Push (current_source);
return true;
} else if (arg == "hidden"){
hidden = true;
}
if (length == line_hidden.Length) {
if (!IsTokenIdentifierEqual (line_hidden))
return false;
if (hidden_block_start.IsNull)
hidden_block_start = loc;
return true;
}
try {
int pos;
if ((pos = arg.IndexOf (' ')) != -1 && pos != 0){
ref_line = System.Int32.Parse (arg.Substring (0, pos));
pos++;
char [] quotes = { '\"' };
string name = arg.Substring (pos). Trim (quotes);
ref_name = context.LookupFile (file_name, name);
file_name.AddIncludeFile (ref_name);
hidden = false;
Location.Push (file_name, ref_name);
} else {
ref_line = System.Int32.Parse (arg);
hidden = false;
if (length != 0 || c < '0' || c > '9') {
//
// Eat any remaining characters to continue parsing on next line
//
while (c != -1 && c != '\n') {
c = get_char ();
}
} catch {
return false;
}
int new_line = TokenizeNumber (c);
if (new_line < 1) {
//
// Eat any remaining characters to continue parsing on next line
//
while (c != -1 && c != '\n') {
c = get_char ();
}
return new_line != 0;
}
c = get_char ();
if (c == ' ') {
// skip over white space
do {
c = get_char ();
} while (c == ' ' || c == '\t');
} else if (c == '"') {
c = 0;
}
if (c != '\n' && c != '/' && c != '"') {
//
// Eat any remaining characters to continue parsing on next line
//
while (c != -1 && c != '\n') {
c = get_char ();
}
Report.Error (1578, loc, "Filename, single-line comment or end-of-line expected");
return true;
}
string new_file_name = null;
if (c == '"') {
new_file_name = TokenizeFileName (ref c);
// skip over white space
while (c == ' ' || c == '\t') {
c = get_char ();
}
}
if (c == '\n') {
} else if (c == '/') {
ReadSingleLineComment ();
} else {
//
// Eat any remaining characters to continue parsing on next line
//
while (c != -1 && c != '\n') {
c = get_char ();
}
Error_EndLineExpected ();
return true;
}
if (new_file_name != null) {
current_source = context.LookupFile (source_file, new_file_name);
source_file.AddIncludeFile (current_source);
Location.Push (current_source);
}
if (!hidden_block_start.IsNull) {
current_source.RegisterHiddenScope (hidden_block_start, loc);
hidden_block_start = Location.Null;
}
ref_line = new_line;
return true;
}
@ -2014,12 +2109,12 @@ namespace Mono.CSharp @@ -2014,12 +2109,12 @@ namespace Mono.CSharp
if (context.Settings.IsConditionalSymbolDefined (ident))
return;
file_name.AddDefine (ident);
source_file.AddDefine (ident);
} else {
//
// #undef ident
//
file_name.AddUndefine (ident);
source_file.AddUndefine (ident);
}
}
@ -2070,26 +2165,13 @@ namespace Mono.CSharp @@ -2070,26 +2165,13 @@ namespace Mono.CSharp
if (c != '"')
return false;
string_builder.Length = 0;
while (c != -1 && c != '\n') {
c = get_char ();
if (c == '"') {
c = get_char ();
break;
}
string_builder.Append ((char) c);
}
if (string_builder.Length == 0) {
Report.Warning (1709, 1, Location, "Filename specified for preprocessor directive is empty");
}
string file_name = TokenizeFileName (ref c);
// TODO: Any white-spaces count
if (c != ' ')
return false;
SourceFile file = context.LookupFile (file_name, string_builder.ToString ());
SourceFile file = context.LookupFile (source_file, file_name);
if (get_char () != '"' || get_char () != '{')
return false;
@ -2156,7 +2238,7 @@ namespace Mono.CSharp @@ -2156,7 +2238,7 @@ namespace Mono.CSharp
}
file.SetChecksum (guid_bytes, checksum_bytes.ToArray ());
ref_name.AutoGenerated = true;
current_source.AutoGenerated = true;
return true;
}
@ -2170,27 +2252,53 @@ namespace Mono.CSharp @@ -2170,27 +2252,53 @@ namespace Mono.CSharp
return true;
}
int TokenizePragmaNumber (ref int c)
int TokenizeNumber (int value)
{
number_pos = 0;
int number;
decimal_digits (value);
uint ui = (uint) (number_builder[0] - '0');
if (c >= '0' && c <= '9') {
decimal_digits (c);
uint ui = (uint) (number_builder[0] - '0');
try {
for (int i = 1; i < number_pos; i++) {
ui = checked ((ui * 10) + ((uint) (number_builder[i] - '0')));
}
try {
for (int i = 1; i < number_pos; i++) {
ui = checked ((ui * 10) + ((uint) (number_builder[i] - '0')));
}
return (int) ui;
} catch (OverflowException) {
Error_NumericConstantTooLong ();
return -1;
}
}
number = (int) ui;
} catch (OverflowException) {
Error_NumericConstantTooLong ();
number = -1;
string TokenizeFileName (ref int c)
{
var string_builder = new StringBuilder ();
while (c != -1 && c != '\n') {
c = get_char ();
if (c == '"') {
c = get_char ();
break;
}
string_builder.Append ((char) c);
}
if (string_builder.Length == 0) {
Report.Warning (1709, 1, Location, "Filename specified for preprocessor directive is empty");
}
return string_builder.ToString ();
}
int TokenizePragmaNumber (ref int c)
{
number_pos = 0;
int number;
if (c >= '0' && c <= '9') {
number = TokenizeNumber (c);
c = get_char ();
@ -2285,9 +2393,9 @@ namespace Mono.CSharp @@ -2285,9 +2393,9 @@ namespace Mono.CSharp
code = TokenizePragmaNumber (ref c);
if (code > 0) {
if (disable) {
Report.RegisterWarningRegion (loc).WarningDisable (loc, code, Report);
Report.RegisterWarningRegion (loc).WarningDisable (loc, code, context.Report);
} else {
Report.RegisterWarningRegion (loc).WarningEnable (loc, code, Report);
Report.RegisterWarningRegion (loc).WarningEnable (loc, code, context);
}
}
} while (code >= 0 && c != '\n' && c != -1);
@ -2323,7 +2431,7 @@ namespace Mono.CSharp @@ -2323,7 +2431,7 @@ namespace Mono.CSharp
if (s == "false")
return false;
return file_name.IsConditionalDefined (context, s);
return source_file.IsConditionalDefined (s);
}
bool pp_primary (ref string s)
@ -2713,10 +2821,10 @@ namespace Mono.CSharp @@ -2713,10 +2821,10 @@ namespace Mono.CSharp
return true;
case PreprocessorDirective.Line:
if (!PreProcessLine (arg))
Report.Error (
1576, Location,
"The line number specified for #line directive is missing or invalid");
Location loc = Location;
if (!PreProcessLine ())
Report.Error (1576, loc, "The line number specified for #line directive is missing or invalid");
return caller_is_taking;
}
@ -2895,7 +3003,7 @@ namespace Mono.CSharp @@ -2895,7 +3003,7 @@ namespace Mono.CSharp
return Token.IDENTIFIER;
}
static string InternIdentifier (char[] charBuffer, int length)
string InternIdentifier (char[] charBuffer, int length)
{
//
// Keep identifiers in an array of hashtables to avoid needless

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

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
#if NET_2_1
using XmlElement = System.Object;
@ -36,18 +37,20 @@ namespace Mono.CSharp { @@ -36,18 +37,20 @@ namespace Mono.CSharp {
// Better name would be DottenName
//
[DebuggerDisplay ("{GetSignatureForError()}")]
public class MemberName {
public readonly string Name;
public TypeArguments TypeArguments;
public class MemberName
{
public static readonly MemberName Null = new MemberName ("");
public readonly MemberName Left;
public readonly string Name;
public TypeParameters TypeParameters;
public readonly FullNamedExpression ExplicitInterface;
public readonly Location Location;
public static readonly MemberName Null = new MemberName ("");
public readonly MemberName Left;
bool is_double_colon;
public bool IsDoubleColon { get { return is_double_colon; } }
public MemberName (string name)
: this (name, Location.Null)
{ }
#if FULL_AST
public Location DotLocation {
@ -55,139 +58,102 @@ namespace Mono.CSharp { @@ -55,139 +58,102 @@ namespace Mono.CSharp {
set;
}
#endif
private MemberName (MemberName left, string name, bool is_double_colon,
Location loc)
public MemberName (string name, Location loc)
: this (null, name, loc)
{ }
public MemberName (string name, TypeParameters tparams, Location loc)
{
this.Name = name;
this.Location = loc;
this.is_double_colon = is_double_colon;
this.Left = left;
this.TypeParameters = tparams;
}
private MemberName (MemberName left, string name, bool is_double_colon,
TypeArguments args, Location loc)
: this (left, name, is_double_colon, loc)
public MemberName (string name, TypeParameters tparams, FullNamedExpression explicitInterface, Location loc)
: this (name, tparams, loc)
{
if (args != null && args.Count > 0)
this.TypeArguments = args;
this.ExplicitInterface = explicitInterface;
}
public MemberName (string name)
: this (name, Location.Null)
{ }
public MemberName (string name, Location loc)
: this (null, name, false, loc)
{ }
public MemberName (string name, TypeArguments args, Location loc)
: this (null, name, false, args, loc)
{ }
public MemberName (MemberName left, string name)
: this (left, name, left != null ? left.Location : Location.Null)
{ }
public MemberName (MemberName left, string name, Location loc)
: this (left, name, false, loc)
{ }
public MemberName (MemberName left, string name, TypeArguments args, Location loc)
: this (left, name, false, args, loc)
{ }
public MemberName (string alias, string name, TypeArguments args, Location loc)
: this (new MemberName (alias, loc), name, true, args, loc)
{ }
public MemberName (MemberName left, MemberName right)
: this (left, right, right.Location)
{ }
{
this.Name = name;
this.Location = loc;
this.Left = left;
}
public MemberName (MemberName left, MemberName right, Location loc)
: this (null, right.Name, false, right.TypeArguments, loc)
public MemberName (MemberName left, string name, FullNamedExpression explicitInterface, Location loc)
: this (left, name, loc)
{
if (right.is_double_colon)
throw new InternalErrorException ("Cannot append double_colon member name");
this.Left = (right.Left == null) ? left : new MemberName (left, right.Left);
this.ExplicitInterface = explicitInterface;
}
// TODO: Remove
public string GetName ()
public MemberName (MemberName left, MemberName right)
{
return GetName (false);
this.Name = right.Name;
this.Location = right.Location;
this.TypeParameters = right.TypeParameters;
this.Left = left;
}
public int Arity {
get {
return TypeArguments == null ? 0 : TypeArguments.Count;
return TypeParameters == null ? 0 : TypeParameters.Count;
}
}
public bool IsGeneric {
get {
if (TypeArguments != null)
return true;
else if (Left != null)
return Left.IsGeneric;
else
return false;
return TypeParameters != null;
}
}
public string GetName (bool is_generic)
{
string name = is_generic ? Basename : Name;
if (Left != null)
return Left.GetName (is_generic) + (is_double_colon ? "::" : ".") + name;
return name;
public string Basename {
get {
if (TypeParameters != null)
return MakeName (Name, TypeParameters);
return Name;
}
}
public ATypeNameExpression GetTypeExpression ()
public void CreateMetadataName (StringBuilder sb)
{
if (Left == null) {
if (TypeArguments != null)
return new SimpleName (Name, TypeArguments, Location);
return new SimpleName (Name, Location);
}
if (Left != null)
Left.CreateMetadataName (sb);
if (is_double_colon) {
if (Left.Left != null)
throw new InternalErrorException ("The left side of a :: should be an identifier");
return new QualifiedAliasMember (Left.Name, Name, TypeArguments, Location);
if (sb.Length != 0) {
sb.Append (".");
}
Expression lexpr = Left.GetTypeExpression ();
var result = new MemberAccess (lexpr, Name, TypeArguments, Location);
#if FULL_AST
result.DotLocation = DotLocation;
#endif
return result;
sb.Append (Basename);
}
public MemberName Clone ()
public string GetSignatureForDocumentation ()
{
MemberName left_clone = Left == null ? null : Left.Clone ();
return new MemberName (left_clone, Name, is_double_colon, TypeArguments, Location);
}
var s = Basename;
public string Basename {
get {
if (TypeArguments != null)
return MakeName (Name, TypeArguments);
return Name;
}
if (ExplicitInterface != null)
s = ExplicitInterface.GetSignatureForError () + "." + s;
if (Left == null)
return s;
return Left.GetSignatureForDocumentation () + "." + s;
}
public string GetSignatureForError ()
{
string append = TypeArguments == null ? "" : "<" + TypeArguments.GetSignatureForError () + ">";
string s = TypeParameters == null ? null : "<" + TypeParameters.GetSignatureForError () + ">";
s = Name + s;
if (ExplicitInterface != null)
s = ExplicitInterface.GetSignatureForError () + "." + s;
if (Left == null)
return Name + append;
string connect = is_double_colon ? "::" : ".";
return Left.GetSignatureForError () + connect + Name + append;
return s;
return Left.GetSignatureForError () + "." + s;
}
public override bool Equals (object other)
@ -201,14 +167,12 @@ namespace Mono.CSharp { @@ -201,14 +167,12 @@ namespace Mono.CSharp {
return true;
if (other == null || Name != other.Name)
return false;
if (is_double_colon != other.is_double_colon)
return false;
if ((TypeArguments != null) &&
(other.TypeArguments == null || TypeArguments.Count != other.TypeArguments.Count))
if ((TypeParameters != null) &&
(other.TypeParameters == null || TypeParameters.Count != other.TypeParameters.Count))
return false;
if ((TypeArguments == null) && (other.TypeArguments != null))
if ((TypeParameters == null) && (other.TypeParameters != null))
return false;
if (Left == null)
@ -222,27 +186,14 @@ namespace Mono.CSharp { @@ -222,27 +186,14 @@ namespace Mono.CSharp {
int hash = Name.GetHashCode ();
for (MemberName n = Left; n != null; n = n.Left)
hash ^= n.Name.GetHashCode ();
if (is_double_colon)
hash ^= 0xbadc01d;
if (TypeArguments != null)
hash ^= TypeArguments.Count << 5;
if (TypeParameters != null)
hash ^= TypeParameters.Count << 5;
return hash & 0x7FFFFFFF;
}
public int CountTypeArguments {
get {
if (TypeArguments != null)
return TypeArguments.Count;
else if (Left != null)
return Left.CountTypeArguments;
else
return 0;
}
}
public static string MakeName (string name, TypeArguments args)
public static string MakeName (string name, TypeParameters args)
{
if (args == null)
return name;
@ -275,20 +226,6 @@ namespace Mono.CSharp { @@ -275,20 +226,6 @@ namespace Mono.CSharp {
[System.Diagnostics.DebuggerDisplay ("{GetSignatureForError()}")]
public abstract class MemberCore : Attributable, IMemberContext, IMemberDefinition
{
/// <summary>
/// Public name
/// </summary>
protected string cached_name;
// TODO: Remove in favor of MemberName
public string Name {
get {
if (cached_name == null)
cached_name = MemberName.GetName (!(this is GenericMethod) && !(this is Method));
return cached_name;
}
}
string IMemberDefinition.Name {
get {
return member_name.Name;
@ -359,7 +296,9 @@ namespace Mono.CSharp { @@ -359,7 +296,9 @@ namespace Mono.CSharp {
IsAssigned = 1 << 12, // Field is assigned
HasExplicitLayout = 1 << 13,
PartialDefinitionExists = 1 << 14, // Set when corresponding partial method definition exists
HasStructLayout = 1 << 15 // Has StructLayoutAttribute
HasStructLayout = 1 << 15, // Has StructLayoutAttribute
HasInstanceConstructor = 1 << 16,
HasUserOperators = 1 << 17
}
/// <summary>
@ -367,9 +306,9 @@ namespace Mono.CSharp { @@ -367,9 +306,9 @@ namespace Mono.CSharp {
/// </summary>
internal Flags caching_flags;
public MemberCore (DeclSpace parent, MemberName name, Attributes attrs)
public MemberCore (TypeContainer parent, MemberName name, Attributes attrs)
{
this.Parent = parent as TypeContainer;
this.Parent = parent;
member_name = name;
caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected;
AddAttributes (attrs, this);
@ -378,7 +317,6 @@ namespace Mono.CSharp { @@ -378,7 +317,6 @@ namespace Mono.CSharp {
protected virtual void SetMemberName (MemberName new_name)
{
member_name = new_name;
cached_name = null;
}
public virtual void Accept (StructuralVisitor visitor)
@ -468,10 +406,11 @@ namespace Mono.CSharp { @@ -468,10 +406,11 @@ namespace Mono.CSharp {
//
public virtual string GetSignatureForError ()
{
if (Parent == null || Parent.Parent == null)
var parent = Parent.GetSignatureForError ();
if (parent == null)
return member_name.GetSignatureForError ();
return Parent.GetSignatureForError () + "." + member_name.GetSignatureForError ();
return parent + "." + member_name.GetSignatureForError ();
}
/// <summary>
@ -522,6 +461,26 @@ namespace Mono.CSharp { @@ -522,6 +461,26 @@ namespace Mono.CSharp {
caching_flags |= Flags.IsAssigned;
}
public void SetConstraints (List<Constraints> constraints_list)
{
var tparams = member_name.TypeParameters;
if (tparams == null) {
Report.Error (80, Location, "Constraints are not allowed on non-generic declarations");
return;
}
foreach (var c in constraints_list) {
var tp = tparams.Find (c.TypeParameter.Value);
if (tp == null) {
Report.Error (699, c.Location, "`{0}': A constraint references nonexistent type parameter `{1}'",
GetSignatureForError (), c.TypeParameter.Value);
continue;
}
tp.Constraints = c;
}
}
/// <summary>
/// Returns instance of ObsoleteAttribute for this MemberCore
/// </summary>
@ -603,7 +562,7 @@ namespace Mono.CSharp { @@ -603,7 +562,7 @@ namespace Mono.CSharp {
case Modifiers.PROTECTED:
if (al == Modifiers.PROTECTED) {
same_access_restrictions = mc.Parent.IsBaseTypeDefinition (p_parent);
same_access_restrictions = mc.Parent.PartialContainer.IsBaseTypeDefinition (p_parent);
break;
}
@ -612,8 +571,8 @@ namespace Mono.CSharp { @@ -612,8 +571,8 @@ namespace Mono.CSharp {
// When type is private and any of its parents derives from
// protected type then the type is accessible
//
while (mc.Parent != null) {
if (mc.Parent.IsBaseTypeDefinition (p_parent))
while (mc.Parent != null && mc.Parent.PartialContainer != null) {
if (mc.Parent.PartialContainer.IsBaseTypeDefinition (p_parent))
same_access_restrictions = true;
mc = mc.Parent;
}
@ -625,7 +584,7 @@ namespace Mono.CSharp { @@ -625,7 +584,7 @@ namespace Mono.CSharp {
if (al == Modifiers.INTERNAL)
same_access_restrictions = p.MemberDefinition.IsInternalAsPublic (mc.Module.DeclaringAssembly);
else if (al == (Modifiers.PROTECTED | Modifiers.INTERNAL))
same_access_restrictions = mc.Parent.IsBaseTypeDefinition (p_parent) && p.MemberDefinition.IsInternalAsPublic (mc.Module.DeclaringAssembly);
same_access_restrictions = mc.Parent.PartialContainer.IsBaseTypeDefinition (p_parent) && p.MemberDefinition.IsInternalAsPublic (mc.Module.DeclaringAssembly);
else
goto case Modifiers.PROTECTED;
@ -639,7 +598,7 @@ namespace Mono.CSharp { @@ -639,7 +598,7 @@ namespace Mono.CSharp {
var decl = mc.Parent;
do {
same_access_restrictions = decl.CurrentType == p_parent;
} while (!same_access_restrictions && !decl.IsTopLevel && (decl = decl.Parent) != null);
} while (!same_access_restrictions && !decl.PartialContainer.IsTopLevel && (decl = decl.Parent) != null);
}
break;
@ -674,7 +633,7 @@ namespace Mono.CSharp { @@ -674,7 +633,7 @@ namespace Mono.CSharp {
return true;
}
if (Parent.PartialContainer.IsClsComplianceRequired ()) {
if (Parent.IsClsComplianceRequired ()) {
caching_flags |= Flags.ClsCompliant;
return true;
}
@ -693,25 +652,40 @@ namespace Mono.CSharp { @@ -693,25 +652,40 @@ namespace Mono.CSharp {
public bool IsExposedFromAssembly ()
{
if ((ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0)
return false;
return this is NamespaceContainer;
DeclSpace parentContainer = Parent.PartialContainer;
while (parentContainer != null && parentContainer.ModFlags != 0) {
var parentContainer = Parent.PartialContainer;
while (parentContainer != null) {
if ((parentContainer.ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0)
return false;
parentContainer = parentContainer.Parent;
parentContainer = parentContainer.Parent.PartialContainer;
}
return true;
}
public virtual ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
//
// Does extension methods look up to find a method which matches name and extensionType.
// Search starts from this namespace and continues hierarchically up to top level.
//
public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
{
return Parent.LookupExtensionMethod (extensionType, name, arity);
var m = Parent;
do {
var ns = m as NamespaceContainer;
if (ns != null)
return ns.LookupExtensionMethod (this, extensionType, name, arity, ns, 0);
m = m.Parent;
} while (m != null);
return null;
}
public virtual FullNamedExpression LookupNamespaceAlias (string name)
{
return Parent.NamespaceEntry.LookupNamespaceAlias (name);
return Parent.LookupNamespaceAlias (name);
}
public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
@ -797,7 +771,7 @@ namespace Mono.CSharp { @@ -797,7 +771,7 @@ namespace Mono.CSharp {
}
if ((caching_flags & Flags.ClsCompliantAttributeFalse) != 0) {
if (Parent.Kind == MemberKind.Interface && Parent.IsClsComplianceRequired ()) {
if (Parent is Interface && Parent.IsClsComplianceRequired ()) {
Report.Warning (3010, 1, Location, "`{0}': CLS-compliant interfaces must have only CLS-compliant members", GetSignatureForError ());
} else if (Parent.Kind == MemberKind.Class && (ModFlags & Modifiers.ABSTRACT) != 0 && Parent.IsClsComplianceRequired ()) {
Report.Warning (3011, 1, Location, "`{0}': only CLS-compliant members can be abstract", GetSignatureForError ());
@ -806,7 +780,7 @@ namespace Mono.CSharp { @@ -806,7 +780,7 @@ namespace Mono.CSharp {
return false;
}
if (Parent.Parent != null && !Parent.IsClsComplianceRequired ()) {
if (Parent.Kind != MemberKind.Namespace && Parent.Kind != 0 && !Parent.IsClsComplianceRequired ()) {
Attribute a = OptAttributes.Search (Module.PredefinedAttributes.CLSCompliant);
Report.Warning (3018, 1, a.Location, "`{0}' cannot be marked as CLS-compliant because it is a member of non CLS-compliant type `{1}'",
GetSignatureForError (), Parent.GetSignatureForError ());
@ -816,23 +790,36 @@ namespace Mono.CSharp { @@ -816,23 +790,36 @@ namespace Mono.CSharp {
if (!IsExposedFromAssembly ())
return false;
if (!Parent.PartialContainer.IsClsComplianceRequired ())
if (!Parent.IsClsComplianceRequired ())
return false;
}
if (member_name.Name [0] == '_') {
Report.Warning (3008, 1, Location, "Identifier `{0}' is not CLS-compliant", GetSignatureForError () );
Warning_IdentifierNotCompliant ();
}
if (member_name.TypeParameters != null)
member_name.TypeParameters.VerifyClsCompliance ();
return true;
}
protected void Warning_IdentifierNotCompliant ()
{
Report.Warning (3008, 1, MemberName.Location, "Identifier `{0}' is not CLS-compliant", GetSignatureForError ());
}
//
// Returns a string that represents the signature for this
// member which should be used in XML documentation.
//
public abstract string GetSignatureForDocumentation ();
public virtual void GetCompletionStartingWith (string prefix, List<string> results)
{
Parent.GetCompletionStartingWith (prefix, results);
}
//
// Generates xml doc comments (if any), and if required,
// handle warning report.
@ -860,7 +847,9 @@ namespace Mono.CSharp { @@ -860,7 +847,9 @@ namespace Mono.CSharp {
#region IMemberContext Members
public virtual CompilerContext Compiler {
get { return Parent.Compiler; }
get {
return Module.Compiler;
}
}
public virtual TypeSpec CurrentType {
@ -871,7 +860,7 @@ namespace Mono.CSharp { @@ -871,7 +860,7 @@ namespace Mono.CSharp {
get { return this; }
}
public virtual TypeParameter[] CurrentTypeParameters {
public virtual TypeParameters CurrentTypeParameters {
get { return null; }
}
@ -1109,7 +1098,13 @@ namespace Mono.CSharp { @@ -1109,7 +1098,13 @@ namespace Mono.CSharp {
public virtual string GetSignatureForError ()
{
var bf = MemberDefinition as Property.BackingField;
var name = bf == null ? Name : bf.OriginalName;
string name;
if (bf == null) {
name = Name;
} else {
name = bf.OriginalProperty.MemberName.Name;
}
return DeclaringType.GetSignatureForError () + "." + name;
}
@ -1204,7 +1199,7 @@ namespace Mono.CSharp { @@ -1204,7 +1199,7 @@ namespace Mono.CSharp {
return (state & StateFlags.CLSCompliant) != 0;
}
public bool IsConditionallyExcluded (CompilerContext ctx, Location loc)
public bool IsConditionallyExcluded (IMemberContext ctx, Location loc)
{
if ((Kind & (MemberKind.Class | MemberKind.Method)) == 0)
return false;
@ -1213,9 +1208,18 @@ namespace Mono.CSharp { @@ -1213,9 +1208,18 @@ namespace Mono.CSharp {
if (conditions == null)
return false;
foreach (var condition in conditions) {
if (loc.CompilationUnit.IsConditionalDefined (ctx, condition))
return false;
var m = ctx.CurrentMemberDefinition;
CompilationSourceFile unit = null;
while (m != null && unit == null) {
unit = m as CompilationSourceFile;
m = m.Parent;
}
if (unit != null) {
foreach (var condition in conditions) {
if (unit.IsConditionalDefined (condition))
return false;
}
}
return true;
@ -1252,331 +1256,4 @@ namespace Mono.CSharp { @@ -1252,331 +1256,4 @@ namespace Mono.CSharp {
{
TypeSpec MemberType { get; }
}
//
// Base type container declaration. It exists to handle partial types
// which share same definition (PartialContainer) but have different
// resolve scopes
//
public abstract class DeclSpace : MemberCore {
/// <summary>
/// This points to the actual definition that is being
/// created with System.Reflection.Emit
/// </summary>
public TypeBuilder TypeBuilder;
//
// This is the namespace in which this typecontainer
// was declared. We use this to resolve names.
//
public NamespaceContainer NamespaceEntry;
public readonly string Basename;
protected Dictionary<string, MemberCore> defined_names;
public TypeContainer PartialContainer;
protected readonly bool is_generic;
readonly int count_type_params;
protected TypeParameter[] type_params;
TypeParameter[] type_param_list;
//
// Whether we are Generic
//
public bool IsGeneric {
get {
if (is_generic)
return true;
else if (Parent != null)
return Parent.IsGeneric;
else
return false;
}
}
static readonly string[] attribute_targets = new string [] { "type" };
public DeclSpace (NamespaceContainer ns, DeclSpace parent, MemberName name,
Attributes attrs)
: base (parent, name, attrs)
{
NamespaceEntry = ns;
Basename = name.Basename;
defined_names = new Dictionary<string, MemberCore> ();
PartialContainer = null;
if (name.TypeArguments != null) {
is_generic = true;
count_type_params = name.TypeArguments.Count;
}
if (parent != null)
count_type_params += parent.count_type_params;
}
/// <summary>
/// Adds the member to defined_names table. It tests for duplications and enclosing name conflicts
/// </summary>
protected virtual bool AddToContainer (MemberCore symbol, string name)
{
MemberCore mc;
if (!defined_names.TryGetValue (name, out mc)) {
defined_names.Add (name, symbol);
return true;
}
if (((mc.ModFlags | symbol.ModFlags) & Modifiers.COMPILER_GENERATED) != 0)
return true;
if (symbol.EnableOverloadChecks (mc))
return true;
InterfaceMemberBase im = mc as InterfaceMemberBase;
if (im != null && im.IsExplicitImpl)
return true;
Report.SymbolRelatedToPreviousError (mc);
if ((mc.ModFlags & Modifiers.PARTIAL) != 0 && (symbol is ClassOrStruct || symbol is Interface)) {
Error_MissingPartialModifier (symbol);
return false;
}
if (symbol is TypeParameter) {
Report.Error (692, symbol.Location,
"Duplicate type parameter `{0}'", symbol.GetSignatureForError ());
} else {
Report.Error (102, symbol.Location,
"The type `{0}' already contains a definition for `{1}'",
GetSignatureForError (), name);
}
return false;
}
protected void RemoveFromContainer (string name)
{
defined_names.Remove (name);
}
/// <summary>
/// Returns the MemberCore associated with a given name in the declaration
/// space. It doesn't return method based symbols !!
/// </summary>
///
public MemberCore GetDefinition (string name)
{
MemberCore mc = null;
defined_names.TryGetValue (name, out mc);
return mc;
}
//
// root_types contains all the types. All TopLevel types
// hence have a parent that points to `root_types', that is
// why there is a non-obvious test down here.
//
public bool IsTopLevel {
get { return (Parent != null && Parent.Parent == null); }
}
public virtual bool IsUnmanagedType ()
{
return false;
}
protected abstract TypeAttributes TypeAttr { get; }
/// <remarks>
/// Should be overriten by the appropriate declaration space
/// </remarks>
public abstract void DefineType ();
protected void Error_MissingPartialModifier (MemberCore type)
{
Report.Error (260, type.Location,
"Missing partial modifier on declaration of type `{0}'. Another partial declaration of this type exists",
type.GetSignatureForError ());
}
public override string GetSignatureForDocumentation ()
{
return Name;
}
public override string GetSignatureForError ()
{
return MemberName.GetSignatureForError ();
}
TypeParameter[] initialize_type_params ()
{
if (type_param_list != null)
return type_param_list;
DeclSpace the_parent = Parent;
if (this is GenericMethod)
the_parent = null;
var list = new List<TypeParameter> ();
if (the_parent != null && the_parent.IsGeneric) {
// FIXME: move generics info out of DeclSpace
TypeParameter[] parent_params = the_parent.TypeParameters;
list.AddRange (parent_params);
}
int count = type_params != null ? type_params.Length : 0;
for (int i = 0; i < count; i++) {
TypeParameter param = type_params [i];
list.Add (param);
if (Parent.CurrentTypeParameters != null) {
foreach (TypeParameter tp in Parent.CurrentTypeParameters) {
if (tp.Name != param.Name)
continue;
Report.SymbolRelatedToPreviousError (tp.Location, null);
Report.Warning (693, 3, param.Location,
"Type parameter `{0}' has the same name as the type parameter from outer type `{1}'",
param.Name, Parent.GetSignatureForError ());
}
}
}
type_param_list = new TypeParameter [list.Count];
list.CopyTo (type_param_list, 0);
return type_param_list;
}
#if FULL_AST
public List<Constraints> PlainConstraints {
get;
private set;
}
public bool HasOptionalSemicolon {
get;
private set;
}
Location optionalSemicolon;
public Location OptionalSemicolon {
get {
return optionalSemicolon;
}
set {
optionalSemicolon = value;
HasOptionalSemicolon = true;
}
}
#endif
public List<Constraints> Constraints {
get;
private set;
}
public virtual void SetParameterInfo (List<Constraints> constraints_list)
{
#if FULL_AST
if (constraints_list != null) {
this.PlainConstraints = constraints_list;
constraints_list = this.Constraints = new List<Constraints> (constraints_list);
}
#else
this.Constraints = constraints_list;
#endif
if (!is_generic) {
if (constraints_list != null) {
Report.Error (
80, Location, "Constraints are not allowed " +
"on non-generic declarations");
}
return;
}
TypeParameterName[] names = MemberName.TypeArguments.GetDeclarations ();
type_params = new TypeParameter [names.Length];
//
// Register all the names
//
for (int i = 0; i < type_params.Length; i++) {
TypeParameterName name = names [i];
Constraints constraints = null;
if (constraints_list != null) {
int total = constraints_list.Count;
for (int ii = 0; ii < total; ++ii) {
Constraints constraints_at = (Constraints)constraints_list[ii];
// TODO: it is used by iterators only
if (constraints_at == null) {
constraints_list.RemoveAt (ii);
--total;
continue;
}
if (constraints_at.TypeParameter.Value == name.Name) {
constraints = constraints_at;
constraints_list.RemoveAt(ii);
break;
}
}
}
Variance variance = name.Variance;
if (name.Variance != Variance.None && !(this is Delegate || this is Interface)) {
Report.Error (1960, name.Location, "Variant type parameters can only be used with interfaces and delegates");
variance = Variance.None;
}
type_params [i] = new TypeParameter (
Parent, i, new MemberName (name.Name, Location), constraints, name.OptAttributes, variance);
AddToContainer (type_params [i], name.Name);
}
if (constraints_list != null && constraints_list.Count > 0) {
foreach (Constraints constraint in constraints_list) {
Report.Error(699, constraint.Location, "`{0}': A constraint references nonexistent type parameter `{1}'",
GetSignatureForError (), constraint.TypeParameter.Value);
}
}
}
protected TypeParameter[] TypeParameters {
get {
if (!IsGeneric)
throw new InvalidOperationException ();
if ((PartialContainer != null) && (PartialContainer != this))
return PartialContainer.TypeParameters;
if (type_param_list == null)
initialize_type_params ();
return type_param_list;
}
}
public int CountTypeParameters {
get {
return count_type_params;
}
}
public override string[] ValidAttributeTargets {
get { return attribute_targets; }
}
protected override bool VerifyClsCompliance ()
{
if (!base.VerifyClsCompliance ()) {
return false;
}
if (type_params != null) {
foreach (TypeParameter tp in type_params) {
tp.VerifyClsCompliance ();
}
}
return true;
}
}
}

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

@ -28,7 +28,7 @@ namespace Mono.CSharp { @@ -28,7 +28,7 @@ namespace Mono.CSharp {
//
// Delegate container implementation
//
public class Delegate : TypeContainer, IParametersMember
public class Delegate : TypeDefinition, IParametersMember
{
public FullNamedExpression ReturnType;
readonly ParametersCompiled parameters;
@ -55,10 +55,9 @@ namespace Mono.CSharp { @@ -55,10 +55,9 @@ namespace Mono.CSharp {
Modifiers.UNSAFE |
Modifiers.PRIVATE;
public Delegate (NamespaceContainer ns, DeclSpace parent, FullNamedExpression type,
Modifiers mod_flags, MemberName name, ParametersCompiled param_list,
public Delegate (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, ParametersCompiled param_list,
Attributes attrs)
: base (ns, parent, name, attrs, MemberKind.Delegate)
: base (parent, name, attrs, MemberKind.Delegate)
{
this.ReturnType = type;
@ -81,6 +80,13 @@ namespace Mono.CSharp { @@ -81,6 +80,13 @@ namespace Mono.CSharp {
return parameters;
}
}
public FullNamedExpression TypExpression {
get {
return ReturnType;
}
}
#endregion
public override void Accept (StructuralVisitor visitor)
@ -123,7 +129,7 @@ namespace Mono.CSharp { @@ -123,7 +129,7 @@ namespace Mono.CSharp {
);
Constructor = new Constructor (this, Constructor.ConstructorName,
Modifiers.PUBLIC, null, ctor_parameters, null, Location);
Modifiers.PUBLIC, null, ctor_parameters, Location);
Constructor.Define ();
//
@ -178,7 +184,7 @@ namespace Mono.CSharp { @@ -178,7 +184,7 @@ namespace Mono.CSharp {
TypeManager.CheckTypeVariance (ret_type, Variance.Covariant, this);
var resolved_rt = new TypeExpression (ret_type, Location);
InvokeBuilder = new Method (this, null, resolved_rt, MethodModifiers, new MemberName (InvokeMethodName), p, null);
InvokeBuilder = new Method (this, resolved_rt, MethodModifiers, new MemberName (InvokeMethodName), p, null);
InvokeBuilder.Define ();
//
@ -232,7 +238,7 @@ namespace Mono.CSharp { @@ -232,7 +238,7 @@ namespace Mono.CSharp {
}
);
BeginInvokeBuilder = new Method (this, null,
BeginInvokeBuilder = new Method (this,
new TypeExpression (iasync_result.TypeSpec, Location), MethodModifiers,
new MemberName ("BeginInvoke"), async_parameters, null);
BeginInvokeBuilder.Define ();
@ -282,19 +288,21 @@ namespace Mono.CSharp { @@ -282,19 +288,21 @@ namespace Mono.CSharp {
//
// Create method, define parameters, register parameters with type system
//
EndInvokeBuilder = new Method (this, null, returnType, MethodModifiers, new MemberName ("EndInvoke"), end_parameters, null);
EndInvokeBuilder = new Method (this, returnType, MethodModifiers, new MemberName ("EndInvoke"), end_parameters, null);
EndInvokeBuilder.Define ();
}
public override void DefineConstants ()
public override void PrepareEmit ()
{
if (!Parameters.IsEmpty) {
parameters.ResolveDefaultValues (this);
}
}
public override void EmitType ()
public override void Emit ()
{
base.Emit ();
if (ReturnType.Type != null) {
if (ReturnType.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
@ -321,12 +329,6 @@ namespace Mono.CSharp { @@ -321,12 +329,6 @@ namespace Mono.CSharp {
BeginInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
EndInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
}
if (OptAttributes != null) {
OptAttributes.Emit ();
}
base.Emit ();
}
protected override TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class)
@ -338,9 +340,7 @@ namespace Mono.CSharp { @@ -338,9 +340,7 @@ namespace Mono.CSharp {
protected override TypeAttributes TypeAttr {
get {
return ModifiersExtensions.TypeAttr (ModFlags, IsTopLevel) |
TypeAttributes.Class | TypeAttributes.Sealed |
base.TypeAttr;
return base.TypeAttr | TypeAttributes.Class | TypeAttributes.Sealed;
}
}
@ -525,7 +525,7 @@ namespace Mono.CSharp { @@ -525,7 +525,7 @@ namespace Mono.CSharp {
Error_ConversionFailed (ec, delegate_method, ret_expr);
}
if (delegate_method.IsConditionallyExcluded (ec.Module.Compiler, loc)) {
if (delegate_method.IsConditionallyExcluded (ec, loc)) {
ec.Report.SymbolRelatedToPreviousError (delegate_method);
MethodOrOperator m = delegate_method.MemberDefinition as MethodOrOperator;
if (m != null && m.IsPartialDefinition) {

154
ICSharpCode.NRefactory.CSharp/Parser/mcs/dmcs.csproj

@ -1,154 +0,0 @@ @@ -1,154 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>dmcs</RootNamespace>
<AssemblyName>dmcs</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET_4_0;MS_COMPATIBLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE;NET_2_0;MS_COMPATIBLE;GMCS_SOURCE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<OutputPath>.\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\build\common\Consts.cs">
</Compile>
<Compile Include="..\class\corlib\Mono.Security.Cryptography\CryptoConvert.cs">
<Link>CryptoConvert.cs</Link>
</Compile>
<Compile Include="..\class\Mono.CompilerServices.SymbolWriter\MonoSymbolFile.cs">
<Link>MonoSymbolFile.cs</Link>
</Compile>
<Compile Include="..\class\Mono.CompilerServices.SymbolWriter\MonoSymbolTable.cs">
<Link>MonoSymbolTable.cs</Link>
</Compile>
<Compile Include="..\class\Mono.CompilerServices.SymbolWriter\MonoSymbolWriter.cs">
<Link>MonoSymbolWriter.cs</Link>
</Compile>
<Compile Include="argument.cs" />
<Compile Include="AssemblyInfo.cs">
</Compile>
<Compile Include="anonymous.cs">
</Compile>
<Compile Include="assign.cs">
</Compile>
<Compile Include="attribute.cs">
</Compile>
<Compile Include="cfold.cs">
</Compile>
<Compile Include="class.cs">
</Compile>
<Compile Include="codegen.cs">
</Compile>
<Compile Include="complete.cs" />
<Compile Include="const.cs">
</Compile>
<Compile Include="constant.cs">
</Compile>
<Compile Include="convert.cs">
</Compile>
<Compile Include="context.cs" />
<Compile Include="dynamic.cs" />
<Compile Include="eval.cs" />
<Compile Include="import.cs" />
<Compile Include="lambda.cs">
</Compile>
<Compile Include="cs-parser.cs" />
<Compile Include="cs-tokenizer.cs">
</Compile>
<Compile Include="decl.cs">
</Compile>
<Compile Include="delegate.cs">
</Compile>
<Compile Include="doc.cs">
</Compile>
<Compile Include="driver.cs">
</Compile>
<Compile Include="ecore.cs">
</Compile>
<Compile Include="enum.cs">
</Compile>
<Compile Include="expression.cs">
</Compile>
<Compile Include="flowanalysis.cs">
</Compile>
<Compile Include="generic.cs" />
<Compile Include="iterators.cs">
</Compile>
<Compile Include="literal.cs">
</Compile>
<Compile Include="location.cs">
</Compile>
<Compile Include="membercache.cs" />
<Compile Include="method.cs" />
<Compile Include="modifiers.cs">
</Compile>
<Compile Include="namespace.cs">
</Compile>
<Compile Include="nullable.cs">
</Compile>
<Compile Include="..\tools\monop\outline.cs">
<Link>outline.cs</Link>
</Compile>
<Compile Include="parameter.cs">
</Compile>
<Compile Include="pending.cs">
</Compile>
<Compile Include="property.cs" />
<Compile Include="report.cs">
</Compile>
<Compile Include="rootcontext.cs">
</Compile>
<Compile Include="roottypes.cs">
</Compile>
<Compile Include="statement.cs">
</Compile>
<Compile Include="support.cs">
</Compile>
<Compile Include="symbolwriter.cs">
</Compile>
<Compile Include="typemanager.cs">
</Compile>
<Compile Include="linq.cs" />
<Compile Include="field.cs" />
<Compile Include="typespec.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

6
ICSharpCode.NRefactory.CSharp/Parser/mcs/dmcs.exe.config

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0.30319"/>
</startup>
</configuration>

55
ICSharpCode.NRefactory.CSharp/Parser/mcs/dmcs.exe.sources

@ -1,55 +0,0 @@ @@ -1,55 +0,0 @@
AssemblyInfo.cs
anonymous.cs
argument.cs
assign.cs
attribute.cs
cs-tokenizer.cs
cfold.cs
class.cs
codegen.cs
complete.cs
const.cs
constant.cs
convert.cs
context.cs
decl.cs
delegate.cs
doc.cs
driver.cs
dynamic.cs
ecore.cs
enum.cs
eval.cs
expression.cs
field.cs
flowanalysis.cs
generic.cs
import.cs
iterators.cs
lambda.cs
linq.cs
literal.cs
location.cs
membercache.cs
method.cs
modifiers.cs
namespace.cs
nullable.cs
parameter.cs
pending.cs
property.cs
report.cs
rootcontext.cs
roottypes.cs
statement.cs
support.cs
typemanager.cs
typespec.cs
visit.cs
symbolwriter.cs
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
../class/corlib/Mono.Security.Cryptography/CryptoConvert.cs
../build/common/Consts.cs
../tools/monop/outline.cs

20
ICSharpCode.NRefactory.CSharp/Parser/mcs/dmcs.sln

@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dmcs", "dmcs.csproj", "{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

59
ICSharpCode.NRefactory.CSharp/Parser/mcs/doc-bootstrap.cs

@ -1,59 +0,0 @@ @@ -1,59 +0,0 @@
//
// doc-bootstrap.cs: Stub support for XML documentation.
//
// Author:
// Raja R Harinath <rharinath@novell.com>
//
// Dual licensed under the terms of the MIT X11 or GNU GPL
//
// Copyright 2004 Novell, Inc.
//
//
#if BOOTSTRAP_WITH_OLDLIB || NET_2_1
using XmlElement = System.Object;
namespace Mono.CSharp {
public class DocUtil
{
internal static void GenerateTypeDocComment (TypeContainer t, DeclSpace ds, Report r)
{
}
internal static void GenerateDocComment (MemberCore mc, DeclSpace ds, Report r)
{
}
public static string GetMethodDocCommentName (MemberCore mc, ParametersCompiled p, DeclSpace ds)
{
return "";
}
internal static void OnMethodGenerateDocComment (MethodCore mc, XmlElement el, Report r)
{
}
public static void GenerateEnumDocComment (Enum e, DeclSpace ds)
{
}
}
public class Documentation
{
public Documentation (string xml_output_filename)
{
}
public bool OutputDocComment (string asmfilename, Report r)
{
return true;
}
public void GenerateDocComment ()
{
}
}
}
#endif

37
ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs

@ -32,6 +32,7 @@ namespace Mono.CSharp @@ -32,6 +32,7 @@ namespace Mono.CSharp
readonly XmlDocument XmlDocumentation;
readonly ModuleContainer module;
readonly ModuleContainer doc_module;
//
// The output for XML documentation.
@ -48,6 +49,9 @@ namespace Mono.CSharp @@ -48,6 +49,9 @@ namespace Mono.CSharp
public DocumentationBuilder (ModuleContainer module)
{
doc_module = new ModuleContainer (module.Compiler);
doc_module.DocumentationBuilder = this;
this.module = module;
XmlDocumentation = new XmlDocument ();
XmlDocumentation.PreserveWhitespace = false;
@ -141,7 +145,7 @@ namespace Mono.CSharp @@ -141,7 +145,7 @@ namespace Mono.CSharp
}
// FIXME: it could be done with XmlReader
DeclSpace ds_target = mc as DeclSpace;
var ds_target = mc as TypeContainer;
if (ds_target == null)
ds_target = mc.Parent;
@ -213,7 +217,7 @@ namespace Mono.CSharp @@ -213,7 +217,7 @@ namespace Mono.CSharp
//
// Handles <see> elements.
//
void HandleSee (MemberCore mc, DeclSpace ds, XmlElement see)
void HandleSee (MemberCore mc, TypeContainer ds, XmlElement see)
{
HandleXrefCommon (mc, ds, see);
}
@ -221,7 +225,7 @@ namespace Mono.CSharp @@ -221,7 +225,7 @@ namespace Mono.CSharp
//
// Handles <seealso> elements.
//
void HandleSeeAlso (MemberCore mc, DeclSpace ds, XmlElement seealso)
void HandleSeeAlso (MemberCore mc, TypeContainer ds, XmlElement seealso)
{
HandleXrefCommon (mc, ds, seealso);
}
@ -229,7 +233,7 @@ namespace Mono.CSharp @@ -229,7 +233,7 @@ namespace Mono.CSharp
//
// Handles <exception> elements.
//
void HandleException (MemberCore mc, DeclSpace ds, XmlElement seealso)
void HandleException (MemberCore mc, TypeContainer ds, XmlElement seealso)
{
HandleXrefCommon (mc, ds, seealso);
}
@ -244,10 +248,8 @@ namespace Mono.CSharp @@ -244,10 +248,8 @@ namespace Mono.CSharp
string tp_name = node.GetAttribute ("name");
if (mc.CurrentTypeParameters != null) {
foreach (var tp in mc.CurrentTypeParameters) {
if (tp.Name == tp_name)
return;
}
if (mc.CurrentTypeParameters.Find (tp_name) != null)
return;
}
// TODO: CS1710, CS1712
@ -269,10 +271,8 @@ namespace Mono.CSharp @@ -269,10 +271,8 @@ namespace Mono.CSharp
var member = mc;
do {
if (member.CurrentTypeParameters != null) {
foreach (var tp in member.CurrentTypeParameters) {
if (tp.Name == tp_name)
return;
}
if (member.CurrentTypeParameters.Find (tp_name) != null)
return;
}
member = member.Parent;
@ -308,7 +308,7 @@ namespace Mono.CSharp @@ -308,7 +308,7 @@ namespace Mono.CSharp
//
// Processes "see" or "seealso" elements from cref attribute.
//
void HandleXrefCommon (MemberCore mc, DeclSpace ds, XmlElement xref)
void HandleXrefCommon (MemberCore mc, TypeContainer ds, XmlElement xref)
{
string cref = xref.GetAttribute ("cref");
// when, XmlReader, "if (cref == null)"
@ -326,13 +326,10 @@ namespace Mono.CSharp @@ -326,13 +326,10 @@ namespace Mono.CSharp
var s = new MemoryStream (encoding.GetBytes (cref));
SeekableStreamReader seekable = new SeekableStreamReader (s, encoding);
var source_file = new CompilationSourceFile ("{documentation}", "", 1);
var doc_module = new ModuleContainer (module.Compiler);
doc_module.DocumentationBuilder = this;
source_file.NamespaceContainer = new NamespaceContainer (null, doc_module, null, source_file);
var source_file = new CompilationSourceFile (doc_module);
var report = new Report (doc_module.Compiler, new NullReportPrinter ());
Report parse_report = new Report (new NullReportPrinter ());
var parser = new CSharpParser (seekable, source_file, parse_report);
var parser = new CSharpParser (seekable, source_file, report);
ParsedParameters = null;
ParsedName = null;
ParsedBuiltinType = null;
@ -340,7 +337,7 @@ namespace Mono.CSharp @@ -340,7 +337,7 @@ namespace Mono.CSharp
parser.Lexer.putback_char = Tokenizer.DocumentationXref;
parser.Lexer.parsing_generic_declaration_doc = true;
parser.parse ();
if (parse_report.Errors > 0) {
if (report.Errors > 0) {
Report.Warning (1584, 1, mc.Location, "XML comment on `{0}' has syntactically incorrect cref attribute `{1}'",
mc.GetSignatureForError (), cref);

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

@ -41,20 +41,22 @@ namespace Mono.CSharp @@ -41,20 +41,22 @@ namespace Mono.CSharp
}
}
void tokenize_file (CompilationSourceFile file)
void tokenize_file (SourceFile sourceFile, ModuleContainer module)
{
Stream input;
try {
input = File.OpenRead (file.Name);
input = File.OpenRead (sourceFile.Name);
} catch {
Report.Error (2001, "Source file `" + file.Name + "' could not be found");
Report.Error (2001, "Source file `" + sourceFile.Name + "' could not be found");
return;
}
using (input){
SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding);
Tokenizer lexer = new Tokenizer (reader, file, ctx);
var file = new CompilationSourceFile (module, sourceFile);
Tokenizer lexer = new Tokenizer (reader, file);
int token, tokens = 0, errors = 0;
while ((token = lexer.token ()) != Token.EOF){
@ -70,20 +72,21 @@ namespace Mono.CSharp @@ -70,20 +72,21 @@ namespace Mono.CSharp
void Parse (ModuleContainer module)
{
Location.Initialize (module.Compiler.SourceFiles);
bool tokenize_only = module.Compiler.Settings.TokenizeOnly;
var sources = module.Compiler.SourceFiles;
Location.Initialize (sources);
for (int i = 0; i < sources.Count; ++i) {
if (tokenize_only) {
tokenize_file (sources[i]);
tokenize_file (sources[i], module);
} else {
Parse (sources[i], module);
}
}
}
public void Parse (CompilationSourceFile file, ModuleContainer module)
public void Parse (SourceFile file, ModuleContainer module)
{
Stream input;
@ -96,6 +99,7 @@ namespace Mono.CSharp @@ -96,6 +99,7 @@ namespace Mono.CSharp
// Check 'MZ' header
if (input.ReadByte () == 77 && input.ReadByte () == 90) {
Report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
input.Close ();
return;
@ -107,30 +111,32 @@ namespace Mono.CSharp @@ -107,30 +111,32 @@ namespace Mono.CSharp
Parse (reader, file, module);
reader.Dispose ();
input.Close ();
}
public void Parse (SeekableStreamReader reader, CompilationSourceFile file, ModuleContainer module)
}
public CSharpParser Parse (SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module)
{
file.NamespaceContainer = new NamespaceContainer (null, module, null, file);
var file = new CompilationSourceFile (module, sourceFile);
module.AddTypeContainer (file);
CSharpParser parser = new CSharpParser (reader, file);
parser.Lexer.sbag = new SpecialsBag ();
parser.parse ();
return parser;
}
public static int Main (string[] args)
{
Location.InEmacs = Environment.GetEnvironmentVariable ("EMACS") == "t";
var r = new Report (new ConsoleReportPrinter ());
CommandLineParser cmd = new CommandLineParser (r);
CommandLineParser cmd = new CommandLineParser (Console.Out);
var settings = cmd.ParseArguments (args);
if (settings == null || r.Errors > 0)
if (settings == null)
return 1;
if (cmd.HasBeenStopped)
return 0;
Driver d = new Driver (new CompilerContext (settings, r));
Driver d = new Driver (new CompilerContext (settings, new ConsoleReportPrinter ()));
if (d.Compile () && d.Report.Errors == 0) {
if (d.Report.Warnings > 0) {
@ -263,7 +269,7 @@ namespace Mono.CSharp @@ -263,7 +269,7 @@ namespace Mono.CSharp
// loaded assembly into compiled builder to be resolved
// correctly
tr.Start (TimeReporter.TimerType.CreateTypeTotal);
module.CreateType ();
module.CreateContainer ();
importer.AddCompiledAssembly (assembly);
tr.Stop (TimeReporter.TimerType.CreateTypeTotal);
@ -292,18 +298,12 @@ namespace Mono.CSharp @@ -292,18 +298,12 @@ namespace Mono.CSharp
if (!assembly.Create (AppDomain.CurrentDomain, AssemblyBuilderAccess.Save))
return false;
module.CreateType ();
module.CreateContainer ();
loader.LoadModules (assembly, module.GlobalRootNamespace);
#endif
module.InitializePredefinedTypes ();
tr.Start (TimeReporter.TimerType.UsingResolve);
foreach (var source_file in ctx.SourceFiles) {
source_file.NamespaceContainer.Resolve ();
}
tr.Stop (TimeReporter.TimerType.UsingResolve);
tr.Start (TimeReporter.TimerType.ModuleDefinitionTotal);
module.Define ();
tr.Stop (TimeReporter.TimerType.ModuleDefinitionTotal);
@ -331,7 +331,7 @@ namespace Mono.CSharp @@ -331,7 +331,7 @@ namespace Mono.CSharp
}
tr.Start (TimeReporter.TimerType.CloseTypes);
module.CloseType ();
module.CloseContainer ();
tr.Stop (TimeReporter.TimerType.CloseTypes);
tr.Start (TimeReporter.TimerType.Resouces);
@ -356,26 +356,24 @@ namespace Mono.CSharp @@ -356,26 +356,24 @@ namespace Mono.CSharp
public class CompilerCompilationUnit {
public ModuleContainer ModuleCompiled { get; set; }
public LocationsBag LocationsBag { get; set; }
public UsingsBag UsingsBag { get; set; }
public SpecialsBag SpecialsBag { get; set; }
public object LastYYValue { get; set; }
}
//
// This is the only public entry point
//
public class CompilerCallableEntryPoint : MarshalByRefObject {
public class CompilerCallableEntryPoint : MarshalByRefObject
{
public static bool InvokeCompiler (string [] args, TextWriter error)
{
try {
var r = new Report (new StreamReportPrinter (error));
CommandLineParser cmd = new CommandLineParser (r, error);
CommandLineParser cmd = new CommandLineParser (error);
var setting = cmd.ParseArguments (args);
if (setting == null || r.Errors > 0)
if (setting == null)
return false;
var d = new Driver (new CompilerContext (setting, r));
var d = new Driver (new CompilerContext (setting, new StreamReportPrinter (error)));
return d.Compile ();
} finally {
Reset ();
@ -400,74 +398,15 @@ namespace Mono.CSharp @@ -400,74 +398,15 @@ namespace Mono.CSharp
public static void Reset (bool full_flag)
{
CSharpParser.yacc_verbose_flag = 0;
Location.Reset ();
if (!full_flag)
return;
AnonymousTypeClass.Reset ();
AnonymousMethodBody.Reset ();
AnonymousMethodStorey.Reset ();
SymbolWriter.Reset ();
Switch.Reset ();
Linq.QueryBlock.TransparentParameter.Reset ();
TypeInfo.Reset ();
}
public static CompilerCompilationUnit ParseFile (string[] args, Stream input, string inputFile, TextWriter reportStream)
{
return ParseFile (args, input, inputFile, new StreamReportPrinter (reportStream));
}
internal static object parseLock = new object ();
public static CompilerCompilationUnit ParseFile (string[] args, Stream input, string inputFile, ReportPrinter reportPrinter)
{
lock (parseLock) {
try {
// Driver d = Driver.Create (args, false, null, reportPrinter);
// if (d == null)
// return null;
var r = new Report (reportPrinter);
CommandLineParser cmd = new CommandLineParser (r, Console.Out);
var setting = cmd.ParseArguments (args);
if (setting == null || r.Errors > 0)
return null;
setting.Version = LanguageVersion.V_5;
CompilerContext ctx = new CompilerContext (setting, r);
var files = new List<CompilationSourceFile> ();
var unit = new CompilationSourceFile (inputFile, inputFile, 0);
var module = new ModuleContainer (ctx);
unit.NamespaceContainer = new NamespaceContainer (null, module, null, unit);
files.Add (unit);
Location.Initialize (files);
// TODO: encoding from driver
SeekableStreamReader reader = new SeekableStreamReader (input, Encoding.UTF8);
RootContext.ToplevelTypes = module;
CSharpParser parser = new CSharpParser (reader, unit);
parser.Lexer.TabSize = 1;
parser.Lexer.sbag = new SpecialsBag ();
parser.LocationsBag = new LocationsBag ();
parser.UsingsBag = new UsingsBag ();
parser.parse ();
return new CompilerCompilationUnit () {
ModuleCompiled = RootContext.ToplevelTypes,
LocationsBag = parser.LocationsBag,
UsingsBag = parser.UsingsBag,
SpecialsBag = parser.Lexer.sbag
};
} finally {
Reset ();
}
}
}
}
}

33
ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs

@ -13,7 +13,7 @@ using System; @@ -13,7 +13,7 @@ using System;
using System.Linq;
using SLE = System.Linq.Expressions;
#if NET_4_0
#if NET_4_0 || MONODROID
using System.Dynamic;
#endif
@ -63,7 +63,7 @@ namespace Mono.CSharp @@ -63,7 +63,7 @@ namespace Mono.CSharp
//
public class RuntimeValueExpression : Expression, IDynamicAssign, IMemoryLocation
{
#if !NET_4_0
#if !NET_4_0 && !MONODROID
public class DynamicMetaObject
{
public TypeSpec RuntimeType;
@ -146,7 +146,7 @@ namespace Mono.CSharp @@ -146,7 +146,7 @@ namespace Mono.CSharp
return base.MakeExpression (ctx);
#else
#if NET_4_0
#if NET_4_0 || MONODROID
if (type.IsStruct && !obj.Expression.Type.IsValueType)
return SLE.Expression.Unbox (obj.Expression, type.GetMetaInfo ());
@ -181,7 +181,7 @@ namespace Mono.CSharp @@ -181,7 +181,7 @@ namespace Mono.CSharp
return this;
}
#if NET_4_0
#if NET_4_0 || MONODROID
public override SLE.Expression MakeExpression (BuilderContext ctx)
{
#if STATIC
@ -253,7 +253,7 @@ namespace Mono.CSharp @@ -253,7 +253,7 @@ namespace Mono.CSharp
protected CSharpBinderFlags flags;
TypeSpec binder_type;
TypeParameter[] context_mvars;
TypeParameters context_mvars;
public DynamicExpressionStatement (IDynamicBinder binder, Arguments args, Location loc)
{
@ -349,7 +349,7 @@ namespace Mono.CSharp @@ -349,7 +349,7 @@ namespace Mono.CSharp
var site_container = ec.CreateDynamicSite ();
if (context_mvars != null) {
TypeParameter[] tparam;
TypeParameters tparam;
TypeContainer sc = site_container;
do {
tparam = sc.CurrentTypeParameters;
@ -430,7 +430,7 @@ namespace Mono.CSharp @@ -430,7 +430,7 @@ namespace Mono.CSharp
p[0] = new Parameter (targs[0], "p0", Parameter.Modifier.NONE, null, loc);
var site = ec.CreateDynamicSite ();
int index = site.Types == null ? 0 : site.Types.Count;
int index = site.Containers == null ? 0 : site.Containers.Count;
if (mutator != null)
rt = mutator.Mutate (rt);
@ -439,17 +439,16 @@ namespace Mono.CSharp @@ -439,17 +439,16 @@ namespace Mono.CSharp
p[i] = new Parameter (targs[i], "p" + i.ToString ("X"), arguments[i - 1].Modifier, null, loc);
}
d = new Delegate (site.NamespaceEntry, site, new TypeExpression (rt, loc),
d = new Delegate (site, new TypeExpression (rt, loc),
Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED,
new MemberName ("Container" + index.ToString ("X")),
new ParametersCompiled (p), null);
d.CreateType ();
d.DefineType ();
d.CreateContainer ();
d.DefineContainer ();
d.Define ();
d.Emit ();
site.AddDelegate (d);
site.AddTypeContainer (d);
del_type = new TypeExpression (d.CurrentType, loc);
if (targs_for_instance != null) {
del_type_instance_access = null;
@ -466,7 +465,7 @@ namespace Mono.CSharp @@ -466,7 +465,7 @@ namespace Mono.CSharp
return;
if (del_type_instance_access == null) {
var dt = d.CurrentType.DeclaringType.MakeGenericType (module, context_mvars.Select (l => l.Type).ToArray ());
var dt = d.CurrentType.DeclaringType.MakeGenericType (module, context_mvars.Types);
del_type_instance_access = new TypeExpression (MemberCache.GetMember (dt, d.CurrentType), loc);
}
@ -482,12 +481,12 @@ namespace Mono.CSharp @@ -482,12 +481,12 @@ namespace Mono.CSharp
if (inflate_using_mvar || context_mvars == null) {
gt = site_container.CurrentType;
} else {
gt = site_container.CurrentType.MakeGenericType (module, context_mvars.Select (l => l.Type).ToArray ());
gt = site_container.CurrentType.MakeGenericType (module, context_mvars.Types);
}
// When site container already exists the inflated version has to be
// updated manually to contain newly created field
if (gt is InflatedTypeSpec && site_container.Fields.Count > 1) {
if (gt is InflatedTypeSpec && site_container.AnonymousMethodsCounter > 1) {
var tparams = gt.MemberDefinition.TypeParametersCount > 0 ? gt.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes;
var inflator = new TypeParameterInflator (module, gt, tparams, gt.TypeArguments);
gt.MemberCache.AddMember (field.InflateMember (inflator));
@ -957,7 +956,7 @@ namespace Mono.CSharp @@ -957,7 +956,7 @@ namespace Mono.CSharp
sealed class DynamicSiteClass : HoistedStoreyClass
{
public DynamicSiteClass (TypeContainer parent, MemberBase host, TypeParameter[] tparams)
public DynamicSiteClass (TypeDefinition parent, MemberBase host, TypeParameters tparams)
: base (parent, MakeMemberName (host, "DynamicSite", parent.DynamicSitesCounter, tparams, Location.Null), tparams, Modifiers.STATIC)
{
parent.DynamicSitesCounter++;
@ -965,7 +964,7 @@ namespace Mono.CSharp @@ -965,7 +964,7 @@ namespace Mono.CSharp
public FieldSpec CreateCallSiteField (FullNamedExpression type, Location loc)
{
int index = fields == null ? 0 : fields.Count;
int index = AnonymousMethodsCounter++;
Field f = new HoistedField (this, type, Modifiers.PUBLIC | Modifiers.STATIC, "Site" + index.ToString ("X"), null, loc);
f.Define ();

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

@ -244,7 +244,7 @@ namespace Mono.CSharp { @@ -244,7 +244,7 @@ namespace Mono.CSharp {
protected void Error_ValueCannotBeConvertedCore (ResolveContext ec, Location loc, TypeSpec target, bool expl)
{
// The error was already reported as CS1660
if (type == InternalType.AnonymousMethod)
if (type == InternalType.AnonymousMethod || type == InternalType.ErrorType)
return;
string from_type = type.GetSignatureForError ();
@ -831,21 +831,11 @@ namespace Mono.CSharp { @@ -831,21 +831,11 @@ namespace Mono.CSharp {
/// <summary>
/// Reports that we were expecting `expr' to be of class `expected'
/// </summary>
public void Error_UnexpectedKind (Report r, MemberCore mc, string expected, Location loc)
public void Error_UnexpectedKind (IMemberContext ctx, Expression memberExpr, string expected, string was, Location loc)
{
Error_UnexpectedKind (r, mc, expected, ExprClassName, loc);
}
var name = memberExpr.GetSignatureForError ();
public void Error_UnexpectedKind (Report r, MemberCore mc, string expected, string was, Location loc)
{
string name;
if (mc != null)
name = mc.GetSignatureForError ();
else
name = GetSignatureForError ();
r.Error (118, loc, "`{0}' is a `{1}' but a `{2}' was expected",
name, was, expected);
ctx.Module.Compiler.Report.Error (118, loc, "`{0}' is a `{1}' but a `{2}' was expected", name, was, expected);
}
public virtual void Error_UnexpectedKind (ResolveContext ec, ResolveFlags flags, Location loc)
@ -2254,12 +2244,10 @@ namespace Mono.CSharp { @@ -2254,12 +2244,10 @@ namespace Mono.CSharp {
protected virtual void Error_TypeOrNamespaceNotFound (IMemberContext ctx)
{
if (ctx.CurrentType != null) {
if (ctx.CurrentMemberDefinition != null) {
MemberCore mc = ctx.CurrentMemberDefinition.Parent.GetDefinition (Name);
if (mc != null) {
Error_UnexpectedKind (ctx.Module.Compiler.Report, mc, "type", GetMemberType (mc), loc);
return;
}
var member = MemberLookup (ctx, false, ctx.CurrentType, Name, 0, MemberLookupRestrictions.ExactArity, loc) as MemberExpr;
if (member != null) {
member.Error_UnexpectedKind (ctx, member, "type", member.KindName, loc);
return;
}
}
@ -2452,13 +2440,11 @@ namespace Mono.CSharp { @@ -2452,13 +2440,11 @@ namespace Mono.CSharp {
rc.Report.Error (841, loc, "A local variable `{0}' cannot be used before it is declared", Name);
} else {
if (Arity > 0) {
TypeParameter[] tparams = rc.CurrentTypeParameters;
var tparams = rc.CurrentTypeParameters;
if (tparams != null) {
foreach (var ctp in tparams) {
if (ctp.Name == Name) {
Error_TypeArgumentsCannotBeUsed (rc, "type parameter", Name, loc);
return null;
}
if (tparams.Find (Name) != null) {
Error_TypeArgumentsCannotBeUsed (rc, "type parameter", Name, loc);
return null;
}
}
@ -2577,7 +2563,7 @@ namespace Mono.CSharp { @@ -2577,7 +2563,7 @@ namespace Mono.CSharp {
TypeExpr te = fne as TypeExpr;
if (te == null) {
fne.Error_UnexpectedKind (mc.Module.Compiler.Report, null, "type", loc);
fne.Error_UnexpectedKind (mc, fne, "type", fne.ExprClassName, loc);
return null;
}
@ -2594,7 +2580,7 @@ namespace Mono.CSharp { @@ -2594,7 +2580,7 @@ namespace Mono.CSharp {
// Obsolete checks cannot be done when resolving base context as they
// require type dependencies to be set but we are in process of resolving them
//
if (!(mc is TypeContainer.BaseContext)) {
if (!(mc is TypeDefinition.BaseContext) && !(mc is UsingAliasNamespace.AliasContext)) {
ObsoleteAttribute obsolete_attr = type.GetAttributeObsolete ();
if (obsolete_attr != null && !mc.IsObsolete) {
AttributeTester.Report_ObsoleteMessage (obsolete_attr, te.GetSignatureForError (), Location, mc.Module.Compiler.Report);
@ -2707,6 +2693,10 @@ namespace Mono.CSharp { @@ -2707,6 +2693,10 @@ namespace Mono.CSharp {
get;
}
public abstract string KindName {
get;
}
protected abstract TypeSpec DeclaringType {
get;
}
@ -3037,20 +3027,17 @@ namespace Mono.CSharp { @@ -3037,20 +3027,17 @@ namespace Mono.CSharp {
public class ExtensionMethodCandidates
{
NamespaceContainer container;
Namespace ns;
IList<MethodSpec> methods;
readonly NamespaceContainer container;
readonly IList<MethodSpec> methods;
readonly int index;
readonly IMemberContext context;
public ExtensionMethodCandidates (IList<MethodSpec> methods, NamespaceContainer nsContainer)
: this (methods, nsContainer, null)
{
}
public ExtensionMethodCandidates (IList<MethodSpec> methods, NamespaceContainer nsContainer, Namespace ns)
public ExtensionMethodCandidates (IMemberContext context, IList<MethodSpec> methods, NamespaceContainer nsContainer, int lookupIndex)
{
this.context = context;
this.methods = methods;
this.container = nsContainer;
this.ns = ns;
this.index = lookupIndex;
}
public NamespaceContainer Container {
@ -3059,11 +3046,15 @@ namespace Mono.CSharp { @@ -3059,11 +3046,15 @@ namespace Mono.CSharp {
}
}
public bool HasUninspectedMembers { get; set; }
public IMemberContext Context {
get {
return context;
}
}
public Namespace Namespace {
public int LookupIndex {
get {
return ns;
return index;
}
}
@ -3106,38 +3097,7 @@ namespace Mono.CSharp { @@ -3106,38 +3097,7 @@ namespace Mono.CSharp {
int arity = type_arguments == null ? 0 : type_arguments.Count;
//
// Here we try to resume the search for extension method at the point
// where the last bunch of candidates was found. It's more tricky than
// it seems as we have to check both namespace containers and namespace
// in correct order.
//
// Consider:
//
// namespace A {
// using N1;
// namespace B.C.D {
// <our first search found candidates in A.B.C.D
// }
// }
//
// In the example above namespace A.B.C.D, A.B.C and A.B have to be
// checked before we hit A.N1 using
//
if (candidates.Namespace == null) {
Namespace scope;
var methods = candidates.Container.NS.LookupExtensionMethod (candidates.Container, ExtensionExpression.Type, Name, arity, out scope);
if (methods != null) {
candidates = new ExtensionMethodCandidates (null, candidates.Container, scope);
return methods.Cast<MemberSpec> ().ToList ();
}
}
var ns_container = candidates.HasUninspectedMembers ? candidates.Container : candidates.Container.Parent;
if (ns_container == null)
return null;
candidates = ns_container.LookupExtensionMethod (ExtensionExpression.Type, Name, arity);
candidates = candidates.Container.LookupExtensionMethod (candidates.Context, ExtensionExpression.Type, Name, arity, candidates.Container, candidates.LookupIndex);
if (candidates == null)
return null;
@ -3282,6 +3242,10 @@ namespace Mono.CSharp { @@ -3282,6 +3242,10 @@ namespace Mono.CSharp {
}
}
public override string KindName {
get { return "method"; }
}
public override string Name {
get {
if (best_candidate != null)
@ -3323,7 +3287,7 @@ namespace Mono.CSharp { @@ -3323,7 +3287,7 @@ namespace Mono.CSharp {
return null;
}
if (best_candidate.IsConditionallyExcluded (ec.Module.Compiler, loc))
if (best_candidate.IsConditionallyExcluded (ec, loc))
ec.Report.Error (765, loc,
"Partial methods with only a defining declaration or removed conditional methods cannot be used in an expression tree");
@ -4418,7 +4382,10 @@ namespace Mono.CSharp { @@ -4418,7 +4382,10 @@ namespace Mono.CSharp {
var ac_p = p as ArrayContainer;
if (ac_p != null) {
var ac_q = ((ArrayContainer) q);
var ac_q = q as ArrayContainer;
if (ac_q == null)
return null;
TypeSpec specific = MoreSpecific (ac_p.Element, ac_q.Element);
if (specific == ac_p.Element)
return p;
@ -5038,6 +5005,10 @@ namespace Mono.CSharp { @@ -5038,6 +5005,10 @@ namespace Mono.CSharp {
get { throw new NotImplementedException (); }
}
public override string KindName {
get { return "constant"; }
}
public override bool IsInstance {
get { return !IsStatic; }
}
@ -5138,6 +5109,10 @@ namespace Mono.CSharp { @@ -5138,6 +5109,10 @@ namespace Mono.CSharp {
}
}
public override string KindName {
get { return "field"; }
}
public FieldSpec Spec {
get {
return spec;
@ -5361,7 +5336,7 @@ namespace Mono.CSharp { @@ -5361,7 +5336,7 @@ namespace Mono.CSharp {
if (ec.HasSet (ResolveContext.Options.ConstructorScope)) {
// InitOnly fields cannot be assigned-to in a different constructor from their declaring type
if (ec.CurrentMemberDefinition.Parent.Definition != spec.DeclaringType.GetDefinition ())
if (ec.CurrentMemberDefinition.Parent.PartialContainer.Definition != spec.DeclaringType.GetDefinition ())
return Report_AssignToReadonly (ec, right_side);
// static InitOnly fields cannot be assigned-to in an instance constructor
if (IsStatic && !ec.IsStatic)
@ -5644,6 +5619,10 @@ namespace Mono.CSharp { @@ -5644,6 +5619,10 @@ namespace Mono.CSharp {
}
}
public override string KindName {
get { return "property"; }
}
public PropertySpec PropertyInfo {
get {
return best_candidate;
@ -6057,6 +6036,10 @@ namespace Mono.CSharp { @@ -6057,6 +6036,10 @@ namespace Mono.CSharp {
}
}
public override string KindName {
get { return "event"; }
}
public MethodSpec Operator {
get {
return op;

30
ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs

@ -102,7 +102,7 @@ namespace Mono.CSharp { @@ -102,7 +102,7 @@ namespace Mono.CSharp {
/// <summary>
/// Enumeration container
/// </summary>
public class Enum : TypeContainer
public class Enum : TypeDefinition
{
//
// Implicit enum member initializer, used when no constant value is provided
@ -164,9 +164,8 @@ namespace Mono.CSharp { @@ -164,9 +164,8 @@ namespace Mono.CSharp {
readonly TypeExpr underlying_type_expr;
public Enum (NamespaceContainer ns, DeclSpace parent, TypeExpression type,
Modifiers mod_flags, MemberName name, Attributes attrs)
: base (ns, parent, name, attrs, MemberKind.Enum)
public Enum (TypeContainer parent, TypeExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, name, attrs, MemberKind.Enum)
{
underlying_type_expr = type;
var accmods = IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE;
@ -190,8 +189,7 @@ namespace Mono.CSharp { @@ -190,8 +189,7 @@ namespace Mono.CSharp {
protected override TypeAttributes TypeAttr {
get {
return ModifiersExtensions.TypeAttr (ModFlags, IsTopLevel) |
TypeAttributes.Class | TypeAttributes.Sealed | base.TypeAttr;
return base.TypeAttr | TypeAttributes.Class | TypeAttributes.Sealed;
}
}
@ -216,7 +214,7 @@ namespace Mono.CSharp { @@ -216,7 +214,7 @@ namespace Mono.CSharp {
return;
}
AddConstant (em);
AddMember (em);
}
public static void Error_1008 (Location loc, Report Report)
@ -225,27 +223,25 @@ namespace Mono.CSharp { @@ -225,27 +223,25 @@ namespace Mono.CSharp {
"Type byte, sbyte, short, ushort, int, uint, long or ulong expected");
}
protected override bool DefineNestedTypes ()
protected override void DoDefineContainer ()
{
((EnumSpec) spec).UnderlyingType = underlying_type_expr == null ? Compiler.BuiltinTypes.Int : underlying_type_expr.Type;
TypeBuilder.DefineField (UnderlyingValueField, UnderlyingType.GetMetaInfo (),
FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName);
return true;
DefineBaseTypes ();
}
protected override bool DoDefineMembers ()
{
if (constants != null) {
for (int i = 0; i < constants.Count; ++i) {
EnumMember em = (EnumMember) constants [i];
if (em.Initializer == null) {
em.Initializer = new ImplicitInitializer (em, i == 0 ? null : (EnumMember) constants[i - 1]);
}
em.Define ();
for (int i = 0; i < Members.Count; ++i) {
EnumMember em = (EnumMember) Members[i];
if (em.Initializer == null) {
em.Initializer = new ImplicitInitializer (em, i == 0 ? null : (EnumMember) Members[i - 1]);
}
em.Define ();
}
return true;

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

@ -72,18 +72,17 @@ namespace Mono.CSharp @@ -72,18 +72,17 @@ namespace Mono.CSharp
readonly ReflectionImporter importer;
readonly CompilationSourceFile source_file;
public Evaluator (CompilerSettings settings, Report report)
public Evaluator (CompilerContext ctx)
{
ctx = new CompilerContext (settings, report);
this.ctx = ctx;
module = new ModuleContainer (ctx);
module.Evaluator = this;
source_file = new CompilationSourceFile ("{interactive}", "", 1);
source_file.NamespaceContainer = new NamespaceContainer (null, module, null, source_file);
source_file = new CompilationSourceFile (module);
module.AddTypeContainer (source_file);
startup_files = ctx.SourceFiles.Count;
ctx.SourceFiles.Add (source_file);
// FIXME: Importer needs this assembly for internalsvisibleto
module.SetDeclaringAssembly (new AssemblyDefinitionDynamic (module, "evaluator"));
@ -97,7 +96,6 @@ namespace Mono.CSharp @@ -97,7 +96,6 @@ namespace Mono.CSharp
{
var loader = new DynamicLoader (importer, ctx);
CompilerCallableEntryPoint.Reset ();
RootContext.ToplevelTypes = module;
//var startup_files = new List<string> ();
@ -118,15 +116,13 @@ namespace Mono.CSharp @@ -118,15 +116,13 @@ namespace Mono.CSharp
Location.Initialize (ctx.SourceFiles);
for (int i = 0; i < startup_files; ++i) {
var sf = ctx.Settings.SourceFiles [i];
var sf = ctx.SourceFiles [i];
d.Parse (sf, module);
}
}
void Reset ()
{
CompilerCallableEntryPoint.PartialReset ();
Location.Reset ();
Location.Initialize (ctx.SourceFiles);
}
@ -355,8 +351,6 @@ namespace Mono.CSharp @@ -355,8 +351,6 @@ namespace Mono.CSharp
bool partial_input;
CSharpParser parser = ParseString (ParseMode.GetCompletions, input, out partial_input);
if (parser == null){
if (CSharpParser.yacc_verbose_flag != 0)
Console.WriteLine ("DEBUG: No completions available");
return null;
}
@ -372,9 +366,9 @@ namespace Mono.CSharp @@ -372,9 +366,9 @@ namespace Mono.CSharp
module.SetDeclaringAssembly (a);
// Need to setup MemberCache
parser_result.CreateType ();
parser_result.CreateContainer ();
var method = parser_result.Methods[0] as Method;
var method = parser_result.Members[0] as Method;
BlockContext bc = new BlockContext (method, method.Block, ctx.BuiltinTypes.Void);
try {
@ -448,7 +442,7 @@ namespace Mono.CSharp @@ -448,7 +442,7 @@ namespace Mono.CSharp
//
InputKind ToplevelOrStatement (SeekableStreamReader seekable)
{
Tokenizer tokenizer = new Tokenizer (seekable, source_file, ctx);
Tokenizer tokenizer = new Tokenizer (seekable, source_file);
int t = tokenizer.token ();
switch (t){
@ -554,7 +548,6 @@ namespace Mono.CSharp @@ -554,7 +548,6 @@ namespace Mono.CSharp
{
partial_input = false;
Reset ();
Tokenizer.LocatedToken.Initialize ();
var enc = ctx.Settings.Encoding;
var s = new MemoryStream (enc.GetBytes (input));
@ -577,7 +570,7 @@ namespace Mono.CSharp @@ -577,7 +570,7 @@ namespace Mono.CSharp
}
seekable.Position = 0;
source_file.NamespaceContainer.DeclarationFound = false;
source_file.DeclarationFound = false;
CSharpParser parser = new CSharpParser (seekable, source_file);
if (kind == InputKind.StatementOrExpression){
@ -592,7 +585,7 @@ namespace Mono.CSharp @@ -592,7 +585,7 @@ namespace Mono.CSharp
parser.Lexer.CompleteOnEOF = true;
ReportPrinter old_printer = null;
if ((mode == ParseMode.Silent || mode == ParseMode.GetCompletions) && CSharpParser.yacc_verbose_flag == 0)
if ((mode == ParseMode.Silent || mode == ParseMode.GetCompletions))
old_printer = ctx.Report.SetPrinter (new StreamReportPrinter (TextWriter.Null));
try {
@ -647,18 +640,19 @@ namespace Mono.CSharp @@ -647,18 +640,19 @@ namespace Mono.CSharp
new TypeExpression (base_class_imported, host.Location)
};
host.AddBasesForPart (host, baseclass_list);
host.AddBasesForPart (baseclass_list);
host.CreateType ();
host.DefineType ();
host.CreateContainer ();
host.DefineContainer ();
host.Define ();
expression_method = (Method) host.Methods[0];
expression_method = (Method) host.Members[0];
} else {
expression_method = null;
}
module.CreateType ();
module.CreateContainer ();
source_file.EnableUsingClausesRedefinition ();
module.Define ();
if (Report.Errors != 0){
@ -669,19 +663,19 @@ namespace Mono.CSharp @@ -669,19 +663,19 @@ namespace Mono.CSharp
}
if (host != null){
host.EmitType ();
host.EmitContainer ();
}
module.Emit ();
module.EmitContainer ();
if (Report.Errors != 0){
if (undo != null)
undo.ExecuteUndo ();
return null;
}
module.CloseType ();
module.CloseContainer ();
if (host != null)
host.CloseType ();
host.CloseContainer ();
if (access == AssemblyBuilderAccess.RunAndSave)
assembly.Save ();
@ -694,36 +688,38 @@ namespace Mono.CSharp @@ -694,36 +688,38 @@ namespace Mono.CSharp
// work from MethodBuilders. Retarded, I know.
//
var tt = assembly.Builder.GetType (host.TypeBuilder.Name);
var mi = tt.GetMethod (expression_method.Name);
if (host.Fields != null) {
//
// We need to then go from FieldBuilder to FieldInfo
// or reflection gets confused (it basically gets confused, and variables override each
// other).
//
foreach (Field field in host.Fields) {
var fi = tt.GetField (field.Name);
Tuple<FieldSpec, FieldInfo> old;
// If a previous value was set, nullify it, so that we do
// not leak memory
if (fields.TryGetValue (field.Name, out old)) {
if (old.Item1.MemberType.IsStruct) {
//
// TODO: Clear fields for structs
//
} else {
try {
old.Item2.SetValue (null, null);
} catch {
}
var mi = tt.GetMethod (expression_method.MemberName.Name);
//
// We need to then go from FieldBuilder to FieldInfo
// or reflection gets confused (it basically gets confused, and variables override each
// other).
//
foreach (var member in host.Members) {
var field = member as Field;
if (field == null)
continue;
var fi = tt.GetField (field.Name);
Tuple<FieldSpec, FieldInfo> old;
// If a previous value was set, nullify it, so that we do
// not leak memory
if (fields.TryGetValue (field.Name, out old)) {
if (old.Item1.MemberType.IsStruct) {
//
// TODO: Clear fields for structs
//
} else {
try {
old.Item2.SetValue (null, null);
} catch {
}
}
fields[field.Name] = Tuple.Create (field.Spec, fi);
}
fields[field.Name] = Tuple.Create (field.Spec, fi);
}
return (CompiledMethod) System.Delegate.CreateDelegate (typeof (CompiledMethod), mi);
@ -760,7 +756,7 @@ namespace Mono.CSharp @@ -760,7 +756,7 @@ namespace Mono.CSharp
//foreach (object x in ns.using_alias_list)
// sb.AppendFormat ("using {0};\n", x);
foreach (var ue in source_file.NamespaceContainer.Usings) {
foreach (var ue in source_file.Usings) {
sb.AppendFormat ("using {0};", ue.ToString ());
sb.Append (Environment.NewLine);
}
@ -768,12 +764,17 @@ namespace Mono.CSharp @@ -768,12 +764,17 @@ namespace Mono.CSharp
return sb.ToString ();
}
internal ICollection<string> GetUsingList ()
internal List<string> GetUsingList ()
{
var res = new List<string> ();
foreach (var ue in source_file.NamespaceContainer.Usings)
res.Add (ue.Name);
foreach (var ue in source_file.Usings) {
if (ue.Alias != null || ue.ResolvedExpression == null)
continue;
res.Add (ue.NamespaceExpression.Name);
}
return res;
}
@ -814,7 +815,7 @@ namespace Mono.CSharp @@ -814,7 +815,7 @@ namespace Mono.CSharp
public void LoadAssembly (string file)
{
var loader = new DynamicLoader (importer, ctx);
var assembly = loader.LoadAssemblyFile (file);
var assembly = loader.LoadAssemblyFile (file, false);
if (assembly == null)
return;
@ -1112,7 +1113,7 @@ namespace Mono.CSharp @@ -1112,7 +1113,7 @@ namespace Mono.CSharp
{
}
public void AddTypeContainer (TypeContainer current_container, TypeContainer tc)
public void AddTypeContainer (TypeContainer current_container, TypeDefinition tc)
{
if (current_container == tc){
Console.Error.WriteLine ("Internal error: inserting container into itself");
@ -1122,14 +1123,13 @@ namespace Mono.CSharp @@ -1122,14 +1123,13 @@ namespace Mono.CSharp
if (undo_actions == null)
undo_actions = new List<Action> ();
var existing = current_container.Types.FirstOrDefault (l => l.MemberName.Basename == tc.MemberName.Basename);
var existing = current_container.Containers.FirstOrDefault (l => l.Basename == tc.Basename);
if (existing != null) {
current_container.RemoveTypeContainer (existing);
existing.NamespaceEntry.SlaveDeclSpace.RemoveTypeContainer (existing);
current_container.RemoveContainer (existing);
undo_actions.Add (() => current_container.AddTypeContainer (existing));
}
undo_actions.Add (() => current_container.RemoveTypeContainer (tc));
undo_actions.Add (() => current_container.RemoveContainer (tc));
}
public void ExecuteUndo ()

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

@ -620,7 +620,7 @@ namespace Mono.CSharp @@ -620,7 +620,7 @@ namespace Mono.CSharp
return is_checked ? SLE.Expression.NegateChecked (expr) : SLE.Expression.Negate (expr);
case Operator.LogicalNot:
return SLE.Expression.Not (expr);
#if NET_4_0
#if NET_4_0 || MONODROID
case Operator.OnesComplement:
return SLE.Expression.OnesComplement (expr);
#endif
@ -801,18 +801,18 @@ namespace Mono.CSharp @@ -801,18 +801,18 @@ namespace Mono.CSharp
LocalTemporary temporary;
bool prepared;
public Expression Expr {
get {
return expr;
}
}
public Indirection (Expression expr, Location l)
{
this.expr = expr;
loc = l;
}
public Expression Expr {
get {
return expr;
}
}
public bool IsFixed {
get { return true; }
}
@ -1017,6 +1017,13 @@ namespace Mono.CSharp @@ -1017,6 +1017,13 @@ namespace Mono.CSharp
// Holds the real operation
Expression operation;
public UnaryMutator (Mode m, Expression e, Location loc)
{
mode = m;
this.loc = loc;
expr = e;
}
public Mode UnaryMutatorMode {
get {
return mode;
@ -1029,13 +1036,6 @@ namespace Mono.CSharp @@ -1029,13 +1036,6 @@ namespace Mono.CSharp
}
}
public UnaryMutator (Mode m, Expression e, Location loc)
{
mode = m;
this.loc = loc;
expr = e;
}
public override bool ContainsEmitWithAwait ()
{
return expr.ContainsEmitWithAwait ();
@ -1268,7 +1268,7 @@ namespace Mono.CSharp @@ -1268,7 +1268,7 @@ namespace Mono.CSharp
}
#if NET_4_0
#if NET_4_0 || MONODROID
public override SLE.Expression MakeExpression (BuilderContext ctx)
{
var target = ((RuntimeValueExpression) expr).MetaObject.Expression;
@ -1283,6 +1283,7 @@ namespace Mono.CSharp @@ -1283,6 +1283,7 @@ namespace Mono.CSharp
target.expr = expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -1371,6 +1372,10 @@ namespace Mono.CSharp @@ -1371,6 +1372,10 @@ namespace Mono.CSharp
{
}
protected override string OperatorName {
get { return "is"; }
}
public override Expression CreateExpressionTree (ResolveContext ec)
{
Arguments args = Arguments.CreateForExpressionTree (ec, null,
@ -1545,10 +1550,6 @@ namespace Mono.CSharp @@ -1545,10 +1550,6 @@ namespace Mono.CSharp
return this;
}
protected override string OperatorName {
get { return "is"; }
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -1566,6 +1567,10 @@ namespace Mono.CSharp @@ -1566,6 +1567,10 @@ namespace Mono.CSharp
{
}
protected override string OperatorName {
get { return "as"; }
}
public override Expression CreateExpressionTree (ResolveContext ec)
{
Arguments args = Arguments.CreateForExpressionTree (ec, null,
@ -1644,14 +1649,10 @@ namespace Mono.CSharp @@ -1644,14 +1649,10 @@ namespace Mono.CSharp
return null;
}
protected override string OperatorName {
get { return "as"; }
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
//
@ -1753,13 +1754,6 @@ namespace Mono.CSharp @@ -1753,13 +1754,6 @@ namespace Mono.CSharp
public class DefaultValueExpression : Expression
{
Expression expr;
public Expression Expr {
get {
return this.expr;
}
}
public DefaultValueExpression (Expression expr, Location loc)
{
@ -1767,6 +1761,12 @@ namespace Mono.CSharp @@ -1767,6 +1761,12 @@ namespace Mono.CSharp
this.loc = loc;
}
public Expression Expr {
get {
return this.expr;
}
}
public override bool IsSideEffectFree {
get {
return true;
@ -1820,7 +1820,7 @@ namespace Mono.CSharp @@ -1820,7 +1820,7 @@ namespace Mono.CSharp
temp_storage.Release (ec);
}
#if NET_4_0 && !STATIC
#if (NET_4_0 || MONODROID) && !STATIC
public override SLE.Expression MakeExpression (BuilderContext ctx)
{
return SLE.Expression.Default (type.GetMetaInfo ());
@ -2225,11 +2225,15 @@ namespace Mono.CSharp @@ -2225,11 +2225,15 @@ namespace Mono.CSharp
}
public Expression Left {
get { return this.left; }
get {
return this.left;
}
}
public Expression Right {
get { return this.right; }
get {
return this.right;
}
}
#endregion
@ -3385,6 +3389,8 @@ namespace Mono.CSharp @@ -3385,6 +3389,8 @@ namespace Mono.CSharp
return this;
}
bool no_arg_conv = false;
//
// LAMESPEC: method groups can be compared when they convert to other side delegate
//
@ -3406,6 +3412,8 @@ namespace Mono.CSharp @@ -3406,6 +3412,8 @@ namespace Mono.CSharp
left = result;
l = r;
} else {
no_arg_conv = l == r && !l.IsStruct;
}
//
@ -3418,11 +3426,12 @@ namespace Mono.CSharp @@ -3418,11 +3426,12 @@ namespace Mono.CSharp
// bool operator != (bool a, bool b)
// bool operator == (bool a, bool b)
//
// LAMESPEC: Reference equality comparison can apply to value types when
// they implement an implicit conversion to any of types above.
// LAMESPEC: Reference equality comparison can apply to value/reference types when
// they implement an implicit conversion to any of types above. This does
// not apply when both operands are of same reference type
//
if (r.BuiltinType != BuiltinTypeSpec.Type.Object && l.BuiltinType != BuiltinTypeSpec.Type.Object) {
result = ResolveOperatorPredefined (ec, ec.BuiltinTypes.OperatorsBinaryEquality, false, null);
result = ResolveOperatorPredefined (ec, ec.BuiltinTypes.OperatorsBinaryEquality, no_arg_conv, null);
if (result != null)
return result;
}
@ -3655,7 +3664,7 @@ namespace Mono.CSharp @@ -3655,7 +3664,7 @@ namespace Mono.CSharp
//
// Merge two sets of user operators into one, they are mostly distinguish
// expect when they share base type and it contains an operator
// except when they share base type and it contains an operator
//
static IList<MemberSpec> CombineUserOperators (IList<MemberSpec> left, IList<MemberSpec> right)
{
@ -5235,7 +5244,7 @@ namespace Mono.CSharp @@ -5235,7 +5244,7 @@ namespace Mono.CSharp
}
}
public Expression Expression {
public Expression Exp {
get {
return expr;
}
@ -5392,7 +5401,8 @@ namespace Mono.CSharp @@ -5392,7 +5401,8 @@ namespace Mono.CSharp
// Any value type has to be pass as by-ref to get back the same
// instance on which the member was called
//
var mod = TypeSpec.IsValueType (ma.LeftExpression.Type) ? Argument.AType.Ref : Argument.AType.None;
var mod = ma.LeftExpression is IMemoryLocation && TypeSpec.IsValueType (ma.LeftExpression.Type) ?
Argument.AType.Ref : Argument.AType.None;
args.Insert (0, new Argument (ma.LeftExpression.Resolve (ec), mod));
}
} else { // is SimpleName
@ -5490,6 +5500,7 @@ namespace Mono.CSharp @@ -5490,6 +5500,7 @@ namespace Mono.CSharp
return SLE.Expression.Call (instance_expr, (MethodInfo) mi.GetMetaInfo (), Arguments.MakeExpression (args, ctx));
#endif
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -5541,6 +5552,12 @@ namespace Mono.CSharp @@ -5541,6 +5552,12 @@ namespace Mono.CSharp
}
}
public Expression TypeExpression {
get {
return RequestedType;
}
}
#endregion
/// <summary>
@ -5933,6 +5950,12 @@ namespace Mono.CSharp @@ -5933,6 +5950,12 @@ namespace Mono.CSharp
get { return elements.Count; }
}
public List<Expression> Elements {
get {
return elements;
}
}
public Expression this [int index] {
get {
return elements [index];
@ -5947,12 +5970,6 @@ namespace Mono.CSharp @@ -5947,12 +5970,6 @@ namespace Mono.CSharp
variable = value;
}
}
public List<Expression> Elements {
get {
return this.elements;
}
}
#endregion
public void Add (Expression expr)
@ -6044,24 +6061,16 @@ namespace Mono.CSharp @@ -6044,24 +6061,16 @@ namespace Mono.CSharp
// The number of constants in array initializers
int const_initializers_count;
// bool only_constant_initializers;
bool only_constant_initializers;
public List<Expression> Arguments {
get { return this.arguments; }
}
public ComposedTypeSpecifier Rank {
get { return this.rank; }
}
public FullNamedExpression NewType {
get { return this.requested_base_type; }
}
public ArrayInitializer Initializers {
get { return this.initializers; }
}
public ArrayCreation (FullNamedExpression requested_base_type, List<Expression> exprs, ComposedTypeSpecifier rank, ArrayInitializer initializers, Location l)
: this (requested_base_type, rank, initializers, l)
{
@ -6099,6 +6108,24 @@ namespace Mono.CSharp @@ -6099,6 +6108,24 @@ namespace Mono.CSharp
{
}
public ComposedTypeSpecifier Rank {
get {
return this.rank;
}
}
public FullNamedExpression TypeExpression {
get {
return this.requested_base_type;
}
}
public ArrayInitializer Initializers {
get {
return this.initializers;
}
}
bool CheckIndices (ResolveContext ec, ArrayInitializer probe, int idx, bool specified_dims, int child_bounds)
{
if (initializers != null && bounds == null) {
@ -6179,7 +6206,7 @@ namespace Mono.CSharp @@ -6179,7 +6206,7 @@ namespace Mono.CSharp
++const_initializers_count;
}
} else {
// only_constant_initializers = false;
only_constant_initializers = false;
}
array_data.Add (element);
@ -6284,7 +6311,7 @@ namespace Mono.CSharp @@ -6284,7 +6311,7 @@ namespace Mono.CSharp
protected bool ResolveInitializers (ResolveContext ec)
{
// only_constant_initializers = true;
only_constant_initializers = true;
if (arguments != null) {
bool res = true;
@ -6489,7 +6516,7 @@ namespace Mono.CSharp @@ -6489,7 +6516,7 @@ namespace Mono.CSharp
return data;
}
#if NET_4_0
#if NET_4_0 || MONODROID
public override SLE.Expression MakeExpression (BuilderContext ctx)
{
#if STATIC
@ -7124,8 +7151,8 @@ namespace Mono.CSharp @@ -7124,8 +7151,8 @@ namespace Mono.CSharp
/// </summary>
public class Arglist : Expression
{
public Arguments Arguments { get; private set; }
Arguments arguments;
public Arglist (Location loc)
: this (null, loc)
{
@ -7133,18 +7160,24 @@ namespace Mono.CSharp @@ -7133,18 +7160,24 @@ namespace Mono.CSharp
public Arglist (Arguments args, Location l)
{
Arguments = args;
arguments = args;
loc = l;
}
public Arguments Arguments {
get {
return arguments;
}
}
public MetaType[] ArgumentTypes {
get {
if (Arguments == null)
if (arguments == null)
return MetaType.EmptyTypes;
var retval = new MetaType[Arguments.Count];
for (int i = 0; i < retval.Length; i++)
retval[i] = Arguments[i].Expr.Type.GetMetaInfo ();
var retval = new MetaType[arguments.Count];
for (int i = 0; i < retval.Length; i++)
retval[i] = arguments[i].Expr.Type.GetMetaInfo ();
return retval;
}
@ -7165,9 +7198,9 @@ namespace Mono.CSharp @@ -7165,9 +7198,9 @@ namespace Mono.CSharp
{
eclass = ExprClass.Variable;
type = InternalType.Arglist;
if (Arguments != null) {
if (arguments != null) {
bool dynamic; // Can be ignored as there is always only 1 overload
Arguments.Resolve (ec, out dynamic);
arguments.Resolve (ec, out dynamic);
}
return this;
@ -7175,17 +7208,18 @@ namespace Mono.CSharp @@ -7175,17 +7208,18 @@ namespace Mono.CSharp
public override void Emit (EmitContext ec)
{
if (Arguments != null)
Arguments.Emit (ec);
if (arguments != null)
arguments.Emit (ec);
}
protected override void CloneTo (CloneContext clonectx, Expression t)
{
Arglist target = (Arglist) t;
if (Arguments != null)
target.Arguments = Arguments.Clone (clonectx);
if (arguments != null)
target.arguments = arguments.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -7207,6 +7241,12 @@ namespace Mono.CSharp @@ -7207,6 +7241,12 @@ namespace Mono.CSharp
this.loc = loc;
}
public FullNamedExpression TypeExpression {
get {
return texpr;
}
}
public override bool ContainsEmitWithAwait ()
{
return false;
@ -7597,12 +7637,12 @@ namespace Mono.CSharp @@ -7597,12 +7637,12 @@ namespace Mono.CSharp
/// Implements the sizeof expression
/// </summary>
public class SizeOf : Expression {
public readonly Expression QueriedType;
readonly Expression texpr;
TypeSpec type_queried;
public SizeOf (Expression queried_type, Location l)
{
this.QueriedType = queried_type;
this.texpr = queried_type;
loc = l;
}
@ -7612,6 +7652,12 @@ namespace Mono.CSharp @@ -7612,6 +7652,12 @@ namespace Mono.CSharp
}
}
public Expression TypeExpression {
get {
return texpr;
}
}
public override bool ContainsEmitWithAwait ()
{
return false;
@ -7625,7 +7671,7 @@ namespace Mono.CSharp @@ -7625,7 +7671,7 @@ namespace Mono.CSharp
protected override Expression DoResolve (ResolveContext ec)
{
type_queried = QueriedType.ResolveAsType (ec);
type_queried = texpr.ResolveAsType (ec);
if (type_queried == null)
return null;
@ -7693,6 +7739,12 @@ namespace Mono.CSharp @@ -7693,6 +7739,12 @@ namespace Mono.CSharp
this.alias = alias;
}
public string Alias {
get {
return alias;
}
}
public override FullNamedExpression ResolveAsTypeOrNamespace (IMemberContext ec)
{
if (alias == GlobalAlias) {
@ -7707,19 +7759,8 @@ namespace Mono.CSharp @@ -7707,19 +7759,8 @@ namespace Mono.CSharp
ec.Module.Compiler.Report.Error (432, loc, "Alias `{0}' not found", alias);
return null;
}
FullNamedExpression fne = base.ResolveAsTypeOrNamespace (ec);
if (fne == null)
return null;
if (expr.eclass == ExprClass.Type) {
ec.Module.Compiler.Report.Error (431, loc,
"Alias `{0}' cannot be used with '::' since it denotes a type. Consider replacing '::' with '.'", alias);
return null;
}
return fne;
return base.ResolveAsTypeOrNamespace (ec);
}
protected override Expression DoResolve (ResolveContext ec)
@ -7727,13 +7768,6 @@ namespace Mono.CSharp @@ -7727,13 +7768,6 @@ namespace Mono.CSharp
return ResolveAsTypeOrNamespace (ec);
}
protected override void Error_IdentifierNotFound (IMemberContext rc, TypeSpec expr_type, string identifier)
{
rc.Module.Compiler.Report.Error (687, loc,
"A namespace alias qualifier `{0}' did not resolve to a namespace or a type",
GetSignatureForError ());
}
public override string GetSignatureForError ()
{
string name = Name;
@ -7746,6 +7780,14 @@ namespace Mono.CSharp @@ -7746,6 +7780,14 @@ namespace Mono.CSharp
public override Expression LookupNameExpression (ResolveContext rc, MemberLookupRestrictions restrictions)
{
if ((restrictions & MemberLookupRestrictions.InvocableOnly) != 0) {
rc.Module.Compiler.Report.Error (687, loc,
"The namespace alias qualifier `::' cannot be used to invoke a method. Consider using `.' instead",
GetSignatureForError ());
return null;
}
return DoResolve (rc);
}
@ -8105,6 +8147,14 @@ namespace Mono.CSharp @@ -8105,6 +8147,14 @@ namespace Mono.CSharp
return null;
}
var qam = this as QualifiedAliasMember;
if (qam != null) {
rc.Module.Compiler.Report.Error (431, loc,
"Alias `{0}' cannot be used with `::' since it denotes a type. Consider replacing `::' with `.'",
qam.Alias);
}
TypeSpec nested = null;
while (expr_type != null) {
nested = MemberCache.FindNestedType (expr_type, Name, Arity);
@ -8159,9 +8209,9 @@ namespace Mono.CSharp @@ -8159,9 +8209,9 @@ namespace Mono.CSharp
return;
}
var any_other_member = MemberLookup (rc, true, expr_type, Name, 0, MemberLookupRestrictions.None, loc);
var any_other_member = MemberLookup (rc, false, expr_type, Name, 0, MemberLookupRestrictions.None, loc);
if (any_other_member != null) {
any_other_member.Error_UnexpectedKind (rc.Module.Compiler.Report, null, "type", loc);
any_other_member.Error_UnexpectedKind (rc, any_other_member, "type", any_other_member.ExprClassName, loc);
return;
}
@ -8265,6 +8315,7 @@ namespace Mono.CSharp @@ -8265,6 +8315,7 @@ namespace Mono.CSharp
target.Expr = Expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -8329,6 +8380,7 @@ namespace Mono.CSharp @@ -8329,6 +8380,7 @@ namespace Mono.CSharp
target.Expr = Expr.Clone (clonectx);
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
@ -8695,7 +8747,7 @@ namespace Mono.CSharp @@ -8695,7 +8747,7 @@ namespace Mono.CSharp
public SLE.Expression MakeAssignExpression (BuilderContext ctx, Expression source)
{
#if NET_4_0
#if NET_4_0 || MONODROID
return SLE.Expression.ArrayAccess (ea.Expr.MakeExpression (ctx), MakeExpressionArguments (ctx));
#else
throw new NotImplementedException ();
@ -8762,6 +8814,10 @@ namespace Mono.CSharp @@ -8762,6 +8814,10 @@ namespace Mono.CSharp
}
}
public override string KindName {
get { return "indexer"; }
}
public override string Name {
get {
return "this";
@ -8863,7 +8919,7 @@ namespace Mono.CSharp @@ -8863,7 +8919,7 @@ namespace Mono.CSharp
#else
var value = new[] { source.MakeExpression (ctx) };
var args = Arguments.MakeExpression (arguments, ctx).Concat (value);
#if NET_4_0
#if NET_4_0 || MONODROID
return SLE.Expression.Block (
SLE.Expression.Call (InstanceExpression.MakeExpression (ctx), (MethodInfo) Setter.GetMetaInfo (), args),
value [0]);
@ -9539,15 +9595,7 @@ namespace Mono.CSharp @@ -9539,15 +9595,7 @@ namespace Mono.CSharp
TypeSpec otype;
Expression t;
Expression count;
public Expression TypeExpression {
get { return this.t; }
}
public Expression CountExpression {
get { return this.count; }
}
public StackAlloc (Expression type, Expression count, Location l)
{
t = type;
@ -9555,6 +9603,18 @@ namespace Mono.CSharp @@ -9555,6 +9603,18 @@ namespace Mono.CSharp
loc = l;
}
public Expression TypeExpression {
get {
return this.t;
}
}
public Expression CountExpression {
get {
return this.count;
}
}
public override bool ContainsEmitWithAwait ()
{
return false;
@ -9961,8 +10021,11 @@ namespace Mono.CSharp @@ -9961,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);
}
}
}
@ -10033,18 +10096,18 @@ namespace Mono.CSharp @@ -10033,18 +10096,18 @@ namespace Mono.CSharp
CollectionOrObjectInitializers initializers;
IMemoryLocation instance;
public CollectionOrObjectInitializers Initializers {
get {
return initializers;
}
}
public NewInitialize (FullNamedExpression requested_type, Arguments arguments, CollectionOrObjectInitializers initializers, Location l)
: base (requested_type, arguments, l)
{
this.initializers = initializers;
}
public CollectionOrObjectInitializers Initializers {
get {
return initializers;
}
}
protected override void CloneTo (CloneContext clonectx, Expression t)
{
base.CloneTo (clonectx, t);
@ -10155,10 +10218,6 @@ namespace Mono.CSharp @@ -10155,10 +10218,6 @@ namespace Mono.CSharp
readonly TypeContainer parent;
AnonymousTypeClass anonymous_type;
public List<AnonymousTypeParameter> Parameters {
get { return this.parameters; }
}
public NewAnonymousType (List<AnonymousTypeParameter> parameters, TypeContainer parent, Location loc)
: base (null, null, loc)
{
@ -10166,6 +10225,12 @@ namespace Mono.CSharp @@ -10166,6 +10225,12 @@ namespace Mono.CSharp
this.parent = parent;
}
public List<AnonymousTypeParameter> Parameters {
get {
return this.parameters;
}
}
protected override void CloneTo (CloneContext clonectx, Expression target)
{
if (parameters == null)
@ -10187,15 +10252,14 @@ namespace Mono.CSharp @@ -10187,15 +10252,14 @@ namespace Mono.CSharp
if (type == null)
return null;
type.CreateType ();
type.DefineType ();
type.ResolveTypeParameters ();
int errors = ec.Report.Errors;
type.CreateContainer ();
type.DefineContainer ();
type.Define ();
type.EmitType ();
if (ec.Report.Errors == 0)
type.CloseType ();
if ((ec.Report.Errors - errors) == 0) {
parent.Module.AddAnonymousType (type);
}
parent.Module.AddAnonymousType (type);
return type;
}
@ -10205,8 +10269,11 @@ namespace Mono.CSharp @@ -10205,8 +10269,11 @@ namespace Mono.CSharp
return base.CreateExpressionTree (ec);
var init = new ArrayInitializer (parameters.Count, loc);
foreach (Property p in anonymous_type.Properties)
init.Add (new TypeOfMethod (MemberCache.GetMember (type, p.Get.Spec), loc));
foreach (var m in anonymous_type.Members) {
var p = m as Property;
if (p != null)
init.Add (new TypeOfMethod (MemberCache.GetMember (type, p.Get.Spec), loc));
}
var ctor_args = new ArrayInitializer (arguments.Count, loc);
foreach (Argument a in arguments)
@ -10235,16 +10302,16 @@ namespace Mono.CSharp @@ -10235,16 +10302,16 @@ 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 = ((AnonymousTypeParameter) parameters [i]).Resolve (ec);
Expression e = parameters [i].Resolve (ec);
if (e == null) {
error = true;
continue;
}
arguments.Add (new Argument (e));
t_args [i] = new TypeExpression (e.Type, e.Location);
t_args [i] = e.Type;
}
if (error)
@ -10254,8 +10321,15 @@ namespace Mono.CSharp @@ -10254,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)

30
ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs

@ -62,10 +62,8 @@ namespace Mono.CSharp @@ -62,10 +62,8 @@ namespace Mono.CSharp
static readonly string[] attribute_targets = new string [] { "field" };
protected FieldBase (DeclSpace parent, FullNamedExpression type, Modifiers mod,
Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, null, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE,
name, attrs)
protected FieldBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE, name, attrs)
{
if ((mod & Modifiers.ABSTRACT) != 0)
Report.Error (681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead");
@ -88,6 +86,12 @@ namespace Mono.CSharp @@ -88,6 +86,12 @@ namespace Mono.CSharp
}
}
public string Name {
get {
return MemberName.Name;
}
}
public FieldSpec Spec {
get {
return spec;
@ -114,8 +118,7 @@ namespace Mono.CSharp @@ -114,8 +118,7 @@ namespace Mono.CSharp
declarators.Add (declarator);
// TODO: This will probably break
Parent.AddMember (this, declarator.Name.Value);
Parent.AddNameToContainer (this, declarator.Name.Value);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
@ -371,7 +374,7 @@ namespace Mono.CSharp @@ -371,7 +374,7 @@ namespace Mono.CSharp
Modifiers.PRIVATE |
Modifiers.UNSAFE;
public FixedField (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
public FixedField (TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
: base (parent, type, mod, AllowedModifiers, name, attrs)
{
}
@ -403,12 +406,12 @@ namespace Mono.CSharp @@ -403,12 +406,12 @@ namespace Mono.CSharp
GetSignatureForError ());
} else if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
int index = Parent.PartialContainer.Fields.IndexOf (this);
foreach (var d in declarators) {
var f = new FixedField (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
f.initializer = d.Initializer;
((ConstInitializer) f.initializer).Name = d.Name.Value;
Parent.PartialContainer.Fields.Insert (++index, f);
f.Define ();
Parent.PartialContainer.Members.Add (f);
}
}
@ -573,8 +576,7 @@ namespace Mono.CSharp @@ -573,8 +576,7 @@ namespace Mono.CSharp
Modifiers.UNSAFE |
Modifiers.READONLY;
public Field (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name,
Attributes attrs)
public Field (TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
: base (parent, type, mod, AllowedModifiers, name, attrs)
{
}
@ -636,19 +638,19 @@ namespace Mono.CSharp @@ -636,19 +638,19 @@ namespace Mono.CSharp
}
if (initializer != null) {
((TypeContainer) Parent).RegisterFieldForInitialization (this,
Parent.RegisterFieldForInitialization (this,
new FieldInitializer (spec, initializer, this));
}
if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
int index = Parent.PartialContainer.Fields.IndexOf (this);
foreach (var d in declarators) {
var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
if (d.Initializer != null)
f.initializer = d.Initializer;
Parent.PartialContainer.Fields.Insert (++index, f);
f.Define ();
Parent.PartialContainer.Members.Add (f);
}
}

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

@ -1213,7 +1213,6 @@ namespace Mono.CSharp @@ -1213,7 +1213,6 @@ namespace Mono.CSharp
class StructInfo
{
public readonly TypeSpec Type;
readonly List<FieldSpec> fields;
public readonly TypeInfo[] StructFields;
public readonly int Length;
@ -1223,14 +1222,13 @@ namespace Mono.CSharp @@ -1223,14 +1222,13 @@ namespace Mono.CSharp
private Dictionary<string, TypeInfo> struct_field_hash;
private Dictionary<string, int> field_hash;
protected bool InTransit;
bool InTransit;
// Private constructor. To save memory usage, we only need to create one instance
// of this class per struct type.
private StructInfo (TypeSpec type)
//
// We only need one instance per type
//
StructInfo (TypeSpec type)
{
this.Type = type;
field_type_hash.Add (type, this);
fields = MemberCache.GetAllFieldsForDefiniteAssignment (type);
@ -1327,7 +1325,7 @@ namespace Mono.CSharp @@ -1327,7 +1325,7 @@ namespace Mono.CSharp
// </summary>
public class VariableInfo {
readonly string Name;
public readonly TypeInfo TypeInfo;
readonly TypeInfo TypeInfo;
// <summary>
// The bit offset of this variable in the flow vector.
@ -1348,7 +1346,7 @@ namespace Mono.CSharp @@ -1348,7 +1346,7 @@ namespace Mono.CSharp
VariableInfo[] sub_info;
protected VariableInfo (string name, TypeSpec type, int offset)
VariableInfo (string name, TypeSpec type, int offset)
{
this.Name = name;
this.Offset = offset;
@ -1359,7 +1357,7 @@ namespace Mono.CSharp @@ -1359,7 +1357,7 @@ namespace Mono.CSharp
Initialize ();
}
protected VariableInfo (VariableInfo parent, TypeInfo type)
VariableInfo (VariableInfo parent, TypeInfo type)
{
this.Name = parent.Name;
this.TypeInfo = type;
@ -1451,6 +1449,11 @@ namespace Mono.CSharp @@ -1451,6 +1449,11 @@ namespace Mono.CSharp
return !ec.DoFlowAnalysis || ec.CurrentBranching.IsStructFieldAssigned (this, name);
}
public bool IsFullyInitialized (BlockContext bc, Location loc)
{
return TypeInfo.IsFullyInitialized (bc, this, loc);
}
public bool IsStructFieldAssigned (MyBitVector vector, string field_name)
{
int field_idx = TypeInfo.GetFieldIndex (field_name);
@ -1495,7 +1498,7 @@ namespace Mono.CSharp @@ -1495,7 +1498,7 @@ namespace Mono.CSharp
var complex_field = TypeInfo.GetStructField (field_name);
if (complex_field != null) {
vector.SetRange (complex_field.Offset, complex_field.TotalLength);
vector.SetRange (Offset + complex_field.Offset, complex_field.TotalLength);
} else {
vector[Offset + field_idx] = true;
}
@ -1505,7 +1508,7 @@ namespace Mono.CSharp @@ -1505,7 +1508,7 @@ namespace Mono.CSharp
//
// Each field must be assigned
//
for (int i = Offset + 1; i <= TypeInfo.TotalLength + Offset; i++) {
for (int i = Offset + 1; i < TypeInfo.TotalLength + Offset; i++) {
if (!vector[i])
return;
}

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

@ -94,6 +94,12 @@ namespace Mono.CSharp { @@ -94,6 +94,12 @@ namespace Mono.CSharp {
#region Properties
public List<FullNamedExpression> TypeExpressions {
get {
return constraints;
}
}
public Location Location {
get {
return loc;
@ -360,15 +366,24 @@ namespace Mono.CSharp { @@ -360,15 +366,24 @@ namespace Mono.CSharp {
GenericTypeParameterBuilder builder;
TypeParameterSpec spec;
public TypeParameter (DeclSpace parent, int index, MemberName name, Constraints constraints, Attributes attrs, Variance variance)
: base (parent, name, attrs)
public TypeParameter (int index, MemberName name, Constraints constraints, Attributes attrs, Variance variance)
: base (null, name, attrs)
{
this.constraints = constraints;
this.spec = new TypeParameterSpec (null, index, this, SpecialConstraint.None, variance, null);
}
public TypeParameter (TypeParameterSpec spec, DeclSpace parent, TypeSpec parentSpec, MemberName name, Attributes attrs)
: base (parent, name, attrs)
//
// Used by parser
//
public TypeParameter (MemberName name, Attributes attrs, Variance variance)
: base (null, name, attrs)
{
this.spec = new TypeParameterSpec (null, -1, this, SpecialConstraint.None, variance, null);
}
public TypeParameter (TypeParameterSpec spec, TypeSpec parentSpec, MemberName name, Attributes attrs)
: base (null, name, attrs)
{
this.spec = new TypeParameterSpec (parentSpec, spec.DeclaredPosition, spec.MemberDefinition, spec.SpecialConstraint, spec.Variance, null) {
BaseType = spec.BaseType,
@ -385,6 +400,15 @@ namespace Mono.CSharp { @@ -385,6 +400,15 @@ namespace Mono.CSharp {
}
}
public Constraints Constraints {
get {
return constraints;
}
set {
constraints = value;
}
}
public IAssemblyDefinition DeclaringAssembly {
get {
return Module.DeclaringAssembly;
@ -404,6 +428,12 @@ namespace Mono.CSharp { @@ -404,6 +428,12 @@ namespace Mono.CSharp {
}
}
public string Name {
get {
return MemberName.Name;
}
}
public string Namespace {
get {
return null;
@ -440,12 +470,6 @@ namespace Mono.CSharp { @@ -440,12 +470,6 @@ namespace Mono.CSharp {
}
}
public Constraints Constraints {
get {
return this.constraints;
}
}
#endregion
//
@ -455,7 +479,7 @@ namespace Mono.CSharp { @@ -455,7 +479,7 @@ namespace Mono.CSharp {
// already have constraints they become our constraints. If we already
// have constraints, we must check that they're the same.
//
public bool AddPartialConstraints (TypeContainer part, TypeParameter tp)
public bool AddPartialConstraints (TypeDefinition part, TypeParameter tp)
{
if (builder == null)
throw new InvalidOperationException ();
@ -493,9 +517,9 @@ namespace Mono.CSharp { @@ -493,9 +517,9 @@ namespace Mono.CSharp {
constraints.CheckGenericConstraints (this, obsoleteCheck);
}
public TypeParameter CreateHoistedCopy (TypeContainer declaringType, TypeSpec declaringSpec)
public TypeParameter CreateHoistedCopy (TypeSpec declaringSpec)
{
return new TypeParameter (spec, declaringType, declaringSpec, MemberName, null);
return new TypeParameter (spec, declaringSpec, MemberName, null);
}
public override bool Define ()
@ -509,11 +533,13 @@ namespace Mono.CSharp { @@ -509,11 +533,13 @@ namespace Mono.CSharp {
// with SRE (by calling `DefineGenericParameters()' on the TypeBuilder /
// MethodBuilder).
//
public void Define (GenericTypeParameterBuilder type, TypeSpec declaringType)
public void Define (GenericTypeParameterBuilder type, TypeSpec declaringType, TypeContainer parent)
{
if (builder != null)
throw new InternalErrorException ();
// Needed to get compiler reference
this.Parent = parent;
this.builder = type;
spec.DeclaringType = declaringType;
spec.SetMetaInfo (type);
@ -625,16 +651,6 @@ namespace Mono.CSharp { @@ -625,16 +651,6 @@ namespace Mono.CSharp {
return true;
}
public static TypeParameter FindTypeParameter (TypeParameter[] tparams, string name)
{
foreach (var tp in tparams) {
if (tp.Name == name)
return tp;
}
return null;
}
public override bool IsClsComplianceRequired ()
{
return false;
@ -645,6 +661,14 @@ namespace Mono.CSharp { @@ -645,6 +661,14 @@ namespace Mono.CSharp {
if (constraints != null)
constraints.VerifyClsCompliance (Report);
}
public void WarningParentNameConflict (TypeParameter conflict)
{
conflict.Report.SymbolRelatedToPreviousError (conflict.Location, null);
conflict.Report.Warning (693, 3, Location,
"Type parameter `{0}' has the same name as the type parameter from outer type `{1}'",
GetSignatureForError (), conflict.CurrentType.GetSignatureForError ());
}
}
[System.Diagnostics.DebuggerDisplay ("{DisplayDebugInfo()}")]
@ -654,7 +678,7 @@ namespace Mono.CSharp { @@ -654,7 +678,7 @@ namespace Mono.CSharp {
Variance variance;
SpecialConstraint spec;
readonly int tp_pos;
int tp_pos;
TypeSpec[] targs;
TypeSpec[] ifaces_defined;
@ -684,6 +708,9 @@ namespace Mono.CSharp { @@ -684,6 +708,9 @@ namespace Mono.CSharp {
get {
return tp_pos;
}
set {
tp_pos = value;
}
}
public bool HasSpecialConstructor {
@ -918,15 +945,8 @@ namespace Mono.CSharp { @@ -918,15 +945,8 @@ namespace Mono.CSharp {
public override string GetSignatureForDocumentation ()
{
int c = 0;
var type = DeclaringType;
while (type != null && type.DeclaringType != null) {
type = type.DeclaringType;
c += type.MemberDefinition.TypeParametersCount;
}
var prefix = IsMethodOwned ? "``" : "`";
return prefix + (c + DeclaredPosition);
return prefix + DeclaredPosition;
}
public override string GetSignatureForError ()
@ -1364,13 +1384,13 @@ namespace Mono.CSharp { @@ -1364,13 +1384,13 @@ namespace Mono.CSharp {
//
public class TypeParameterMutator
{
readonly TypeParameter[] mvar;
readonly TypeParameter[] var;
readonly TypeParameters mvar;
readonly TypeParameters var;
Dictionary<TypeSpec, TypeSpec> mutated_typespec;
public TypeParameterMutator (TypeParameter[] mvar, TypeParameter[] var)
public TypeParameterMutator (TypeParameters mvar, TypeParameters var)
{
if (mvar.Length != var.Length)
if (mvar.Count != var.Count)
throw new ArgumentException ();
this.mvar = mvar;
@ -1379,7 +1399,7 @@ namespace Mono.CSharp { @@ -1379,7 +1399,7 @@ namespace Mono.CSharp {
#region Properties
public TypeParameter[] MethodTypeParameters {
public TypeParameters MethodTypeParameters {
get {
return mvar;
}
@ -1416,7 +1436,7 @@ namespace Mono.CSharp { @@ -1416,7 +1436,7 @@ namespace Mono.CSharp {
public TypeParameterSpec Mutate (TypeParameterSpec tp)
{
for (int i = 0; i < mvar.Length; ++i) {
for (int i = 0; i < mvar.Count; ++i) {
if (mvar[i].Type == tp)
return var[i].Type;
}
@ -1811,9 +1831,13 @@ namespace Mono.CSharp { @@ -1811,9 +1831,13 @@ namespace Mono.CSharp {
return;
}
var tc = open_type.MemberDefinition as TypeContainer;
if (tc != null && !tc.HasMembersDefined)
throw new InternalErrorException ("Inflating MemberCache with undefined members");
var tc = open_type.MemberDefinition as TypeDefinition;
if (tc != null && !tc.HasMembersDefined) {
//
// Inflating MemberCache with undefined members
//
return;
}
if ((state & StateFlags.PendingBaseTypeInflate) != 0) {
BaseType = inflator.Inflate (open_type.BaseType);
@ -1879,12 +1903,6 @@ namespace Mono.CSharp { @@ -1879,12 +1903,6 @@ namespace Mono.CSharp {
args.Add (type);
}
// TODO: Kill this monster
public TypeParameterName[] GetDeclarations ()
{
return args.ConvertAll (i => (TypeParameterName) i).ToArray ();
}
/// <summary>
/// We may only be used after Resolve() is called and return the fully
/// resolved types.
@ -1911,6 +1929,12 @@ namespace Mono.CSharp { @@ -1911,6 +1929,12 @@ namespace Mono.CSharp {
}
}
public List<FullNamedExpression> TypeExpressions {
get {
return this.args;
}
}
public string GetSignatureForError()
{
StringBuilder sb = new StringBuilder ();
@ -1998,32 +2022,106 @@ namespace Mono.CSharp { @@ -1998,32 +2022,106 @@ namespace Mono.CSharp {
}
}
public class TypeParameterName : SimpleName
public class TypeParameters
{
Attributes attributes;
Variance variance;
List<TypeParameter> names;
TypeParameterSpec[] types;
public TypeParameterName (string name, Attributes attrs, Location loc)
: this (name, attrs, Variance.None, loc)
public TypeParameters ()
{
names = new List<TypeParameter> ();
}
public TypeParameterName (string name, Attributes attrs, Variance variance, Location loc)
: base (name, loc)
public TypeParameters (int count)
{
attributes = attrs;
this.variance = variance;
names = new List<TypeParameter> (count);
}
public Attributes OptAttributes {
#region Properties
public int Count {
get {
return attributes;
return names.Count;
}
}
public Variance Variance {
public TypeParameterSpec[] Types {
get {
return variance;
return types;
}
}
#endregion
public void Add (TypeParameter tparam)
{
names.Add (tparam);
}
public void Add (TypeParameters tparams)
{
names.AddRange (tparams.names);
}
public void Define (GenericTypeParameterBuilder[] buiders, TypeSpec declaringType, int parentOffset, TypeContainer parent)
{
types = new TypeParameterSpec[Count];
for (int i = 0; i < types.Length; ++i) {
var tp = names[i];
tp.Define (buiders[i + parentOffset], declaringType, parent);
types[i] = tp.Type;
types[i].DeclaredPosition = i + parentOffset;
if (tp.Variance != Variance.None && !(declaringType != null && (declaringType.Kind == MemberKind.Interface || declaringType.Kind == MemberKind.Delegate))) {
parent.Compiler.Report.Error (1960, tp.Location, "Variant type parameters can only be used with interfaces and delegates");
}
}
}
public TypeParameter this[int index] {
get {
return names [index];
}
set {
names[index] = value;
}
}
public TypeParameter Find (string name)
{
foreach (var tp in names) {
if (tp.Name == name)
return tp;
}
return null;
}
public string[] GetAllNames ()
{
return names.Select (l => l.Name).ToArray ();
}
public string GetSignatureForError ()
{
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < Count; ++i) {
if (i > 0)
sb.Append (',');
var name = names[i];
if (name != null)
sb.Append (name.GetSignatureForError ());
}
return sb.ToString ();
}
public void VerifyClsCompliance ()
{
foreach (var tp in names) {
tp.VerifyClsCompliance ();
}
}
}
@ -2429,121 +2527,6 @@ namespace Mono.CSharp { @@ -2429,121 +2527,6 @@ namespace Mono.CSharp {
}
}
/// <summary>
/// A generic method definition.
/// </summary>
public class GenericMethod : DeclSpace
{
ParametersCompiled parameters;
public GenericMethod (NamespaceContainer ns, DeclSpace parent, MemberName name,
FullNamedExpression return_type, ParametersCompiled parameters)
: base (ns, parent, name, null)
{
this.parameters = parameters;
}
public GenericMethod (NamespaceContainer ns, DeclSpace parent, MemberName name, TypeParameter[] tparams,
FullNamedExpression return_type, ParametersCompiled parameters)
: this (ns, parent, name, return_type, parameters)
{
this.type_params = tparams;
}
public override TypeParameter[] CurrentTypeParameters {
get {
return base.type_params;
}
}
protected override TypeAttributes TypeAttr {
get {
throw new NotSupportedException ();
}
}
public override void DefineType ()
{
throw new Exception ();
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
throw new NotSupportedException ();
}
public override bool Define ()
{
throw new NotSupportedException ();
}
/// <summary>
/// Define and resolve the type parameters.
/// We're called from Method.Define().
/// </summary>
public bool Define (MethodOrOperator m)
{
TypeParameterName[] names = MemberName.TypeArguments.GetDeclarations ();
string[] snames = new string [names.Length];
var block = m.Block;
for (int i = 0; i < names.Length; i++) {
string type_argument_name = names[i].Name;
if (block == null) {
int idx = parameters.GetParameterIndexByName (type_argument_name);
if (idx >= 0) {
var b = m.Block;
if (b == null)
b = new ToplevelBlock (Compiler, Location);
b.Error_AlreadyDeclaredTypeParameter (type_argument_name, parameters[i].Location);
}
} else {
INamedBlockVariable variable = null;
block.GetLocalName (type_argument_name, m.Block, ref variable);
if (variable != null)
variable.Block.Error_AlreadyDeclaredTypeParameter (type_argument_name, variable.Location);
}
snames[i] = type_argument_name;
}
GenericTypeParameterBuilder[] gen_params = m.MethodBuilder.DefineGenericParameters (snames);
for (int i = 0; i < TypeParameters.Length; i++)
TypeParameters [i].Define (gen_params [i], null);
return true;
}
public void EmitAttributes ()
{
if (OptAttributes != null)
OptAttributes.Emit ();
}
public override string GetSignatureForError ()
{
return base.GetSignatureForError () + parameters.GetSignatureForError ();
}
public override AttributeTargets AttributeTargets {
get {
return AttributeTargets.Method | AttributeTargets.ReturnValue;
}
}
public override string DocCommentHeader {
get { return "M:"; }
}
public new void VerifyClsCompliance ()
{
foreach (TypeParameter tp in TypeParameters) {
tp.VerifyClsCompliance ();
}
}
}
public partial class TypeManager
{
public static Variance CheckTypeVariance (TypeSpec t, Variance expected, IMemberContext member)
@ -2875,16 +2858,17 @@ namespace Mono.CSharp { @@ -2875,16 +2858,17 @@ namespace Mono.CSharp {
if (!u.IsArray)
return 0;
// TODO MemberCache: GetMetaInfo ()
if (u.GetMetaInfo ().GetArrayRank () != v.GetMetaInfo ().GetArrayRank ())
var ac_u = (ArrayContainer) u;
var ac_v = (ArrayContainer) v;
if (ac_u.Rank != ac_v.Rank)
return 0;
return ExactInference (TypeManager.GetElementType (u), TypeManager.GetElementType (v));
return ExactInference (ac_u.Element, ac_v.Element);
}
// If V is constructed type and U is constructed type
if (TypeManager.IsGenericType (v)) {
if (!TypeManager.IsGenericType (u))
if (!TypeManager.IsGenericType (u) || v.MemberDefinition != u.MemberDefinition)
return 0;
TypeSpec [] ga_u = TypeManager.GetTypeArguments (u);

111
ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.csproj

@ -1,111 +0,0 @@ @@ -1,111 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>gmcs</RootNamespace>
<AssemblyName>gmcs</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\monodevelop\main\build\bin</OutputPath>
<DefineConstants>TRACE;DEBUG;NET_2_0;MS_COMPATIBLE;FULL_AST;BOOTSTRAP_BASIC</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE;NET_2_0;MS_COMPATIBLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<DefineConstants>TRACE;NET_2_0;MS_COMPATIBLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<OutputPath>..\..\..\monodevelop\main\build\bin</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\class\corlib\Mono.Security.Cryptography\CryptoConvert.cs" />
<Compile Include="..\class\Mono.CompilerServices.SymbolWriter\MonoSymbolFile.cs" />
<Compile Include="..\class\Mono.CompilerServices.SymbolWriter\MonoSymbolTable.cs" />
<Compile Include="..\class\Mono.CompilerServices.SymbolWriter\MonoSymbolWriter.cs" />
<Compile Include="argument.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="anonymous.cs" />
<Compile Include="assign.cs" />
<Compile Include="attribute.cs" />
<Compile Include="cfold.cs" />
<Compile Include="class.cs" />
<Compile Include="codegen.cs" />
<Compile Include="complete.cs" />
<Compile Include="const.cs" />
<Compile Include="constant.cs" />
<Compile Include="context.cs" />
<Compile Include="convert.cs" />
<Compile Include="dynamic.cs" />
<Compile Include="eval.cs" />
<Compile Include="import.cs" />
<Compile Include="lambda.cs" />
<Compile Include="cs-parser.cs" />
<Compile Include="cs-tokenizer.cs" />
<Compile Include="decl.cs" />
<Compile Include="delegate.cs" />
<Compile Include="doc.cs" />
<Compile Include="driver.cs" />
<Compile Include="ecore.cs" />
<Compile Include="enum.cs" />
<Compile Include="expression.cs" />
<Compile Include="flowanalysis.cs" />
<Compile Include="generic.cs" />
<Compile Include="iterators.cs" />
<Compile Include="literal.cs" />
<Compile Include="location.cs" />
<Compile Include="membercache.cs" />
<Compile Include="method.cs" />
<Compile Include="modifiers.cs" />
<Compile Include="namespace.cs" />
<Compile Include="nullable.cs" />
<Compile Include="..\tools\monop\outline.cs" />
<Compile Include="parameter.cs" />
<Compile Include="pending.cs" />
<Compile Include="property.cs" />
<Compile Include="report.cs" />
<Compile Include="rootcontext.cs" />
<Compile Include="roottypes.cs" />
<Compile Include="statement.cs" />
<Compile Include="support.cs" />
<Compile Include="symbolwriter.cs" />
<Compile Include="typemanager.cs" />
<Compile Include="linq.cs" />
<Compile Include="field.cs" />
<Compile Include="typespec.cs" />
<Compile Include="visit.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

14
ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.exe.config

@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="compilerLogListener" type="System.Diagnostics.TextWriterTraceListener,System"
initializeData="mcs.log" />
<remove type="System.Diagnostics.DefaultTraceListener,System"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>

56
ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.exe.sources

@ -1,56 +0,0 @@ @@ -1,56 +0,0 @@
AssemblyInfo.cs
anonymous.cs
argument.cs
assign.cs
attribute.cs
cs-tokenizer.cs
cfold.cs
class.cs
codegen.cs
complete.cs
const.cs
constant.cs
convert.cs
context.cs
decl.cs
delegate.cs
doc.cs
doc-bootstrap.cs
driver.cs
dynamic.cs
ecore.cs
enum.cs
eval.cs
expression.cs
field.cs
flowanalysis.cs
generic.cs
import.cs
iterators.cs
lambda.cs
linq.cs
literal.cs
location.cs
membercache.cs
method.cs
modifiers.cs
namespace.cs
nullable.cs
parameter.cs
pending.cs
property.cs
report.cs
rootcontext.cs
roottypes.cs
statement.cs
support.cs
typemanager.cs
typespec.cs
visit.cs
symbolwriter.cs
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
../class/corlib/Mono.Security.Cryptography/CryptoConvert.cs
../build/common/Consts.cs
../tools/monop/outline.cs

20
ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.sln

@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C# Express 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gmcs", "gmcs.csproj", "{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

23
ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs.userprefs

@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="cs-parser.jay">
<Files>
<File FileName="cs-parser.jay" Line="5349" Column="43" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State expanded="True">
<Node name="gmcs" expanded="True">
<Option id="ShowVersionControlOverlays" value="True" />
<Option id="ShowAllFiles" value="True" />
<Node name="cs-parser.jay" selected="True" />
</Node>
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>

29
ICSharpCode.NRefactory.CSharp/Parser/mcs/gmcs2.csproj

@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyName>gmcs</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ResponseFile>gmcs.exe.sources</ResponseFile>
<CodePage>65001</CodePage>
<OutputPath>..\class\lib\basic\</OutputPath>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'basic|AnyCPU' ">
<DefineConstants>BOOTSTRAP_BASIC,NET_1_1,NET_2_0</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_2_0|AnyCPU' ">
<DefineConstants>NET_1_1,NET_2_0</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="cs-parser.cs"/>
<Reference Include="System.dll"/>
<Reference Include="System.Core.dll"/>
<Reference Include="System.XML.dll"/>
</ItemGroup>
<Import Project="$(MSBuildProjectDirectory)\..\build\msbuild\Mono.Common.targets"/>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild" DependsOnTargets="SetupProject">
<Exec Command="..\jay\jay.exe -cvt &lt; ..\jay\skeleton.cs cs-parser.jay &gt; cs-parser.cs"/>
</Target>
</Project>

0
ICSharpCode.NRefactory.CSharp/Parser/mcs/hosting.cs

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

@ -33,16 +33,16 @@ namespace Mono.CSharp @@ -33,16 +33,16 @@ namespace Mono.CSharp
protected T machine_initializer;
int resume_pc;
public Expression Expr {
get { return this.expr; }
}
protected YieldStatement (Expression expr, Location l)
{
this.expr = expr;
loc = l;
}
public Expression Expr {
get { return this.expr; }
}
protected override void CloneTo (CloneContext clonectx, Statement t)
{
var target = (YieldStatement<T>) t;
@ -160,7 +160,7 @@ namespace Mono.CSharp @@ -160,7 +160,7 @@ namespace Mono.CSharp
Field pc_field;
StateMachineMethod method;
protected StateMachine (Block block, TypeContainer parent, MemberBase host, TypeParameter[] tparams, string name)
protected StateMachine (Block block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name)
: base (block, parent, host, tparams, name)
{
}
@ -187,7 +187,7 @@ namespace Mono.CSharp @@ -187,7 +187,7 @@ namespace Mono.CSharp
throw new InternalErrorException ();
this.method = method;
AddMethod (method);
Members.Add (method);
}
protected override bool DoDefineMembers ()
@ -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;
}
}
@ -329,9 +342,10 @@ namespace Mono.CSharp @@ -329,9 +342,10 @@ namespace Mono.CSharp
: base (host, null, new TypeExpression (host.Compiler.BuiltinTypes.Void, host.Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
new MemberName ("Dispose", host.Location))
{
host.AddMethod (this);
host.Members.Add (this);
Block.AddStatement (new DisposeMethodStatement (host.Iterator));
Block.IsCompilerGenerated = true;
}
}
@ -394,7 +408,7 @@ namespace Mono.CSharp @@ -394,7 +408,7 @@ namespace Mono.CSharp
public IteratorStorey (Iterator iterator)
: base (iterator.Container.ParametersBlock, iterator.Host,
iterator.OriginalMethod as MemberBase, iterator.GenericMethod == null ? null : iterator.GenericMethod.CurrentTypeParameters, "Iterator")
iterator.OriginalMethod as MemberBase, iterator.OriginalMethod.CurrentTypeParameters, "Iterator")
{
this.Iterator = iterator;
}
@ -478,29 +492,24 @@ namespace Mono.CSharp @@ -478,29 +492,24 @@ namespace Mono.CSharp
Define_Reset ();
if (Iterator.IsEnumerable) {
MemberName name = new MemberName (QualifiedAliasMember.GlobalAlias, "System", null, Location);
name = new MemberName (name, "Collections", Location);
name = new MemberName (name, "IEnumerable", Location);
name = new MemberName (name, "GetEnumerator", Location);
FullNamedExpression explicit_iface = new TypeExpression (Compiler.BuiltinTypes.IEnumerable, 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);
name = new MemberName (name.Left.Left, "Generic", Location);
name = new MemberName (name, "IEnumerable", generic_args, Location);
name = new MemberName (name, "GetEnumerator", Location);
Method gget_enumerator = new GetEnumeratorMethod (this, generic_enumerator_type, name);
explicit_iface = new GenericTypeExpr (Module.PredefinedTypes.IEnumerableGeneric.Resolve (), generic_args, Location);
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);
AddMethod (get_enumerator);
AddMethod (gget_enumerator);
Members.Add (get_enumerator);
Members.Add (gget_enumerator);
} else {
AddMethod (new GetEnumeratorMethod (this, enumerator_type, name));
Members.Add (GetEnumeratorMethod.Create (this, enumerator_type, name));
}
}
@ -510,41 +519,42 @@ namespace Mono.CSharp @@ -510,41 +519,42 @@ namespace Mono.CSharp
void Define_Current (bool is_generic)
{
TypeExpr type;
MemberName name = new MemberName (QualifiedAliasMember.GlobalAlias, "System", null, Location);
name = new MemberName (name, "Collections", Location);
FullNamedExpression explicit_iface;
if (is_generic) {
name = new MemberName (name, "Generic", Location);
name = new MemberName (name, "IEnumerator", generic_args, Location);
explicit_iface = new GenericTypeExpr (Module.PredefinedTypes.IEnumeratorGeneric.Resolve (), generic_args, Location);
type = iterator_type_expr;
} else {
name = new MemberName (name, "IEnumerator");
explicit_iface = new TypeExpression (Module.Compiler.BuiltinTypes.IEnumerator, Location);
type = new TypeExpression (Compiler.BuiltinTypes.Object, Location);
}
name = new MemberName (name, "Current", Location);
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;
AddProperty (current);
Members.Add (current);
}
void Define_Reset ()
{
Method reset = new Method (
this, null, new TypeExpression (Compiler.BuiltinTypes.Void, Location),
Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
this, new TypeExpression (Compiler.BuiltinTypes.Void, Location),
Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN | Modifiers.COMPILER_GENERATED,
new MemberName ("Reset", Location),
ParametersCompiled.EmptyReadOnlyParameters, null);
AddMethod (reset);
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)
@ -570,11 +580,11 @@ namespace Mono.CSharp @@ -570,11 +580,11 @@ namespace Mono.CSharp
readonly StateMachineInitializer expr;
public StateMachineMethod (StateMachine host, StateMachineInitializer expr, FullNamedExpression returnType, Modifiers mod, MemberName name)
: base (host, null, returnType, mod | Modifiers.COMPILER_GENERATED,
: base (host, returnType, mod | Modifiers.COMPILER_GENERATED,
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)
@ -617,7 +627,7 @@ namespace Mono.CSharp @@ -617,7 +627,7 @@ namespace Mono.CSharp
}
}
public readonly TypeContainer Host;
public readonly TypeDefinition Host;
protected StateMachine storey;
//
@ -630,7 +640,7 @@ namespace Mono.CSharp @@ -630,7 +640,7 @@ namespace Mono.CSharp
protected LocalBuilder current_pc;
protected List<ResumableStatement> resume_points;
protected StateMachineInitializer (ParametersBlock block, TypeContainer host, TypeSpec returnType)
protected StateMachineInitializer (ParametersBlock block, TypeDefinition host, TypeSpec returnType)
: base (block, returnType, block.StartLocation)
{
this.Host = host;
@ -721,7 +731,7 @@ namespace Mono.CSharp @@ -721,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);
@ -735,9 +745,11 @@ namespace Mono.CSharp @@ -735,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);
@ -757,7 +769,7 @@ namespace Mono.CSharp @@ -757,7 +769,7 @@ namespace Mono.CSharp
move_next_error = ec.DefineLabel ();
if (resume_points == null) {
EmitMoveNext_NoResumePoints (ec, block);
EmitMoveNext_NoResumePoints (ec);
return;
}
@ -791,22 +803,20 @@ namespace Mono.CSharp @@ -791,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);
@ -826,6 +836,7 @@ namespace Mono.CSharp @@ -826,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);
@ -845,8 +856,6 @@ namespace Mono.CSharp @@ -845,8 +856,6 @@ namespace Mono.CSharp
ec.EmitInt (1);
ec.Emit (OpCodes.Ret);
}
SymbolWriter.EndIteratorDispatcher (ec);
}
protected virtual void EmitMoveNextEpilogue (EmitContext ec)
@ -903,7 +912,7 @@ namespace Mono.CSharp @@ -903,7 +912,7 @@ namespace Mono.CSharp
public readonly bool IsEnumerable;
public readonly TypeSpec OriginalIteratorType;
public Iterator (ParametersBlock block, IMethodData method, TypeContainer host, TypeSpec iterator_type, bool is_enumerable)
public Iterator (ParametersBlock block, IMethodData method, TypeDefinition host, TypeSpec iterator_type, bool is_enumerable)
: base (block, host, host.Compiler.BuiltinTypes.Bool)
{
this.OriginalMethod = method;
@ -916,10 +925,6 @@ namespace Mono.CSharp @@ -916,10 +925,6 @@ namespace Mono.CSharp
get { return OriginalMethod.Block; }
}
public GenericMethod GenericMethod {
get { return OriginalMethod.GenericMethod; }
}
public override string ContainerType {
get { return "iterator"; }
}
@ -1035,7 +1040,7 @@ namespace Mono.CSharp @@ -1035,7 +1040,7 @@ namespace Mono.CSharp
return bc;
}
public static void CreateIterator (IMethodData method, TypeContainer parent, Modifiers modifiers)
public static void CreateIterator (IMethodData method, TypeDefinition parent, Modifiers modifiers)
{
bool is_enumerable;
TypeSpec iterator_type;

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

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

24
ICSharpCode.NRefactory.CSharp/Parser/mcs/lambda.todo

@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
Tasks for completing Lambda support:
* Port the grammar to mcs
* Everywhere where we use Arguments, we need to clone them.
* We need a "CloneContext" that would keep track of mappings between
the old blocks and the new blocks, so that expression that keep
pointers to blocks can get the proper block on cloning, something like:
CloneTo (CloneContext cc, Expression t)
{
MyClass target = (MyClass) t;
target.Block = cc.RemapBlock (Block);
}
* Generics section support.
* Fix the bug in the modified l1.cs that introduces two rets instead
of a single one.
* Complete CloneTo for Statements.
* Write an extensive test suite to exercise CloneTo

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

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

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

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

410
ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs

@ -17,16 +17,42 @@ using Mono.CompilerServices.SymbolWriter; @@ -17,16 +17,42 @@ using Mono.CompilerServices.SymbolWriter;
using System.Diagnostics;
using System.Linq;
namespace Mono.CSharp {
/// <summary>
/// This is one single source file.
/// </summary>
/// <remarks>
/// This is intentionally a class and not a struct since we need
/// to pass this by reference.
/// </remarks>
public class SourceFile : ISourceFile, IEquatable<SourceFile>
namespace Mono.CSharp
{
//
// This is one single source file.
//
public class SourceFile : IEquatable<SourceFile>
{
//
// Used by #line directive to track hidden sequence point
// regions
//
struct LocationRegion : IComparable<LocationRegion>
{
public readonly Location Start;
public readonly Location End;
public LocationRegion (Location start, Location end)
{
this.Start = start;
this.End = end;
}
public int CompareTo (LocationRegion other)
{
if (Start.Row == other.Start.Row)
return Start.Column.CompareTo (other.Start.Column);
return Start.Row.CompareTo (other.Start.Row);
}
public override string ToString ()
{
return Start.ToString () + " - " + End.ToString ();
}
}
public readonly string Name;
public readonly string FullPathName;
public readonly int Index;
@ -34,6 +60,7 @@ namespace Mono.CSharp { @@ -34,6 +60,7 @@ namespace Mono.CSharp {
SourceFileEntry file;
byte[] guid, checksum;
List<LocationRegion> hidden_lines;
public SourceFile (string name, string path, int index)
{
@ -43,11 +70,9 @@ namespace Mono.CSharp { @@ -43,11 +70,9 @@ namespace Mono.CSharp {
}
public SourceFileEntry SourceFileEntry {
get { return file; }
}
SourceFileEntry ISourceFile.Entry {
get { return file; }
get {
return file;
}
}
public void SetChecksum (byte[] guid, byte[] checksum)
@ -56,8 +81,11 @@ namespace Mono.CSharp { @@ -56,8 +81,11 @@ namespace Mono.CSharp {
this.checksum = checksum;
}
public virtual void DefineSymbolInfo (MonoSymbolWriter symwriter)
public SourceFileEntry CreateSymbolInfo (MonoSymbolWriter symwriter)
{
if (hidden_lines != null)
hidden_lines.Sort ();
if (guid != null)
file = symwriter.DefineDocument (FullPathName, guid, checksum);
else {
@ -65,6 +93,8 @@ namespace Mono.CSharp { @@ -65,6 +93,8 @@ namespace Mono.CSharp {
if (AutoGenerated)
file.SetAutoGenerated ();
}
return file;
}
public bool Equals (SourceFile other)
@ -72,97 +102,33 @@ namespace Mono.CSharp { @@ -72,97 +102,33 @@ namespace Mono.CSharp {
return FullPathName == other.FullPathName;
}
public override string ToString ()
public bool IsHiddenLocation (Location loc)
{
return String.Format ("SourceFile ({0}:{1}:{2}:{3})",
Name, FullPathName, Index, SourceFileEntry);
}
}
public class CompilationSourceFile : SourceFile, ICompileUnit
{
CompileUnitEntry comp_unit;
Dictionary<string, SourceFile> include_files;
Dictionary<string, bool> conditionals;
NamespaceContainer ns_container;
if (hidden_lines == null)
return false;
public CompilationSourceFile (string name, string fullPathName, int index)
: base (name, fullPathName, index)
{
}
CompileUnitEntry ICompileUnit.Entry {
get { return comp_unit; }
}
public CompileUnitEntry CompileUnitEntry {
get { return comp_unit; }
}
public NamespaceContainer NamespaceContainer {
get {
return ns_container;
int index = hidden_lines.BinarySearch (new LocationRegion (loc, loc));
index = ~index;
if (index > 0) {
var found = hidden_lines[index - 1];
if (loc.Row < found.End.Row)
return true;
}
set {
ns_container = value;
}
}
public void AddIncludeFile (SourceFile file)
{
if (file == this)
return;
if (include_files == null)
include_files = new Dictionary<string, SourceFile> ();
if (!include_files.ContainsKey (file.FullPathName))
include_files.Add (file.FullPathName, file);
return false;
}
public void AddDefine (string value)
public void RegisterHiddenScope (Location start, Location end)
{
if (conditionals == null)
conditionals = new Dictionary<string, bool> (2);
if (hidden_lines == null)
hidden_lines = new List<LocationRegion> ();
conditionals [value] = true;
hidden_lines.Add (new LocationRegion (start, end));
}
public void AddUndefine (string value)
{
if (conditionals == null)
conditionals = new Dictionary<string, bool> (2);
conditionals [value] = false;
}
public override void DefineSymbolInfo (MonoSymbolWriter symwriter)
{
base.DefineSymbolInfo (symwriter);
comp_unit = symwriter.DefineCompilationUnit (SourceFileEntry);
if (include_files != null) {
foreach (SourceFile include in include_files.Values) {
include.DefineSymbolInfo (symwriter);
comp_unit.AddFile (include.SourceFileEntry);
}
}
}
public bool IsConditionalDefined (CompilerContext ctx, string value)
public override string ToString ()
{
if (conditionals != null) {
bool res;
if (conditionals.TryGetValue (value, out res))
return res;
// When conditional was undefined
if (conditionals.ContainsKey (value))
return false;
}
return ctx.Settings.IsConditionalSymbolDefined (value);
return String.Format ("SourceFile ({0}:{1}:{2})", Name, FullPathName, Index);
}
}
@ -186,41 +152,37 @@ namespace Mono.CSharp { @@ -186,41 +152,37 @@ namespace Mono.CSharp {
{
struct Checkpoint {
public readonly int LineOffset;
public readonly int CompilationUnit;
public readonly int File;
public Checkpoint (int compile_unit, int file, int line)
public Checkpoint (int file, int line)
{
File = file;
CompilationUnit = compile_unit;
LineOffset = line - (int) (line % (1 << line_delta_bits));
}
}
#if FULL_AST
long token;
readonly long token;
const int column_bits = 24;
const int line_delta_bits = 24;
#else
int token;
readonly int token;
const int column_bits = 8;
const int line_delta_bits = 8;
#endif
const int checkpoint_bits = 16;
// -2 because the last one is used for hidden
const int max_column = (1 << column_bits) - 2;
const int column_mask = (1 << column_bits) - 1;
const int max_column = column_mask;
static List<SourceFile> source_list;
static int current_source;
static int current_compile_unit;
static Checkpoint [] checkpoints;
static int checkpoint_index;
public readonly static Location Null = new Location (-1);
public readonly static Location Null = new Location ();
public static bool InEmacs;
static Location ()
@ -232,15 +194,12 @@ namespace Mono.CSharp { @@ -232,15 +194,12 @@ namespace Mono.CSharp {
{
source_list = new List<SourceFile> ();
current_source = 0;
current_compile_unit = 0;
checkpoint_index = 0;
}
public static SourceFile AddFile (string name, string fullName)
public static void AddFile (SourceFile file)
{
var source = new SourceFile (name, fullName, source_list.Count + 1);
source_list.Add (source);
return source;
source_list.Add (file);
}
// <summary>
@ -249,31 +208,25 @@ namespace Mono.CSharp { @@ -249,31 +208,25 @@ namespace Mono.CSharp {
// source file. We reserve some extra space for files we encounter via #line
// directives while parsing.
// </summary>
static public void Initialize (List<CompilationSourceFile> files)
static public void Initialize (List<SourceFile> files)
{
#if NET_4_0
#if NET_4_0 || MONODROID
source_list.AddRange (files);
#else
source_list.AddRange (files.ToArray ());
#endif
checkpoints = new Checkpoint [source_list.Count * 2];
checkpoints = new Checkpoint [System.Math.Max (1, source_list.Count * 2)];
if (checkpoints.Length > 0)
checkpoints [0] = new Checkpoint (0, 0, 0);
checkpoints [0] = new Checkpoint (0, 0);
}
static public void Push (CompilationSourceFile compile_unit, SourceFile file)
static public void Push (SourceFile file)
{
current_source = file != null ? file.Index : -1;
current_compile_unit = compile_unit != null ? compile_unit.Index : -1;
// File is always pushed before being changed.
}
public Location (int row)
: this (row, 0)
{
}
public Location (int row, int column)
{
if (row <= 0)
@ -281,8 +234,6 @@ namespace Mono.CSharp { @@ -281,8 +234,6 @@ namespace Mono.CSharp {
else {
if (column > max_column)
column = max_column;
else if (column < 0)
column = max_column + 1;
long target = -1;
long delta = 0;
@ -301,7 +252,7 @@ namespace Mono.CSharp { @@ -301,7 +252,7 @@ namespace Mono.CSharp {
}
}
if (target == -1) {
AddCheckpoint (current_compile_unit, current_source, row);
AddCheckpoint (current_source, row);
target = checkpoint_index;
delta = row % (1 << line_delta_bits);
}
@ -322,12 +273,12 @@ namespace Mono.CSharp { @@ -322,12 +273,12 @@ namespace Mono.CSharp {
return new Location (loc.Row, loc.Column - columns);
}
static void AddCheckpoint (int compile_unit, int file, int row)
static void AddCheckpoint (int file, int row)
{
if (checkpoints.Length == ++checkpoint_index) {
Array.Resize (ref checkpoints, checkpoint_index * 2);
}
checkpoints [checkpoint_index] = new Checkpoint (compile_unit, file, row);
checkpoints [checkpoint_index] = new Checkpoint (file, row);
}
string FormatLocation (string fileName)
@ -359,10 +310,9 @@ namespace Mono.CSharp { @@ -359,10 +310,9 @@ namespace Mono.CSharp {
public string Name {
get {
int index = File;
if (token == 0 || index == 0)
return "Internal";
if (source_list == null || index - 1 >= source_list.Count)
return "unknown_file";
if (token == 0 || index <= 0)
return null;
SourceFile file = source_list [index - 1];
return file.Name;
@ -372,8 +322,8 @@ namespace Mono.CSharp { @@ -372,8 +322,8 @@ namespace Mono.CSharp {
public string NameFullPath {
get {
int index = File;
if (token == 0 || index == 0)
return "Internal";
if (token == 0 || index <= 0)
return null;
return source_list[index - 1].FullPathName;
}
@ -402,23 +352,7 @@ namespace Mono.CSharp { @@ -402,23 +352,7 @@ namespace Mono.CSharp {
get {
if (token == 0)
return 1;
int col = (int) (token & column_mask);
return col > max_column ? 1 : col;
}
}
public bool Hidden {
get {
return (int) (token & column_mask) == max_column + 1;
}
}
public int CompilationUnitIndex {
get {
if (token == 0)
return 0;
if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format ("Should not happen. Token is {0:X04}, checkpoints are {1}, index is {2}", token, checkpoints.Length, CheckpointIndex));
return checkpoints [CheckpointIndex].CompilationUnit;
return (int) (token & column_mask);
}
}
@ -448,16 +382,7 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" @@ -448,16 +382,7 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format ("
int index = File;
if (index == 0)
return null;
return (SourceFile) source_list [index - 1];
}
}
public CompilationSourceFile CompilationUnit {
get {
int index = CompilationUnitIndex;
if (index == 0)
return null;
return (CompilationSourceFile) source_list [index - 1];
return source_list [index - 1];
}
}
@ -765,173 +690,4 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" @@ -765,173 +690,4 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format ("
return found;
}
}
public class UsingsBag
{
public class Namespace {
public Location NamespaceLocation { get; set; }
public MemberName Name { get; set; }
public Location OpenBrace { get; set; }
public Location CloseBrace { get; set; }
public Location OptSemicolon { get; set; }
public List<object> usings = new List<object> ();
public List<object> members = new List<object> ();
public Namespace ()
{
// in case of missing close brace, set it to the highest value.
CloseBrace = new Location (int.MaxValue, int.MaxValue);
}
public virtual void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
public class AliasUsing
{
public readonly Location UsingLocation;
public readonly Tokenizer.LocatedToken Identifier;
public readonly Location AssignLocation;
public readonly MemberName Nspace;
public readonly Location SemicolonLocation;
public AliasUsing (Location usingLocation, Tokenizer.LocatedToken identifier, Location assignLocation, MemberName nspace, Location semicolonLocation)
{
this.UsingLocation = usingLocation;
this.Identifier = identifier;
this.AssignLocation = assignLocation;
this.Nspace = nspace;
this.SemicolonLocation = semicolonLocation;
}
public virtual void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
public class Using
{
public readonly Location UsingLocation;
public readonly MemberName NSpace;
public readonly Location SemicolonLocation;
public Using (Location usingLocation, MemberName nSpace, Location semicolonLocation)
{
this.UsingLocation = usingLocation;
this.NSpace = nSpace;
this.SemicolonLocation = semicolonLocation;
}
public virtual void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
public class ExternAlias
{
public readonly Location ExternLocation;
public readonly Location AliasLocation;
public readonly Tokenizer.LocatedToken Identifier;
public readonly Location SemicolonLocation;
public ExternAlias (Location externLocation, Location aliasLocation, Tokenizer.LocatedToken identifier, Location semicolonLocation)
{
this.ExternLocation = externLocation;
this.AliasLocation = aliasLocation;
this.Identifier = identifier;
this.SemicolonLocation = semicolonLocation;
}
public virtual void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
public Namespace Global {
get;
set;
}
Stack<Namespace> curNamespace = new Stack<Namespace> ();
public UsingsBag ()
{
Global = new Namespace ();
Global.OpenBrace = new Location (1, 1);
Global.CloseBrace = new Location (int.MaxValue, int.MaxValue);
curNamespace.Push (Global);
}
[Conditional ("FULL_AST")]
public void AddUsingAlias (Location usingLocation, Tokenizer.LocatedToken identifier, Location assignLocation, MemberName nspace, Location semicolonLocation)
{
curNamespace.Peek ().usings.Add (new AliasUsing (usingLocation, identifier, assignLocation, nspace, semicolonLocation));
}
[Conditional ("FULL_AST")]
public void AddUsing (Location usingLocation, MemberName nspace, Location semicolonLocation)
{
curNamespace.Peek ().usings.Add (new Using (usingLocation, nspace, semicolonLocation));
}
[Conditional ("FULL_AST")]
public void AddExternAlias (Location externLocation, Location aliasLocation, Tokenizer.LocatedToken identifier, Location semicolonLocation)
{
curNamespace.Peek ().usings.Add (new ExternAlias (externLocation, aliasLocation, identifier, semicolonLocation));
}
[Conditional ("FULL_AST")]
public void DeclareNamespace (Location namespaceLocation, MemberName nspace)
{
var newNamespace = new Namespace () { NamespaceLocation = namespaceLocation, Name = nspace };
curNamespace.Peek ().members.Add (newNamespace);
curNamespace.Push (newNamespace);
}
int typeLevel = 0;
[Conditional ("FULL_AST")]
public void PushTypeDeclaration (object type)
{
if (typeLevel == 0)
curNamespace.Peek ().members.Add (type);
typeLevel++;
}
[Conditional ("FULL_AST")]
public void PopTypeDeclaration ()
{
typeLevel--;
}
[Conditional ("FULL_AST")]
public void EndNamespace (Location optSemicolon)
{
curNamespace.Peek ().OptSemicolon = optSemicolon;
curNamespace.Pop ();
}
[Conditional ("FULL_AST")]
public void EndNamespace ()
{
curNamespace.Pop ();
}
[Conditional ("FULL_AST")]
public void OpenNamespace (Location bracketLocation)
{
curNamespace.Peek ().OpenBrace = bracketLocation;
}
[Conditional ("FULL_AST")]
public void CloseNamespace (Location bracketLocation)
{
curNamespace.Peek ().CloseBrace = bracketLocation;
}
}
}

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

@ -41,6 +41,7 @@ namespace Mono.CSharp { @@ -41,6 +41,7 @@ namespace Mono.CSharp {
InternalCompilerType = 1 << 21,
MissingType = 1 << 22,
Void = 1 << 23,
Namespace = 1 << 24,
NestedMask = Class | Struct | Delegate | Enum | Interface,
GenericMask = Method | Class | Struct | Delegate | Interface,
@ -303,24 +304,28 @@ namespace Mono.CSharp { @@ -303,24 +304,28 @@ namespace Mono.CSharp {
{
if (member.Kind == MemberKind.Operator) {
var dt = member.DeclaringType;
switch (dt.BuiltinType) {
case BuiltinTypeSpec.Type.String:
case BuiltinTypeSpec.Type.Delegate:
case BuiltinTypeSpec.Type.MulticastDelegate:
// Some core types have user operators but they cannot be used as normal
// user operators as they are predefined and therefore having different
// rules (e.g. binary operators) by not setting the flag we hide them for
// user conversions
// TODO: Should I do this for all core types ?
break;
default:
if (name == Operator.GetMetadataName (Operator.OpType.Implicit) || name == Operator.GetMetadataName (Operator.OpType.Explicit)) {
state |= StateFlags.HasConversionOperator;
} else {
state |= StateFlags.HasUserOperator;
}
break;
//
// Some core types have user operators but they cannot be used like normal
// user operators as they are predefined and therefore having different
// rules (e.g. binary operators) by not setting the flag we hide them for
// user conversions
//
if (!BuiltinTypeSpec.IsPrimitiveType (dt)) {
switch (dt.BuiltinType) {
case BuiltinTypeSpec.Type.String:
case BuiltinTypeSpec.Type.Delegate:
case BuiltinTypeSpec.Type.MulticastDelegate:
break;
default:
if (name == Operator.GetMetadataName (Operator.OpType.Implicit) || name == Operator.GetMetadataName (Operator.OpType.Explicit)) {
state |= StateFlags.HasConversionOperator;
} else {
state |= StateFlags.HasUserOperator;
}
break;
}
}
}
@ -468,7 +473,7 @@ namespace Mono.CSharp { @@ -468,7 +473,7 @@ namespace Mono.CSharp {
// based on type definition
var tc = container.MemberDefinition as TypeContainer;
if (tc != null)
tc.DefineType ();
tc.DefineContainer ();
if (container.MemberCacheTypes.member_hash.TryGetValue (name, out applicable)) {
for (int i = applicable.Count - 1; i >= 0; i--) {
@ -889,7 +894,7 @@ namespace Mono.CSharp { @@ -889,7 +894,7 @@ namespace Mono.CSharp {
return IndexerNameAlias;
if (mc is Constructor)
return Constructor.ConstructorName;
return mc.IsStatic ? Constructor.TypeConstructorName : Constructor.ConstructorName;
return mc.MemberName.Name;
}

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

@ -47,10 +47,9 @@ namespace Mono.CSharp { @@ -47,10 +47,9 @@ namespace Mono.CSharp {
protected ToplevelBlock block;
protected MethodSpec spec;
public MethodCore (DeclSpace parent, GenericMethod generic,
FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
public MethodCore (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
MemberName name, Attributes attrs, ParametersCompiled parameters)
: base (parent, generic, type, mod, allowed_mod, name, attrs)
: base (parent, type, mod, allowed_mod, name, attrs)
{
this.parameters = parameters;
}
@ -518,11 +517,9 @@ namespace Mono.CSharp { @@ -518,11 +517,9 @@ namespace Mono.CSharp {
static readonly string[] attribute_targets = new string [] { "method", "return" };
protected MethodOrOperator (DeclSpace parent, GenericMethod generic, FullNamedExpression type, Modifiers mod,
Modifiers allowed_mod, MemberName name,
protected MethodOrOperator (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name,
Attributes attrs, ParametersCompiled parameters)
: base (parent, generic, type, mod, allowed_mod, name,
attrs, parameters)
: base (parent, type, mod, allowed_mod, name, attrs, parameters)
{
}
@ -612,7 +609,7 @@ namespace Mono.CSharp { @@ -612,7 +609,7 @@ namespace Mono.CSharp {
}
MethodData = new MethodData (
this, ModFlags, flags, this, MethodBuilder, GenericMethod, base_method);
this, ModFlags, flags, this, MethodBuilder, base_method);
if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName)))
return false;
@ -777,15 +774,6 @@ namespace Mono.CSharp { @@ -777,15 +774,6 @@ namespace Mono.CSharp {
return conditions;
}
GenericMethod IMethodData.GenericMethod {
get {
return GenericMethod;
}
}
public virtual void EmitExtraSymbolInfo (SourceMethod source)
{ }
#endregion
}
@ -793,13 +781,11 @@ namespace Mono.CSharp { @@ -793,13 +781,11 @@ namespace Mono.CSharp {
public class SourceMethod : IMethodDef
{
MethodBase method;
SourceMethodBuilder builder;
protected SourceMethod (DeclSpace parent, MethodBase method, ICompileUnit file)
SourceMethod (MethodBase method, ICompileUnit file)
{
this.method = method;
builder = SymbolWriter.OpenMethod (file, parent.NamespaceEntry.SymbolFileID, this);
SymbolWriter.OpenMethod (file, this);
}
public string Name {
@ -827,28 +813,16 @@ namespace Mono.CSharp { @@ -827,28 +813,16 @@ namespace Mono.CSharp {
SymbolWriter.CloseMethod ();
}
public void SetRealMethodName (string name)
{
if (builder != null)
builder.SetRealMethodName (name);
}
public static SourceMethod Create (DeclSpace parent, MethodBase method, Block block)
public static SourceMethod Create (TypeDefinition parent, MethodBase method)
{
if (!SymbolWriter.HasSymbolWriter)
return null;
if (block == null)
return null;
Location start_loc = block.StartLocation;
if (start_loc.IsNull)
return null;
ICompileUnit compile_unit = start_loc.CompilationUnit;
if (compile_unit == null)
var source_file = parent.GetCompilationSourceFile ();
if (source_file == null)
return null;
return new SourceMethod (parent, method, compile_unit);
return new SourceMethod (method, source_file.SymbolUnitEntry);
}
}
@ -856,10 +830,8 @@ namespace Mono.CSharp { @@ -856,10 +830,8 @@ namespace Mono.CSharp {
{
Method partialMethodImplementation;
public Method (DeclSpace parent, GenericMethod generic,
FullNamedExpression return_type, Modifiers mod,
MemberName name, ParametersCompiled parameters, Attributes attrs)
: base (parent, generic, return_type, mod,
public Method (TypeDefinition parent, FullNamedExpression return_type, Modifiers mod, MemberName name, ParametersCompiled parameters, Attributes attrs)
: base (parent, return_type, mod,
parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface :
parent.PartialContainer.Kind == MemberKind.Struct ? AllowedModifiersStruct | Modifiers.ASYNC :
AllowedModifiersClass | Modifiers.ASYNC,
@ -867,42 +839,43 @@ namespace Mono.CSharp { @@ -867,42 +839,43 @@ namespace Mono.CSharp {
{
}
protected Method (DeclSpace parent, FullNamedExpression return_type, Modifiers mod, Modifiers amod,
protected Method (TypeDefinition parent, FullNamedExpression return_type, Modifiers mod, Modifiers amod,
MemberName name, ParametersCompiled parameters, Attributes attrs)
: base (parent, null, return_type, mod, amod, name, attrs, parameters)
: base (parent, return_type, mod, amod, name, attrs, parameters)
{
}
#region Properties
public override TypeParameter[] CurrentTypeParameters {
public override TypeParameters CurrentTypeParameters {
get {
if (GenericMethod != null)
return GenericMethod.CurrentTypeParameters;
return null;
return MemberName.TypeParameters;
}
}
public TypeParameterSpec[] TypeParameters {
get {
// TODO: Cache this
return CurrentTypeParameters.Select (l => l.Type).ToArray ();
return CurrentTypeParameters.Types;
}
}
public int TypeParametersCount {
get {
return CurrentTypeParameters == null ? 0 : CurrentTypeParameters.Length;
return CurrentTypeParameters == null ? 0 : CurrentTypeParameters.Count;
}
}
#endregion
public static Method Create (DeclSpace parent, GenericMethod generic, FullNamedExpression returnType, Modifiers mod,
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public static Method Create (TypeDefinition parent, FullNamedExpression returnType, Modifiers mod,
MemberName name, ParametersCompiled parameters, Attributes attrs, bool hasConstraints)
{
var m = new Method (parent, generic, returnType, mod, name, parameters, attrs);
var m = new Method (parent, returnType, mod, name, parameters, attrs);
if (hasConstraints && ((mod & Modifiers.OVERRIDE) != 0 || m.IsExplicitImpl)) {
m.Report.Error (460, m.Location,
@ -966,9 +939,9 @@ namespace Mono.CSharp { @@ -966,9 +939,9 @@ namespace Mono.CSharp {
public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
if (arity == 0) {
TypeParameter[] tp = CurrentTypeParameters;
var tp = CurrentTypeParameters;
if (tp != null) {
TypeParameter t = TypeParameter.FindTypeParameter (tp, name);
TypeParameter t = tp.Find (name);
if (t != null)
return new TypeParameterExpr (t, loc);
}
@ -1023,6 +996,45 @@ namespace Mono.CSharp { @@ -1023,6 +996,45 @@ namespace Mono.CSharp {
base.ApplyAttributeBuilder (a, ctor, cdata, pa);
}
void CreateTypeParameters ()
{
var tparams = MemberName.TypeParameters;
string[] snames = new string[MemberName.Arity];
var parent_tparams = Parent.TypeParametersAll;
for (int i = 0; i < snames.Length; i++) {
string type_argument_name = tparams[i].MemberName.Name;
if (block == null) {
int idx = parameters.GetParameterIndexByName (type_argument_name);
if (idx >= 0) {
var b = block;
if (b == null)
b = new ToplevelBlock (Compiler, Location);
b.Error_AlreadyDeclaredTypeParameter (type_argument_name, parameters[i].Location);
}
} else {
INamedBlockVariable variable = null;
block.GetLocalName (type_argument_name, block, ref variable);
if (variable != null)
variable.Block.Error_AlreadyDeclaredTypeParameter (type_argument_name, variable.Location);
}
if (parent_tparams != null) {
var tp = parent_tparams.Find (type_argument_name);
if (tp != null) {
tparams[i].WarningParentNameConflict (tp);
}
}
snames[i] = type_argument_name;
}
GenericTypeParameterBuilder[] gen_params = MethodBuilder.DefineGenericParameters (snames);
tparams.Define (gen_params, null, 0, Parent);
}
protected virtual void DefineTypeParameters ()
{
var tparams = CurrentTypeParameters;
@ -1065,10 +1077,10 @@ namespace Mono.CSharp { @@ -1065,10 +1077,10 @@ namespace Mono.CSharp {
if (base_decl_tparams.Length != 0) {
base_decl_tparams = base_decl_tparams.Concat (base_tparams).ToArray ();
base_targs = base_targs.Concat (tparams.Select<TypeParameter, TypeSpec> (l => l.Type)).ToArray ();
base_targs = base_targs.Concat (tparams.Types).ToArray ();
} else {
base_decl_tparams = base_tparams;
base_targs = tparams.Select (l => l.Type).ToArray ();
base_targs = tparams.Types;
}
}
} else if (MethodData.implementing != null) {
@ -1085,7 +1097,7 @@ namespace Mono.CSharp { @@ -1085,7 +1097,7 @@ namespace Mono.CSharp {
}
}
for (int i = 0; i < tparams.Length; ++i) {
for (int i = 0; i < tparams.Count; ++i) {
var tp = tparams[i];
if (!tp.ResolveConstraints (this))
@ -1175,11 +1187,6 @@ namespace Mono.CSharp { @@ -1175,11 +1187,6 @@ namespace Mono.CSharp {
return true;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
//
// Creates the type
//
@ -1202,10 +1209,10 @@ namespace Mono.CSharp { @@ -1202,10 +1209,10 @@ namespace Mono.CSharp {
}
if (CurrentTypeParameters == null) {
if (base_method != null) {
if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && Name == "Equals")
if (base_method != null && !IsExplicitImpl) {
if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && MemberName.Name == "Equals")
Parent.PartialContainer.Mark_HasEquals ();
else if (parameters.IsEmpty && Name == "GetHashCode")
else if (parameters.IsEmpty && MemberName.Name == "GetHashCode")
Parent.PartialContainer.Mark_HasGetHashCode ();
}
@ -1238,7 +1245,7 @@ namespace Mono.CSharp { @@ -1238,7 +1245,7 @@ namespace Mono.CSharp {
return true;
if (parameters.HasExtensionMethodType) {
if (Parent.PartialContainer.IsStatic && !Parent.IsGeneric) {
if (Parent.PartialContainer.IsStatic && !Parent.IsGenericOrParentIsGeneric) {
if (!Parent.IsTopLevel)
Report.Error (1109, Location, "`{0}': Extension methods cannot be defined in a nested class",
GetSignatureForError ());
@ -1264,10 +1271,10 @@ namespace Mono.CSharp { @@ -1264,10 +1271,10 @@ namespace Mono.CSharp {
// This is used to track the Entry Point,
//
var settings = Compiler.Settings;
if (settings.NeedsEntryPoint && Name == "Main" && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) {
if (settings.NeedsEntryPoint && MemberName.Name == "Main" && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) {
if (IsEntryPoint ()) {
if (Parent.DeclaringAssembly.EntryPoint == null) {
if (Parent.IsGeneric || MemberName.IsGeneric) {
if (Parent.IsGenericOrParentIsGeneric || MemberName.IsGeneric) {
Report.Warning (402, 4, Location, "`{0}': an entry point cannot be generic or in a generic type",
GetSignatureForError ());
} else if ((ModFlags & Modifiers.ASYNC) != 0) {
@ -1313,7 +1320,7 @@ namespace Mono.CSharp { @@ -1313,7 +1320,7 @@ namespace Mono.CSharp {
}
if (CurrentTypeParameters != null) {
for (int i = 0; i < CurrentTypeParameters.Length; ++i) {
for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
var tp = CurrentTypeParameters [i];
tp.CheckGenericConstraints (false);
tp.Emit ();
@ -1333,10 +1340,6 @@ namespace Mono.CSharp { @@ -1333,10 +1340,6 @@ namespace Mono.CSharp {
public override bool EnableOverloadChecks (MemberCore overload)
{
// TODO: It can be deleted when members will be defined in correct order
if (overload is Operator)
return overload.EnableOverloadChecks (this);
if (overload is Indexer)
return false;
@ -1350,10 +1353,9 @@ namespace Mono.CSharp { @@ -1350,10 +1353,9 @@ namespace Mono.CSharp {
protected override bool ResolveMemberType ()
{
if (GenericMethod != null) {
if (CurrentTypeParameters != null) {
MethodBuilder = Parent.TypeBuilder.DefineMethod (GetFullName (MemberName), flags);
if (!GenericMethod.Define (this))
return false;
CreateTypeParameters ();
}
return base.ResolveMemberType ();
@ -1461,7 +1463,7 @@ namespace Mono.CSharp { @@ -1461,7 +1463,7 @@ namespace Mono.CSharp {
ec.Report.Error (516, loc, "Constructor `{0}' cannot call itself",
caller_builder.GetSignatureForError ());
}
return this;
}
@ -1471,8 +1473,6 @@ namespace Mono.CSharp { @@ -1471,8 +1473,6 @@ namespace Mono.CSharp {
if (base_ctor == null)
return;
ec.Mark (loc);
var call = new CallEmitter ();
call.InstanceExpression = new CompilerGeneratedThis (type, loc);
call.EmitPredefined (ec, base_ctor, argument_list);
@ -1528,20 +1528,15 @@ namespace Mono.CSharp { @@ -1528,20 +1528,15 @@ namespace Mono.CSharp {
public static readonly string ConstructorName = ".ctor";
public static readonly string TypeConstructorName = ".cctor";
//
// The spec claims that static is not permitted, but
// my very own code has static constructors.
//
public Constructor (DeclSpace parent, string name, Modifiers mod, Attributes attrs, ParametersCompiled args,
ConstructorInitializer init, Location loc)
: base (parent, null, null, mod, AllowedModifiers,
new MemberName (name, loc), attrs, args)
public Constructor (TypeDefinition parent, string name, Modifiers mod, Attributes attrs, ParametersCompiled args, Location loc)
: base (parent, null, mod, AllowedModifiers, new MemberName (name, loc), attrs, args)
{
Initializer = init;
}
public bool HasCompliantArgs {
get { return has_compliant_args; }
get {
return has_compliant_args;
}
}
public override AttributeTargets AttributeTargets {
@ -1569,6 +1564,11 @@ namespace Mono.CSharp { @@ -1569,6 +1564,11 @@ namespace Mono.CSharp {
(Initializer.Arguments == null);
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.IsValidSecurityAttribute ()) {
@ -1592,6 +1592,9 @@ namespace Mono.CSharp { @@ -1592,6 +1592,9 @@ namespace Mono.CSharp {
return false;
}
if ((caching_flags & Flags.MethodOverloadsExist) != 0)
Parent.MemberCache.CheckExistingMembersOverloads (this, parameters);
// the rest can be ignored
return true;
}
@ -1614,11 +1617,6 @@ namespace Mono.CSharp { @@ -1614,11 +1617,6 @@ namespace Mono.CSharp {
return true;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
//
// Creates the ConstructorBuilder
//
@ -1627,14 +1625,6 @@ namespace Mono.CSharp { @@ -1627,14 +1625,6 @@ namespace Mono.CSharp {
if (ConstructorBuilder != null)
return true;
var ca = MethodAttributes.RTSpecialName | MethodAttributes.SpecialName;
if ((ModFlags & Modifiers.STATIC) != 0) {
ca |= MethodAttributes.Static | MethodAttributes.Private;
} else {
ca |= ModifiersExtensions.MethodAttr (ModFlags);
}
if (!CheckAbstractAndExtern (block != null))
return false;
@ -1642,6 +1632,8 @@ namespace Mono.CSharp { @@ -1642,6 +1632,8 @@ namespace Mono.CSharp {
if (!CheckBase ())
return false;
var ca = ModifiersExtensions.MethodAttr (ModFlags) | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName;
ConstructorBuilder = Parent.TypeBuilder.DefineConstructor (
ca, CallingConventions,
parameters.GetMetaInfo ());
@ -1685,50 +1677,56 @@ namespace Mono.CSharp { @@ -1685,50 +1677,56 @@ namespace Mono.CSharp {
base.Emit ();
parameters.ApplyAttributes (this, ConstructorBuilder);
//
// If we use a "this (...)" constructor initializer, then
// do not emit field initializers, they are initialized in the other constructor
//
bool emit_field_initializers = ((ModFlags & Modifiers.STATIC) != 0) ||
!(Initializer is ConstructorThisInitializer);
BlockContext bc = new BlockContext (this, block, Compiler.BuiltinTypes.Void);
bc.Set (ResolveContext.Options.ConstructorScope);
if (emit_field_initializers)
//
// If we use a "this (...)" constructor initializer, then
// do not emit field initializers, they are initialized in the other constructor
//
if (!(Initializer is ConstructorThisInitializer))
Parent.PartialContainer.ResolveFieldInitializers (bc);
if (block != null) {
// If this is a non-static `struct' constructor and doesn't have any
// initializer, it must initialize all of the struct's fields.
if ((Parent.PartialContainer.Kind == MemberKind.Struct) &&
((ModFlags & Modifiers.STATIC) == 0) && (Initializer == null))
block.AddThisVariable (bc);
if ((ModFlags & Modifiers.STATIC) == 0){
if (Parent.PartialContainer.Kind == MemberKind.Class && Initializer == null)
Initializer = new GeneratedBaseInitializer (Location);
if (!IsStatic) {
if (Initializer == null) {
if (Parent.PartialContainer.Kind == MemberKind.Struct) {
//
// If this is a non-static `struct' constructor and doesn't have any
// initializer, it must initialize all of the struct's fields.
//
block.AddThisVariable (bc);
} else if (Parent.PartialContainer.Kind == MemberKind.Class) {
Initializer = new GeneratedBaseInitializer (Location);
}
}
if (Initializer != null) {
block.AddScopeStatement (new StatementExpression (Initializer));
//
// Use location of the constructor to emit sequence point of initializers
// at beginning of constructor name
//
// TODO: Need to extend mdb to support line regions to allow set a breakpoint at
// initializer
//
block.AddScopeStatement (new StatementExpression (Initializer, Location));
}
}
}
SourceMethod source = SourceMethod.Create (Parent, ConstructorBuilder, block);
if (block != null) {
if (block.Resolve (null, bc, this)) {
EmitContext ec = new EmitContext (this, ConstructorBuilder.GetILGenerator (), bc.ReturnType);
ec.With (EmitContext.Options.ConstructorScope, true);
SourceMethod source = SourceMethod.Create (Parent, ConstructorBuilder);
block.Emit (ec);
if (source != null)
source.CloseMethod ();
}
}
if (source != null)
source.CloseMethod ();
if (declarative_security != null) {
foreach (var de in declarative_security) {
#if STATIC
@ -1807,15 +1805,6 @@ namespace Mono.CSharp { @@ -1807,15 +1805,6 @@ namespace Mono.CSharp {
return false;
}
GenericMethod IMethodData.GenericMethod {
get {
return null;
}
}
void IMethodData.EmitExtraSymbolInfo (SourceMethod source)
{ }
#endregion
}
@ -1828,7 +1817,6 @@ namespace Mono.CSharp { @@ -1828,7 +1817,6 @@ namespace Mono.CSharp {
Location Location { get; }
MemberName MethodName { get; }
TypeSpec ReturnType { get; }
GenericMethod GenericMethod { get; }
ParametersCompiled ParameterInfo { get; }
MethodSpec Spec { get; }
bool IsAccessor { get; }
@ -1837,7 +1825,6 @@ namespace Mono.CSharp { @@ -1837,7 +1825,6 @@ namespace Mono.CSharp {
ToplevelBlock Block { get; set; }
EmitContext CreateEmitContext (ILGenerator ig);
void EmitExtraSymbolInfo (SourceMethod source);
}
//
@ -1851,8 +1838,6 @@ namespace Mono.CSharp { @@ -1851,8 +1838,6 @@ namespace Mono.CSharp {
public readonly IMethodData method;
public readonly GenericMethod GenericMethod;
//
// Are we implementing an interface ?
//
@ -1893,15 +1878,14 @@ namespace Mono.CSharp { @@ -1893,15 +1878,14 @@ namespace Mono.CSharp {
public MethodData (InterfaceMemberBase member,
Modifiers modifiers, MethodAttributes flags,
IMethodData method, MethodBuilder builder,
GenericMethod generic, MethodSpec parent_method)
MethodSpec parent_method)
: this (member, modifiers, flags, method)
{
this.builder = builder;
this.GenericMethod = generic;
this.parent_method = parent_method;
}
public bool Define (TypeContainer container, string method_full_name)
public bool Define (TypeDefinition container, string method_full_name)
{
PendingImplementation pending = container.PendingImplementations;
MethodSpec ambig_iface_method;
@ -2073,7 +2057,7 @@ namespace Mono.CSharp { @@ -2073,7 +2057,7 @@ namespace Mono.CSharp {
/// <summary>
/// Create the MethodBuilder for the method
/// </summary>
void DefineMethodBuilder (TypeContainer container, string method_name, ParametersCompiled param)
void DefineMethodBuilder (TypeDefinition container, string method_name, ParametersCompiled param)
{
var return_type = method.ReturnType.GetMetaInfo ();
var p_types = param.GetMetaInfo ();
@ -2109,30 +2093,25 @@ namespace Mono.CSharp { @@ -2109,30 +2093,25 @@ namespace Mono.CSharp {
//
// Emits the code
//
public void Emit (DeclSpace parent)
public void Emit (TypeDefinition parent)
{
if (GenericMethod != null)
GenericMethod.EmitAttributes ();
var mc = (IMemberContext) method;
method.ParameterInfo.ApplyAttributes (mc, MethodBuilder);
SourceMethod source = SourceMethod.Create (parent, MethodBuilder, method.Block);
ToplevelBlock block = method.Block;
if (block != null) {
BlockContext bc = new BlockContext (mc, block, method.ReturnType);
if (block.Resolve (null, bc, method)) {
EmitContext ec = method.CreateEmitContext (MethodBuilder.GetILGenerator ());
SourceMethod source = SourceMethod.Create (parent, MethodBuilder);
block.Emit (ec);
}
}
if (source != null) {
method.EmitExtraSymbolInfo (source);
source.CloseMethod ();
if (source != null)
source.CloseMethod ();
}
}
}
}
@ -2147,14 +2126,18 @@ namespace Mono.CSharp { @@ -2147,14 +2126,18 @@ namespace Mono.CSharp {
public static readonly string MetadataName = "Finalize";
public Destructor (DeclSpace parent, Modifiers mod, ParametersCompiled parameters, Attributes attrs, Location l)
: base (parent, null, null, mod, AllowedModifiers,
new MemberName (MetadataName, l), attrs, parameters)
public Destructor (TypeDefinition parent, Modifiers mod, ParametersCompiled parameters, Attributes attrs, Location l)
: base (parent, null, mod, AllowedModifiers, new MemberName (MetadataName, l), attrs, parameters)
{
ModFlags &= ~Modifiers.PRIVATE;
ModFlags |= Modifiers.PROTECTED | Modifiers.OVERRIDE;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.Conditional) {
@ -2164,10 +2147,6 @@ namespace Mono.CSharp { @@ -2164,10 +2147,6 @@ namespace Mono.CSharp {
base.ApplyAttributeBuilder (a, ctor, cdata, pa);
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
protected override bool CheckBase ()
{
@ -2188,15 +2167,19 @@ namespace Mono.CSharp { @@ -2188,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);
@ -2242,7 +2225,7 @@ namespace Mono.CSharp { @@ -2242,7 +2225,7 @@ namespace Mono.CSharp {
static MemberName SetupName (string prefix, InterfaceMemberBase member, Location loc)
{
return new MemberName (member.MemberName.Left, prefix + member.ShortName, loc);
return new MemberName (member.MemberName.Left, prefix + member.ShortName, member.MemberName.ExplicitInterface, loc);
}
public void UpdateName (InterfaceMemberBase member)
@ -2284,12 +2267,6 @@ namespace Mono.CSharp { @@ -2284,12 +2267,6 @@ namespace Mono.CSharp {
return false;
}
GenericMethod IMethodData.GenericMethod {
get {
return null;
}
}
public MemberName MethodName {
get {
return MemberName;
@ -2348,7 +2325,7 @@ namespace Mono.CSharp { @@ -2348,7 +2325,7 @@ namespace Mono.CSharp {
throw new NotSupportedException ();
}
public virtual void Emit (DeclSpace parent)
public virtual void Emit (TypeDefinition parent)
{
method_data.Emit (parent);
@ -2415,9 +2392,6 @@ namespace Mono.CSharp { @@ -2415,9 +2392,6 @@ namespace Mono.CSharp {
public override string DocCommentHeader {
get { throw new InvalidOperationException ("Unexpected attempt to get doc comment from " + this.GetType () + "."); }
}
void IMethodData.EmitExtraSymbolInfo (SourceMethod source)
{ }
}
public class Operator : MethodOrOperator {
@ -2503,17 +2477,20 @@ namespace Mono.CSharp { @@ -2503,17 +2477,20 @@ namespace Mono.CSharp {
names [(int) OpType.Implicit] = new string [] { "implicit", "op_Implicit" };
names [(int) OpType.Explicit] = new string [] { "explicit", "op_Explicit" };
}
public Operator (DeclSpace parent, OpType type, FullNamedExpression ret_type,
Modifiers mod_flags, ParametersCompiled parameters,
public Operator (TypeDefinition parent, OpType type, FullNamedExpression ret_type, Modifiers mod_flags, ParametersCompiled parameters,
ToplevelBlock block, Attributes attrs, Location loc)
: base (parent, null, ret_type, mod_flags, AllowedModifiers,
new MemberName (GetMetadataName (type), loc), attrs, parameters)
: base (parent, ret_type, mod_flags, AllowedModifiers, new MemberName (GetMetadataName (type), loc), attrs, parameters)
{
OperatorType = type;
Block = block;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.Conditional) {
@ -2524,11 +2501,6 @@ namespace Mono.CSharp { @@ -2524,11 +2501,6 @@ namespace Mono.CSharp {
base.ApplyAttributeBuilder (a, ctor, cdata, pa);
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override bool Define ()
{
const Modifiers RequiredModifiers = Modifiers.PUBLIC | Modifiers.STATIC;

241
ICSharpCode.NRefactory.CSharp/Parser/mcs/roottypes.cs → ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// roottypes.cs: keeps a tree representation of the generated code
// module.cs: keeps a tree representation of the generated code
//
// Authors: Miguel de Icaza (miguel@gnu.org)
// Marek Safar (marek.safar@gmail.com)
@ -15,6 +15,7 @@ using System; @@ -15,6 +15,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Mono.CompilerServices.SymbolWriter;
using System.Linq;
#if STATIC
using IKVM.Reflection;
@ -38,7 +39,7 @@ namespace Mono.CSharp @@ -38,7 +39,7 @@ namespace Mono.CSharp
sealed class StaticDataContainer : CompilerGeneratedClass
{
readonly Dictionary<int, Struct> size_types;
new int fields;
int fields;
public StaticDataContainer (ModuleContainer module)
: base (module, new MemberName ("<PrivateImplementationDetails>" + module.builder.ModuleVersionId.ToString ("B"), Location.Null), Modifiers.STATIC)
@ -46,12 +47,12 @@ namespace Mono.CSharp @@ -46,12 +47,12 @@ namespace Mono.CSharp
size_types = new Dictionary<int, Struct> ();
}
public override void CloseType ()
public override void CloseContainer ()
{
base.CloseType ();
base.CloseContainer ();
foreach (var entry in size_types) {
entry.Value.CloseType ();
entry.Value.CloseContainer ();
}
}
@ -64,9 +65,9 @@ namespace Mono.CSharp @@ -64,9 +65,9 @@ namespace Mono.CSharp
// DefineInitializedData because it creates public type,
// and its name is not unique among modules
//
size_type = new Struct (null, this, new MemberName ("$ArrayType=" + data.Length, loc), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null);
size_type.CreateType ();
size_type.DefineType ();
size_type = new Struct (this, new MemberName ("$ArrayType=" + data.Length, loc), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null);
size_type.CreateContainer ();
size_type.DefineContainer ();
size_types.Add (data.Length, size_type);
@ -93,8 +94,8 @@ namespace Mono.CSharp @@ -93,8 +94,8 @@ namespace Mono.CSharp
{
if (static_data == null) {
static_data = new StaticDataContainer (this);
static_data.CreateType ();
static_data.DefineType ();
static_data.CreateContainer ();
static_data.DefineContainer ();
AddCompilerGeneratedClass (static_data);
}
@ -112,9 +113,6 @@ namespace Mono.CSharp @@ -112,9 +113,6 @@ namespace Mono.CSharp
readonly Dictionary<TypeSpec, ReferenceContainer> reference_types;
readonly Dictionary<TypeSpec, MethodSpec> attrs_cache;
// Used for unique namespaces/types during parsing
Dictionary<MemberName, ITypesContainer> defined_type_containers;
AssemblyDefinition assembly;
readonly CompilerContext context;
readonly RootNamespace global_ns;
@ -131,13 +129,13 @@ namespace Mono.CSharp @@ -131,13 +129,13 @@ namespace Mono.CSharp
static readonly string[] attribute_targets = new string[] { "assembly", "module" };
public ModuleContainer (CompilerContext context)
: base (null, null, MemberName.Null, null, 0)
: base (null, MemberName.Null, null, 0)
{
this.context = context;
caching_flags &= ~(Flags.Obsolete_Undetected | Flags.Excluded_Undetected);
types = new List<TypeContainer> ();
containers = new List<TypeContainer> ();
anonymous_types = new Dictionary<int, List<AnonymousTypeClass>> ();
global_ns = new GlobalRootNamespace ();
alias_ns = new Dictionary<string, RootNamespace> ();
@ -145,8 +143,6 @@ namespace Mono.CSharp @@ -145,8 +143,6 @@ namespace Mono.CSharp
pointer_types = new Dictionary<TypeSpec, PointerContainer> ();
reference_types = new Dictionary<TypeSpec, ReferenceContainer> ();
attrs_cache = new Dictionary<TypeSpec, MethodSpec> ();
defined_type_containers = new Dictionary<MemberName, ITypesContainer> ();
}
#region Properties
@ -184,7 +180,12 @@ namespace Mono.CSharp @@ -184,7 +180,12 @@ namespace Mono.CSharp
}
}
public override AssemblyDefinition DeclaringAssembly {
public int CounterAnonymousTypes { get; set; }
public int CounterAnonymousMethods { get; set; }
public int CounterAnonymousContainers { get; set; }
public int CounterSwitchTypes { get; set; }
public AssemblyDefinition DeclaringAssembly {
get {
return assembly;
}
@ -194,6 +195,12 @@ namespace Mono.CSharp @@ -194,6 +195,12 @@ namespace Mono.CSharp
get; set;
}
public override string DocCommentHeader {
get {
throw new NotSupportedException ();
}
}
public Evaluator Evaluator {
get; set;
}
@ -299,9 +306,9 @@ namespace Mono.CSharp @@ -299,9 +306,9 @@ namespace Mono.CSharp
attributes.AddAttribute (attr);
}
public override TypeContainer AddPartial (TypeContainer nextPart)
public override void AddTypeContainer (TypeContainer tc)
{
return AddPartial (nextPart, nextPart.Name);
containers.Add (tc);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
@ -345,15 +352,15 @@ namespace Mono.CSharp @@ -345,15 +352,15 @@ namespace Mono.CSharp
builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
}
public override void CloseType ()
public override void CloseContainer ()
{
foreach (TypeContainer tc in types) {
tc.CloseType ();
if (anonymous_types != null) {
foreach (var atypes in anonymous_types)
foreach (var at in atypes.Value)
at.CloseContainer ();
}
if (compiler_generated != null)
foreach (CompilerGeneratedClass c in compiler_generated)
c.CloseType ();
base.CloseContainer ();
}
public TypeBuilder CreateBuilder (string name, TypeAttributes attr, int typeSize)
@ -367,7 +374,7 @@ namespace Mono.CSharp @@ -367,7 +374,7 @@ namespace Mono.CSharp
public RootNamespace CreateRootNamespace (string alias)
{
if (alias == global_ns.Alias) {
NamespaceContainer.Error_GlobalNamespaceRedefined (Location.Null, Report);
RootNamespace.Error_GlobalNamespaceRedefined (Report, Location.Null);
return global_ns;
}
@ -386,43 +393,25 @@ namespace Mono.CSharp @@ -386,43 +393,25 @@ namespace Mono.CSharp
builder = moduleBuilder;
}
public new void CreateType ()
public override bool Define ()
{
// Release cache used by parser only
if (Evaluator == null)
defined_type_containers = null;
else
defined_type_containers.Clear ();
DefineContainer ();
foreach (TypeContainer tc in types)
tc.CreateType ();
}
base.Define ();
public new void Define ()
{
foreach (TypeContainer tc in types) {
try {
tc.DefineType ();
} catch (Exception e) {
throw new InternalErrorException (tc, e);
}
}
HasTypesFullyDefined = true;
foreach (TypeContainer tc in types)
tc.ResolveTypeParameters ();
return true;
}
foreach (TypeContainer tc in types) {
try {
tc.Define ();
} catch (Exception e) {
throw new InternalErrorException (tc, e);
}
}
public override bool DefineContainer ()
{
DefineNamespace ();
HasTypesFullyDefined = true;
return base.DefineContainer ();
}
public override void Emit ()
public override void EmitContainer ()
{
if (OptAttributes != null)
OptAttributes.Emit ();
@ -433,26 +422,25 @@ namespace Mono.CSharp @@ -433,26 +422,25 @@ namespace Mono.CSharp
pa.EmitAttribute (builder);
}
foreach (var tc in types)
tc.DefineConstants ();
foreach (TypeContainer tc in types)
tc.EmitType ();
foreach (var tc in containers) {
tc.PrepareEmit ();
}
if (Compiler.Report.Errors > 0)
return;
base.EmitContainer ();
foreach (TypeContainer tc in types)
tc.VerifyMembers ();
if (Compiler.Report.Errors == 0)
VerifyMembers ();
if (compiler_generated != null)
foreach (var c in compiler_generated)
c.EmitType ();
if (anonymous_types != null) {
foreach (var atypes in anonymous_types)
foreach (var at in atypes.Value)
at.EmitContainer ();
}
}
internal override void GenerateDocComment (DocumentationBuilder builder)
{
foreach (var tc in types)
foreach (var tc in containers)
tc.GenerateDocComment (builder);
}
@ -476,6 +464,12 @@ namespace Mono.CSharp @@ -476,6 +464,12 @@ namespace Mono.CSharp
return null;
}
public override void GetCompletionStartingWith (string prefix, List<string> results)
{
var names = Evaluator.GetVarNames ();
results.AddRange (names.Where (l => l.StartsWith (prefix)));
}
public RootNamespace GetRootNamespace (string name)
{
RootNamespace rn;
@ -500,62 +494,6 @@ namespace Mono.CSharp @@ -500,62 +494,6 @@ namespace Mono.CSharp
return DeclaringAssembly.IsCLSCompliant;
}
protected override bool AddMemberType (TypeContainer tc)
{
if (AddTypesContainer (tc)) {
if ((tc.ModFlags & Modifiers.PARTIAL) != 0)
defined_names.Add (tc.Name, tc);
tc.NamespaceEntry.NS.AddType (this, tc.Definition);
return true;
}
return false;
}
public bool AddTypesContainer (ITypesContainer container)
{
var mn = container.MemberName;
ITypesContainer found;
if (!defined_type_containers.TryGetValue (mn, out found)) {
defined_type_containers.Add (mn, container);
return true;
}
if (container is NamespaceContainer && found is NamespaceContainer)
return true;
var container_tc = container as TypeContainer;
var found_tc = found as TypeContainer;
if (container_tc != null && found_tc != null && container_tc.Kind == found_tc.Kind) {
if ((found_tc.ModFlags & container_tc.ModFlags & Modifiers.PARTIAL) != 0) {
return false;
}
if (((found_tc.ModFlags | container_tc.ModFlags) & Modifiers.PARTIAL) != 0) {
Report.SymbolRelatedToPreviousError (found_tc);
Error_MissingPartialModifier (container_tc);
return false;
}
}
string ns = mn.Left != null ? mn.Left.GetSignatureForError () : Module.GlobalRootNamespace.GetSignatureForError ();
mn = new MemberName (mn.Name, mn.TypeArguments, mn.Location);
Report.SymbolRelatedToPreviousError (found.Location, "");
Report.Error (101, container.Location,
"The namespace `{0}' already contains a definition for `{1}'",
ns, mn.GetSignatureForError ());
return false;
}
protected override void RemoveMemberType (TypeContainer ds)
{
defined_type_containers.Remove (ds.MemberName);
ds.NamespaceEntry.NS.RemoveDeclSpace (ds.Basename);
base.RemoveMemberType (ds);
}
public Attribute ResolveAssemblyAttribute (PredefinedAttribute a_type)
{
Attribute a = OptAttributes.Search ("assembly", a_type);
@ -571,57 +509,4 @@ namespace Mono.CSharp @@ -571,57 +509,4 @@ namespace Mono.CSharp
this.assembly = assembly;
}
}
sealed class RootDeclSpace : TypeContainer {
public RootDeclSpace (ModuleContainer module, NamespaceContainer ns)
: base (ns, null, MemberName.Null, null, 0)
{
PartialContainer = module;
}
public override AttributeTargets AttributeTargets {
get { throw new InternalErrorException ("should not be called"); }
}
public override CompilerContext Compiler {
get {
return PartialContainer.Compiler;
}
}
public override string DocCommentHeader {
get { throw new InternalErrorException ("should not be called"); }
}
public override void DefineType ()
{
throw new InternalErrorException ("should not be called");
}
public override ModuleContainer Module {
get {
return PartialContainer.Module;
}
}
public override void Accept (StructuralVisitor visitor)
{
throw new InternalErrorException ("should not be called");
}
public override bool IsClsComplianceRequired ()
{
return PartialContainer.IsClsComplianceRequired ();
}
public override ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
{
return null;
}
public override FullNamedExpression LookupNamespaceAlias (string name)
{
return NamespaceEntry.LookupNamespaceAlias (name);
}
}
}

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

File diff suppressed because it is too large Load Diff

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

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

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

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

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

@ -67,7 +67,7 @@ namespace Mono.CSharp { @@ -67,7 +67,7 @@ namespace Mono.CSharp {
}
}
public TypeParameter[] CurrentTypeParameters {
public TypeParameters CurrentTypeParameters {
get {
throw new NotImplementedException ();
}
@ -129,7 +129,7 @@ namespace Mono.CSharp { @@ -129,7 +129,7 @@ namespace Mono.CSharp {
/// <summary>
/// The container for this PendingImplementation
/// </summary>
readonly TypeContainer container;
readonly TypeDefinition container;
/// <summary>
/// This is the array of TypeAndMethods that describes the pending implementations
@ -137,7 +137,7 @@ namespace Mono.CSharp { @@ -137,7 +137,7 @@ namespace Mono.CSharp {
/// </summary>
TypeAndMethods [] pending_implementations;
PendingImplementation (TypeContainer container, MissingInterfacesInfo[] missing_ifaces, MethodSpec[] abstract_methods, int total)
PendingImplementation (TypeDefinition container, MissingInterfacesInfo[] missing_ifaces, MethodSpec[] abstract_methods, int total)
{
var type_builder = container.Definition;
@ -189,7 +189,7 @@ namespace Mono.CSharp { @@ -189,7 +189,7 @@ namespace Mono.CSharp {
static readonly MissingInterfacesInfo [] EmptyMissingInterfacesInfo = new MissingInterfacesInfo [0];
static MissingInterfacesInfo [] GetMissingInterfaces (TypeContainer container)
static MissingInterfacesInfo [] GetMissingInterfaces (TypeDefinition container)
{
//
// Notice that Interfaces will only return the interfaces that the Type
@ -233,7 +233,7 @@ namespace Mono.CSharp { @@ -233,7 +233,7 @@ namespace Mono.CSharp {
// Register method implementations are either abstract methods
// flagged as such on the base class or interface methods
//
static public PendingImplementation GetPendingImplementations (TypeContainer container)
static public PendingImplementation GetPendingImplementations (TypeDefinition container)
{
TypeSpec b = container.BaseType;
@ -443,7 +443,7 @@ namespace Mono.CSharp { @@ -443,7 +443,7 @@ namespace Mono.CSharp {
optional = tm.optional;
}
if (op == Operation.Lookup && name.Left != null && ambiguousCandidate == null) {
if (op == Operation.Lookup && name.ExplicitInterface != null && ambiguousCandidate == null) {
ambiguousCandidate = m;
continue;
}

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

@ -34,10 +34,8 @@ namespace Mono.CSharp @@ -34,10 +34,8 @@ namespace Mono.CSharp
// This includes properties, indexers, and events
public abstract class PropertyBasedMember : InterfaceMemberBase
{
public PropertyBasedMember (DeclSpace parent, GenericMethod generic,
FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
MemberName name, Attributes attrs)
: base (parent, generic, type, mod, allowed_mod, name, attrs)
public PropertyBasedMember (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod, allowed_mod, name, attrs)
{
}
@ -198,7 +196,7 @@ namespace Mono.CSharp @@ -198,7 +196,7 @@ namespace Mono.CSharp
{
}
public override MethodBuilder Define (DeclSpace parent)
public override MethodBuilder Define (TypeContainer parent)
{
base.Define (parent);
@ -263,7 +261,7 @@ namespace Mono.CSharp @@ -263,7 +261,7 @@ namespace Mono.CSharp
}
}
public override MethodBuilder Define (DeclSpace parent)
public override MethodBuilder Define (TypeContainer parent)
{
parameters.Resolve (this);
@ -335,9 +333,9 @@ namespace Mono.CSharp @@ -335,9 +333,9 @@ namespace Mono.CSharp
return method.IsClsComplianceRequired ();
}
public virtual MethodBuilder Define (DeclSpace parent)
public virtual MethodBuilder Define (TypeContainer parent)
{
TypeContainer container = parent.PartialContainer;
var container = parent.PartialContainer;
//
// Check for custom access modifier
@ -404,9 +402,8 @@ namespace Mono.CSharp @@ -404,9 +402,8 @@ namespace Mono.CSharp
PropertyMethod get, set, first;
PropertyBuilder PropertyBuilder;
public PropertyBase (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags,
Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, null, type, mod_flags, allowed_mod, name, attrs)
public PropertyBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, allowed_mod, name, attrs)
{
}
@ -448,7 +445,7 @@ namespace Mono.CSharp @@ -448,7 +445,7 @@ namespace Mono.CSharp
if (first == null)
first = value;
Parent.AddMember (get);
Parent.AddNameToContainer (get, get.MemberName.Basename);
}
}
@ -461,7 +458,7 @@ namespace Mono.CSharp @@ -461,7 +458,7 @@ namespace Mono.CSharp
if (first == null)
first = value;
Parent.AddMember (set);
Parent.AddNameToContainer (set, set.MemberName.Basename);
}
}
@ -711,9 +708,9 @@ namespace Mono.CSharp @@ -711,9 +708,9 @@ namespace Mono.CSharp
this.property = p;
}
public string OriginalName {
public Property OriginalProperty {
get {
return property.Name;
return property;
}
}
@ -723,7 +720,7 @@ namespace Mono.CSharp @@ -723,7 +720,7 @@ namespace Mono.CSharp
}
}
public Property (DeclSpace parent, FullNamedExpression type, Modifiers mod,
public Property (TypeDefinition parent, FullNamedExpression type, Modifiers mod,
MemberName name, Attributes attrs)
: base (parent, type, mod,
parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface :
@ -733,6 +730,12 @@ namespace Mono.CSharp @@ -733,6 +730,12 @@ namespace Mono.CSharp
{
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
void CreateAutomaticProperty ()
{
// Create backing field
@ -740,26 +743,25 @@ namespace Mono.CSharp @@ -740,26 +743,25 @@ namespace Mono.CSharp
if (!field.Define ())
return;
Parent.PartialContainer.AddField (field);
Parent.PartialContainer.Members.Add (field);
FieldExpr fe = new FieldExpr (field, Location);
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));
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
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 ()
@ -789,7 +791,7 @@ namespace Mono.CSharp @@ -789,7 +791,7 @@ namespace Mono.CSharp
else
pm = new GetMethod (this, 0, null, Location);
Parent.AddMember (pm);
Parent.AddNameToContainer (pm, pm.MemberName.Basename);
}
if (!CheckBase ())
@ -822,7 +824,7 @@ namespace Mono.CSharp @@ -822,7 +824,7 @@ namespace Mono.CSharp
{
}
public override MethodBuilder Define (DeclSpace ds)
public override MethodBuilder Define (TypeContainer ds)
{
CheckAbstractAndExtern (block != null);
return base.Define (ds);
@ -852,11 +854,16 @@ namespace Mono.CSharp @@ -852,11 +854,16 @@ namespace Mono.CSharp
static readonly string[] attribute_targets = new string [] { "event" };
public EventProperty (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
public EventProperty (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, name, attrs)
{
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override bool Define()
{
if (!base.Define ())
@ -871,12 +878,6 @@ namespace Mono.CSharp @@ -871,12 +878,6 @@ namespace Mono.CSharp
return attribute_targets;
}
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
/// <summary>
@ -893,10 +894,12 @@ namespace Mono.CSharp @@ -893,10 +894,12 @@ namespace Mono.CSharp
protected abstract MethodSpec GetOperation (Location loc);
public override void Emit (DeclSpace parent)
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 ();
}
@ -909,8 +912,8 @@ namespace Mono.CSharp @@ -909,8 +912,8 @@ namespace Mono.CSharp
// Delegate obj1 = backing_field
// do {
// Delegate obj2 = obj1;
// obj1 = Interlocked.CompareExchange (ref backing_field, Delegate.Combine|Remove(obj2, value), obj1);
// } while (obj1 != obj2)
// obj1 = Interlocked.CompareExchange (ref backing_field, Delegate.Combine|Remove(obj2, value), obj1);
// } while ((object)obj1 != (object)obj2)
//
var field_info = ((EventField) method).backing_field;
@ -924,7 +927,9 @@ namespace Mono.CSharp @@ -924,7 +927,9 @@ namespace Mono.CSharp
block.AddStatement (new StatementExpression (new SimpleAssign (new LocalVariableReference (obj1, Location), f_expr)));
var cond = new BooleanExpression (new Binary (Binary.Operator.Inequality,
new LocalVariableReference (obj1, Location), new LocalVariableReference (obj2, Location), Location));
new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj1, Location), Location),
new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj2, Location), Location),
Location));
var body = new ExplicitBlock (block, Location, Location);
block.AddStatement (new Do (body, cond, Location));
@ -990,7 +995,7 @@ namespace Mono.CSharp @@ -990,7 +995,7 @@ namespace Mono.CSharp
Field backing_field;
List<FieldDeclarator> declarators;
public EventField (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
public EventField (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, name, attrs)
{
Add = new AddDelegateMethod (this);
@ -999,6 +1004,12 @@ namespace Mono.CSharp @@ -999,6 +1004,12 @@ namespace Mono.CSharp
#region Properties
public List<FieldDeclarator> Declarators {
get {
return this.declarators;
}
}
bool HasBackingField {
get {
return !IsInterface && (ModFlags & Modifiers.ABSTRACT) == 0;
@ -1020,14 +1031,14 @@ namespace Mono.CSharp @@ -1020,14 +1031,14 @@ namespace Mono.CSharp
}
}
public List<FieldDeclarator> Declarators {
get {
return this.declarators;
}
}
#endregion
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public void AddDeclarator (FieldDeclarator declarator)
{
if (declarators == null)
@ -1035,8 +1046,7 @@ namespace Mono.CSharp @@ -1035,8 +1046,7 @@ namespace Mono.CSharp
declarators.Add (declarator);
// TODO: This will probably break
Parent.AddMember (this, declarator.Name.Value);
Parent.AddNameToContainer (this, declarator.Name.Value);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
@ -1069,14 +1079,14 @@ namespace Mono.CSharp @@ -1069,14 +1079,14 @@ namespace Mono.CSharp
mod_flags_src &= ~(Modifiers.AccessibilityMask | Modifiers.DEFAULT_ACCESS_MODIFER);
var t = new TypeExpression (MemberType, TypeExpression.Location);
int index = Parent.PartialContainer.Events.IndexOf (this);
foreach (var d in declarators) {
var ef = new EventField (Parent, t, mod_flags_src, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
if (d.Initializer != null)
ef.initializer = d.Initializer;
Parent.PartialContainer.Events.Insert (++index, ef);
ef.Define ();
Parent.PartialContainer.Members.Add (ef);
}
}
@ -1093,7 +1103,7 @@ namespace Mono.CSharp @@ -1093,7 +1103,7 @@ namespace Mono.CSharp
Modifiers.BACKING_FIELD | Modifiers.COMPILER_GENERATED | Modifiers.PRIVATE | (ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)),
MemberName, null);
Parent.PartialContainer.AddField (backing_field);
Parent.PartialContainer.Members.Add (backing_field);
backing_field.Initializer = Initializer;
backing_field.ModFlags &= ~Modifiers.COMPILER_GENERATED;
@ -1105,11 +1115,6 @@ namespace Mono.CSharp @@ -1105,11 +1115,6 @@ namespace Mono.CSharp
return true;
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
public abstract class Event : PropertyBasedMember
@ -1166,7 +1171,7 @@ namespace Mono.CSharp @@ -1166,7 +1171,7 @@ namespace Mono.CSharp
return method.IsClsComplianceRequired ();
}
public virtual MethodBuilder Define (DeclSpace parent)
public virtual MethodBuilder Define (TypeContainer parent)
{
// Fill in already resolved event type to speed things up and
// avoid confusing duplicate errors
@ -1215,8 +1220,8 @@ namespace Mono.CSharp @@ -1215,8 +1220,8 @@ namespace Mono.CSharp
EventBuilder EventBuilder;
protected EventSpec spec;
protected Event (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, null, type, mod_flags,
protected Event (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, type, mod_flags,
parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface :
parent.PartialContainer.Kind == MemberKind.Struct ? AllowedModifiersStruct :
AllowedModifiersClass,
@ -1238,7 +1243,7 @@ namespace Mono.CSharp @@ -1238,7 +1243,7 @@ namespace Mono.CSharp
}
set {
add = value;
Parent.AddMember (value);
Parent.AddNameToContainer (value, value.MemberName.Basename);
}
}
@ -1254,7 +1259,7 @@ namespace Mono.CSharp @@ -1254,7 +1259,7 @@ namespace Mono.CSharp
}
set {
remove = value;
Parent.AddMember (value);
Parent.AddNameToContainer (value, value.MemberName.Basename);
}
}
#endregion
@ -1310,7 +1315,7 @@ namespace Mono.CSharp @@ -1310,7 +1315,7 @@ namespace Mono.CSharp
spec = new EventSpec (Parent.Definition, this, MemberType, ModFlags, Add.Spec, remove.Spec);
Parent.MemberCache.AddMember (this, Name, spec);
Parent.MemberCache.AddMember (this, GetFullName (MemberName), spec);
Parent.MemberCache.AddMember (this, AddBuilder.Name, Add.Spec);
Parent.MemberCache.AddMember (this, RemoveBuilder.Name, remove.Spec);
@ -1417,7 +1422,7 @@ namespace Mono.CSharp @@ -1417,7 +1422,7 @@ namespace Mono.CSharp
this.parameters = parameters;
}
public override MethodBuilder Define (DeclSpace parent)
public override MethodBuilder Define (TypeContainer parent)
{
parameters.Resolve (this);
return base.Define (parent);
@ -1488,8 +1493,7 @@ namespace Mono.CSharp @@ -1488,8 +1493,7 @@ namespace Mono.CSharp
readonly ParametersCompiled parameters;
public Indexer (DeclSpace parent, FullNamedExpression type, MemberName name, Modifiers mod,
ParametersCompiled parameters, Attributes attrs)
public Indexer (TypeDefinition parent, FullNamedExpression type, MemberName name, Modifiers mod, ParametersCompiled parameters, Attributes attrs)
: base (parent, type, mod,
parent.PartialContainer.Kind == MemberKind.Interface ? AllowedInterfaceModifiers : AllowedModifiers,
name, attrs)
@ -1513,15 +1517,15 @@ namespace Mono.CSharp @@ -1513,15 +1517,15 @@ namespace Mono.CSharp
#endregion
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.IndexerName) {
if (IsExplicitImpl) {
Report.Error (415, a.Location,
"The `{0}' attribute is valid only on an indexer that is not an explicit interface member declaration",
TypeManager.CSharpName (a.Type));
}
// Attribute was copied to container
return;
}
@ -1534,11 +1538,6 @@ namespace Mono.CSharp @@ -1534,11 +1538,6 @@ namespace Mono.CSharp
return Parent.MemberCache.CheckExistingMembersOverloads (this, parameters);
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
public override bool Define ()
{
if (!base.Define ())
@ -1554,25 +1553,31 @@ namespace Mono.CSharp @@ -1554,25 +1553,31 @@ namespace Mono.CSharp
if (compiling != null)
compiling.Define ();
string name = indexer_attr.GetIndexerAttributeValue ();
if ((ModFlags & Modifiers.OVERRIDE) != 0) {
if (IsExplicitImpl) {
Report.Error (415, indexer_attr.Location,
"The `{0}' attribute is valid only on an indexer that is not an explicit interface member declaration",
indexer_attr.Type.GetSignatureForError ());
} else if ((ModFlags & Modifiers.OVERRIDE) != 0) {
Report.Error (609, indexer_attr.Location,
"Cannot set the `IndexerName' attribute on an indexer marked override");
}
} else {
string name = indexer_attr.GetIndexerAttributeValue ();
if (!string.IsNullOrEmpty (name))
ShortName = name;
if (!string.IsNullOrEmpty (name)) {
SetMemberName (new MemberName (MemberName.Left, name, Location));
}
}
}
}
if (InterfaceType != null) {
string base_IndexerName = InterfaceType.MemberDefinition.GetAttributeDefaultMember ();
if (base_IndexerName != Name)
ShortName = base_IndexerName;
if (base_IndexerName != ShortName) {
SetMemberName (new MemberName (MemberName.Left, base_IndexerName, new TypeExpression (InterfaceType, Location), Location));
}
}
if (!Parent.PartialContainer.AddMember (this))
return false;
Parent.AddNameToContainer (this, MemberName.Basename);
flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName;
@ -1606,9 +1611,9 @@ namespace Mono.CSharp @@ -1606,9 +1611,9 @@ namespace Mono.CSharp
public override string GetSignatureForError ()
{
StringBuilder sb = new StringBuilder (Parent.GetSignatureForError ());
if (MemberName.Left != null) {
if (MemberName.ExplicitInterface != null) {
sb.Append (".");
sb.Append (MemberName.Left.GetSignatureForError ());
sb.Append (MemberName.ExplicitInterface.GetSignatureForError ());
}
sb.Append (".this");

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

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

168
ICSharpCode.NRefactory.CSharp/Parser/mcs/repl.txt

@ -1,168 +0,0 @@ @@ -1,168 +0,0 @@
Things to do for the REPL support in MCS:
Documentation for the REPL mode for MCS can be found here:
http://mono-project.com/CsharpRepl
* Embedding API
* Booting the compiler without Main ()
* Expose LoadAssembly/LoadPackage
* Register fields?
* Register a lookup function for fields?
* Register classes to expose to REPL
* Embedded Library
* Run a REPL on a socket (from Joe Shaw)
* Host a REPL on XSP (from Nat).
* TODO
Clear struct fields inside the clearing code.
* Other ideas:
MD addin for "csharp"
* Supporting class-level declarations
Currently the evaluator has this feature disabled, to enable
it edit the eval.cs file and make this be the default:
- parser.Lexer.putback_char = Tokenizer.EvalUsingDeclarationsParserCharacter;
- //parser.Lexer.putback_char = Tokenizer.EvalCompilationUnitParserCharacter;
+ //parser.Lexer.putback_char = Tokenizer.EvalUsingDeclarationsParserCharacter;
+ parser.Lexer.putback_char = Tokenizer.EvalCompilationUnitParserCharacter;
It currently has a few problems:
* Support for overwritting existing defined
classes is not supported.
* The usability is not as useful, since the defaults
for C# are still to make members private, we should
change this default to be public in those cases.
* The error lookup system lacks information from types, for
example this causes an unsupported call into a TypeBuilder:
csharp>class D { void DD () {} }
csharp>var d = new D ();
csharp>d.DD ();
Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class0::Host]
System.NotSupportedException: The invoked member is not supported in a dynamic module.
at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in <filename unknown>:0
at Mono.CSharp.Report.SymbolRelatedToPreviousError (System.Reflection.MemberInfo mi) [0x00000] in
at Mono.CSharp.MethodGroupExpr.NoExactMatch (Mono.CSharp.ResolveContext ec,
Mono.CSharp.Arguments& Arguments, IDictionary`2 c
The above is caused by TypeManager.LookupDeclSpace (dt)
failing to return a value (it returns null) so our code
assumes we have an Assembly instead of an assemblybuilder.
* Declaring a class twice produces an internal parse error:
class X {}
class X {}
The second declaration will no longer be parsed, so it could even
contain junk, and wont be flagged. We probably need to allow for
type redefinition in REPL modes, the exception from the second is:
csharp -v -v
> class X {}
> class X {}
System.ArgumentException: An element with the same key already exists in the dictionary.
at System.Collections.Generic.Dictionary`2[System.String,Mono.CSharp.DeclSpace].Add (System.String key, Mono.CSharp.DeclSpace value) [0x00000] in <filename unknown>:0
at Mono.CSharp.Namespace.AddDeclSpace (System.String name, Mono.CSharp.DeclSpace ds) [0x00000] in <filename unknown>:0
at Mono.CSharp.ModuleCompiled.AddMemberType (Mono.CSharp.DeclSpace ds) [0x00000] in <filename unknown>:0
at Mono.CSharp.TypeContainer.AddTypeContainer (Mono.CSharp.TypeContainer tc) [0x00000] in <filename unknown>:0
at Mono.CSharp.CSharpParser.push_current_class (Mono.CSharp.TypeContainer tc, System.Object partial_token) [0x00000] in <filename unknown>:0
at Mono.CSharp.CSharpParser.yyparse (yyInput yyLex) [0x00000] in <filename unknown>:0
at Mono.CSharp.CSharpParser.yyparse (yyInput yyLex, System.Object yyd) [0x00000] in <filename unknown>:0
at Mono.CSharp.CSharpParser.parse () [0x00000] in <filename unknown>:0
* Mix statements with other top-level declarations.
csharp> class Y {static void Main () {Console.WriteLine ("Foo"); }}
csharp> typeof (Y);
Y
csharp> Y.Main ();
Exception caught by the compiler while compiling:
Block that caused the problem begin at: Internal(1,1):
Block being compiled: [<interactive>(1,2):,<interactive>(1,11):]
System.NotSupportedException: The invoked member is not supported in a dynamic module.
Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class2::Host]
System.NotSupportedException: The invoked member is not supported in a dynamic module.
at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in /second/home/cvs/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:214
at Mono.CSharp.Report.SymbolRelatedToPreviousError (System.Reflection.MemberInfo mi) [0x00036] in /second/home/cvs/mcs/mcs/report.cs:664
at Mono.CSharp.Expression.Error_MemberLookupFailed (System.Type container_type, System.Type qualifier_type, System.Type queried_type, System.String name, System.String class_name, MemberTypes mt, BindingFlags bf) [0x00121] in /second/home/cvs/mcs/mcs/ecore.cs:857
at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression right_side) [0x00230] in /second/home/cvs/mcs/mcs/expression.cs:7426
at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/expression.cs:7494
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479
at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x0000d] in /second/home/cvs/mcs/mcs/expression.cs:4725
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506
at Mono.CSharp.OptionalAssign.DoResolve (Mono.CSharp.EmitContext ec) [0x00013] in /second/home/cvs/mcs/mcs/repl.cs:681
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506
at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:1307
at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec) [0x0000b] in /second/home/cvs/mcs/mcs/statement.cs:743
at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x000f0] in /second/home/cvs/mcs/mcs/statement.cs:2254
at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/statement.cs:2550
at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext anonymous_method_host, Mono.CSharp.ToplevelBlock block, Mono.CSharp.Parameters ip, IMethodData md, System.Boolean& unreachable) [0x00087] in /second/home/cvs/mcs/mcs/codegen.cs:796
csharp>
* Another one:
csharp> class X { X (){ Console.WriteLine ("Called"); } }
csharp> new X ();
Exception caught by the compiler while compiling:
Block that caused the problem begin at: Internal(1,1):
Block being compiled: [<interactive>(1,2):,<interactive>(1,10):]
System.NotSupportedException: The invoked member is not supported in a dynamic module.
Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class0::Host]
System.NotSupportedException: The invoked member is not supported in a dynamic module.
at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in /second/home/cvs/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:214
at Mono.CSharp.Report.SymbolRelatedToPreviousError (System.Reflection.MemberInfo mi) [0x00036] in /second/home/cvs/mcs/mcs/report.cs:664
at Mono.CSharp.Expression.Error_MemberLookupFailed (System.Type container_type, System.Type qualifier_type, System.Type queried_type, System.String name, System.String class_name, MemberTypes mt, BindingFlags bf) [0x00121] in /second/home/cvs/mcs/mcs/ecore.cs:857
at Mono.CSharp.Expression.MemberLookupFinal (Mono.CSharp.EmitContext ec, System.Type qualifier_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x0002f] in /second/home/cvs/mcs/mcs/ecore.cs:804
at Mono.CSharp.New.DoResolve (Mono.CSharp.EmitContext ec) [0x002ad] in /second/home/cvs/mcs/mcs/expression.cs:5486
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506
at Mono.CSharp.OptionalAssign.DoResolve (Mono.CSharp.EmitContext ec) [0x00013] in /second/home/cvs/mcs/mcs/repl.cs:687
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506
at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:1307
at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec) [0x0000b] in /second/home/cvs/mcs/mcs/statement.cs:743
at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x000f0] in /second/home/cvs/mcs/mcs/statement.cs:2254
at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/statement.cs:2550
at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext anonymous_method_host, Mono.CSharp.ToplevelBlock block, Mono.CSharp.Parameters ip, IMethodData md, System.Boolean& unreachable) [0x00087] in /second/home/cvs/mcs/mcs/codegen.cs:796
csharp>
* Important: we need to replace TypeBuidlers with Types after things
have been emitted, or stuff like this happens:
csharp> public class y {}
csharp> typeof (y);
Class1
* Clearing data
TODO: when clearing data for variables that have been overwritten
we need to check for structs and clear all the fields that contain
reference types.
* DEBATABLE: Implement auto-insert-semicolon
This is easy to implement, just retry the parse with a
semicolon, the question is whether this is a good idea to do
in the first place or not.

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

@ -21,27 +21,15 @@ namespace Mono.CSharp { @@ -21,27 +21,15 @@ namespace Mono.CSharp {
//
public class Report
{
/// <summary>
/// Whether warnings should be considered errors
/// </summary>
public bool WarningsAreErrors;
List<int> warnings_as_error;
List<int> warnings_only;
public const int RuntimeErrorId = 10000;
//
// Keeps track of the warnings that we are ignoring
//
HashSet<int> warning_ignore_table;
Dictionary<int, WarningRegions> warning_regions_table;
int warning_level;
ReportPrinter printer;
int reporting_disabled;
readonly CompilerSettings settings;
/// <summary>
/// List of symbols related to reported error/warning. You have to fill it before error/warning is reported.
@ -72,13 +60,15 @@ namespace Mono.CSharp { @@ -72,13 +60,15 @@ namespace Mono.CSharp {
static HashSet<int> AllWarningsHashSet;
public Report (ReportPrinter printer)
public Report (CompilerContext context, ReportPrinter printer)
{
if (context == null)
throw new ArgumentNullException ("settings");
if (printer == null)
throw new ArgumentNullException ("printer");
this.settings = context.Settings;
this.printer = printer;
warning_level = 4;
}
public void DisableReporting ()
@ -125,44 +115,6 @@ namespace Mono.CSharp { @@ -125,44 +115,6 @@ namespace Mono.CSharp {
"Feature `{0}' is not supported in Mono mcs1 compiler. Consider using the `gmcs' compiler instead",
feature);
}
bool IsWarningEnabled (int code, int level, Location loc)
{
if (WarningLevel < level)
return false;
if (IsWarningDisabledGlobally (code))
return false;
if (warning_regions_table == null || loc.IsNull)
return true;
WarningRegions regions;
if (!warning_regions_table.TryGetValue (loc.File, out regions))
return true;
return regions.IsWarningEnabled (code, loc.Row);
}
public bool IsWarningDisabledGlobally (int code)
{
return warning_ignore_table != null && warning_ignore_table.Contains (code);
}
bool IsWarningAsError (int code)
{
bool is_error = WarningsAreErrors;
// Check specific list
if (warnings_as_error != null)
is_error |= warnings_as_error.Contains (code);
// Ignore excluded warnings
if (warnings_only != null && warnings_only.Contains (code))
is_error = false;
return is_error;
}
public void RuntimeMissingSupport (Location loc, string feature)
{
@ -217,44 +169,6 @@ namespace Mono.CSharp { @@ -217,44 +169,6 @@ namespace Mono.CSharp {
extra_information.Add (msg);
}
public void AddWarningAsError (string warningId)
{
int id;
try {
id = int.Parse (warningId);
} catch {
CheckWarningCode (warningId, Location.Null);
return;
}
if (!CheckWarningCode (id, Location.Null))
return;
if (warnings_as_error == null)
warnings_as_error = new List<int> ();
warnings_as_error.Add (id);
}
public void RemoveWarningAsError (string warningId)
{
int id;
try {
id = int.Parse (warningId);
} catch {
CheckWarningCode (warningId, Location.Null);
return;
}
if (!CheckWarningCode (id, Location.Null))
return;
if (warnings_only == null)
warnings_only = new List<int> ();
warnings_only.Add (id);
}
public bool CheckWarningCode (string code, Location loc)
{
Warning (1691, 1, loc, "`{0}' is not a valid warning number", code);
@ -300,11 +214,17 @@ namespace Mono.CSharp { @@ -300,11 +214,17 @@ namespace Mono.CSharp {
if (reporting_disabled > 0)
return;
if (!IsWarningEnabled (code, level, loc))
if (!settings.IsWarningEnabled (code, level))
return;
if (warning_regions_table != null && !loc.IsNull) {
WarningRegions regions;
if (warning_regions_table.TryGetValue (loc.File, out regions) && !regions.IsWarningEnabled (code, loc.Row))
return;
}
AbstractMessage msg;
if (IsWarningAsError (code)) {
if (settings.IsWarningAsError (code)) {
message = "Warning as Error: " + message;
msg = new ErrorMessage (code, loc, message, extra_information);
} else {
@ -420,14 +340,6 @@ namespace Mono.CSharp { @@ -420,14 +340,6 @@ namespace Mono.CSharp {
get { return printer; }
}
public void SetIgnoreWarning (int code)
{
if (warning_ignore_table == null)
warning_ignore_table = new HashSet<int> ();
warning_ignore_table.Add (code);
}
public ReportPrinter SetPrinter (ReportPrinter printer)
{
ReportPrinter old = this.printer;
@ -435,15 +347,6 @@ namespace Mono.CSharp { @@ -435,15 +347,6 @@ namespace Mono.CSharp {
return old;
}
public int WarningLevel {
get {
return warning_level;
}
set {
warning_level = value;
}
}
[Conditional ("MCS_DEBUG")]
static public void Debug (string message, params object[] args)
{
@ -999,7 +902,6 @@ namespace Mono.CSharp { @@ -999,7 +902,6 @@ namespace Mono.CSharp {
ReferencesImporting,
PredefinedTypesInit,
ModuleDefinitionTotal,
UsingResolve,
EmitTotal,
CloseTypes,
Resouces,
@ -1058,7 +960,6 @@ namespace Mono.CSharp { @@ -1058,7 +960,6 @@ namespace Mono.CSharp {
{ TimerType.ReferencesImporting, "Referenced assemblies importing" },
{ TimerType.PredefinedTypesInit, "Predefined types initialization" },
{ TimerType.ModuleDefinitionTotal, "Module definition" },
{ TimerType.UsingResolve, "Top-level usings resolve" },
{ TimerType.EmitTotal, "Resolving and emitting members blocks" },
{ TimerType.CloseTypes, "Module types closed" },
{ TimerType.Resouces, "Embedding resources" },
@ -1202,13 +1103,13 @@ namespace Mono.CSharp { @@ -1202,13 +1103,13 @@ namespace Mono.CSharp {
regions.Add (new EnableAll (line));
}
public void WarningEnable (Location location, int code, Report Report)
public void WarningEnable (Location location, int code, CompilerContext context)
{
if (!Report.CheckWarningCode (code, location))
if (!context.Report.CheckWarningCode (code, location))
return;
if (Report.IsWarningDisabledGlobally (code))
Report.Warning (1635, 1, location, "Cannot restore warning `CS{0:0000}' because it was disabled globally", code);
if (context.Settings.IsWarningDisabledGlobally (code))
context.Report.Warning (1635, 1, location, "Cannot restore warning `CS{0:0000}' because it was disabled globally", code);
regions.Add (new Enable (location.Row, code));
}

170
ICSharpCode.NRefactory.CSharp/Parser/mcs/rootcontext.cs → ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// rootcontext.cs: keeps track of our tree representation, and assemblies loaded.
// settings.cs: All compiler settings
//
// Author: Miguel de Icaza (miguel@ximian.com)
// Ravi Pratap (ravi@ximian.com)
@ -66,6 +66,11 @@ namespace Mono.CSharp { @@ -66,6 +66,11 @@ namespace Mono.CSharp {
public string StrongNameKeyContainer;
public bool StrongNameDelaySign;
public int TabSize;
public bool WarningsAreErrors;
public int WarningLevel;
//
// Assemblies references to be loaded
//
@ -133,6 +138,7 @@ namespace Mono.CSharp { @@ -133,6 +138,7 @@ namespace Mono.CSharp {
// Compiler debug flags only
public bool ParseOnly, TokenizeOnly, Timestamps;
public int DebugFlags;
public int VerboseParserFlag;
//
// Whether we are being linked against the standard libraries.
@ -145,7 +151,11 @@ namespace Mono.CSharp { @@ -145,7 +151,11 @@ namespace Mono.CSharp {
readonly List<string> conditional_symbols;
readonly List<CompilationSourceFile> source_files;
readonly List<SourceFile> source_files;
List<int> warnings_as_error;
List<int> warnings_only;
HashSet<int> warning_ignore_table;
public CompilerSettings ()
{
@ -155,10 +165,15 @@ namespace Mono.CSharp { @@ -155,10 +165,15 @@ namespace Mono.CSharp {
Platform = Platform.AnyCPU;
Version = LanguageVersion.Default;
VerifyClsCompliance = true;
Optimize = true;
Encoding = Encoding.UTF8;
LoadDefaultReferences = true;
StdLibRuntimeVersion = RuntimeVersion.v4;
WarningLevel = 4;
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
TabSize = 4;
else
TabSize = 8;
AssemblyReferences = new List<string> ();
AssemblyReferencesAliases = new List<Tuple<string, string>> ();
@ -171,12 +186,12 @@ namespace Mono.CSharp { @@ -171,12 +186,12 @@ namespace Mono.CSharp {
//
conditional_symbols.Add ("__MonoCS__");
source_files = new List<CompilationSourceFile> ();
source_files = new List<SourceFile> ();
}
#region Properties
public CompilationSourceFile FirstSourceFile {
public SourceFile FirstSourceFile {
get {
return source_files.Count > 0 ? source_files [0] : null;
}
@ -194,7 +209,7 @@ namespace Mono.CSharp { @@ -194,7 +209,7 @@ namespace Mono.CSharp {
}
}
public List<CompilationSourceFile> SourceFiles {
public List<SourceFile> SourceFiles {
get {
return source_files;
}
@ -208,10 +223,62 @@ namespace Mono.CSharp { @@ -208,10 +223,62 @@ namespace Mono.CSharp {
conditional_symbols.Add (symbol);
}
public void AddWarningAsError (int id)
{
if (warnings_as_error == null)
warnings_as_error = new List<int> ();
warnings_as_error.Add (id);
}
public void AddWarningOnly (int id)
{
if (warnings_only == null)
warnings_only = new List<int> ();
warnings_only.Add (id);
}
public bool IsConditionalSymbolDefined (string symbol)
{
return conditional_symbols.Contains (symbol);
}
public bool IsWarningAsError (int code)
{
bool is_error = WarningsAreErrors;
// Check specific list
if (warnings_as_error != null)
is_error |= warnings_as_error.Contains (code);
// Ignore excluded warnings
if (warnings_only != null && warnings_only.Contains (code))
is_error = false;
return is_error;
}
public bool IsWarningEnabled (int code, int level)
{
if (WarningLevel < level)
return false;
return !IsWarningDisabledGlobally (code);
}
public bool IsWarningDisabledGlobally (int code)
{
return warning_ignore_table != null && warning_ignore_table.Contains (code);
}
public void SetIgnoreWarning (int code)
{
if (warning_ignore_table == null)
warning_ignore_table = new HashSet<int> ();
warning_ignore_table.Add (code);
}
}
public class CommandLineParser
@ -227,22 +294,27 @@ namespace Mono.CSharp { @@ -227,22 +294,27 @@ namespace Mono.CSharp {
static readonly char[] argument_value_separator = new char[] { ';', ',' };
static readonly char[] numeric_value_separator = new char[] { ';', ',', ' ' };
readonly Report report;
readonly TextWriter output;
readonly Report report;
bool stop_argument;
Dictionary<string, int> source_file_index;
public event Func<string[], int, int> UnknownOptionHandler;
public CommandLineParser (Report report)
: this (report, Console.Out)
CompilerSettings parser_settings;
public CommandLineParser (TextWriter errorOutput)
: this (errorOutput, Console.Out)
{
}
public CommandLineParser (Report report, TextWriter messagesOutput)
public CommandLineParser (TextWriter errorOutput, TextWriter messagesOutput)
{
this.report = report;
var rp = new StreamReportPrinter (errorOutput);
parser_settings = new CompilerSettings ();
report = new Report (new CompilerContext (parser_settings, rp), rp);
this.output = messagesOutput;
}
@ -363,10 +435,13 @@ namespace Mono.CSharp { @@ -363,10 +435,13 @@ namespace Mono.CSharp {
ProcessSourceFiles (arg, false, settings.SourceFiles);
}
if (report.Errors > 0)
return null;
return settings;
}
void ProcessSourceFiles (string spec, bool recurse, List<CompilationSourceFile> sourceFiles)
void ProcessSourceFiles (string spec, bool recurse, List<SourceFile> sourceFiles)
{
string path, pattern;
@ -460,7 +535,7 @@ namespace Mono.CSharp { @@ -460,7 +535,7 @@ namespace Mono.CSharp {
settings.Resources.Add (res);
}
void AddSourceFile (string fileName, List<CompilationSourceFile> sourceFiles)
void AddSourceFile (string fileName, List<SourceFile> sourceFiles)
{
string path = Path.GetFullPath (fileName);
@ -475,11 +550,43 @@ namespace Mono.CSharp { @@ -475,11 +550,43 @@ namespace Mono.CSharp {
return;
}
var unit = new CompilationSourceFile (fileName, path, sourceFiles.Count + 1);
var unit = new SourceFile (fileName, path, sourceFiles.Count + 1);
sourceFiles.Add (unit);
source_file_index.Add (path, unit.Index);
}
void AddWarningAsError (string warningId, CompilerSettings settings)
{
int id;
try {
id = int.Parse (warningId);
} catch {
report.CheckWarningCode (warningId, Location.Null);
return;
}
if (!report.CheckWarningCode (id, Location.Null))
return;
settings.AddWarningAsError (id);
}
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))
return;
settings.AddWarningOnly (id);
}
void Error_RequiresArgument (string option)
{
report.Error (2006, "Missing argument for `{0}' option", option);
@ -830,10 +937,18 @@ namespace Mono.CSharp { @@ -830,10 +937,18 @@ namespace Mono.CSharp {
return ParseResult.Success;
case "/debug":
if (value == "full" || value == "")
if (value == "full" || value == "pdbonly" || idx < 0) {
settings.GenerateDebugInfo = true;
return ParseResult.Success;
}
return ParseResult.Success;
if (value.Length > 0) {
report.Error (1902, "Invalid debug option `{0}'. Valid options are `full' or `pdbonly'", value);
} else {
Error_RequiresArgument (option);
}
return ParseResult.Error;
case "/debug+":
settings.GenerateDebugInfo = true;
@ -869,19 +984,20 @@ namespace Mono.CSharp { @@ -869,19 +984,20 @@ namespace Mono.CSharp {
case "/warnaserror":
case "/warnaserror+":
if (value.Length == 0) {
report.WarningsAreErrors = true;
settings.WarningsAreErrors = true;
parser_settings.WarningsAreErrors = true;
} else {
foreach (string wid in value.Split (numeric_value_separator))
report.AddWarningAsError (wid);
AddWarningAsError (wid, settings);
}
return ParseResult.Success;
case "/warnaserror-":
if (value.Length == 0) {
report.WarningsAreErrors = false;
settings.WarningsAreErrors = false;
} else {
foreach (string wid in value.Split (numeric_value_separator))
report.RemoveWarningAsError (wid);
RemoveWarningAsError (wid, settings);
}
return ParseResult.Success;
@ -891,7 +1007,7 @@ namespace Mono.CSharp { @@ -891,7 +1007,7 @@ namespace Mono.CSharp {
return ParseResult.Error;
}
SetWarningLevel (value);
SetWarningLevel (value, settings);
return ParseResult.Success;
case "/nowarn":
@ -910,7 +1026,7 @@ namespace Mono.CSharp { @@ -910,7 +1026,7 @@ namespace Mono.CSharp {
if (warn < 1) {
throw new ArgumentOutOfRangeException ("warn");
}
report.SetIgnoreWarning (warn);
settings.SetIgnoreWarning (warn);
} catch {
report.Error (1904, "`{0}' is not a valid warning number", wc);
return ParseResult.Error;
@ -1095,7 +1211,7 @@ namespace Mono.CSharp { @@ -1095,7 +1211,7 @@ namespace Mono.CSharp {
{
switch (arg){
case "-v":
CSharpParser.yacc_verbose_flag++;
settings.VerboseParserFlag++;
return ParseResult.Success;
case "--version":
@ -1263,7 +1379,7 @@ namespace Mono.CSharp { @@ -1263,7 +1379,7 @@ namespace Mono.CSharp {
Usage ();
Environment.Exit (1);
}
report.SetIgnoreWarning (warn);
settings.SetIgnoreWarning (warn);
return ParseResult.Success;
case "--wlevel":
@ -1273,7 +1389,7 @@ namespace Mono.CSharp { @@ -1273,7 +1389,7 @@ namespace Mono.CSharp {
return ParseResult.Error;
}
SetWarningLevel (args [++i]);
SetWarningLevel (args [++i], settings);
return ParseResult.Success;
case "--mcs-debug":
@ -1351,7 +1467,7 @@ namespace Mono.CSharp { @@ -1351,7 +1467,7 @@ namespace Mono.CSharp {
}
}
void SetWarningLevel (string s)
void SetWarningLevel (string s, CompilerSettings settings)
{
int level = -1;
@ -1363,7 +1479,7 @@ namespace Mono.CSharp { @@ -1363,7 +1479,7 @@ namespace Mono.CSharp {
report.Error (1900, "Warning level must be in the range 0-4");
return;
}
report.WarningLevel = level;
settings.WarningLevel = level;
}
//

53
ICSharpCode.NRefactory.CSharp/Parser/mcs/smcs.exe.sources

@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
AssemblyInfo.cs
anonymous.cs
argument.cs
assign.cs
attribute.cs
driver.cs
cs-tokenizer.cs
cfold.cs
class.cs
codegen.cs
complete.cs
const.cs
constant.cs
convert.cs
context.cs
decl.cs
delegate.cs
doc-bootstrap.cs
dynamic.cs
enum.cs
ecore.cs
eval.cs
expression.cs
field.cs
flowanalysis.cs
generic.cs
import.cs
iterators.cs
lambda.cs
linq.cs
literal.cs
location.cs
membercache.cs
method.cs
modifiers.cs
namespace.cs
nullable.cs
parameter.cs
pending.cs
property.cs
report.cs
rootcontext.cs
roottypes.cs
statement.cs
support.cs
typemanager.cs
typespec.cs
symbolwriter.cs
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
../class/corlib/Mono.Security.Cryptography/CryptoConvert.cs
../build/common/Consts.cs

384
ICSharpCode.NRefactory.CSharp/Parser/mcs/smcs.exe.sources-xml

@ -1,384 +0,0 @@ @@ -1,384 +0,0 @@
../build/common/MonoTODOAttribute.cs
../build/common/Locale.cs
../class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs
../class/System.XML/Mono.Xml.Schema/XsdIdentityPath.cs
../class/System.XML/Mono.Xml.Schema/XsdIdentityState.cs
../class/System.XML/Mono.Xml.Schema/XsdKeyTable.cs
../class/System.XML/Mono.Xml.Schema/XsdParticleValidationState.cs
../class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs
../class/System.XML/Mono.Xml.Schema/XsdWildcard.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathDocument.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathDocumentWriter.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathNavigator.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathNode.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathDocument2.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathDocumentWriter2.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs
../class/System.XML/Mono.Xml.XPath/DTMXPathNode2.cs
../class/System.XML/Mono.Xml.XPath/IdPattern.cs
../class/System.XML/Mono.Xml.XPath/KeyPattern.cs
../class/System.XML/Mono.Xml.XPath/LocationPathPattern.cs
../class/System.XML/Mono.Xml.XPath/Pattern.cs
../class/System.XML/Mono.Xml.XPath/UnionPattern.cs
../class/System.XML/Mono.Xml.XPath/XPathEditableDocument.cs
../class/System.XML/Mono.Xml.XPath/XPathNavigatorReader.cs
../class/System.XML/Mono.Xml/IHasXmlParserContext.cs
../class/System.XML/Mono.Xml/IHasXmlSchemaInfo.cs
../class/System.XML/Mono.Xml/SubtreeXmlReader.cs
../class/System.XML/Mono.Xml/XmlFilterReader.cs
../class/System.XML/Mono.Xml/XmlNodeWriter.cs
../class/System.XML/System.Xml/ConformanceLevel.cs
../class/System.XML/System.Xml/DTDAutomata.cs
../class/System.XML/System.Xml/DTDObjectModel.cs
../class/System.XML/System.Xml/DTDReader.cs
../class/System.XML/System.Xml/DTDValidatingReader2.cs
../class/System.XML/System.Xml/EntityResolvingXmlReader.cs
../class/System.XML/System.Xml/EntityHandling.cs
../class/System.XML/System.Xml/Formatting.cs
../class/System.XML/System.Xml/IHasXmlNode.cs
../class/System.XML/System.Xml/IXmlLineInfo.cs
../class/System.XML/System.Xml/IHasXmlChildNode.cs
../class/System.XML/System.Xml/IXmlNamespaceResolver.cs
../class/System.XML/System.Xml/MonoFIXAttribute.cs
../class/System.XML/System.Xml/NameTable.cs
../class/System.XML/System.Xml/NewLineHandling.cs
../class/System.XML/System.Xml/ReadState.cs
../class/System.XML/System.Xml/ValidationType.cs
../class/System.XML/System.Xml/WhitespaceHandling.cs
../class/System.XML/System.Xml/WriteState.cs
../class/System.XML/System.Xml/XmlEntity.cs
../class/System.XML/System.Xml/XmlAttribute.cs
../class/System.XML/System.Xml/XmlAttributeCollection.cs
../class/System.XML/System.Xml/XmlCDataSection.cs
../class/System.XML/System.Xml/XmlConstructs.cs
../class/System.XML/System.Xml/XmlChar.cs
../class/System.XML/System.Xml/XmlCharacterData.cs
../class/System.XML/System.Xml/XmlComment.cs
../class/System.XML/System.Xml/XmlNotation.cs
../class/System.XML/System.Xml/XmlDeclaration.cs
../class/System.XML/System.Xml/XmlDocument.cs
../class/System.XML/System.Xml/XmlDocumentFragment.cs
../class/System.XML/System.Xml/XmlDocumentNavigator.cs
../class/System.XML/System.Xml/XmlDocumentType.cs
../class/System.XML/System.Xml/XmlElement.cs
../class/System.XML/System.Xml/XmlEntityReference.cs
../class/System.XML/System.Xml/XmlException.cs
../class/System.XML/System.Xml/XmlImplementation.cs
../class/System.XML/System.Xml/XmlConvert.cs
../class/System.XML/System.Xml/XmlDateTimeSerializationMode.cs
../class/System.XML/System.Xml/XmlLinkedNode.cs
../class/System.XML/System.Xml/XmlNameEntry.cs
../class/System.XML/System.Xml/XmlNameEntryCache.cs
../class/System.XML/System.Xml/XmlNameTable.cs
../class/System.XML/System.Xml/XmlNamedNodeMap.cs
../class/System.XML/System.Xml/XmlNamespaceScope.cs
../class/System.XML/System.Xml/XmlNamespaceManager.cs
../class/System.XML/System.Xml/XmlNode.cs
../class/System.XML/System.Xml/XmlNodeChangedAction.cs
../class/System.XML/System.Xml/XmlNodeChangedEventArgs.cs
../class/System.XML/System.Xml/XmlNodeChangedEventHandler.cs
../class/System.XML/System.Xml/XmlNodeList.cs
../class/System.XML/System.Xml/XmlNodeListChildren.cs
../class/System.XML/System.Xml/XmlNodeArrayList.cs
../class/System.XML/System.Xml/XmlIteratorNodeList.cs
../class/System.XML/System.Xml/XmlNodeOrder.cs
../class/System.XML/System.Xml/XmlNodeReader2.cs
../class/System.XML/System.Xml/XmlNodeReaderImpl.cs
../class/System.XML/System.Xml/XmlNodeType.cs
../class/System.XML/System.Xml/XmlOutputMethod.cs
../class/System.XML/System.Xml/XmlParserContext.cs
../class/System.XML/System.Xml/XmlProcessingInstruction.cs
../class/System.XML/System.Xml/XmlQualifiedName.cs
../class/System.XML/System.Xml/XmlReader.cs
../class/System.XML/System.Xml/XmlReaderBinarySupport.cs
../class/System.XML/System.Xml/XmlReaderSettings.cs
../class/System.XML/System.Xml/XmlResolver.cs
../class/System.XML/System.Xml/XmlSecureResolver.cs
../class/System.XML/System.Xml/XmlSignificantWhitespace.cs
../class/System.XML/System.Xml/XmlSpace.cs
../class/System.XML/System.Xml/XmlText.cs
../class/System.XML/System.Xml/XmlTextReader.cs
../class/System.XML/System.Xml/XmlTextReader2.cs
../class/System.XML/System.Xml/XmlTokenizedType.cs
../class/System.XML/System.Xml/XmlUrlResolver.cs
../class/System.XML/System.Xml/XmlValidatingReader.cs
../class/System.XML/System.Xml/XmlWhitespace.cs
../class/System.XML/System.Xml/XmlWriter.cs
../class/System.XML/System.Xml/XmlWriterSettings.cs
../class/System.XML/System.Xml/XmlTextWriter2.cs
../class/System.XML/System.Xml/XmlInputStream.cs
../class/System.XML/System.Xml/XmlParserInput.cs
../class/System.XML/System.Xml.XPath/IXPathNavigable.cs
../class/System.XML/System.Xml.XPath/XPathNavigator.cs
../class/System.XML/System.Xml.XPath/XPathExpression.cs
../class/System.XML/System.Xml.XPath/XPathItem.cs
../class/System.XML/System.Xml.XPath/XPathNamespaceScope.cs
../class/System.XML/System.Xml.XPath/XPathNodeIterator.cs
../class/System.XML/System.Xml.XPath/XPathResultType.cs
../class/System.XML/System.Xml.XPath/XPathNodeType.cs
../class/System.XML/System.Xml.XPath/XmlDataType.cs
../class/System.XML/System.Xml.XPath/XmlSortOrder.cs
../class/System.XML/System.Xml.XPath/XmlCaseOrder.cs
../class/System.XML/System.Xml.XPath/XPathDocument.cs
../class/System.XML/System.Xml.XPath/XPathException.cs
../class/System.XML/System.Xml.XPath/XPathComparer.cs
../class/System.XML/System.Xml.XPath/DefaultContext.cs
../class/System.XML/System.Xml.XPath/Expression.cs
../class/System.XML/System.Xml.XPath/Iterator.cs
../class/System.XML/System.Xml.XPath/Tokenizer.cs
../class/System.XML/System.Xml.XPath/Parser.cs
../class/System.XML/System.Xml.Schema/BuiltInDatatype.cs
../class/System.XML/System.Xml.Schema/IXmlSchemaInfo.cs
../class/System.XML/System.Xml.Schema/SchemaDataValueType.cs
../class/System.XML/System.Xml.Schema/ValidationEventArgs.cs
../class/System.XML/System.Xml.Schema/XmlAtomicValue.cs
../class/System.XML/System.Xml.Schema/XmlSchema.cs
../class/System.XML/System.Xml.Schema/XmlSchemaAll.cs
../class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs
../class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs
../class/System.XML/System.Xml.Schema/XmlSchemaAny.cs
../class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs
../class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs
../class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs
../class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs
../class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs
../class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs
../class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs
../class/System.XML/System.Xml.Schema/XmlSchemaCollectionEnumerator.cs
../class/System.XML/System.Xml.Schema/XmlSchemaCompilationSettings.cs
../class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs
../class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs
../class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
../class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
../class/System.XML/System.Xml.Schema/XmlSchemaContent.cs
../class/System.XML/System.Xml.Schema/XmlSchemaContentModel.cs
../class/System.XML/System.Xml.Schema/XmlSchemaContentProcessing.cs
../class/System.XML/System.Xml.Schema/XmlSchemaContentType.cs
../class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs
../class/System.XML/System.Xml.Schema/XmlSchemaDatatypeVariety.cs
../class/System.XML/System.Xml.Schema/XmlSchemaDerivationMethod.cs
../class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs
../class/System.XML/System.Xml.Schema/XmlSchemaElement.cs
../class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaException.cs
../class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs
../class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaForm.cs
../class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs
../class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs
../class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
../class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs
../class/System.XML/System.Xml.Schema/XmlSchemaImport.cs
../class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs
../class/System.XML/System.Xml.Schema/XmlSchemaInference.cs
../class/System.XML/System.Xml.Schema/XmlSchemaInferenceException.cs
../class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs
../class/System.XML/System.Xml.Schema/XmlSchemaKey.cs
../class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs
../class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs
../class/System.XML/System.Xml.Schema/XmlSchemaNumericFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaObject.cs
../class/System.XML/System.Xml.Schema/XmlSchemaObjectCollection.cs
../class/System.XML/System.Xml.Schema/XmlSchemaObjectEnumerator.cs
../class/System.XML/System.Xml.Schema/XmlSchemaObjectTable.cs
../class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs
../class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSerializer.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeContent.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
../class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs
../class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaType.cs
../class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs
../class/System.XML/System.Xml.Schema/XmlSchemaUse.cs
../class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs
../class/System.XML/System.Xml.Schema/XmlSchemaValidity.cs
../class/System.XML/System.Xml.Schema/XmlSchemaValidationException.cs
../class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs
../class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs
../class/System.XML/System.Xml.Schema/XmlSeverityType.cs
../class/System.XML/System.Xml.Schema/ValidationHandler.cs
../class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs
../class/System.XML/System.Xml.Schema/XmlSchemaReader.cs
../class/System.XML/System.Xml.Schema/XmlSchemaValidationFlags.cs
../class/System.XML/System.Xml.Schema/XmlTypeCode.cs
../class/System.XML/System.Xml.Schema/XmlValueGetter.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslApplyImports.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslApplyTemplates.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslAvt.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslCallTemplate.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslChoose.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslComment.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslCompiledElement.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslFallback.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslForEach.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslIf.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslMessage.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslNotSupportedOperation.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslOperation.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslProcessingInstruction.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslTemplateContent.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslText.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslValueOf.cs
../class/System.XML/Mono.Xml.Xsl.Operations/XslVariable.cs
../class/System.XML/Mono.Xml.Xsl/Attribute.cs
../class/System.XML/Mono.Xml.Xsl/Compiler.cs
../class/System.XML/Mono.Xml.Xsl/Debug.cs
../class/System.XML/Mono.Xml.Xsl/Emitter.cs
../class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs
../class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs
../class/System.XML/Mono.Xml.Xsl/MSXslScriptManager.cs
../class/System.XML/Mono.Xml.Xsl/Outputter.cs
../class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs
../class/System.XML/Mono.Xml.Xsl/TextEmitter.cs
../class/System.XML/Mono.Xml.Xsl/TextOutputter.cs
../class/System.XML/Mono.Xml.Xsl/PatternParser.cs
../class/System.XML/Mono.Xml.Xsl/PatternTokenizer.cs
../class/System.XML/Mono.Xml.Xsl/XmlWriterEmitter.cs
../class/System.XML/Mono.Xml.Xsl/XslAttributeSet.cs
../class/System.XML/Mono.Xml.Xsl/XslDecimalFormat.cs
../class/System.XML/Mono.Xml.Xsl/XslKey.cs
../class/System.XML/Mono.Xml.Xsl/XslOutput.cs
../class/System.XML/Mono.Xml.Xsl/XslSortEvaluator.cs
../class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
../class/System.XML/Mono.Xml.Xsl/XslTemplate.cs
../class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
../class/System.XML/Mono.Xml.Xsl/XsltCompiledContext.cs
../class/System.XML/Mono.Xml.Xsl/XsltDebuggerWrapper.cs
../class/System.XML/Mono.Xml.Xsl/XslFunctions.cs
../class/System.XML/System.Xml.Xsl/IXsltContextFunction.cs
../class/System.XML/System.Xml.Xsl/IXsltContextVariable.cs
../class/System.XML/System.Xml.Xsl/XslCompiledTransform.cs
../class/System.XML/System.Xml.Xsl/XslTransform.cs
../class/System.XML/System.Xml.Xsl/XsltArgumentList.cs
../class/System.XML/System.Xml.Xsl/XsltCompileException.cs
../class/System.XML/System.Xml.Xsl/XsltContext.cs
../class/System.XML/System.Xml.Xsl/XsltException.cs
../class/System.XML/System.Xml.Xsl/XsltMessageEncounteredEventArgs.cs
../class/System.XML/System.Xml.Xsl/XsltMessageEncounteredEventHandler.cs
../class/System.XML/System.Xml.Xsl/XsltSettings.cs
../class/System.XML/System.Xml/XQueryConvert.cs
../class/System.XML/System.Xml.Serialization/IXmlTextParser.cs
../class/System.XML/System.Xml.Serialization/CodeExporter.cs
../class/System.XML/System.Xml.Serialization/CodeGenerationOptions.cs
../class/System.XML/System.Xml.Serialization/CodeIdentifier.cs
../class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs
../class/System.XML/System.Xml.Serialization/IXmlSerializable.cs
../class/System.XML/System.Xml.Serialization/ImportContext.cs
../class/System.XML/System.Xml.Serialization/MapCodeGenerator.cs
../class/System.XML/System.Xml.Serialization/ReflectionHelper.cs
../class/System.XML/System.Xml.Serialization/SchemaImporter.cs
../class/System.XML/System.Xml.Serialization/SchemaTypes.cs
../class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs
../class/System.XML/System.Xml.Serialization/SerializationCodeGeneratorConfiguration.cs
../class/System.XML/System.Xml.Serialization/SerializationSource.cs
../class/System.XML/System.Xml.Serialization/SoapAttributeAttribute.cs
../class/System.XML/System.Xml.Serialization/SoapAttributeOverrides.cs
../class/System.XML/System.Xml.Serialization/SoapAttributes.cs
../class/System.XML/System.Xml.Serialization/SoapCodeExporter.cs
../class/System.XML/System.Xml.Serialization/SoapElementAttribute.cs
../class/System.XML/System.Xml.Serialization/SoapEnumAttribute.cs
../class/System.XML/System.Xml.Serialization/SoapIgnoreAttribute.cs
../class/System.XML/System.Xml.Serialization/SoapIncludeAttribute.cs
../class/System.XML/System.Xml.Serialization/SoapSchemaImporter.cs
../class/System.XML/System.Xml.Serialization/SoapSchemaExporter.cs
../class/System.XML/System.Xml.Serialization/SoapSchemaMember.cs
../class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs
../class/System.XML/System.Xml.Serialization/SoapTypeAttribute.cs
../class/System.XML/System.Xml.Serialization/TypeData.cs
../class/System.XML/System.Xml.Serialization/TypeMember.cs
../class/System.XML/System.Xml.Serialization/TypeTranslator.cs
../class/System.XML/System.Xml.Serialization/UnreferencedObjectEventArgs.cs
../class/System.XML/System.Xml.Serialization/UnreferencedObjectEventHandler.cs
../class/System.XML/System.Xml.Serialization/XmlAnyAttributeAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlAnyElementAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlAnyElementAttributes.cs
../class/System.XML/System.Xml.Serialization/XmlArrayAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlArrayItemAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlArrayItemAttributes.cs
../class/System.XML/System.Xml.Serialization/XmlAttributeAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlAttributeEventArgs.cs
../class/System.XML/System.Xml.Serialization/XmlAttributeEventHandler.cs
../class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs
../class/System.XML/System.Xml.Serialization/XmlAttributes.cs
../class/System.XML/System.Xml.Serialization/XmlCodeExporter.cs
../class/System.XML/System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs
../class/System.XML/System.Xml.Serialization/XmlDeserializationEvents.cs
../class/System.XML/System.Xml.Serialization/XmlElementAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlElementAttributes.cs
../class/System.XML/System.Xml.Serialization/XmlElementEventArgs.cs
../class/System.XML/System.Xml.Serialization/XmlEnumAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlIgnoreAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlIncludeAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlMemberMapping.cs
../class/System.XML/System.Xml.Serialization/XmlMembersMapping.cs
../class/System.XML/System.Xml.Serialization/XmlMapping.cs
../class/System.XML/System.Xml.Serialization/XmlMappingAccess.cs
../class/System.XML/System.Xml.Serialization/XmlNamespaceDeclarationsAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlNodeEventArgs.cs
../class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
../class/System.XML/System.Xml.Serialization/XmlReflectionMember.cs
../class/System.XML/System.Xml.Serialization/XmlRootAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlSchemaEnumerator.cs
../class/System.XML/System.Xml.Serialization/XmlSchemaExporter.cs
../class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
../class/System.XML/System.Xml.Serialization/XmlSchemaProviderAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlSchemas.cs
../class/System.XML/System.Xml.Serialization/XmlSerializationCollectionFixupCallback.cs
../class/System.XML/System.Xml.Serialization/XmlSerializationFixupCallback.cs
../class/System.XML/System.Xml.Serialization/XmlSerializationGeneratedCode.cs
../class/System.XML/System.Xml.Serialization/XmlSerializationReadCallback.cs
../class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs
../class/System.XML/System.Xml.Serialization/XmlSerializationReaderInterpreter.cs
../class/System.XML/System.Xml.Serialization/XmlSerializationWriteCallback.cs
../class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs
../class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
../class/System.XML/System.Xml.Serialization/XmlSerializer.cs
../class/System.XML/System.Xml.Serialization/XmlSerializerAssemblyAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlSerializerFactory.cs
../class/System.XML/System.Xml.Serialization/XmlSerializerImplementation.cs
../class/System.XML/System.Xml.Serialization/XmlSerializerNamespaces.cs
../class/System.XML/System.Xml.Serialization/XmlSerializerVersionAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlTextAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlTypeAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlTypeMapElementInfo.cs
../class/System.XML/System.Xml.Serialization/XmlTypeMapMember.cs
../class/System.XML/System.Xml.Serialization/XmlTypeMapMemberAttribute.cs
../class/System.XML/System.Xml.Serialization/XmlTypeMapMemberElement.cs
../class/System.XML/System.Xml.Serialization/XmlTypeMapMemberNamespaces.cs
../class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs
../class/System.XML/System.Xml.Serialization/XmlElementEventHandler.cs
../class/System.XML/System.Xml.Serialization/XmlNodeEventHandler.cs
../class/System.XML/System.Xml.Serialization.Advanced/SchemaImporterExtension.cs
../class/System.XML/System.Xml.Serialization.Advanced/SchemaImporterExtensionCollection.cs
../class/System.XML/System.Xml.Serialization.Configuration/DateTimeSerializationSection.cs
../class/System.XML/System.Xml.Serialization.Configuration/SchemaImporterExtensionElement.cs
../class/System.XML/System.Xml.Serialization.Configuration/SchemaImporterExtensionElementCollection.cs
../class/System.XML/System.Xml.Serialization.Configuration/SchemaImporterExtensionsSection.cs
../class/System.XML/System.Xml.Serialization.Configuration/SerializationSectionGroup.cs
../class/System.XML/System.Xml.Serialization.Configuration/XmlSerializerSection.cs

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

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save