+ /// <summary>
+ /// Compiles the input string and returns a delegate that represents the compiled code.
+ /// </summary>
+ /// <remarks>
+ ///
+ /// Compiles the input string as a C# expression or
+ /// statement, unlike the Evaluate method, the
+ /// resulting delegate can be invoked multiple times
+ /// without incurring in the compilation overhead.
+ ///
+ /// If the return value of this function is null,
+ /// this indicates that the parsing was complete.
+ /// If the return value is a string it indicates
+ /// that the input string was partial and that the
+ /// invoking code should provide more code before
+ /// the code can be successfully compiled.
+ ///
+ /// If you know that you will always get full expressions or
+ /// statements and do not care about partial input, you can use
+ /// the other Compile overload.
+ ///
+ /// On success, in addition to returning null, the
+ /// compiled parameter will be set to the delegate
+ /// that can be invoked to execute the code.
+ ///
+ /// </remarks>
+ static public string Compile (string input, out CompiledMethod compiled)
+ {
+ if (input == null || input.Length == 0){
+ compiled = null;
+ return null;
+ }
+
+ lock (evaluator_lock){
+ if (!inited)
+ Init ();
+
+ bool partial_input;
+ CSharpParser parser = ParseString (ParseMode.Silent, input, out partial_input);
+ if (parser == null){
+ compiled = null;
+ if (partial_input)
+ return input;
+
+ ParseString (ParseMode.ReportErrors, input, out partial_input);
+ return null;
+ }
+
+ object parser_result = parser.InteractiveResult;
+
+ if (!(parser_result is Class)){
+ int errors = ctx.Report.Errors;
+
+ NamespaceEntry.VerifyAllUsing ();
+ if (errors == ctx.Report.Errors)
+ parser.CurrentNamespace.Extract (using_alias_list, using_list);
+ }
+
+ compiled = CompileBlock (parser_result as Class, parser.undo, ctx.Report);
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Compiles the input string and returns a delegate that represents the compiled code.
+ /// </summary>
+ /// <remarks>
+ ///
+ /// Compiles the input string as a C# expression or
+ /// statement, unlike the Evaluate method, the
+ /// resulting delegate can be invoked multiple times
+ /// without incurring in the compilation overhead.
+ ///
+ /// This method can only deal with fully formed input
+ /// strings and does not provide a completion mechanism.
+ /// If you must deal with partial input (for example for
+ /// interactive use) use the other overload.
+ ///
+ /// On success, a delegate is returned that can be used
+ /// to invoke the method.
+ ///
+ /// </remarks>
+ static public CompiledMethod Compile (string input)
+ {
+ CompiledMethod compiled;
+
+ // Ignore partial inputs
+ if (Compile (input, out compiled) != null){
+ // Error, the input was partial.
+ return null;
+ }
+
+ // Either null (on error) or the compiled method.
+ return compiled;
+ }
+