aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs117
1 files changed, 0 insertions, 117 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs
deleted file mode 100644
index 7ea3cfc..0000000
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs
+++ /dev/null
@@ -1,117 +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 OpenSimulator 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.Shared.YieldProlog;
35
36namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
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 //m_log.Debug("Mycode\n ===================================\n" + myCode+"\n");
72
73// disable warning: don't see how we can code this differently short
74// of rewriting the whole thing
75#pragma warning disable 0168, 0219
76 foreach (bool l1 in Parser.parseInput(TermList))
77 {
78 foreach (bool l2 in YPCompiler.makeFunctionPseudoCode(TermList, FunctionCode))
79 {
80 // ListPair VFC = new ListPair(FunctionCode, new Variable());
81 //m_log.Debug("-------------------------")
82 //m_log.Debug(FunctionCode.ToString())
83 //m_log.Debug("-------------------------")
84 YPCompiler.convertFunctionCSharp(FunctionCode);
85 //YPCompiler.convertStringCodesCSharp(VFC);
86 }
87 }
88#pragma warning restore 0168, 0219
89 YP.seen();
90 myCS_SW.Close();
91 YP.told();
92 StringBuilder bu = myCS_SW.GetStringBuilder();
93 string finalcode = "//YPEncoded\n" + bu.ToString();
94 // FIX script events (we're in the same script)
95 // 'YP.script_event(Atom.a(@"sayit"),' ==> 'sayit('
96 finalcode = Regex.Replace(finalcode,
97 @"YP.script_event\(Atom.a\(\@\""(.*?)""\)\,",
98 @"this.$1(",
99 RegexOptions.Compiled | RegexOptions.Singleline);
100 finalcode = Regex.Replace(finalcode,
101 @"YP.script_event\(Atom.a\(\""(.*?)""\)\,",
102 @"this.$1(",
103 RegexOptions.Compiled | RegexOptions.Singleline);
104 finalcode = Regex.Replace(finalcode,
105 @" static ",
106 @" ",
107 RegexOptions.Compiled | RegexOptions.Singleline);
108
109 finalcode = CS_code+"\n\r"+ finalcode;
110 finalcode = Regex.Replace(finalcode,
111 @"PrologCallback",
112 @"public IEnumerable<bool> ",
113 RegexOptions.Compiled | RegexOptions.Singleline);
114 return finalcode;
115 }
116 }
117}