internal static List<NamespaceEntry.UsingEntry> using_list = new List<NamespaceEntry.UsingEntry> ();
static Dictionary<string, FieldInfo> fields = new Dictionary<string, FieldInfo> ();
- static Type interactive_base_class = typeof (InteractiveBase);
+ static TypeSpec interactive_base_class;
static Driver driver;
static bool inited;
{
return ctx.Report.SetPrinter (report_printer);
}
-
+
/// <summary>
/// Optional initialization for the Evaluator.
/// </summary>
CompilerCallableEntryPoint.Reset ();
RootContext.ToplevelTypes = new ModuleCompiled (ctx, true);
+ /*var ctypes = */TypeManager.InitCoreTypes ();
+ TypeManager.InitExpressionTypes ();
+ Import.Initialize ();
driver.LoadReferences ();
+ TypeManager.InitOptionalCoreTypes (ctx);
+
RootContext.EvalMode = true;
inited = true;
static void Reset ()
{
CompilerCallableEntryPoint.PartialReset ();
+ RootContext.PartialReset ();
// Workaround for API limitation where full message printer cannot be passed
ReportPrinter printer;
//
// PartialReset should not reset the core types, this is very redundant.
//
- if (!TypeManager.InitCoreTypes (ctx))
- throw new Exception ("Failed to InitCoreTypes");
- TypeManager.InitOptionalCoreTypes (ctx);
+// if (!TypeManager.InitCoreTypes (ctx, null))
+// throw new Exception ("Failed to InitCoreTypes");
+// TypeManager.InitOptionalCoreTypes (ctx);
Location.AddFile (null, "{interactive}");
Location.Initialize ();
/// base class and the static members that are
/// available to your evaluated code.
/// </remarks>
- static public Type InteractiveBaseClass {
+ static public TypeSpec InteractiveBaseClass {
get {
- return interactive_base_class;
+ if (interactive_base_class != null)
+ return interactive_base_class;
+
+ return Import.ImportType (typeof (InteractiveBase));
}
+ }
- set {
- if (value == null)
- throw new ArgumentNullException ();
+ public static void SetInteractiveBaseClass (Type type)
+ {
+ if (type == null)
+ throw new ArgumentNullException ();
- lock (evaluator_lock)
- interactive_base_class = value;
- }
+ lock (evaluator_lock)
+ interactive_base_class = Import.ImportType (type);
}
/// <summary>
}
RootContext.EmitCode ();
- if (Report.Errors != 0)
+ if (Report.Errors != 0){
+ undo.ExecuteUndo ();
return null;
+ }
RootContext.CloseTypes ();
// Unlike Mono, .NET requires that the MethodInfo is fetched, it cant
// work from MethodBuilders. Retarded, I know.
//
- Type tt = CodeGen.Assembly.Builder.GetType (tb.Name);
+ var tt = CodeGen.Assembly.Builder.GetType (tb.Name);
MethodInfo mi = tt.GetMethod (mb.Name);
// Pull the FieldInfos from the type, and keep track of them
// If a previous value was set, nullify it, so that we do
// not leak memory
if (fields.TryGetValue (field.Name, out old)){
- if (TypeManager.IsStruct (old.FieldType)){
+ if (old.FieldType.IsValueType){
//
// TODO: Clear fields for structs
//
foreach (var de in fields){
FieldInfo fi = LookupField (de.Key);
object value = null;
- bool error = false;
+ //bool error = false;
try {
if (value == null)
if (value is string)
value = Quote ((string)value);
} catch {
- error = true;
+ //error = true;
}
-
- if (error)
- sb.Append (String.Format ("{0} {1} <error reading value>", TypeManager.CSharpName(fi.FieldType), de.Key));
- else
- sb.Append (String.Format ("{0} {1} = {2}", TypeManager.CSharpName(fi.FieldType), de.Key, value));
+
+ throw new NotImplementedException ("net");
+ //if (error)
+ // sb.Append (String.Format ("{0} {1} <error reading value>", TypeManager.CSharpName(fi.FieldType), de.Key));
+ //else
+ // sb.Append (String.Format ("{0} {1} = {2}", TypeManager.CSharpName(fi.FieldType), de.Key, value));
}
return sb.ToString ();
static public void ReferenceAssembly (Assembly a)
{
lock (evaluator_lock){
- GlobalRootNamespace.Instance.AddAssemblyReference (a);
- GlobalRootNamespace.Instance.ComputeNamespaces (ctx);
+// GlobalRootNamespace.Instance.AddAssemblyReference (a);
+// GlobalRootNamespace.Instance.ComputeNamespaces (ctx);
+ GlobalRootNamespace.Instance.ImportAssembly (a);
}
}
if (x == null)
return "";
- Type t = x as Type;
- if (t == null)
- t = x.GetType ();
+ TypeSpec t = x as TypeSpec;
+// if (t == null)
+// t = x.GetType ();
StringWriter sw = new StringWriter ();
- new Outline (t, sw, true, false, false).OutlineType ();
+ new Outline (t.GetMetaInfo (), sw, true, false, false).OutlineType ();
return sw.ToString ();
}
#endif
CloneContext cc = new CloneContext ();
Expression clone = source.Clone (cc);
- var old_printer = Evaluator.SetPrinter (new StreamReportPrinter (TextWriter.Null));
- clone = clone.Resolve (ec);
- if (clone == null){
- //
- // A useful feature for the REPL: if we can resolve the expression
- // as a type, Describe the type;
- //
- if (Evaluator.DescribeTypeExpressions){
+ //
+ // A useful feature for the REPL: if we can resolve the expression
+ // as a type, Describe the type;
+ //
+ if (Evaluator.DescribeTypeExpressions){
+ var old_printer = Evaluator.SetPrinter (new StreamReportPrinter (TextWriter.Null));
+ clone = clone.Resolve (ec);
+ if (clone == null){
clone = source.Clone (cc);
clone = clone.Resolve (ec, ResolveFlags.Type);
if (clone == null){
clone = clone.Resolve (ec);
return null;
}
-
+
Arguments args = new Arguments (1);
args.Add (new Argument (new TypeOf (source, Location)));
source = new Invocation (new SimpleName ("Describe", Location), args).Resolve (ec);
- } else {
- Evaluator.SetPrinter (old_printer);
- return null;
}
+ Evaluator.SetPrinter (old_printer);
+ } else {
+ clone = clone.Resolve (ec);
+ if (clone == null)
+ return null;
}
- Evaluator.SetPrinter (old_printer);
// This means its really a statement.
if (clone.Type == TypeManager.void_type){