aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs')
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs
new file mode 100644
index 0000000..7120b6c
--- /dev/null
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs
@@ -0,0 +1,45 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Rail.Transformation;
5using Rail.Reflect;
6using Rail.Exceptions;
7using Rail.MSIL;
8
9namespace OpenSim.Grid.ScriptEngine.DotNetEngine
10{
11 /// <summary>
12 /// Tedds Sandbox for RAIL/microtrheading. This class is only for testing purposes!
13 /// Its offspring will be the actual implementation.
14 /// </summary>
15 class TempDotNetMicroThreadingCodeInjector
16 {
17 public static string TestFix(string FileName)
18 {
19 string ret = System.IO.Path.GetFileNameWithoutExtension(FileName + "_fixed.dll");
20
21 Console.WriteLine("Loading: \"" + FileName + "\"");
22 RAssemblyDef rAssembly = RAssemblyDef.LoadAssembly(FileName);
23
24
25 //Get the type of the method to copy from assembly Teste2.exe to assembly Teste.exe
26 RTypeDef type = (RTypeDef)rAssembly.RModuleDef.GetType("SecondLife.Script");
27
28 //Get the methods in the type
29 RMethod[] m = type.GetMethods();
30
31 //Create a MethodPrologueAdder visitor object with the method to add
32 //and with the flag that enables local variable creation set to true
33 MethodPrologueAdder mpa = new MethodPrologueAdder((RMethodDef)m[0], true);
34
35 //Apply the changes to the assembly
36 rAssembly.Accept(mpa);
37
38 //Save the new assembly
39 rAssembly.SaveAssembly(ret);
40
41 return ret;
42
43 }
44 }
45}