aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs165
1 files changed, 80 insertions, 85 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs
index 3fc9e00..557c1c9 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs
@@ -26,88 +26,83 @@
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.IO; 30using System.IO;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Text; 32using System.Text;
33using System.Text.RegularExpressions; 33using System.Text.RegularExpressions;
34using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog; 34using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog;
35 35
36namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL 36namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
37{ 37{
38 public class YP2CSConverter 38 public class YP2CSConverter
39 { 39 {
40 public YP2CSConverter() 40 public YP2CSConverter()
41 { 41 {
42 } 42 }
43 43
44 public string Convert(string Script) 44 public string Convert(string Script)
45 { 45 {
46 string CS_code = GenCode(Script); 46 string CS_code = GenCode(Script);
47 return CS_code; 47 return CS_code;
48 } 48 }
49 49
50 50 static string GenCode(string myCode)
51 static string GenCode(string myCode) 51 {
52 { 52 Variable TermList = new Variable();
53 Variable TermList = new Variable(); 53 Variable FunctionCode = new Variable();
54 Variable FunctionCode = new Variable(); 54
55 55 string CS_code = "";
56 string CS_code = ""; 56
57 57 int cs_pointer = myCode.IndexOf("\n//cs");
58 int cs_pointer = myCode.IndexOf("\n//cs"); 58 if (cs_pointer > 0)
59 if (cs_pointer > 0) 59 {
60 { 60 CS_code = myCode.Substring(cs_pointer); // CS code comes after
61 CS_code = myCode.Substring(cs_pointer); // CS code comes after 61 myCode = myCode.Substring(0, cs_pointer);
62 myCode = myCode.Substring(0, cs_pointer); 62 }
63 } 63 myCode.Replace("//yp", "%YPCode");
64 myCode.Replace("//yp", "%YPCode"); 64
65 65 StringWriter myCS_SW = new StringWriter();
66 66 StringReader myCode_SR = new StringReader(" yp_nop_header_nop. \n "+myCode + "\n");
67 StringWriter myCS_SW = new StringWriter(); 67
68 StringReader myCode_SR = new StringReader(" yp_nop_header_nop. \n "+myCode + "\n"); 68 YP.see(myCode_SR);
69 69 YP.tell(myCS_SW);
70 YP.see(myCode_SR); 70
71 YP.tell(myCS_SW); 71 //Console.WriteLine("Mycode\n ===================================\n" + myCode+"\n");
72 72 foreach (bool l1 in Parser.parseInput(TermList))
73 //Console.WriteLine("Mycode\n ===================================\n" + myCode+"\n"); 73 {
74 foreach (bool l1 in Parser.parseInput(TermList)) 74 foreach (bool l2 in YPCompiler.makeFunctionPseudoCode(TermList, FunctionCode))
75 { 75 {
76 foreach (bool l2 in YPCompiler.makeFunctionPseudoCode(TermList, FunctionCode)) 76 ListPair VFC = new ListPair(FunctionCode, new Variable());
77 { 77 //Console.WriteLine("-------------------------")
78 ListPair VFC = new ListPair(FunctionCode, new Variable()); 78 //Console.WriteLine( FunctionCode.ToString())
79 //Console.WriteLine("-------------------------") 79 //Console.WriteLine("-------------------------")
80 //Console.WriteLine( FunctionCode.ToString()) 80 YPCompiler.convertFunctionCSharp(FunctionCode);
81 //Console.WriteLine("-------------------------") 81 //YPCompiler.convertStringCodesCSharp(VFC);
82 YPCompiler.convertFunctionCSharp(FunctionCode); 82 }
83 //YPCompiler.convertStringCodesCSharp(VFC); 83 }
84 84 YP.seen();
85 } 85 myCS_SW.Close();
86 } 86 YP.told();
87 YP.seen(); 87 StringBuilder bu = myCS_SW.GetStringBuilder();
88 myCS_SW.Close(); 88 string finalcode = "//YPEncoded\n" + bu.ToString();
89 YP.told(); 89 // FIX script events (we're in the same script)
90 StringBuilder bu = myCS_SW.GetStringBuilder(); 90 // 'YP.script_event(Atom.a(@"sayit"),' ==> 'sayit('
91 string finalcode = "//YPEncoded\n" + bu.ToString(); 91 finalcode = Regex.Replace(finalcode,
92 // FIX script events (we're in the same script) 92 @"YP.script_event\(Atom.a\(\@\""(.*?)""\)\,",
93 // 'YP.script_event(Atom.a(@"sayit"),' ==> 'sayit(' 93 @"this.$1(",
94 finalcode = Regex.Replace(finalcode, 94 RegexOptions.Compiled | RegexOptions.Singleline);
95 @"YP.script_event\(Atom.a\(\@\""(.*?)""\)\,", 95 finalcode = Regex.Replace(finalcode,
96 @"this.$1(", 96 @" static ",
97 RegexOptions.Compiled | RegexOptions.Singleline); 97 @" ",
98 finalcode = Regex.Replace(finalcode, 98 RegexOptions.Compiled | RegexOptions.Singleline);
99 @" static ", 99
100 @" ", 100 finalcode = CS_code+"\n\r"+ finalcode;
101 RegexOptions.Compiled | RegexOptions.Singleline); 101 finalcode = Regex.Replace(finalcode,
102 102 @"PrologCallback",
103 finalcode = CS_code+"\n\r"+ finalcode; 103 @"public IEnumerable<bool> ",
104 finalcode = Regex.Replace(finalcode, 104 RegexOptions.Compiled | RegexOptions.Singleline);
105 @"PrologCallback", 105 return finalcode;
106 @"public IEnumerable<bool> ", 106 }
107 RegexOptions.Compiled | RegexOptions.Singleline); 107 }
108 return finalcode; 108}
109 }
110
111
112 }
113}