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