[gbrainy] Fixes to Mono.CSharp dynamic library class
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Fixes to Mono.CSharp dynamic library class
- Date: Sun, 27 Mar 2011 16:25:35 +0000 (UTC)
commit 44431572f5316bb03121fa60c2f44810f6bb0147
Author: Jordi Mas <jmas softcatala org>
Date: Sun Mar 27 18:27:06 2011 +0200
Fixes to Mono.CSharp dynamic library class
src/Core/Libraries/CSharpCompiler.cs | 23 ++++++++++++++++++-
.../Libraries/CSharpCompilerStaticDomainProxy.cs | 2 +-
2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/Core/Libraries/CSharpCompiler.cs b/src/Core/Libraries/CSharpCompiler.cs
index 0d1f812..c15610d 100644
--- a/src/Core/Libraries/CSharpCompiler.cs
+++ b/src/Core/Libraries/CSharpCompiler.cs
@@ -50,9 +50,28 @@ namespace gbrainy.Core.Libraries
evaluator = new Evaluator (settings, report);
}
- public void EvaluateCode (string c)
+ public void EvaluateCode (string code)
{
- evaluator.Evaluate (c);
+ string eval;
+
+ try
+ {
+ // Using's for the variables section
+ // We need to evaluate either declarations (like using) or expression/statements separately
+ eval = "using System;\n";
+ evaluator.Run (eval);
+
+ // Infrastructure for the user available
+ eval = "Random random = new Random ();\n";
+
+ // As Mono 2.4.4 this call is killing in terms of memory leaking
+ evaluator.Run (eval + code);
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine ("CSharpCompiler. Error {0} when evaluating variable definition [{1}]", e.Message, code);
+ };
}
public string GetAllVariables ()
diff --git a/src/Core/Libraries/CSharpCompilerStaticDomainProxy.cs b/src/Core/Libraries/CSharpCompilerStaticDomainProxy.cs
index e31150f..a3f07ea 100644
--- a/src/Core/Libraries/CSharpCompilerStaticDomainProxy.cs
+++ b/src/Core/Libraries/CSharpCompilerStaticDomainProxy.cs
@@ -61,7 +61,7 @@ namespace gbrainy.Core.Libraries
catch (Exception e)
{
- Console.WriteLine ("GameXml. Error in games.xml: {0} when evaluating variable definition [{1}]", e.Message, code);
+ Console.WriteLine ("CSharpCompilerStaticDomainProxy. Error {0} when evaluating variable definition [{1}]", e.Message, code);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]