mirror of https://github.com/icsharpcode/ILSpy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
168 lines
10 KiB
168 lines
10 KiB
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.
|
|
|