diff options
author | Charles Krinke | 2008-05-31 17:52:44 +0000 |
---|---|---|
committer | Charles Krinke | 2008-05-31 17:52:44 +0000 |
commit | 25b7d9944d5875e1887eed156f31dd5779761265 (patch) | |
tree | 2c4f6f066ef2b5f60d399ab4862ed7b9dbe0c78f /OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL | |
parent | * Implements UserServer logoff in a few situations (diff) | |
download | opensim-SC-25b7d9944d5875e1887eed156f31dd5779761265.zip opensim-SC-25b7d9944d5875e1887eed156f31dd5779761265.tar.gz opensim-SC-25b7d9944d5875e1887eed156f31dd5779761265.tar.bz2 opensim-SC-25b7d9944d5875e1887eed156f31dd5779761265.tar.xz |
Mantis#1314. Thank you kindly, Kinoc for YieldProlog.
I have added everything *except* the patch to
.../LSL/Compiler.cs. The Compiler.cs patch has a
namespace issue. Lets make a second patch to close
the gap.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs new file mode 100644 index 0000000..3766246 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs | |||
@@ -0,0 +1,85 @@ | |||
1 | ?using System; | ||
2 | using System.IO; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Text; | ||
5 | using System.Text.RegularExpressions; | ||
6 | using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog; | ||
7 | |||
8 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | ||
9 | { | ||
10 | public class YP2CSConverter | ||
11 | { | ||
12 | public YP2CSConverter() | ||
13 | { | ||
14 | } | ||
15 | |||
16 | public string Convert(string Script) | ||
17 | { | ||
18 | string CS_code = GenCode(Script); | ||
19 | return CS_code; | ||
20 | } | ||
21 | |||
22 | |||
23 | static string GenCode(string myCode) | ||
24 | { | ||
25 | Variable TermList = new Variable(); | ||
26 | Variable FunctionCode = new Variable(); | ||
27 | |||
28 | string CS_code = ""; | ||
29 | |||
30 | int cs_pointer = myCode.IndexOf("\n//cs"); | ||
31 | if (cs_pointer > 0) | ||
32 | { | ||
33 | CS_code = myCode.Substring(cs_pointer); // CS code comes after | ||
34 | myCode = myCode.Substring(0, cs_pointer); | ||
35 | } | ||
36 | myCode.Replace("//yp", "%YPCode"); | ||
37 | |||
38 | |||
39 | StringWriter myCS_SW = new StringWriter(); | ||
40 | StringReader myCode_SR = new StringReader(" yp_nop_header_nop. \n "+myCode + "\n"); | ||
41 | |||
42 | YP.see(myCode_SR); | ||
43 | YP.tell(myCS_SW); | ||
44 | |||
45 | //Console.WriteLine("Mycode\n ===================================\n" + myCode+"\n"); | ||
46 | foreach (bool l1 in Parser.parseInput(TermList)) | ||
47 | { | ||
48 | foreach (bool l2 in YPCompiler.makeFunctionPseudoCode(TermList, FunctionCode)) | ||
49 | { | ||
50 | ListPair VFC = new ListPair(FunctionCode, new Variable()); | ||
51 | //Console.WriteLine("-------------------------") | ||
52 | //Console.WriteLine( FunctionCode.ToString()) | ||
53 | //Console.WriteLine("-------------------------") | ||
54 | YPCompiler.convertFunctionCSharp(FunctionCode); | ||
55 | //YPCompiler.convertStringCodesCSharp(VFC); | ||
56 | |||
57 | } | ||
58 | } | ||
59 | YP.seen(); | ||
60 | myCS_SW.Close(); | ||
61 | YP.told(); | ||
62 | StringBuilder bu = myCS_SW.GetStringBuilder(); | ||
63 | string finalcode = "//YPEncoded\n" + bu.ToString(); | ||
64 | // FIX script events (we're in the same script) | ||
65 | // 'YP.script_event(Atom.a(@"sayit"),' ==> 'sayit(' | ||
66 | finalcode = Regex.Replace(finalcode, | ||
67 | @"YP.script_event\(Atom.a\(\@\""(.*?)""\)\,", | ||
68 | @"this.$1(", | ||
69 | RegexOptions.Compiled | RegexOptions.Singleline); | ||
70 | finalcode = Regex.Replace(finalcode, | ||
71 | @" static ", | ||
72 | @" ", | ||
73 | RegexOptions.Compiled | RegexOptions.Singleline); | ||
74 | |||
75 | finalcode = CS_code+"\n\r"+ finalcode; | ||
76 | finalcode = Regex.Replace(finalcode, | ||
77 | @"PrologCallback", | ||
78 | @"public IEnumerable<bool> ", | ||
79 | RegexOptions.Compiled | RegexOptions.Singleline); | ||
80 | return finalcode; | ||
81 | } | ||
82 | |||
83 | |||
84 | } | ||
85 | } | ||