PageRenderTime 14ms CodeModel.GetById 7ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

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

http://github.com/icsharpcode/ILSpy
Plain Text | 168 lines | 128 code | 40 blank | 0 comment | 0 complexity | 9e36263d5f33da668b60a137bbc2f9a9 MD5 | raw file
  1Things to do for the REPL support in MCS:
  2
  3Documentation for the REPL mode for MCS can be found here:
  4
  5	      http://mono-project.com/CsharpRepl
  6
  7* Embedding API
  8
  9	* Booting the compiler without Main ()
 10	* Expose LoadAssembly/LoadPackage
 11	* Register fields?
 12	* Register a lookup function for fields?
 13	* Register classes to expose to REPL
 14
 15* Embedded Library
 16
 17	* Run a REPL on a socket (from Joe Shaw)
 18	* Host a REPL on XSP (from Nat).
 19
 20* TODO
 21
 22	Clear struct fields inside the clearing code.
 23
 24* Other ideas:
 25
 26	MD addin for "csharp"
 27
 28* Supporting class-level declarations
 29
 30	Currently the evaluator has this feature disabled, to enable
 31	it edit the eval.cs file and make this be the default:
 32
 33-				parser.Lexer.putback_char = Tokenizer.EvalUsingDeclarationsParserCharacter;
 34-				//parser.Lexer.putback_char = Tokenizer.EvalCompilationUnitParserCharacter;
 35+				//parser.Lexer.putback_char = Tokenizer.EvalUsingDeclarationsParserCharacter;
 36+				parser.Lexer.putback_char = Tokenizer.EvalCompilationUnitParserCharacter;
 37
 38	
 39	It currently has a few problems:
 40
 41	* Support for overwritting existing defined
 42	  classes is not supported.
 43
 44	* The usability is not as useful, since the defaults
 45	  for C# are still to make members private, we should
 46	  change this default to be public in those cases.
 47
 48	* The error lookup system lacks information from types, for
 49          example this causes an unsupported call into a TypeBuilder:
 50
 51	  csharp>class D { void DD () {} }
 52	  csharp>var d = new D ();
 53	  csharp>d.DD ();
 54
 55		Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class0::Host]
 56		System.NotSupportedException: The invoked member is not supported in a dynamic module.
 57		  at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in <filename unknown>:0 
 58		  at Mono.CSharp.Report.SymbolRelatedToPreviousError (System.Reflection.MemberInfo mi) [0x00000] in
 59		  at Mono.CSharp.MethodGroupExpr.NoExactMatch (Mono.CSharp.ResolveContext ec, 
 60					    Mono.CSharp.Arguments& Arguments, IDictionary`2 c
 61
 62
 63	  The above is caused by TypeManager.LookupDeclSpace (dt)
 64	  failing to return a value (it returns null) so our code
 65	  assumes we have an Assembly instead of an assemblybuilder.
 66
 67	  
 68
 69* Declaring a class twice produces an internal parse error:
 70
 71  class X {}
 72  class X {}
 73
 74  The second declaration will no longer be parsed, so it could even
 75  contain junk, and wont be flagged.   We probably need to allow for
 76  type redefinition in REPL modes, the exception from the second is:
 77
 78  csharp -v -v
 79  > class X {}
 80  > class X {}
 81
 82    System.ArgumentException: An element with the same key already exists in the dictionary.
 83      at System.Collections.Generic.Dictionary`2[System.String,Mono.CSharp.DeclSpace].Add (System.String key, Mono.CSharp.DeclSpace value) [0x00000] in <filename unknown>:0 
 84      at Mono.CSharp.Namespace.AddDeclSpace (System.String name, Mono.CSharp.DeclSpace ds) [0x00000] in <filename unknown>:0 
 85      at Mono.CSharp.ModuleCompiled.AddMemberType (Mono.CSharp.DeclSpace ds) [0x00000] in <filename unknown>:0 
 86      at Mono.CSharp.TypeContainer.AddTypeContainer (Mono.CSharp.TypeContainer tc) [0x00000] in <filename unknown>:0 
 87      at Mono.CSharp.CSharpParser.push_current_class (Mono.CSharp.TypeContainer tc, System.Object partial_token) [0x00000] in <filename unknown>:0 
 88      at Mono.CSharp.CSharpParser.yyparse (yyInput yyLex) [0x00000] in <filename unknown>:0 
 89      at Mono.CSharp.CSharpParser.yyparse (yyInput yyLex, System.Object yyd) [0x00000] in <filename unknown>:0 
 90      at Mono.CSharp.CSharpParser.parse () [0x00000] in <filename unknown>:0 
 91    
 92* Mix statements with other top-level declarations.
 93
 94csharp> class Y {static void Main () {Console.WriteLine ("Foo"); }}
 95csharp> typeof (Y);
 96Y
 97csharp> Y.Main ();
 98Exception caught by the compiler while compiling:
 99   Block that caused the problem begin at: Internal(1,1):
100                     Block being compiled: [<interactive>(1,2):,<interactive>(1,11):]
101System.NotSupportedException: The invoked member is not supported in a dynamic module.
102Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class2::Host]
103System.NotSupportedException: The invoked member is not supported in a dynamic module.
104  at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in /second/home/cvs/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:214 
105  at Mono.CSharp.Report.SymbolRelatedToPreviousError (System.Reflection.MemberInfo mi) [0x00036] in /second/home/cvs/mcs/mcs/report.cs:664 
106  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 
107  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression right_side) [0x00230] in /second/home/cvs/mcs/mcs/expression.cs:7426 
108  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/expression.cs:7494 
109  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479 
110  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x0000d] in /second/home/cvs/mcs/mcs/expression.cs:4725 
111  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479 
112  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506 
113  at Mono.CSharp.OptionalAssign.DoResolve (Mono.CSharp.EmitContext ec) [0x00013] in /second/home/cvs/mcs/mcs/repl.cs:681 
114  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479 
115  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506 
116  at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:1307 
117  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec) [0x0000b] in /second/home/cvs/mcs/mcs/statement.cs:743 
118  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x000f0] in /second/home/cvs/mcs/mcs/statement.cs:2254 
119  at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/statement.cs:2550 
120  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 
121csharp>  
122
123* Another one:
124
125csharp> class X { X (){ Console.WriteLine ("Called"); } }              
126csharp> new X ();
127Exception caught by the compiler while compiling:
128   Block that caused the problem begin at: Internal(1,1):
129                     Block being compiled: [<interactive>(1,2):,<interactive>(1,10):]
130System.NotSupportedException: The invoked member is not supported in a dynamic module.
131Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class0::Host]
132System.NotSupportedException: The invoked member is not supported in a dynamic module.
133  at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in /second/home/cvs/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:214 
134  at Mono.CSharp.Report.SymbolRelatedToPreviousError (System.Reflection.MemberInfo mi) [0x00036] in /second/home/cvs/mcs/mcs/report.cs:664 
135  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 
136  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 
137  at Mono.CSharp.New.DoResolve (Mono.CSharp.EmitContext ec) [0x002ad] in /second/home/cvs/mcs/mcs/expression.cs:5486 
138  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479 
139  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506 
140  at Mono.CSharp.OptionalAssign.DoResolve (Mono.CSharp.EmitContext ec) [0x00013] in /second/home/cvs/mcs/mcs/repl.cs:687 
141  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479 
142  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506 
143  at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:1307 
144  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec) [0x0000b] in /second/home/cvs/mcs/mcs/statement.cs:743 
145  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x000f0] in /second/home/cvs/mcs/mcs/statement.cs:2254 
146  at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/statement.cs:2550 
147  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 
148csharp>  
149
150* Important: we need to replace TypeBuidlers with Types after things
151  have been emitted, or stuff like this happens:
152
153csharp> public class y  {}
154csharp> typeof (y); 
155Class1
156
157
158* Clearing data
159
160	TODO: when clearing data for variables that have been overwritten
161	we need to check for structs and clear all the fields that contain
162	reference types.
163
164* DEBATABLE: Implement auto-insert-semicolon
165
166	This is easy to implement, just retry the parse with a
167	semicolon, the question is whether this is a good idea to do
168	in the first place or not.