1 Things to do for the REPL support in MCS:
3 Documentation for the REPL mode for MCS can be found here:
5 http://mono-project.com/CsharpRepl
9 * Booting the compiler without Main ()
10 * Expose LoadAssembly/LoadPackage
12 * Register a lookup function for fields?
13 * Register classes to expose to REPL
17 * Run a REPL on a socket (from Joe Shaw)
18 * Host a REPL on XSP (from Nat).
22 Clear struct fields inside the clearing code.
28 * Supporting class-level declarations
30 Currently the evaluator has this feature disabled, to enable
31 it edit the eval.cs file and make this be the default:
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;
39 It currently has a few problems:
41 * Support for overwritting existing defined
42 classes is not supported.
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.
48 * The error lookup system lacks information from types, for
49 example this causes an unsupported call into a TypeBuilder:
51 csharp>class D { void DD () {} }
52 csharp>var d = new D ();
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
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.
69 * Declaring a class twice produces an internal parse error:
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:
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
92 * Mix statements with other top-level declarations.
94 csharp> class Y {static void Main () {Console.WriteLine ("Foo"); }}
98 Exception 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):]
101 System.NotSupportedException: The invoked member is not supported in a dynamic module.
102 Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class2::Host]
103 System.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
125 csharp> class X { X (){ Console.WriteLine ("Called"); } }
127 Exception 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):]
130 System.NotSupportedException: The invoked member is not supported in a dynamic module.
131 Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class0::Host]
132 System.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
150 * Important: we need to replace TypeBuidlers with Types after things
151 have been emitted, or stuff like this happens:
153 csharp> public class y {}
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
164 * DEBATABLE: Implement auto-insert-semicolon
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.