aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs116
1 files changed, 0 insertions, 116 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs
deleted file mode 100644
index 8618d6c..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs
+++ /dev/null
@@ -1,116 +0,0 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.IO;
31using System.Collections.Generic;
32using System.Text;
33using System.Text.RegularExpressions;
34using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog;
35
36namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
37{
38 public class YP2CSConverter
39 {
40 public YP2CSConverter()
41 {
42 }
43
44 public string Convert(string Script)
45 {
46 string CS_code = GenCode(Script);
47 return CS_code;
48 }
49
50 static string GenCode(string myCode)
51 {
52 Variable TermList = new Variable();
53 Variable FunctionCode = new Variable();
54
55 string CS_code = "";
56
57 int cs_pointer = myCode.IndexOf("\n//cs");
58 if (cs_pointer > 0)
59 {
60 CS_code = myCode.Substring(cs_pointer); // CS code comes after
61 myCode = myCode.Substring(0, cs_pointer);
62 }
63 myCode.Replace("//yp", "%YPCode");
64
65 StringWriter myCS_SW = new StringWriter();
66 StringReader myCode_SR = new StringReader(" yp_nop_header_nop. \n "+myCode + "\n");
67
68 YP.see(myCode_SR);
69 YP.tell(myCS_SW);
70
71 //Console.WriteLine("Mycode\n ===================================\n" + myCode+"\n");
72 // disable warning on l1, don't see how we can
73 // code this differently
74 #pragma warning disable 0168
75 foreach (bool l1 in Parser.parseInput(TermList))
76 {
77 foreach (bool l2 in YPCompiler.makeFunctionPseudoCode(TermList, FunctionCode))
78 {
79 // ListPair VFC = new ListPair(FunctionCode, new Variable());
80 //Console.WriteLine("-------------------------")
81 //Console.WriteLine(FunctionCode.ToString())
82 //Console.WriteLine("-------------------------")
83 YPCompiler.convertFunctionCSharp(FunctionCode);
84 //YPCompiler.convertStringCodesCSharp(VFC);
85 }
86 }
87 #pragma warning restore 0168
88 YP.seen();
89 myCS_SW.Close();
90 YP.told();
91 StringBuilder bu = myCS_SW.GetStringBuilder();
92 string finalcode = "//YPEncoded\n" + bu.ToString();
93 // FIX script events (we're in the same script)
94 // 'YP.script_event(Atom.a(@"sayit"),' ==> 'sayit('
95 finalcode = Regex.Replace(finalcode,
96 @"YP.script_event\(Atom.a\(\@\""(.*?)""\)\,",
97 @"this.$1(",
98 RegexOptions.Compiled | RegexOptions.Singleline);
99 finalcode = Regex.Replace(finalcode,
100 @"YP.script_event\(Atom.a\(\""(.*?)""\)\,",
101 @"this.$1(",
102 RegexOptions.Compiled | RegexOptions.Singleline);
103 finalcode = Regex.Replace(finalcode,
104 @" static ",
105 @" ",
106 RegexOptions.Compiled | RegexOptions.Singleline);
107
108 finalcode = CS_code+"\n\r"+ finalcode;
109 finalcode = Regex.Replace(finalcode,
110 @"PrologCallback",
111 @"public IEnumerable<bool> ",
112 RegexOptions.Compiled | RegexOptions.Singleline);
113 return finalcode;
114 }
115 }
116}