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 It currently has a few problems:
32 * Support for overwritting existing defined
33 classes is not supported.
35 * The usability is not as useful, since the defaults
36 for C# are still to make members private, we should
37 change this default to be public in those cases.
39 * The "using" statements are not exposed to the
40 underlying "class" declarations, so the following
41 code after a few using statements fail:
43 csharp> class X { public void Foo () { Console.WriteLine ("Foo"); } }
44 {interactive}(1,33): error CS0103: The name `Console' does not exist in the current context
46 * The error lookup system lacks information from types, for
47 example this causes an unsupported call into a TypeBuilder:
49 csharp>class D { void DD () {} }
50 csharp>var d = new D ();
53 Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class0::Host]
54 System.NotSupportedException: The invoked member is not supported in a dynamic module.
55 at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in <filename unknown>:0
56 at Mono.CSharp.Report.SymbolRelatedToPreviousError (System.Reflection.MemberInfo mi) [0x00000] in
57 at Mono.CSharp.MethodGroupExpr.NoExactMatch (Mono.CSharp.ResolveContext ec,
58 Mono.CSharp.Arguments& Arguments, IDictionary`2 c
61 The above is caused by TypeManager.LookupDeclSpace (dt)
62 failing to return a value (it returns null) so our code
63 assumes we have an Assembly instead of an assemblybuilder.
67 * Declaring a class twice produces an internal parse error:
72 The second declaration will no longer be parsed, so it could even
73 contain junk, and wont be flagged. We probably need to allow for
74 type redefinition in REPL modes, the exception from the second is:
80 System.ArgumentException: An element with the same key already exists in the dictionary.
81 at System.Collections.Generic.Dictionary`2[System.String,Mono.CSharp.DeclSpace].Add (System.String key, Mono.CSharp.DeclSpace value) [0x00000] in <filename unknown>:0
82 at Mono.CSharp.Namespace.AddDeclSpace (System.String name, Mono.CSharp.DeclSpace ds) [0x00000] in <filename unknown>:0
83 at Mono.CSharp.ModuleCompiled.AddMemberType (Mono.CSharp.DeclSpace ds) [0x00000] in <filename unknown>:0
84 at Mono.CSharp.TypeContainer.AddTypeContainer (Mono.CSharp.TypeContainer tc) [0x00000] in <filename unknown>:0
85 at Mono.CSharp.CSharpParser.push_current_class (Mono.CSharp.TypeContainer tc, System.Object partial_token) [0x00000] in <filename unknown>:0
86 at Mono.CSharp.CSharpParser.yyparse (yyInput yyLex) [0x00000] in <filename unknown>:0
87 at Mono.CSharp.CSharpParser.yyparse (yyInput yyLex, System.Object yyd) [0x00000] in <filename unknown>:0
88 at Mono.CSharp.CSharpParser.parse () [0x00000] in <filename unknown>:0
90 * Mix statements with other top-level declarations.
92 csharp> class Y {static void Main () {Console.WriteLine ("Foo"); }}
96 Exception caught by the compiler while compiling:
97 Block that caused the problem begin at: Internal(1,1):
98 Block being compiled: [<interactive>(1,2):,<interactive>(1,11):]
99 System.NotSupportedException: The invoked member is not supported in a dynamic module.
100 Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class2::Host]
101 System.NotSupportedException: The invoked member is not supported in a dynamic module.
102 at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in /second/home/cvs/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:214
103 at Mono.CSharp.Report.SymbolRelatedToPreviousError (System.Reflection.MemberInfo mi) [0x00036] in /second/home/cvs/mcs/mcs/report.cs:664
104 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
105 at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression right_side) [0x00230] in /second/home/cvs/mcs/mcs/expression.cs:7426
106 at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/expression.cs:7494
107 at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479
108 at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x0000d] in /second/home/cvs/mcs/mcs/expression.cs:4725
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.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506
111 at Mono.CSharp.OptionalAssign.DoResolve (Mono.CSharp.EmitContext ec) [0x00013] in /second/home/cvs/mcs/mcs/repl.cs:681
112 at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479
113 at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506
114 at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:1307
115 at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec) [0x0000b] in /second/home/cvs/mcs/mcs/statement.cs:743
116 at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x000f0] in /second/home/cvs/mcs/mcs/statement.cs:2254
117 at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/statement.cs:2550
118 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
123 csharp> class X { X (){ Console.WriteLine ("Called"); } }
125 Exception caught by the compiler while compiling:
126 Block that caused the problem begin at: Internal(1,1):
127 Block being compiled: [<interactive>(1,2):,<interactive>(1,10):]
128 System.NotSupportedException: The invoked member is not supported in a dynamic module.
129 Internal compiler error at Internal(1,1):: exception caught while emitting MethodBuilder [Class0::Host]
130 System.NotSupportedException: The invoked member is not supported in a dynamic module.
131 at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in /second/home/cvs/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:214
132 at Mono.CSharp.Report.SymbolRelatedToPreviousError (System.Reflection.MemberInfo mi) [0x00036] in /second/home/cvs/mcs/mcs/report.cs:664
133 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
134 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
135 at Mono.CSharp.New.DoResolve (Mono.CSharp.EmitContext ec) [0x002ad] in /second/home/cvs/mcs/mcs/expression.cs:5486
136 at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479
137 at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506
138 at Mono.CSharp.OptionalAssign.DoResolve (Mono.CSharp.EmitContext ec) [0x00013] in /second/home/cvs/mcs/mcs/repl.cs:687
139 at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags flags) [0x00075] in /second/home/cvs/mcs/mcs/ecore.cs:479
140 at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:506
141 at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/ecore.cs:1307
142 at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec) [0x0000b] in /second/home/cvs/mcs/mcs/statement.cs:743
143 at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x000f0] in /second/home/cvs/mcs/mcs/statement.cs:2254
144 at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] in /second/home/cvs/mcs/mcs/statement.cs:2550
145 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
148 * Important: we need to replace TypeBuidlers with Types after things
149 have been emitted, or stuff like this happens:
151 csharp> public class y {}
158 TODO: when clearing data for variables that have been overwritten
159 we need to check for structs and clear all the fields that contain
162 * DEBATABLE: Implement auto-insert-semicolon
164 This is easy to implement, just retry the parse with a
165 semicolon, the question is whether this is a good idea to do
166 in the first place or not.