├── .gitattributes ├── .gitignore ├── CSLightEvil_windows.sln ├── README.md ├── core ├── CSLightEvil │ ├── C#LE │ │ ├── Bug.txt │ │ ├── CLS_Environment.cs │ │ ├── Compitler │ │ │ ├── CLS_Compiler.cs │ │ │ ├── CLS_Compiler_00Util.cs │ │ │ ├── CLS_Compiler_01Block.cs │ │ │ ├── CLS_Compiler_02Value.cs │ │ │ ├── CLS_Compiler_03DefineSet.cs │ │ │ ├── CLS_Compiler_04Math.cs │ │ │ ├── CLS_Compiler_05Function.cs │ │ │ ├── CLS_Compiler_06Loop.cs │ │ │ └── CLS_Compiler_07OO.cs │ │ ├── Delegate │ │ │ └── Delegate.cs │ │ ├── Expression │ │ │ ├── CLS_Expression_Block.cs │ │ │ ├── CLS_Expression_Define.cs │ │ │ ├── CLS_Expression_GetValue.cs │ │ │ ├── CLS_Expression_SetValue.cs │ │ │ ├── Function │ │ │ │ ├── CLS_Expression_Function.cs │ │ │ │ ├── CLS_Expression_FunctionNew.cs │ │ │ │ ├── CLS_Expression_FunctionNewArray.cs │ │ │ │ ├── CLS_Expression_IndexFind.cs │ │ │ │ ├── CLS_Expression_IndexSetValue.cs │ │ │ │ ├── CLS_Expression_Lambda.cs │ │ │ │ ├── CLS_Expression_MemberFind.cs │ │ │ │ ├── CLS_Expression_MemberFunction.cs │ │ │ │ ├── CLS_Expression_MemberMath.cs │ │ │ │ ├── CLS_Expression_MemberSetValue.cs │ │ │ │ ├── CLS_Expression_StaticFind.cs │ │ │ │ ├── CLS_Expression_StaticFunction.cs │ │ │ │ ├── CLS_Expression_StaticMath.cs │ │ │ │ ├── CLS_Expression_StaticSetValue.cs │ │ │ │ └── CLS_Expression_Throw.cs │ │ │ ├── Loop │ │ │ │ ├── CLS_Expression_LoopBreak.cs │ │ │ │ ├── CLS_Expression_LoopContinue.cs │ │ │ │ ├── CLS_Expression_LoopDowhile.cs │ │ │ │ ├── CLS_Expression_LoopFor.cs │ │ │ │ ├── CLS_Expression_LoopForEach.cs │ │ │ │ ├── CLS_Expression_LoopIf.cs │ │ │ │ ├── CLS_Expression_LoopReturn.cs │ │ │ │ ├── CLS_Expression_LoopTry.cs │ │ │ │ └── CLS_Expression_LoopWhile.cs │ │ │ └── Math │ │ │ │ ├── CLS_Expression_Math2Value.cs │ │ │ │ ├── CLS_Expression_Math2ValueAndOR.cs │ │ │ │ ├── CLS_Expression_Math2ValueLogic.cs │ │ │ │ ├── CLS_Expression_Math3Value.cs │ │ │ │ ├── CLS_Expression_NegativeLogic.cs │ │ │ │ ├── CLS_Expression_NegativeValue.cs │ │ │ │ ├── CLS_Expression_SelfOp.cs │ │ │ │ ├── CLS_Expression_SelfOpWithValue.cs │ │ │ │ ├── CLS_Expression_TypeCheck.cs │ │ │ │ └── CLS_Expression_TypeConvert.cs │ │ ├── Log.txt │ │ ├── RegHelper │ │ │ ├── FunctionTrace.cs │ │ │ ├── RegHelper_DeleAction.cs │ │ │ ├── RegHelper_DeleAction1Param.cs │ │ │ ├── RegHelper_DeleAction2Param.cs │ │ │ ├── RegHelper_DeleAction3Param.cs │ │ │ ├── RegHelper_DeleNonVoidAction.cs │ │ │ ├── RegHelper_DeleNonVoidAction1Param.cs │ │ │ ├── RegHelper_DeleNonVoidAction2Param.cs │ │ │ ├── RegHelper_DeleNonVoidAction3Param.cs │ │ │ ├── RegHelper_Function.cs │ │ │ └── RegHelper_Type.cs │ │ ├── Token │ │ │ └── CLS_Token.cs │ │ ├── Type │ │ │ ├── CLS_Type_Bool.cs │ │ │ ├── CLS_Type_Class.cs │ │ │ ├── CLS_Type_Delegate.cs │ │ │ ├── CLS_Type_Double.cs │ │ │ ├── CLS_Type_Float.cs │ │ │ ├── CLS_Type_Lambda.cs │ │ │ ├── CLS_Type_Null.cs │ │ │ ├── CLS_Type_String.cs │ │ │ ├── CLS_Type_Var.cs │ │ │ ├── ints │ │ │ │ ├── CLS_Type_Byte.cs │ │ │ │ ├── CLS_Type_Char.cs │ │ │ │ ├── CLS_Type_Int.cs │ │ │ │ ├── CLS_Type_Long.cs │ │ │ │ ├── CLS_Type_Sbyte.cs │ │ │ │ ├── CLS_Type_Short.cs │ │ │ │ ├── CLS_Type_UInt.cs │ │ │ │ ├── CLS_Type_ULong.cs │ │ │ │ └── CLS_Type_Ushort.cs │ │ │ └── utils │ │ │ │ └── NumericTypeUtils.cs │ │ ├── Value │ │ │ └── CLS_Value_Value.cs │ │ └── _Interface │ │ │ ├── CLS_Content.cs │ │ │ ├── CLS_Expression.cs │ │ │ ├── CLS_Function.cs │ │ │ ├── CLS_Loger.cs │ │ │ └── CLS_Type.cs │ ├── CSLightEvil.csproj │ ├── CSLightEvil35.csproj │ └── Properties │ │ └── AssemblyInfo.cs └── myjson │ ├── MyJson.cs │ ├── MyJson.cs.meta │ └── MyJsonCompress.cs └── windows ├── CSEvilTestor ├── CSEvilTestor.csproj ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── TestDele.cs ├── TestReg.cs ├── app.config ├── script │ ├── ScriptClass.cs │ ├── ScriptClass2.cs │ ├── test01 │ │ ├── Test01.cs │ │ └── test.txt │ ├── test02 │ │ ├── Test02.cs │ │ └── test.txt │ ├── test03 │ │ ├── Test03.cs │ │ └── test.txt │ ├── test04 │ │ ├── Test04.cs │ │ └── test.txt │ ├── test05 │ │ ├── Test05.cs │ │ └── test.txt │ ├── test06 │ │ ├── Test06.cs │ │ └── test.txt │ ├── test07 │ │ ├── Test07.cs │ │ └── test.txt │ ├── test08 │ │ ├── Test08.cs │ │ └── test.txt │ └── test09 │ │ ├── Test09.cs │ │ └── test.txt └── testfunc │ ├── CSLEConvert.cs │ ├── MyJson.cs │ ├── MyJsonCompress.cs │ ├── TestClass.cs │ └── TestDele.cs └── CSLightTestor ├── CLScriptExt ├── Country.cs ├── MyJson.cs ├── Student.cs └── Vector3.cs ├── CSLightTestor.csproj ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs ├── Properties ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── UniLua.dll ├── app.config ├── code ├── _1001_expression.cls.txt ├── _1002_expression.cls.txt ├── _1003_expression.cls.txt ├── _1004_expression.cls.txt ├── _1005_expression.cls.txt ├── _2001_defineandset.cls.txt ├── _2002_defineandset.cls.txt ├── _2003_defineandset.cls.txt ├── _3001_mathandlogic.cls.txt ├── _3002_mathandlogic.cls.txt ├── _4001_loops.cls.txt ├── _4002_loops.cls.txt ├── _4003_loops.cls.txt ├── _5001_function.cls.txt ├── _5002_function.cls.txt ├── _5003_function.cls.txt ├── _6001_object.cls.txt ├── _6002_object.cls.txt ├── _6003_object.cls.txt ├── _6004_object.cls.txt ├── _6005_enum.cls.txt ├── _6006_object.cls.txt ├── _6007_object.cls.txt ├── _6008_object.cls.txt ├── _7001_array.cls.txt ├── _7002_array.cls.txt └── _7003_array.cls.txt └── ssharp.dll /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | bin 17 | Bin 18 | obj 19 | Obj 20 | 21 | # ========================= 22 | # Operating System Files 23 | # ========================= 24 | 25 | # OSX 26 | # ========================= 27 | 28 | .DS_Store 29 | .AppleDouble 30 | .LSOverride 31 | 32 | # Icon must end with two \r 33 | Icon 34 | 35 | # Thumbnails 36 | ._* 37 | 38 | # Files that might appear on external disk 39 | .Spotlight-V100 40 | .Trashes 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | 49 | core/CSLightEvil.dll 50 | core/CSLightEvil.pdb 51 | /core/CSLightEvil/obj 52 | /*.suo 53 | /windows/bin 54 | /windows/CSEvilTestor/obj 55 | /windows/CSLightTestor/obj 56 | core/CSLightEvil35.dll 57 | core/CSLightEvil35.pdb 58 | -------------------------------------------------------------------------------- /CSLightEvil_windows.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSLightTestor", "windows\CSLightTestor\CSLightTestor.csproj", "{76074628-FC6D-4B22-B3FA-BFCD879DAE16}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSEvilTestor", "windows\CSEvilTestor\CSEvilTestor.csproj", "{B321C533-C288-4FDB-A34A-1C25B063F669}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSLightEvil35", "core\CSLightEvil\CSLightEvil35.csproj", "{8D3C48F1-DFB1-4344-8962-5D09CB02BAC2}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {76074628-FC6D-4B22-B3FA-BFCD879DAE16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {76074628-FC6D-4B22-B3FA-BFCD879DAE16}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {76074628-FC6D-4B22-B3FA-BFCD879DAE16}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {76074628-FC6D-4B22-B3FA-BFCD879DAE16}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {B321C533-C288-4FDB-A34A-1C25B063F669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {B321C533-C288-4FDB-A34A-1C25B063F669}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {B321C533-C288-4FDB-A34A-1C25B063F669}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {B321C533-C288-4FDB-A34A-1C25B063F669}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {8D3C48F1-DFB1-4344-8962-5D09CB02BAC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {8D3C48F1-DFB1-4344-8962-5D09CB02BAC2}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {8D3C48F1-DFB1-4344-8962-5D09CB02BAC2}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {8D3C48F1-DFB1-4344-8962-5D09CB02BAC2}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cslightcore 2 | =========== 3 | 2015-01-12 0.64.1Beta 4 | 修复一个long识别的问题 5 | 6 | 2015-01-12 0.64Beta 7 | 所有的循环体在处理break的时候都会有个作用域bug,双层foreach内层break就会出现。 8 | 已修复 9 | 10 | 2015-01-08 0.63.1Beta 11 | 12 | 13 | 2015-01-05 0.63Beta 14 | 15 | 修复几处delegate的+=Bug 16 | 修改一些接口名字 17 | 18 | 2014-12-27 0.62.3Beta 19 | 20 | 发现一些定义delegate的+= -=方面的问题,修正 21 | 以及delegate为null时+=的问题,修正 22 | 23 | 2014-12-23 0.62.2Beta 24 | 25 | 修改一处ctor阶段表达式识别问题 26 | 27 | 2014-12-23 0.62.1Beta 28 | 29 | 修改同一函数付给多个委托的问题 30 | 31 | 2014-12-22 0.62Beta 32 | 33 | 改写了所有的参数默认值,方便使用monodeveloper把他编译成dll 34 | 35 | 2014-12-22 0.61Beta 36 | 37 | 整合了sulbon做了多一些错误提示,和改写了一些冗余的临时变量操作 38 | 增加了新的注册方法,删除了0.60.5的委托注册方式 39 | //新的委托注册方法 40 | env.RegType(CSLE.RegHelper_Type.MakeDelegate(typeof(TestDele.myup), "TestDele.myup")); 41 | env.RegType(CSLE.RegHelper_Type.MakeDelegate(typeof(Action), "Action")); 42 | env.RegType(CSLE.RegHelper_Type.MakeDelegate(typeof(Action), "Action")); 43 | env.RegType(CSLE.RegHelper_Type.MakeDelegate(typeof(Action), "Action")); 44 | //新的类型注册方法 45 | env.RegType(CSLE.RegHelper_Type.MakeClass(typeof(Color), "Color")); 46 | 47 | 2014-12-17 0.60.5Beta 48 | 49 | 委托注册很多人理解困难,增加一个不那么容易出错的注册工具 50 | 51 | Action reg2 = (i, j) => { };//定义一个指定类型的委托,函数是啥不重要,不执行,只抽取参数 52 | CSLE.RegHelper_Dele_Util.RegWithDelegate(env, reg2, "Action");//用这个委托注册 53 | 54 | 2014-12-08 0.60.3Beta 55 | 56 | 修复一处int to enum 的问题 57 | 58 | 59 | 2014-12-05 0.60.2Beta 60 | 61 | 修复一处tokenparser bug,可能导致某些字符串解析时出错 62 | 63 | 修复 List[] 索引 不自动转型的问题 64 | 65 | 2014-12-04 0.60.1Beta 66 | 67 | 修复这种表达式问题Vector3 vec= new Vector3(1,2,3)*0.5f; 68 | 之前new 之后的不会执行 69 | 70 | 2014-12-04 0.6Beta 71 | 72 | 增加了一个C#Light序列化到Json的例子 73 | 见EvilTestor 用例9 74 | 可以参照此例子建立脚本到数据的映射 75 | 完成协议传输等工作 76 | 77 | class Like 78 | { 79 | public string name; 80 | public string desc; 81 | } 82 | class Love 83 | { 84 | public int id; 85 | } 86 | class TSave 87 | { 88 | public string name; 89 | public int age; 90 | public Love love; 91 | public List like; 92 | public List strs; 93 | } 94 | class Test09 95 | { 96 | public Color vv; 97 | 98 | public static void Test() 99 | { 100 | MyJson.JsonNode_Object objst =MyJson.Parse 101 | ("{\"love\":{\"id\":12345}\"name\":\"aname\",\"age\":123,\"like\":[{\"name\":\"aaa\",\"desc\":\"aaaaaa\"},{\"name\":\"bbb\",\"desc\":\"bbbbbb\"}],\"strs\":[\"aa\",\"bb\"]}") 102 | as MyJson.JsonNode_Object; 103 | 104 | TSave read = CSLEConvert.FromJson("TSave", objst) as TSave; 105 | 106 | Debug.Log("read.name=" + read.name); 107 | Debug.Log("read.like[0].name=" + read.like[0].name); 108 | Debug.Log("read.strs[1]=" + read.strs[1]); 109 | Debug.Log("read.love.id=" + read.love.id); 110 | Debug.Log("write" + CSLEConvert.ToJson(read).ToString()); 111 | } 112 | 113 | } 114 | 115 | 116 | 2014-12-03 0.59.1Beta 117 | 118 | 追加如下三个默认注册,不用再自行注册 119 | RegType(new RegHelper_Type(typeof(object),"object")); 120 | RegType(new RegHelper_Type(typeof(List<>), "List")); 121 | RegType(new RegHelper_Type(typeof(Dictionary<,>), "Dictionary")); 122 | 123 | 修改了一处强制转换表达式识别错误 124 | 125 | 126 | 2014-12-02 0.59Beta 127 | 128 | 修正了 int +String null+string 的问题 129 | 130 | 修改了一个机制 131 | 132 | List (ScriptType是脚本类型) 可以使用了,只需要注册List<> 133 | 134 | 其内部会变成List 135 | 136 | 但是保证脚本看起来像是把脚本放进了模板元 137 | 138 | 见eviltestor用例08 139 | 140 | 2014-12-02 0.58.1Beta 141 | 142 | 修正了参数传null无法识别类型的问题 143 | 144 | 145 | 2014-12-02 0.58Beta 146 | 147 | 修正了模板函数调用的多处错误 148 | 149 | 泛型函数调用未检查父类型已修正 150 | 151 | 泛型函数调用时多余的空格导致的识别错误已修正 152 | 153 | 泛型函数调用参数还是泛型时的识别错误已修正 154 | 155 | 156 | 157 | 2014-12-01 0.57.1Beta 158 | 159 | Fix 一点小问题 160 | 161 | string[] ss = str.Split(new char[]{','}); 162 | 163 | 保证这种char表达式可以正当执行(需要注册char[],string[]) 164 | 165 | 166 | 167 | 2014-12-01 0.57Beta 168 | 169 | 修改了函数调用机制,已经可以处理委托直接作为函数参数输入的情况。 170 | 171 | 调用函数参数可以自动转型的情况也已经处理。 172 | 173 | 调用默认参数的情况也已经处理。 174 | 175 | 176 | 2014-12-01 0.56Beta 177 | 178 | fix一处优化笔误,get set 出了问题 179 | 180 | 重写了混乱的委托 -= 的处理 181 | 182 | 183 | 2014-11-29 0.55Beta 184 | 185 | 加入了表达式缓存,MemberCall调用和StaticCall调用加入了表达式缓存。 186 | 187 | 多次执行表达式时会极大的提升效率 188 | 189 | indexset,indexget,valueget valueset加入了类型缓存 190 | 191 | 效率都有一定提升 192 | 193 | 194 | 2014-11-17 0.51Beta 195 | 196 | 允许成员函数和类型重名 197 | 修改字符串识别逻辑bug 198 | 199 | 200 | 2014-11-05 0.50Beta 201 | 202 | 修改了 as 表达式的一些不严谨问题 203 | 增加了 is 表达式 204 | 205 | 206 | 2014-10-28 0.49.7Beta 207 | 208 | 添加了单引号char表达式 209 | 210 | 211 | 2014-10-14 0.49.61Beta 212 | 213 | 之前的修改导致了bug,换了一种实现方式 214 | 215 | 216 | 2014-10-13 0.49.6Beta 217 | 218 | 修改了 !表达式 无视运算优先级的bug 219 | 220 | 221 | 2014-10-11 0.49.5Beta【Graphics修改】 222 | 223 | 加入了ulong 224 | 225 | 226 | 2014-09-29 0.49.4Beta 227 | 228 | 修正了if(null==xxx)这种表达式 229 | 修正了用子类访问父类的静态成员的问题 230 | 231 | 232 | 2014-09-22 0.49.3Beta 233 | 234 | 结构体没有默认构造函数,修改此问题 235 | 236 | 237 | 2014-09-19 238 | 239 | c#light core project 240 | 这是将CSLightStudio中的Core部分搬运出来的一个新仓库 241 | 因为中国地区访问github太缓慢,clone整个CSLightStudio几乎是不可能的任务 242 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Bug.txt: -------------------------------------------------------------------------------- 1 | 2014-12-22 2 | 已知bug 3 | 构造函数参数不会自动转型 -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Compitler/CLS_Compiler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | public partial class CLS_Expression_Compiler : ICLS_Expression_Compiler 7 | { 8 | ICLS_Logger logger; 9 | public CLS_Expression_Compiler(ICLS_Logger logger) 10 | { 11 | this.logger = logger; 12 | } 13 | public ICLS_Expression Compile(IList tlist, ICLS_Environment content) 14 | { 15 | ICLS_Expression value; 16 | 17 | int expbegin = 0; 18 | int expend = FindCodeBlock(tlist, expbegin); 19 | if (expend != tlist.Count - 1) 20 | { 21 | LogError(tlist, "CodeBlock 识别问题,异常结尾", expbegin, expend); 22 | return null; 23 | } 24 | bool succ = Compiler_Expression_Block(tlist, content, expbegin, expend, out value); 25 | if (succ) 26 | { 27 | if (value == null) 28 | { 29 | logger.Log_Warn("编译为null:"); 30 | } 31 | return value; 32 | 33 | } 34 | else 35 | { 36 | LogError(tlist, "编译失败:", expbegin, expend); 37 | return null; 38 | } 39 | 40 | 41 | 42 | } 43 | 44 | public ICLS_Expression Compile_NoBlock(IList tlist, ICLS_Environment content) 45 | { 46 | ICLS_Expression value; 47 | int expbegin = 0; 48 | int expend = tlist.Count - 1; 49 | bool succ = Compiler_Expression(tlist, content, expbegin, expend, out value); 50 | if (succ) 51 | { 52 | if (value == null) 53 | { 54 | logger.Log_Warn("编译为null:"); 55 | } 56 | return value; 57 | 58 | } 59 | else 60 | { 61 | LogError(tlist, "编译失败:", expbegin, expend); 62 | return null; 63 | } 64 | 65 | 66 | } 67 | public ICLS_Expression Optimize(ICLS_Expression value, ICLS_Environment env) 68 | { 69 | ICLS_Expression expr = value as ICLS_Expression; 70 | if (expr == null) return value; 71 | else return OptimizeDepth(expr, new CLS_Content(env)); 72 | } 73 | ICLS_Expression OptimizeDepth(ICLS_Expression expr, CLS_Content content) 74 | { 75 | //先进行深入优化 76 | if (expr.listParam != null) 77 | { 78 | for (int i = 0; i < expr.listParam.Count; i++) 79 | { 80 | ICLS_Expression subexpr = expr.listParam[i] as ICLS_Expression; 81 | if (subexpr != null) 82 | { 83 | expr.listParam[i] = OptimizeDepth(subexpr, content); 84 | } 85 | } 86 | } 87 | 88 | 89 | return OptimizeSingle(expr, content); 90 | 91 | } 92 | ICLS_Expression OptimizeSingle(ICLS_Expression expr, CLS_Content content) 93 | { 94 | 95 | if (expr is CLS_Expression_Math2Value || expr is CLS_Expression_Math2ValueAndOr || expr is CLS_Expression_Math2ValueLogic) 96 | { 97 | 98 | if (expr.listParam[0] is ICLS_Value && 99 | expr.listParam[1] is ICLS_Value) 100 | { 101 | CLS_Content.Value result = expr.ComputeValue(content); 102 | if ((Type)result.type == typeof(bool)) 103 | { 104 | CLS_Value_Value value = new CLS_Value_Value(); 105 | value.value_value = (bool)result.value; 106 | value.tokenBegin = expr.listParam[0].tokenBegin; 107 | value.tokenEnd = expr.listParam[1].tokenEnd; 108 | value.lineBegin = expr.listParam[0].lineBegin; 109 | value.lineEnd = expr.listParam[1].lineEnd; 110 | return value; 111 | } 112 | else 113 | { 114 | ICLS_Type v = content.environment.GetType(result.type); 115 | ICLS_Value value = v.MakeValue(result.value); 116 | value.tokenBegin = expr.listParam[0].tokenBegin; 117 | value.tokenEnd = expr.listParam[1].tokenEnd; 118 | value.lineBegin = expr.listParam[0].lineBegin; 119 | value.lineEnd = expr.listParam[1].lineEnd; 120 | return value; 121 | } 122 | 123 | 124 | } 125 | } 126 | if (expr is CLS_Expression_Math3Value) 127 | { 128 | CLS_Content.Value result = expr.listParam[0].ComputeValue(content); 129 | if ((Type)result.type == typeof(bool)) 130 | { 131 | bool bv = (bool)result.value; 132 | if (bv) 133 | return expr.listParam[1]; 134 | else 135 | return expr.listParam[2]; 136 | } 137 | } 138 | 139 | return expr; 140 | } 141 | 142 | 143 | public IList FileCompile(ICLS_Environment env,string filename,IList tlist, bool embDebugToken) 144 | { 145 | return _FileCompiler(filename, tlist, embDebugToken, env, false); 146 | } 147 | public IList FilePreCompile(ICLS_Environment env, string filename, IList tlist) 148 | { 149 | return _FileCompiler(filename, tlist, false, env, true); 150 | } 151 | } 152 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/CLS_Expression_Block.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_Block : ICLS_Expression 8 | { 9 | public CLS_Expression_Block(int tbegin,int tend,int lbegin,int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | //Block的参数 一个就是一行,顺序执行,没有 18 | public List listParam 19 | { 20 | get; 21 | private set; 22 | } 23 | public int tokenBegin 24 | { 25 | get; 26 | private set; 27 | } 28 | public int tokenEnd 29 | { 30 | get; 31 | private set; 32 | } 33 | public int lineBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int lineEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | content.DepthAdd(); 47 | CLS_Content.Value value = null; 48 | foreach (ICLS_Expression i in listParam) 49 | { 50 | ICLS_Expression e =i as ICLS_Expression; 51 | if (e != null) 52 | value =e.ComputeValue(content); 53 | 54 | 55 | if (value!=null&&value.breakBlock != 0) break; 56 | } 57 | content.DepthRemove(); 58 | content.OutStack(this); 59 | return value; 60 | } 61 | 62 | 63 | public override string ToString() 64 | { 65 | return "Block|"; 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/CLS_Expression_Define.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_Define : ICLS_Expression 8 | { 9 | public CLS_Expression_Define(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | //listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | //Block的参数 一个就是一行,顺序执行,没有 18 | List _listParam = null; 19 | public List listParam 20 | { 21 | get 22 | { 23 | if (_listParam == null) 24 | { 25 | _listParam = new List(); 26 | } 27 | return _listParam; 28 | } 29 | } 30 | public int tokenBegin 31 | { 32 | get; 33 | private set; 34 | } 35 | public int tokenEnd 36 | { 37 | get; 38 | private set; 39 | } 40 | public int lineBegin 41 | { 42 | get; 43 | private set; 44 | } 45 | public int lineEnd 46 | { 47 | get; 48 | private set; 49 | } 50 | public CLS_Content.Value ComputeValue(CLS_Content content) 51 | { 52 | content.InStack(this); 53 | 54 | if (_listParam != null && _listParam.Count > 0) 55 | { 56 | 57 | CLS_Content.Value v = _listParam[0].ComputeValue(content); 58 | object val = v.value; 59 | if ((Type)value_type == typeof(CLS_Type_Var.var)) 60 | { 61 | if(v.type!=null) 62 | value_type = v.type; 63 | 64 | } 65 | else if (v.type != value_type) 66 | { 67 | val = content.environment.GetType(v.type).ConvertTo(content, v.value, value_type); 68 | 69 | } 70 | 71 | content.DefineAndSet(value_name, value_type, val); 72 | } 73 | else 74 | { 75 | content.Define(value_name, value_type); 76 | } 77 | //设置环境变量为 78 | content.OutStack(this); 79 | 80 | return null; 81 | } 82 | public string value_name; 83 | public CLType value_type; 84 | public override string ToString() 85 | { 86 | string outs = "Define|" + value_type.Name + " " + value_name; 87 | if (_listParam != null) 88 | { 89 | if (_listParam.Count > 0) 90 | { 91 | outs += "="; 92 | } 93 | } 94 | return outs; 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/CLS_Expression_GetValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_GetValue : ICLS_Expression 8 | { 9 | public CLS_Expression_GetValue(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | this.tokenBegin = tbegin; 12 | this.tokenEnd = tend; 13 | lineBegin = lbegin; 14 | lineEnd = lend; 15 | } 16 | //Block的参数 一个就是一行,顺序执行,没有 17 | public List listParam 18 | { 19 | get 20 | { 21 | return null; 22 | } 23 | } 24 | public int tokenBegin 25 | { 26 | get; 27 | private set; 28 | } 29 | public int tokenEnd 30 | { 31 | get; 32 | private set; 33 | } 34 | public int lineBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int lineEnd 40 | { 41 | get; 42 | private set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | var value=content.Get(value_name); 48 | content.OutStack(this); 49 | 50 | //从上下文取值 51 | 52 | return value; 53 | } 54 | 55 | public string value_name; 56 | 57 | public override string ToString() 58 | { 59 | return "GetValue|" + value_name; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/CLS_Expression_SetValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_SetValue : ICLS_Expression 8 | { 9 | public CLS_Expression_SetValue(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | 33 | } 34 | public int tokenBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int tokenEnd 40 | { 41 | get; 42 | private set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | 48 | { 49 | 50 | CLS_Content.Value v = listParam[0].ComputeValue(content); 51 | 52 | { 53 | object val = v.value; 54 | CLType value_type = null; 55 | if (content.values.ContainsKey(value_name)) 56 | { 57 | value_type = content.values[value_name].type; 58 | } 59 | else 60 | { 61 | if (content.CallType != null) 62 | { 63 | if (content.CallType.members.ContainsKey(value_name)) 64 | { 65 | if (content.CallType.members[value_name].bStatic) 66 | { 67 | value_type = content.CallType.staticMemberInstance[value_name].type; 68 | } 69 | else 70 | { 71 | value_type = content.CallThis.member[value_name].type; 72 | } 73 | 74 | } 75 | 76 | } 77 | } 78 | //val = v.value; 79 | if ((Type)value_type != typeof(CLS_Type_Var.var) && value_type != v.type) 80 | { 81 | val = content.environment.GetType(v.type).ConvertTo(content, v.value, value_type); 82 | } 83 | 84 | 85 | content.Set(value_name, val); 86 | } 87 | } 88 | content.OutStack(this); 89 | return null; 90 | } 91 | 92 | 93 | public string value_name; 94 | 95 | public override string ToString() 96 | { 97 | return "SetValue|" + value_name + "="; 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_Function.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_Function : ICLS_Expression 8 | { 9 | public CLS_Expression_Function(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | //Block的参数 一个就是一行,顺序执行,没有 18 | public List listParam 19 | { 20 | get; 21 | private set; 22 | } 23 | public int tokenBegin 24 | { 25 | get; 26 | private set; 27 | } 28 | public int tokenEnd 29 | { 30 | get; 31 | set; 32 | } 33 | public int lineBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int lineEnd 39 | { 40 | get; 41 | set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | List list = new List(); 47 | foreach (ICLS_Expression p in listParam) 48 | { 49 | if (p != null) 50 | { 51 | list.Add(p.ComputeValue(content)); 52 | } 53 | } 54 | CLS_Content.Value v = null; 55 | 56 | SType.Function retFunc = null; 57 | bool bFind = false; 58 | if (content.CallType != null) 59 | bFind = content.CallType.functions.TryGetValue(funcname, out retFunc); 60 | 61 | if (bFind) 62 | { 63 | if (retFunc.bStatic) 64 | { 65 | v = content.CallType.StaticCall(content, funcname, list); 66 | 67 | } 68 | else 69 | { 70 | v = content.CallType.MemberCall(content, content.CallThis, funcname, list); 71 | 72 | } 73 | } 74 | 75 | 76 | else 77 | { 78 | v = content.GetQuiet(funcname); 79 | if (v != null && v.value is Delegate) 80 | { 81 | //if(v.value is Delegate) 82 | { 83 | Delegate d = v.value as Delegate; 84 | v = new CLS_Content.Value(); 85 | object[] obja = new object[list.Count]; 86 | for (int i = 0; i < list.Count; i++) 87 | { 88 | obja[i] = list[i].value; 89 | } 90 | v.value = d.DynamicInvoke(obja); 91 | if (v.value == null) 92 | { 93 | v.type = null; 94 | } 95 | else 96 | { 97 | v.type = v.value.GetType(); 98 | } 99 | } 100 | //else 101 | //{ 102 | // throw new Exception(funcname + "不是函数"); 103 | //} 104 | } 105 | else 106 | { 107 | v = content.environment.GetFunction(funcname).Call(content, list); 108 | } 109 | } 110 | //操作变量之 111 | //做数学计算 112 | //从上下文取值 113 | //_value = null; 114 | content.OutStack(this); 115 | return v; 116 | } 117 | public string funcname; 118 | 119 | public override string ToString() 120 | { 121 | 122 | return "Call|" + funcname + "(params[" + listParam.Count + ")"; 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_FunctionNew.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_FunctionNew: ICLS_Expression 8 | { 9 | public CLS_Expression_FunctionNew(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | //Block的参数 一个就是一行,顺序执行,没有 18 | public List listParam 19 | { 20 | get; 21 | private set; 22 | } 23 | public int tokenBegin 24 | { 25 | get; 26 | private set; 27 | } 28 | public int tokenEnd 29 | { 30 | get; 31 | private set; 32 | } 33 | public int lineBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int lineEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | List list = new List(); 47 | foreach(ICLS_Expression p in listParam) 48 | { 49 | if(p!=null) 50 | { 51 | list.Add(p.ComputeValue(content)); 52 | } 53 | } 54 | var value= type.function.New(content,list); 55 | content.OutStack(this); 56 | return value; 57 | 58 | } 59 | public CSLE.ICLS_Type type; 60 | 61 | public override string ToString() 62 | { 63 | return "new|" + type.keyword + "(params[" + listParam.Count + ")"; 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_FunctionNewArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_FunctionNewArray : ICLS_Expression 8 | { 9 | public CLS_Expression_FunctionNewArray(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | //Block的参数 一个就是一行,顺序执行,没有 18 | //0 count; 19 | //1~where,first value; 20 | public List listParam 21 | { 22 | get; 23 | private set; 24 | } 25 | public int tokenBegin 26 | { 27 | get; 28 | private set; 29 | } 30 | public int tokenEnd 31 | { 32 | get; 33 | private set; 34 | } 35 | public int lineBegin 36 | { 37 | get; 38 | private set; 39 | } 40 | public int lineEnd 41 | { 42 | get; 43 | private set; 44 | } 45 | public CLS_Content.Value ComputeValue(CLS_Content content) 46 | { 47 | content.InStack(this); 48 | List list = new List(); 49 | int count = listParam[0] == null ? (listParam.Count - 1) : (int)listParam[0].ComputeValue(content).value; 50 | if (count == 0) 51 | throw new Exception("不能创建0长度数组"); 52 | CLS_Content.Value vcount = new CLS_Content.Value(); 53 | vcount.type = typeof(int); 54 | vcount.value = count; 55 | for (int i = 1; i < listParam.Count; i++) 56 | { 57 | //if (listParam[i] != null) 58 | { 59 | list.Add(listParam[i].ComputeValue(content).value); 60 | } 61 | } 62 | List p = new List(); 63 | p.Add(vcount); 64 | var outvalue = type.function.New(content, p); 65 | for (int i = 0; i < list.Count; i++) 66 | { 67 | type.function.IndexSet(content, outvalue.value, i, list[i]); 68 | } 69 | content.OutStack(this); 70 | return outvalue; 71 | 72 | } 73 | public CSLE.ICLS_Type type; 74 | 75 | public override string ToString() 76 | { 77 | return "new|" + type.keyword + "(params[" + listParam.Count + ")"; 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_IndexFind.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_IndexFind : ICLS_Expression 8 | { 9 | public CLS_Expression_IndexFind(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | //Block的参数 一个就是一行,顺序执行,没有 18 | public List listParam 19 | { 20 | get; 21 | private set; 22 | } 23 | public int tokenBegin 24 | { 25 | get; 26 | private set; 27 | } 28 | public int tokenEnd 29 | { 30 | get; 31 | set; 32 | } 33 | public int lineBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int lineEnd 39 | { 40 | get; 41 | set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | var parent = listParam[0].ComputeValue(content); 47 | if (parent == null) 48 | { 49 | throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString()); 50 | } 51 | var key = listParam[1].ComputeValue(content); 52 | var type = content.environment.GetType(parent.type); 53 | 54 | var value = type.function.IndexGet(content, parent.value, key.value); 55 | content.OutStack(this); 56 | 57 | //IndexGet返回的值类型是 System.Object. 58 | //在这里需要将类型明确化. 59 | //value.type = value.value.GetType(); 60 | 61 | return value; 62 | //return type.function.MemberValueGet(content.environment, parent.value, membername); 63 | //做数学计算 64 | //从上下文取值 65 | //_value = null; 66 | //return null; 67 | } 68 | 69 | public override string ToString() 70 | { 71 | return "IndexFind[]|"; 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_IndexSetValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_IndexSetValue : ICLS_Expression 8 | { 9 | public CLS_Expression_IndexSetValue(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam= new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | //Block的参数 一个就是一行,顺序执行,没有 18 | public List listParam 19 | { 20 | get; 21 | private set; 22 | } 23 | public int tokenBegin 24 | { 25 | get; 26 | private set; 27 | } 28 | public int tokenEnd 29 | { 30 | get; 31 | private set; 32 | } 33 | public int lineBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int lineEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | var parent = listParam[0].ComputeValue(content); 47 | if (parent == null) 48 | { 49 | throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString()); 50 | } 51 | var key = listParam[1].ComputeValue(content); 52 | var value = listParam[2].ComputeValue(content); 53 | //object setv=value.value; 54 | //if(value.type!=parent.type) 55 | //{ 56 | // var vtype = content.environment.GetType(value.type); 57 | // setv = vtype.ConvertTo(content.environment, setv, parent.type); 58 | //} 59 | var type = content.environment.GetType(parent.type); 60 | type.function.IndexSet(content, parent.value, key.value, value.value); 61 | //做数学计算 62 | //从上下文取值 63 | //_value = null; 64 | content.OutStack(this); 65 | return null; 66 | } 67 | 68 | 69 | public override string ToString() 70 | { 71 | return "IndexSet[]=|"; 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_Lambda.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_Lambda: ICLS_Expression 8 | { 9 | public CLS_Expression_Lambda(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | //Block的参数 一个就是一行,顺序执行,没有 18 | public List listParam 19 | { 20 | get; 21 | private set; 22 | } 23 | public List lambdaParams = new List(); 24 | public int tokenBegin 25 | { 26 | get; 27 | private set; 28 | } 29 | public int tokenEnd 30 | { 31 | get; 32 | private set; 33 | } 34 | public int lineBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int lineEnd 40 | { 41 | get; 42 | private set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | //List list = new List(); 48 | CLS_Content.Value value = new CLS_Content.Value(); 49 | value.type = typeof(DeleLambda); 50 | value.value = new DeleLambda(content,(this.listParam[0] as CLS_Expression_Block).listParam,this.listParam[1]); 51 | //创建一个匿名方法 52 | content.OutStack(this); 53 | return value; 54 | 55 | } 56 | 57 | 58 | public override string ToString() 59 | { 60 | return "()=>{}|"; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_MemberFind.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_MemberFind : ICLS_Expression 8 | { 9 | public CLS_Expression_MemberFind(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam= new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | var parent = listParam[0].ComputeValue(content); 47 | if (parent == null) 48 | { 49 | throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString()); 50 | } 51 | ICLS_TypeFunction typefunction = content.environment.GetType(parent.type).function; 52 | if(parent.type is object) 53 | { 54 | SInstance s =parent.value as SInstance; 55 | if(s!=null) 56 | { 57 | typefunction = s.type; 58 | } 59 | } 60 | //var type = content.environment.GetType(parent.type); 61 | var value=typefunction.MemberValueGet(content, parent.value, membername); 62 | content.OutStack(this); 63 | return value; 64 | //做数学计算 65 | //从上下文取值 66 | //_value = null; 67 | //return null; 68 | 69 | } 70 | 71 | 72 | public string membername; 73 | 74 | public override string ToString() 75 | { 76 | return "MemberFind|a." + membername; 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_MemberFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_MemberFunction : ICLS_Expression 8 | { 9 | public CLS_Expression_MemberFunction(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | MethodCache cache = null; 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | var parent = listParam[0].ComputeValue(content); 48 | if (parent == null) 49 | { 50 | throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString()); 51 | } 52 | var typefunction = content.environment.GetType(parent.type).function; 53 | if(parent.type is object) 54 | { 55 | SInstance s = parent.value as SInstance; 56 | if(s!=null) 57 | { 58 | typefunction = s.type; 59 | } 60 | } 61 | List _params = new List(); 62 | for (int i = 1; i < listParam.Count; i++) 63 | { 64 | _params.Add(listParam[i].ComputeValue(content)); 65 | } 66 | CLS_Content.Value value = null; 67 | if (cache == null||cache.cachefail) 68 | { 69 | cache = new MethodCache(); 70 | value = typefunction.MemberCall(content, parent.value, functionName, _params,cache); 71 | } 72 | else 73 | { 74 | value = typefunction.MemberCallCache(content, parent.value, _params, cache); 75 | } 76 | content.OutStack(this); 77 | return value; 78 | //做数学计算 79 | //从上下文取值 80 | //_value = null; 81 | //return null; 82 | } 83 | 84 | 85 | public string functionName; 86 | 87 | public override string ToString() 88 | { 89 | return "MemberCall|a." + functionName; 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_MemberMath.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_MemberMath : ICLS_Expression 8 | { 9 | public CLS_Expression_MemberMath(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | var parent = listParam[0].ComputeValue(content); 47 | if (parent == null) 48 | { 49 | throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString()); 50 | } 51 | var type = content.environment.GetType(parent.type); 52 | //string membername=null; 53 | 54 | 55 | var getvalue = type.function.MemberValueGet(content, parent.value, membername); 56 | 57 | CLS_Content.Value vright = CLS_Content.Value.One; 58 | if (listParam.Count > 1) 59 | { 60 | vright = listParam[1].ComputeValue(content); 61 | } 62 | CLS_Content.Value vout =new CLS_Content.Value(); 63 | var mtype = content.environment.GetType(getvalue.type); 64 | vout.value = mtype.Math2Value(content, mathop, getvalue.value, vright, out vout.type); 65 | 66 | type.function.MemberValueSet(content, parent.value, membername, vout.value); 67 | //CLS_Content.Value v = new CLS_Content.Value(); 68 | 69 | content.OutStack(this); 70 | return vout; 71 | //做数学计算 72 | //从上下文取值 73 | //_value = null; 74 | //return null; 75 | 76 | } 77 | 78 | public string membername; 79 | public char mathop; 80 | public override string ToString() 81 | { 82 | return "CLS_Expression_MemberMath|a." + membername + " |" + mathop; 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_MemberSetValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_MemberSetValue : ICLS_Expression 8 | { 9 | public CLS_Expression_MemberSetValue(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam= new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | var parent = listParam[0].ComputeValue(content); 47 | if (parent == null) 48 | { 49 | throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString()); 50 | } 51 | var value = listParam[1].ComputeValue(content); 52 | object setv=value.value; 53 | //if(value.type!=parent.type) 54 | //{ 55 | // var vtype = content.environment.GetType(value.type); 56 | // setv = vtype.ConvertTo(content.environment, setv, parent.type); 57 | //} 58 | var typefunction = content.environment.GetType(parent.type).function; 59 | if(parent.type is object) 60 | { 61 | SInstance s = parent.value as SInstance; 62 | if(s!=null) 63 | { 64 | typefunction = s.type; 65 | } 66 | } 67 | typefunction.MemberValueSet(content, parent.value, membername, setv); 68 | //做数学计算 69 | //从上下文取值 70 | //_value = null; 71 | content.OutStack(this); 72 | return null; 73 | } 74 | 75 | public string membername; 76 | 77 | public override string ToString() 78 | { 79 | return "MemberSetvalue|a." + membername ; 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_StaticFind.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_StaticFind : ICLS_Expression 8 | { 9 | public CLS_Expression_StaticFind(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | tokenBegin = tbegin; 12 | tokenEnd = tend; 13 | 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get 31 | { 32 | return null; 33 | } 34 | } 35 | public int tokenBegin 36 | { 37 | get; 38 | private set; 39 | } 40 | public int tokenEnd 41 | { 42 | get; 43 | private set; 44 | } 45 | public CLS_Content.Value ComputeValue(CLS_Content content) 46 | { 47 | content.InStack(this); 48 | var value=type.function.StaticValueGet(content, staticmembername); 49 | content.OutStack(this); 50 | return value; 51 | 52 | 53 | } 54 | 55 | 56 | public ICLS_Type type; 57 | public string staticmembername; 58 | 59 | public override string ToString() 60 | { 61 | return "StaticFind|" + type.keyword + "." + staticmembername; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_StaticFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_StaticFunction : ICLS_Expression 8 | { 9 | public CLS_Expression_StaticFunction(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | MethodCache cache = null; 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | //var parent = listParam[0].ComputeValue(content); 48 | //var type = content.environment.GetType(parent.type); 49 | List _params = new List(); 50 | for (int i = 0; i < listParam.Count; i++) 51 | { 52 | _params.Add(listParam[i].ComputeValue(content)); 53 | } 54 | CLS_Content.Value value = null; 55 | if (cache == null || cache.cachefail) 56 | { 57 | cache = new MethodCache(); 58 | value = type.function.StaticCall(content, functionName, _params, cache); 59 | } 60 | else 61 | { 62 | value = type.function.StaticCallCache(content, _params, cache); 63 | } 64 | 65 | content.OutStack(this); 66 | return value; 67 | //做数学计算 68 | //从上下文取值 69 | //_value = null; 70 | //return null; 71 | } 72 | 73 | public ICLS_Type type; 74 | public string functionName; 75 | 76 | public override string ToString() 77 | { 78 | return "StaticCall|" + type.keyword + "." + functionName; 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_StaticMath.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_StaticMath : ICLS_Expression 8 | { 9 | public CLS_Expression_StaticMath(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | 15 | lineBegin = lbegin; 16 | lineEnd = lend; 17 | } 18 | public int lineBegin 19 | { 20 | get; 21 | private set; 22 | } 23 | public int lineEnd 24 | { 25 | get; 26 | private set; 27 | } 28 | //Block的参数 一个就是一行,顺序执行,没有 29 | public List listParam 30 | { 31 | get; 32 | private set; 33 | } 34 | public int tokenBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int tokenEnd 40 | { 41 | get; 42 | private set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | 48 | 49 | var getvalue=type.function.StaticValueGet(content, staticmembername); 50 | 51 | CLS_Content.Value vright = CLS_Content.Value.One; 52 | if (listParam.Count > 0) 53 | { 54 | vright = listParam[0].ComputeValue(content); 55 | } 56 | CLS_Content.Value vout = new CLS_Content.Value(); 57 | var mtype = content.environment.GetType(getvalue.type); 58 | vout.value = mtype.Math2Value(content, mathop, getvalue.value, vright, out vout.type); 59 | 60 | type.function.StaticValueSet(content, staticmembername, vout.value); 61 | 62 | content.OutStack(this); 63 | return vout; 64 | 65 | 66 | } 67 | 68 | 69 | public ICLS_Type type; 70 | public string staticmembername; 71 | public char mathop; 72 | public override string ToString() 73 | { 74 | return "StaticMath|" + type.keyword + "." + staticmembername +" |"+mathop; 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_StaticSetValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_StaticSetValue : ICLS_Expression 8 | { 9 | public CLS_Expression_StaticSetValue(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | //var parent = listParam[0].ComputeValue(content); 47 | var value = listParam[0].ComputeValue(content); 48 | 49 | type.function.StaticValueSet(content, staticmembername, value.value); 50 | //做数学计算 51 | //从上下文取值 52 | //_value = null; 53 | content.OutStack(this); 54 | return null; 55 | } 56 | public ICLS_Type type; 57 | public string staticmembername; 58 | 59 | public override string ToString() 60 | { 61 | return "StaticSetvalue|" + type.keyword + "." + staticmembername + "="; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Function/CLS_Expression_Throw.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_Throw : ICLS_Expression 8 | { 9 | public CLS_Expression_Throw(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | CLS_Content.Value rv = new CLS_Content.Value(); 47 | 48 | 49 | { 50 | var v = listParam[0].ComputeValue(content); 51 | { 52 | rv.type = v.type; 53 | rv.value = v.value; 54 | } 55 | Exception err = v.value as Exception; 56 | if (err != null) 57 | { 58 | throw err; 59 | } 60 | else 61 | { 62 | throw new Exception(v.ToString()); 63 | } 64 | } 65 | 66 | //content.OutStack(this); 67 | //return rv; 68 | 69 | //for 逻辑 70 | //做数学计算 71 | //从上下文取值 72 | //_value = null; 73 | } 74 | 75 | 76 | public override string ToString() 77 | { 78 | return "throw|"; 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Loop/CLS_Expression_LoopBreak.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_LoopBreak : ICLS_Expression 8 | { 9 | public CLS_Expression_LoopBreak(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | tokenBegin = tbegin; 12 | tokenEnd = tend; 13 | lineBegin = lbegin; 14 | lineEnd = lend; 15 | } 16 | public int lineBegin 17 | { 18 | get; 19 | private set; 20 | } 21 | public int lineEnd 22 | { 23 | get; 24 | private set; 25 | } 26 | //Block的参数 一个就是一行,顺序执行,没有 27 | public List listParam 28 | { 29 | get 30 | { 31 | return null; 32 | } 33 | } 34 | public int tokenBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int tokenEnd 40 | { 41 | get; 42 | private set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | CLS_Content.Value rv = new CLS_Content.Value(); 48 | rv.breakBlock = 2; 49 | //跳出逻辑 50 | content.OutStack(this); 51 | return rv; 52 | } 53 | 54 | public override string ToString() 55 | { 56 | return "break;"; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Loop/CLS_Expression_LoopContinue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_LoopContinue : ICLS_Expression 8 | { 9 | public CLS_Expression_LoopContinue(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | tokenBegin = tbegin; 12 | tokenEnd = tend; 13 | lineBegin = lbegin; 14 | lineEnd = lend; 15 | } 16 | public int lineBegin 17 | { 18 | get; 19 | private set; 20 | } 21 | public int lineEnd 22 | { 23 | get; 24 | private set; 25 | } 26 | //Block的参数 一个就是一行,顺序执行,没有 27 | public List listParam 28 | { 29 | get 30 | { 31 | return null; 32 | } 33 | } 34 | public int tokenBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int tokenEnd 40 | { 41 | get; 42 | private set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | CLS_Content.Value rv = new CLS_Content.Value(); 48 | rv.breakBlock = 1; 49 | //跳出逻辑 50 | content.OutStack(this); 51 | return rv; 52 | } 53 | 54 | public override string ToString() 55 | { 56 | return "continue;"; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Loop/CLS_Expression_LoopDowhile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_LoopDowhile : ICLS_Expression 8 | { 9 | public CLS_Expression_LoopDowhile(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | 15 | lineBegin = lbegin; 16 | lineEnd = lend; 17 | } 18 | public int lineBegin 19 | { 20 | get; 21 | private set; 22 | } 23 | public int lineEnd 24 | { 25 | get; 26 | set; 27 | } 28 | //Block的参数 一个就是一行,顺序执行,没有 29 | public List listParam 30 | { 31 | get; 32 | private set; 33 | } 34 | public int tokenBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int tokenEnd 40 | { 41 | get; 42 | set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | content.DepthAdd(); 48 | ICLS_Expression expr_while = listParam[1] as ICLS_Expression; 49 | ICLS_Expression expr_block = listParam[0] as ICLS_Expression; 50 | 51 | CLS_Content.Value vrt = null; 52 | do 53 | { 54 | if (expr_block != null) 55 | { 56 | if (expr_block is CLS_Expression_Block) 57 | { 58 | var v = expr_block.ComputeValue(content); 59 | if (v != null) 60 | { 61 | if (v.breakBlock > 2) vrt = v; 62 | if (v.breakBlock > 1) break; 63 | } 64 | } 65 | else 66 | { 67 | content.DepthAdd(); 68 | bool bbreak = false; 69 | var v = expr_block.ComputeValue(content); 70 | if (v != null) 71 | { 72 | if (v.breakBlock > 2) vrt = v; 73 | if (v.breakBlock > 1) bbreak = true; 74 | } 75 | content.DepthRemove(); 76 | if (bbreak) break; 77 | } 78 | //if (v.breakBlock == 1) continue; 79 | //if (v.breakBlock == 2) break; 80 | //if (v.breakBlock == 10) return v; 81 | } 82 | } while ((bool)expr_while.ComputeValue(content).value); 83 | content.DepthRemove(); 84 | content.OutStack(this); 85 | return vrt; 86 | //for 逻辑 87 | //做数学计算 88 | //从上下文取值 89 | //_value = null; 90 | } 91 | 92 | 93 | public override string ToString() 94 | { 95 | return "Do{}While|"; 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Loop/CLS_Expression_LoopFor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_LoopFor : ICLS_Expression 8 | { 9 | public CLS_Expression_LoopFor(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | 15 | lineBegin = lbegin; 16 | lineEnd = lend; 17 | } 18 | public int lineBegin 19 | { 20 | get; 21 | private set; 22 | } 23 | public int lineEnd 24 | { 25 | get; 26 | set; 27 | } 28 | //Block的参数 一个就是一行,顺序执行,没有 29 | public List listParam 30 | { 31 | get; 32 | private set; 33 | } 34 | public int tokenBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int tokenEnd 40 | { 41 | get; 42 | set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | content.DepthAdd(); 48 | ICLS_Expression expr_init = listParam[0] as ICLS_Expression; 49 | if (expr_init != null) expr_init.ComputeValue(content);//expr1 50 | 51 | ICLS_Expression expr_continue = listParam[1] as ICLS_Expression; 52 | ICLS_Expression expr_step = listParam[2] as ICLS_Expression; 53 | 54 | ICLS_Expression expr_block = listParam[3] as ICLS_Expression; 55 | CLS_Content.Value vrt = null; 56 | for (; ; ) 57 | { 58 | if (expr_continue != null && !(bool)expr_continue.ComputeValue(content).value) break;//expr2 59 | 60 | if (expr_block != null) 61 | { 62 | if (expr_block is CLS_Expression_Block) 63 | { 64 | var v = expr_block.ComputeValue(content); 65 | if (v != null) 66 | { 67 | if (v.breakBlock > 2) vrt = v; 68 | if (v.breakBlock > 1) break; 69 | } 70 | } 71 | else 72 | { 73 | content.DepthAdd(); 74 | bool bbreak = false; 75 | var v = expr_block.ComputeValue(content); 76 | if (v != null) 77 | { 78 | if (v.breakBlock > 2) vrt = v; 79 | if (v.breakBlock > 1) bbreak = true; 80 | } 81 | content.DepthRemove(); 82 | if (bbreak) break; 83 | } 84 | //if (v.breakBlock == 1) continue; 85 | //if (v.breakBlock == 2) break; 86 | //if (v.breakBlock == 10) return v; 87 | } 88 | 89 | if (expr_step != null) 90 | expr_step.ComputeValue(content);//expr3 91 | } 92 | content.DepthRemove(); 93 | content.OutStack(this); 94 | return vrt; 95 | //for 逻辑 96 | //做数学计算 97 | //从上下文取值 98 | //_value = null; 99 | } 100 | 101 | 102 | public override string ToString() 103 | { 104 | return "For|"; 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Loop/CLS_Expression_LoopForEach.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_LoopForEach : ICLS_Expression 8 | { 9 | public CLS_Expression_LoopForEach(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | content.DepthAdd(); 47 | CLS_Expression_Define define = listParam[0] as CLS_Expression_Define; 48 | if (define == null) 49 | { 50 | 51 | } 52 | define.ComputeValue(content); 53 | 54 | System.Collections.IEnumerable emu = listParam[1].ComputeValue(content).value as System.Collections.IEnumerable; 55 | 56 | ICLS_Expression expr_block = listParam[2] as ICLS_Expression; 57 | 58 | var it = emu.GetEnumerator(); 59 | CLS_Content.Value vrt = null; 60 | while (it.MoveNext()) 61 | { 62 | 63 | content.Set(define.value_name, it.Current); 64 | if (expr_block != null) 65 | { 66 | if (expr_block is CLS_Expression_Block) 67 | { 68 | var v = expr_block.ComputeValue(content); 69 | if (v != null) 70 | { 71 | if (v.breakBlock > 2) vrt = v; 72 | if (v.breakBlock > 1) break; 73 | } 74 | } 75 | else 76 | { 77 | content.DepthAdd(); 78 | bool bbreak = false; 79 | var v = expr_block.ComputeValue(content); 80 | if (v != null) 81 | { 82 | if (v.breakBlock > 2) vrt = v; 83 | if (v.breakBlock > 1) bbreak = true; 84 | 85 | } 86 | content.DepthRemove(); 87 | if (bbreak) 88 | break; 89 | } 90 | } 91 | } 92 | //ICLS_Expression expr_continue = listParam[1] as ICLS_Expression; 93 | //ICLS_Expression expr_step = listParam[2] as ICLS_Expression; 94 | 95 | //ICLS_Expression expr_block = listParam[3] as ICLS_Expression; 96 | 97 | //for (;(bool)expr_continue.ComputeValue(content).value; expr_step.ComputeValue(content)) 98 | //{ 99 | // if(expr_block!=null) 100 | // { 101 | // var v = expr_block.ComputeValue(content); 102 | // if (v != null && v.breakBlock > 1) break; ; 103 | // //if (v.breakBlock == 1) continue; 104 | // //if (v.breakBlock == 2) break; 105 | // //if (v.breakBlock == 10) return v; 106 | // } 107 | //} 108 | content.DepthRemove(); 109 | content.OutStack(this); 110 | return vrt; 111 | //for 逻辑 112 | //做数学计算 113 | //从上下文取值 114 | //_value = null; 115 | } 116 | 117 | 118 | public override string ToString() 119 | { 120 | return "ForEach|"; 121 | } 122 | } 123 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Loop/CLS_Expression_LoopIf.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_LoopIf : ICLS_Expression 8 | { 9 | public CLS_Expression_LoopIf(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | ICLS_Expression expr_if = listParam[0]; 47 | bool bif = (bool)expr_if.ComputeValue(content).value; 48 | //if (expr_init != null) expr_init.ComputeValue(content); 49 | ICLS_Expression expr_go1 = listParam[1]; 50 | ICLS_Expression expr_go2 = null; 51 | if(listParam.Count>2)expr_go2= listParam[2]; 52 | CLS_Content.Value value = null; 53 | if (bif && expr_go1 != null) 54 | { 55 | if (expr_go1 is CLS_Expression_Block) 56 | { 57 | value = expr_go1.ComputeValue(content); 58 | } 59 | else 60 | { 61 | content.DepthAdd(); 62 | value = expr_go1.ComputeValue(content); 63 | content.DepthRemove(); 64 | } 65 | 66 | } 67 | else if (!bif && expr_go2 != null) 68 | { 69 | 70 | if (expr_go2 is CLS_Expression_Block) 71 | { 72 | value = expr_go2.ComputeValue(content); 73 | } 74 | else 75 | { 76 | content.DepthAdd(); 77 | value = expr_go2.ComputeValue(content); 78 | content.DepthRemove(); 79 | } 80 | 81 | } 82 | 83 | //while((bool)expr_continue.value); 84 | 85 | //for 逻辑 86 | //做数学计算 87 | //从上下文取值 88 | //_value = null; 89 | content.OutStack(this); 90 | return value; 91 | } 92 | 93 | 94 | public override string ToString() 95 | { 96 | return "If|"; 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Loop/CLS_Expression_LoopReturn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_LoopReturn : ICLS_Expression 8 | { 9 | public CLS_Expression_LoopReturn(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | CLS_Content.Value rv = new CLS_Content.Value(); 47 | rv.breakBlock = 10; 48 | if (listParam.Count > 0&&listParam[0]!=null) 49 | { 50 | var v = listParam[0].ComputeValue(content); 51 | { 52 | rv.type = v.type; 53 | rv.value = v.value; 54 | } 55 | } 56 | else 57 | { 58 | rv.type = typeof(void); 59 | } 60 | content.OutStack(this); 61 | return rv; 62 | 63 | //for 逻辑 64 | //做数学计算 65 | //从上下文取值 66 | //_value = null; 67 | } 68 | 69 | 70 | public override string ToString() 71 | { 72 | return "return|"; 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Loop/CLS_Expression_LoopTry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_LoopTry : ICLS_Expression 8 | { 9 | public CLS_Expression_LoopTry(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | List depth__; 47 | content.Record(out depth__); 48 | try 49 | { 50 | ICLS_Expression expr = listParam[0]; 51 | if (expr is CLS_Expression_Block) 52 | { 53 | expr.ComputeValue(content); 54 | } 55 | else 56 | { 57 | content.DepthAdd(); 58 | expr.ComputeValue(content); 59 | content.DepthRemove(); 60 | } 61 | 62 | } 63 | catch (Exception err) 64 | { 65 | bool bParse = false; 66 | int i = 1; 67 | while (i < listParam.Count) 68 | { 69 | CLS_Expression_Define def = listParam[i] as CLS_Expression_Define; 70 | if (err.GetType()==(Type)def.value_type || err.GetType().IsSubclassOf((Type)def.value_type)) 71 | { 72 | content.DepthAdd(); 73 | content.DefineAndSet(def.value_name, def.value_type, err); 74 | 75 | listParam[i + 1].ComputeValue(content); 76 | content.DepthRemove(); 77 | bParse = true; 78 | break; 79 | } 80 | i += 2; 81 | } 82 | if (!bParse) 83 | { 84 | throw err; 85 | } 86 | } 87 | content.Restore(depth__, this); 88 | //while((bool)expr_continue.value); 89 | 90 | //for 逻辑 91 | //做数学计算 92 | //从上下文取值 93 | //_value = null; 94 | content.OutStack(this); 95 | return null; 96 | } 97 | 98 | 99 | public override string ToString() 100 | { 101 | return "Try|"; 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Loop/CLS_Expression_LoopWhile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_LoopWhile : ICLS_Expression 8 | { 9 | public CLS_Expression_LoopWhile(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | 15 | lineBegin = lbegin; 16 | lineEnd = lend; 17 | } 18 | public int lineBegin 19 | { 20 | get; 21 | private set; 22 | } 23 | public int lineEnd 24 | { 25 | get; 26 | set; 27 | } 28 | //Block的参数 一个就是一行,顺序执行,没有 29 | public List listParam 30 | { 31 | get; 32 | private set; 33 | } 34 | public int tokenBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int tokenEnd 40 | { 41 | get; 42 | set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | content.DepthAdd(); 48 | ICLS_Expression expr_while = listParam[0] as ICLS_Expression; 49 | ICLS_Expression expr_block = listParam[1] as ICLS_Expression; 50 | CLS_Content.Value vrt = null; 51 | while ((bool)expr_while.ComputeValue(content).value) 52 | { 53 | if (expr_block != null) 54 | { 55 | if (expr_block is CLS_Expression_Block) 56 | { 57 | var v = expr_block.ComputeValue(content); 58 | if (v != null) 59 | { 60 | if (v.breakBlock > 2) vrt = v; 61 | if (v.breakBlock > 1) break; 62 | } 63 | } 64 | else 65 | { 66 | content.DepthAdd(); 67 | bool bbreak = false; 68 | var v = expr_block.ComputeValue(content); 69 | if (v != null) 70 | { 71 | if (v.breakBlock > 2) vrt = v; 72 | if (v.breakBlock > 1) bbreak = true; 73 | } 74 | content.DepthRemove(); 75 | if (bbreak) break; 76 | } 77 | //if (v.breakBlock == 1) continue; 78 | //if (v.breakBlock == 2) break; 79 | //if (v.breakBlock == 10) return v; 80 | } 81 | } 82 | content.DepthRemove(); 83 | content.OutStack(this); 84 | return vrt; 85 | //for 逻辑 86 | //做数学计算 87 | //从上下文取值 88 | //_value = null; 89 | } 90 | 91 | 92 | public override string ToString() 93 | { 94 | return "While|"; 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_Math2Value.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_Math2Value : ICLS_Expression 8 | { 9 | public CLS_Expression_Math2Value(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | CLS_Content.Value result = null; 47 | 48 | 49 | { 50 | result = new CLS_Content.Value(); 51 | var left = listParam[0].ComputeValue(content); 52 | var right = listParam[1].ComputeValue(content); 53 | result.value = content.environment.GetType(left.type).Math2Value(content, mathop, left.value, right, out result.type); 54 | 55 | } 56 | content.OutStack(this); 57 | return result; 58 | 59 | 60 | } 61 | 62 | 63 | public char mathop; 64 | 65 | 66 | public override string ToString() 67 | { 68 | return "Math2Value|a" + mathop + "b"; 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_Math2ValueAndOR.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_Math2ValueAndOr : ICLS_Expression 8 | { 9 | public CLS_Expression_Math2ValueAndOr(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | CLS_Content.Value result = new CLS_Content.Value(); 47 | 48 | //if (mathop == "&&" || mathop == "||") 49 | { 50 | bool bleft = false; 51 | bool bright = false; 52 | if (listParam[0] is ICLS_Value) 53 | { 54 | bleft = (bool)((listParam[0] as ICLS_Value).value); 55 | } 56 | else 57 | { 58 | bleft = (bool)listParam[0].ComputeValue(content).value; 59 | } 60 | result.type = typeof(bool); 61 | if(mathop=='&') 62 | { 63 | if (!bleft) 64 | { 65 | result.value = false; 66 | } 67 | else 68 | { 69 | if (listParam[1] is ICLS_Value) 70 | { 71 | bright = (bool)((listParam[1] as ICLS_Value).value); 72 | } 73 | else 74 | { 75 | bright = (bool)listParam[1].ComputeValue(content).value; 76 | } 77 | result.value = (bool)(bleft && bright); 78 | } 79 | } 80 | else if (mathop == '|') 81 | { 82 | if (bleft) 83 | { 84 | result.value = true; 85 | } 86 | else 87 | { 88 | if (listParam[1] is ICLS_Value) 89 | { 90 | bright = (bool)((listParam[1] as ICLS_Value).value); 91 | } 92 | else 93 | { 94 | bright = (bool)listParam[1].ComputeValue(content).value; 95 | } 96 | result.value = (bool)(bleft || bright); 97 | } 98 | 99 | } 100 | 101 | } 102 | content.OutStack(this); 103 | return result; 104 | 105 | } 106 | 107 | 108 | public char mathop; 109 | 110 | public override string ToString() 111 | { 112 | return "Math2ValueAndOr|a" + mathop + "b"; 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_Math2ValueLogic.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_Math2ValueLogic : ICLS_Expression 8 | { 9 | public CLS_Expression_Math2ValueLogic(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | CLS_Content.Value result = new CLS_Content.Value(); 47 | 48 | 49 | //if(mathop=="<"||mathop=="<="||mathop==">"||mathop==">="||mathop=="=="||mathop=="!=") 50 | { 51 | result.type = typeof(bool); 52 | var left = listParam[0].ComputeValue(content); 53 | var right = listParam[1].ComputeValue(content); 54 | if(left.type==null||right.type==null) 55 | { 56 | if (mathop == logictoken.equal) 57 | { 58 | result.value = left.value == right.value; 59 | } 60 | if(mathop== logictoken.not_equal) 61 | { 62 | result.value = left.value != right.value; 63 | } 64 | } 65 | else if ((Type)left.type == typeof(bool) && (Type)right.type == typeof(bool)) 66 | { 67 | if (mathop == logictoken.equal) 68 | { 69 | result.value = (bool)left.value == (bool)right.value; 70 | //return result; 71 | } 72 | else if (mathop == logictoken.not_equal) 73 | { 74 | result.value = (bool)left.value != (bool)right.value; 75 | //return result; 76 | } 77 | else 78 | { 79 | throw new Exception("bool 不支持此运算符"); 80 | } 81 | } 82 | else 83 | { 84 | 85 | result.value = content.environment.GetType(left.type).MathLogic(content, mathop, left.value, right); 86 | 87 | } 88 | } 89 | content.OutStack(this); 90 | 91 | return result; 92 | } 93 | 94 | public logictoken mathop; 95 | 96 | public override string ToString() 97 | { 98 | return "Math2ValueLogic|a" + mathop + "b"; 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_Math3Value.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_Math3Value : ICLS_Expression 8 | { 9 | public CLS_Expression_Math3Value(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | this.tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | CLS_Content.Value result = null; 47 | 48 | 49 | { 50 | result = new CLS_Content.Value(); 51 | var value = listParam[0].ComputeValue(content); 52 | if ((Type)value.type != typeof(bool)) 53 | { 54 | throw new Exception("三元表达式要求条件为bool型"); 55 | } 56 | bool bv = (bool)value.value; 57 | if (bv) 58 | result = listParam[1].ComputeValue(content); 59 | else 60 | result = listParam[2].ComputeValue(content); 61 | } 62 | content.OutStack(this); 63 | return result; 64 | 65 | 66 | } 67 | 68 | 69 | public override string ToString() 70 | { 71 | return "Math3Value|a?b:c"; 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_NegativeLogic.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_NegativeLogic : ICLS_Expression 8 | { 9 | public CLS_Expression_NegativeLogic(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | 47 | CLS_Content.Value r = listParam[0].ComputeValue(content); 48 | 49 | 50 | CLS_Content.Value r2 = new CLS_Content.Value(); 51 | r2.type = r.type; 52 | r2.breakBlock = r.breakBlock; 53 | r2.value = !(bool)r.value; 54 | content.OutStack(this); 55 | 56 | return r2; 57 | } 58 | 59 | 60 | public override string ToString() 61 | { 62 | return "(!)|" ; 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_NegativeValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_NegativeValue : ICLS_Expression 8 | { 9 | public CLS_Expression_NegativeValue(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | 47 | CLS_Content.Value r = listParam[0].ComputeValue(content); 48 | ICLS_Type type =content.environment.GetType(r.type); 49 | 50 | r.value= type.Math2Value(content, '*', r.value, CLS_Content.Value.OneMinus, out r.type); 51 | content.OutStack(this); 52 | 53 | return r; 54 | } 55 | 56 | 57 | public override string ToString() 58 | { 59 | return "(-)|"; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_SelfOp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_SelfOp : ICLS_Expression 8 | { 9 | public CLS_Expression_SelfOp(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | tokenBegin = tbegin; 12 | tokenEnd = tend; 13 | lineBegin = lbegin; 14 | lineEnd = lend; 15 | } 16 | public int lineBegin 17 | { 18 | get; 19 | private set; 20 | } 21 | public int lineEnd 22 | { 23 | get; 24 | private set; 25 | } 26 | //Block的参数 一个就是一行,顺序执行,没有 27 | public List listParam 28 | { 29 | get 30 | { 31 | return null; 32 | } 33 | } 34 | public int tokenBegin 35 | { 36 | get; 37 | private set; 38 | } 39 | public int tokenEnd 40 | { 41 | get; 42 | private set; 43 | } 44 | public CLS_Content.Value ComputeValue(CLS_Content content) 45 | { 46 | content.InStack(this); 47 | 48 | var v = content.Get(value_name); 49 | ICLS_Type type = content.environment.GetType(v.type); 50 | CLType returntype; 51 | object value = type.Math2Value(content,mathop, v.value, CLS_Content.Value.One, out returntype); 52 | value = type.ConvertTo(content, value, v.type); 53 | content.Set(value_name, value); 54 | 55 | //操作变量之 56 | //做数学计算 57 | //从上下文取值 58 | //_value = null; 59 | content.OutStack(this); 60 | 61 | return content.Get(value_name); 62 | } 63 | 64 | 65 | public string value_name; 66 | public char mathop; 67 | 68 | public override string ToString() 69 | { 70 | return "MathSelfOp|" + value_name + mathop; 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_SelfOpWithValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_SelfOpWithValue : ICLS_Expression 8 | { 9 | public CLS_Expression_SelfOpWithValue(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | this.tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | 47 | 48 | var left = listParam[0].ComputeValue(content); 49 | var right = listParam[1].ComputeValue(content); 50 | ICLS_Type type = content.environment.GetType(left.type); 51 | //if (mathop == "+=") 52 | 53 | { 54 | CLType returntype; 55 | object value = type.Math2Value(content, mathop, left.value, right, out returntype); 56 | value = type.ConvertTo(content, value, left.type); 57 | left.value = value; 58 | 59 | Type t = right.type; 60 | //if(t.IsSubclassOf(typeof(MulticastDelegate))||t.IsSubclassOf(typeof(Delegate))) 61 | //{ 62 | 63 | //} 64 | ////content.Set(value_name, value); 65 | //else if (t == typeof(CSLE.DeleLambda) || t == typeof(CSLE.DeleFunction) || t == typeof(CSLE.DeleEvent)) 66 | //{ 67 | 68 | //} 69 | //else 70 | { 71 | if (listParam[0] is CLS_Expression_MemberFind) 72 | { 73 | CLS_Expression_MemberFind f = listParam[0] as CLS_Expression_MemberFind; 74 | 75 | var parent = f.listParam[0].ComputeValue(content); 76 | if (parent == null) 77 | { 78 | throw new Exception("调用空对象的方法:" + f.listParam[0].ToString() + ":" + ToString()); 79 | } 80 | var ptype = content.environment.GetType(parent.type); 81 | ptype.function.MemberValueSet(content, parent.value, f.membername, value); 82 | } 83 | if (listParam[0] is CLS_Expression_StaticFind) 84 | { 85 | CLS_Expression_StaticFind f = listParam[0] as CLS_Expression_StaticFind; 86 | f.type.function.StaticValueSet(content, f.staticmembername, value); 87 | } 88 | } 89 | } 90 | 91 | 92 | //操作变量之 93 | //做数学计算 94 | //从上下文取值 95 | //_value = null; 96 | content.OutStack(this); 97 | 98 | return null; 99 | } 100 | 101 | 102 | //public string value_name; 103 | public char mathop; 104 | 105 | public override string ToString() 106 | { 107 | return "MathSelfOp|" + mathop; 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_TypeCheck.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_TypeCheck : ICLS_Expression 8 | { 9 | public CLS_Expression_TypeCheck(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | 47 | var right = listParam[0].ComputeValue(content); 48 | ICLS_Type type = content.environment.GetType(right.type); 49 | CLS_Content.Value value = new CLS_Content.Value(); 50 | value.type = typeof(bool); 51 | value.value = type.ConvertTo(content, right.value, targettype) != null; 52 | 53 | //操作变量之 54 | //做数学计算 55 | //从上下文取值 56 | //_value = null; 57 | content.OutStack(this); 58 | 59 | return value; 60 | } 61 | 62 | public CLType type 63 | { 64 | get { return null; } 65 | } 66 | public CLType targettype; 67 | 68 | public override string ToString() 69 | { 70 | return "convert<" + targettype.Name + ">"; 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Expression/Math/CLS_Expression_TypeConvert.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public class CLS_Expression_TypeConvert : ICLS_Expression 8 | { 9 | public CLS_Expression_TypeConvert(int tbegin, int tend, int lbegin, int lend) 10 | { 11 | listParam = new List(); 12 | tokenBegin = tbegin; 13 | tokenEnd = tend; 14 | lineBegin = lbegin; 15 | lineEnd = lend; 16 | } 17 | public int lineBegin 18 | { 19 | get; 20 | private set; 21 | } 22 | public int lineEnd 23 | { 24 | get; 25 | private set; 26 | } 27 | //Block的参数 一个就是一行,顺序执行,没有 28 | public List listParam 29 | { 30 | get; 31 | private set; 32 | } 33 | public int tokenBegin 34 | { 35 | get; 36 | private set; 37 | } 38 | public int tokenEnd 39 | { 40 | get; 41 | private set; 42 | } 43 | public CLS_Content.Value ComputeValue(CLS_Content content) 44 | { 45 | content.InStack(this); 46 | 47 | var right = listParam[0].ComputeValue(content); 48 | ICLS_Type type = content.environment.GetType(right.type); 49 | CLS_Content.Value value = new CLS_Content.Value(); 50 | value.type = targettype; 51 | value.value = type.ConvertTo(content, right.value, targettype); 52 | 53 | //操作变量之 54 | //做数学计算 55 | //从上下文取值 56 | //_value = null; 57 | content.OutStack(this); 58 | 59 | return value; 60 | } 61 | 62 | public CLType type 63 | { 64 | get { return null; } 65 | } 66 | public CLType targettype; 67 | 68 | public override string ToString() 69 | { 70 | return "convert<" + targettype.Name + ">"; 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/RegHelper/FunctionTrace.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | public class FunctionTrace : ICLS_Function 8 | { 9 | public string keyword 10 | { 11 | get { return "trace"; } 12 | } 13 | 14 | public CLS_Content.Value Call(CLS_Content content, IList param) 15 | { 16 | string output = "trace:"; 17 | bool bfirst = true; 18 | foreach (var p in param) 19 | { 20 | if (bfirst) bfirst = false; 21 | else output += ","; 22 | if (p.value == null) output += "null"; 23 | else output += p.value.ToString(); 24 | } 25 | content.environment.logger.Log(output); 26 | return CLS_Content.Value.Void; 27 | } 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/RegHelper/RegHelper_Function.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | public class RegHelper_Function : ICLS_Function 8 | { 9 | Delegate dele; 10 | public RegHelper_Function(Delegate dele) 11 | { 12 | this.dele = dele; 13 | 14 | this.keyword = dele.Method.Name; 15 | 16 | returntype = dele.Method.ReturnType; 17 | foreach (System.Reflection.ParameterInfo p in dele.Method.GetParameters()) 18 | { 19 | defvalues.Add(p.DefaultValue); 20 | paramtype.Add(p.ParameterType); 21 | } 22 | } 23 | public RegHelper_Function(Delegate dele,string setkeyword) 24 | { 25 | this.dele = dele; 26 | if (setkeyword != null) 27 | { 28 | this.keyword = setkeyword; 29 | } 30 | else 31 | { 32 | this.keyword = dele.Method.Name; 33 | } 34 | returntype = dele.Method.ReturnType; 35 | foreach (System.Reflection.ParameterInfo p in dele.Method.GetParameters()) 36 | { 37 | defvalues.Add(p.DefaultValue); 38 | paramtype.Add(p.ParameterType); 39 | } 40 | } 41 | List defvalues = new List(); 42 | List paramtype = new List(); 43 | Type returntype; 44 | public string keyword 45 | { 46 | get; 47 | private set; 48 | } 49 | 50 | public CLS_Content.Value Call(CLS_Content content, IList param) 51 | { 52 | CLS_Content.Value v = new CLS_Content.Value(); 53 | List objs = new List(); 54 | //var _params = dele.Method.GetParameters(); 55 | for (int i = 0; i < this.defvalues.Count; i++) 56 | { 57 | if (i >= param.Count) 58 | { 59 | objs.Add(defvalues[i]); 60 | } 61 | else 62 | { 63 | if (this.paramtype[i] == (Type)param[i].type) 64 | { 65 | objs.Add(param[i].value); 66 | } 67 | else 68 | { 69 | object conv = content.environment.GetType(param[i].type).ConvertTo(content, param[i].value, paramtype[i]); 70 | objs.Add(conv); 71 | } 72 | } 73 | } 74 | v.type = this.returntype; 75 | v.value = dele.DynamicInvoke(objs.ToArray()); 76 | return v; 77 | } 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/CLS_Type_Bool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | public class CLS_Type_Bool : ICLS_Type 8 | { 9 | public class var 10 | { 11 | 12 | } 13 | public string keyword 14 | { 15 | get { return "bool"; } 16 | } 17 | public string _namespace 18 | { 19 | get { return ""; } 20 | } 21 | public CLType type 22 | { 23 | get { return (typeof(bool)); } 24 | } 25 | 26 | public ICLS_Value MakeValue(object value) 27 | { 28 | throw new NotImplementedException(); 29 | } 30 | 31 | public object ConvertTo(CLS_Content env, object src, CLType targetType) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | 36 | public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 37 | { 38 | throw new NotImplementedException(); 39 | } 40 | 41 | public bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 42 | { 43 | throw new NotImplementedException(); 44 | } 45 | 46 | public ICLS_TypeFunction function 47 | { 48 | get { throw new NotImplementedException(); } 49 | } 50 | public object DefValue 51 | { 52 | get { return false; } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/CLS_Type_Delegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Delegate: ICLS_Type 8 | { 9 | public CLS_Type_Delegate() 10 | { 11 | 12 | function = null; 13 | } 14 | public string keyword 15 | { 16 | get { return "(){}"; } 17 | } 18 | public string _namespace 19 | { 20 | get { return ""; } 21 | } 22 | public CLType type 23 | { 24 | get { return typeof(DeleFunction); } 25 | } 26 | 27 | public ICLS_Value MakeValue(object value) 28 | { 29 | throw new NotSupportedException(); 30 | 31 | } 32 | 33 | public object ConvertTo(CLS_Content env, object src, CLType targetType) 34 | { 35 | ICLS_Type_Dele dele = env.environment.GetType(targetType) as ICLS_Type_Dele; 36 | return dele.CreateDelegate(env.environment, src as DeleFunction); 37 | //throw new NotImplementedException(); 38 | } 39 | 40 | public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 41 | { 42 | 43 | throw new NotImplementedException("code:"+code +" right:+"+right.type.ToString()+"="+ right.value); 44 | } 45 | 46 | public bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 47 | { 48 | 49 | throw new NotImplementedException(); 50 | } 51 | 52 | 53 | 54 | public ICLS_TypeFunction function 55 | { 56 | get; 57 | private set; 58 | } 59 | public object DefValue 60 | { 61 | get { return null; } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/CLS_Type_Double.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Double : RegHelper_Type 8 | { 9 | public CLS_Type_Double() 10 | : base(typeof(double), "double", false) 11 | { 12 | 13 | //function = new RegHelper_TypeFunction(typeof(double)); 14 | } 15 | 16 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 17 | { 18 | bool convertSuccess = false; 19 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 20 | if (convertSuccess) { 21 | return convertedObject; 22 | } 23 | 24 | return base.ConvertTo(env, src, targetType); 25 | } 26 | 27 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 28 | { 29 | bool math2ValueSuccess = false; 30 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 31 | if (math2ValueSuccess) { 32 | return value; 33 | } 34 | 35 | return base.Math2Value(env, code, left, right, out returntype); 36 | } 37 | 38 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 39 | { 40 | bool mathLogicSuccess = false; 41 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 42 | if (mathLogicSuccess) { 43 | return value; 44 | } 45 | 46 | return base.MathLogic(env, code, left, right); 47 | } 48 | 49 | public override object DefValue 50 | { 51 | get { return (double)0; } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/CLS_Type_Float.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Float : RegHelper_Type 8 | { 9 | public CLS_Type_Float() 10 | : base(typeof(float), "float",false) 11 | { 12 | //function = new RegHelper_TypeFunction(typeof(float)); 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (float)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/CLS_Type_Lambda.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Lambda: ICLS_Type 8 | { 9 | public CLS_Type_Lambda() 10 | { 11 | 12 | function = null; 13 | } 14 | public string keyword 15 | { 16 | get { return "()=>"; } 17 | } 18 | public string _namespace 19 | { 20 | get { return ""; } 21 | } 22 | public CLType type 23 | { 24 | get { return typeof(DeleLambda); } 25 | } 26 | 27 | public ICLS_Value MakeValue(object value) 28 | { 29 | throw new NotSupportedException(); 30 | 31 | } 32 | 33 | public object ConvertTo(CLS_Content env, object src, CLType targetType) 34 | { 35 | ICLS_Type_Dele dele = env.environment.GetType(targetType) as ICLS_Type_Dele; 36 | return dele.CreateDelegate(env.environment, src as DeleLambda); 37 | //throw new NotImplementedException(); 38 | } 39 | 40 | public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 41 | { 42 | 43 | throw new NotImplementedException("code:"+code +" right:+"+right.type.ToString()+"="+ right.value); 44 | } 45 | 46 | public bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 47 | { 48 | 49 | throw new NotImplementedException(); 50 | } 51 | 52 | 53 | 54 | public ICLS_TypeFunction function 55 | { 56 | get; 57 | private set; 58 | } 59 | public object DefValue 60 | { 61 | get { return null; } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/CLS_Type_Null.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_NULL : ICLS_Type 8 | { 9 | public string keyword 10 | { 11 | get { return "null"; } 12 | } 13 | public string _namespace 14 | { 15 | get { return ""; } 16 | } 17 | public CLType type 18 | { 19 | get { return null; } 20 | } 21 | 22 | public ICLS_Value MakeValue(object value) 23 | { 24 | CLS_Value_Null v = new CLS_Value_Null(); 25 | 26 | return v; 27 | 28 | } 29 | 30 | public object ConvertTo(CLS_Content env, object src, CLType targetType) 31 | { 32 | return null; 33 | } 34 | 35 | public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 36 | { 37 | 38 | if ((Type)right.type == typeof(string)) 39 | { 40 | returntype = typeof(String); 41 | return "null" + right.value; 42 | } 43 | throw new NotImplementedException(); 44 | } 45 | 46 | public bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 47 | { 48 | if (code == logictoken.equal) 49 | { 50 | return null == right.value; 51 | } 52 | else if(code== logictoken.not_equal) 53 | { 54 | return null != right.value; 55 | } 56 | throw new NotImplementedException(); 57 | } 58 | 59 | 60 | 61 | public ICLS_TypeFunction function 62 | { 63 | get { throw new NotImplementedException(); } 64 | } 65 | public object DefValue 66 | { 67 | get { return null; } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/CLS_Type_String.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_String : ICLS_Type 8 | { 9 | public CLS_Type_String() 10 | { 11 | function = new RegHelper_TypeFunction(typeof(string)); 12 | } 13 | public string keyword 14 | { 15 | get { return "string"; } 16 | } 17 | public string _namespace 18 | { 19 | get { return ""; } 20 | } 21 | public CLType type 22 | { 23 | get { return typeof(string); } 24 | } 25 | 26 | public ICLS_Value MakeValue(object value) 27 | { 28 | CLS_Value_Value v = new CLS_Value_Value(); 29 | v.value_value = (string)value; 30 | 31 | return v; 32 | 33 | } 34 | 35 | public object ConvertTo(CLS_Content env, object src, CLType targetType) 36 | { 37 | if ((Type)targetType == typeof(string)) return src; 38 | if ((Type)targetType == typeof(void)) 39 | { 40 | return null; 41 | } 42 | if (((Type)targetType).IsAssignableFrom(typeof(string))) 43 | //if((Type)targetType== typeof(object)) 44 | { 45 | return src; 46 | } 47 | return null; 48 | } 49 | 50 | public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 51 | { 52 | returntype = typeof(string); 53 | if (code == '+') 54 | { 55 | if (right.value == null) 56 | { 57 | return (string)left + "null"; 58 | } 59 | else 60 | { 61 | return (string)left + right.value.ToString(); 62 | } 63 | } 64 | throw new NotImplementedException(); 65 | } 66 | 67 | public bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 68 | { 69 | if (code == logictoken.equal) 70 | { 71 | return (string)left == (string)right.value; 72 | } 73 | else if(code== logictoken.not_equal) 74 | { 75 | return (string)left != (string)right.value; 76 | } 77 | throw new NotImplementedException(); 78 | } 79 | 80 | 81 | public ICLS_TypeFunction function 82 | { 83 | get; 84 | private set; 85 | } 86 | public object DefValue 87 | { 88 | get { return null; } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/CLS_Type_Var.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | public class CLS_Type_Var : ICLS_Type 8 | { 9 | public class var 10 | { 11 | 12 | } 13 | public string keyword 14 | { 15 | get { return "var"; } 16 | } 17 | public string _namespace 18 | { 19 | get { return ""; } 20 | } 21 | public CLType type 22 | { 23 | get { return (typeof(var)); } 24 | } 25 | 26 | public ICLS_Value MakeValue(object value) 27 | { 28 | throw new NotImplementedException(); 29 | } 30 | 31 | public object ConvertTo(CLS_Content env, object src, CLType targetType) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | 36 | public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 37 | { 38 | throw new NotImplementedException(); 39 | } 40 | 41 | public bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 42 | { 43 | throw new NotImplementedException(); 44 | } 45 | 46 | public ICLS_TypeFunction function 47 | { 48 | get { throw new NotImplementedException(); } 49 | } 50 | public object DefValue 51 | { 52 | get { return null; } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/ints/CLS_Type_Byte.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Byte : RegHelper_Type 8 | { 9 | public CLS_Type_Byte() 10 | : base(typeof(byte), "byte",false) 11 | { 12 | //function = new RegHelper_TypeFunction(typeof(uint)); 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (byte)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/ints/CLS_Type_Char.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Char : RegHelper_Type 8 | { 9 | public CLS_Type_Char() 10 | : base(typeof(char), "char", false) 11 | { 12 | //function = new RegHelper_TypeFunction(typeof(uint)); 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (char)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/ints/CLS_Type_Int.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Int : RegHelper_Type 8 | { 9 | public CLS_Type_Int() 10 | : base(typeof(int), "int", false) 11 | { 12 | 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (int)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/ints/CLS_Type_Long.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Long : RegHelper_Type 8 | { 9 | public CLS_Type_Long() 10 | : base(typeof(long), "long", false) 11 | { 12 | 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (long)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/ints/CLS_Type_Sbyte.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Sbyte : RegHelper_Type 8 | { 9 | public CLS_Type_Sbyte() 10 | : base(typeof(sbyte), "sbyte",false) 11 | { 12 | 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (sbyte)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/ints/CLS_Type_Short.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_Short : RegHelper_Type 8 | { 9 | public CLS_Type_Short() 10 | : base(typeof(short), "short",false) 11 | { 12 | 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (short)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/ints/CLS_Type_UInt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_UInt : RegHelper_Type 8 | { 9 | public CLS_Type_UInt() 10 | : base(typeof(uint), "uint",false) 11 | { 12 | //function = new RegHelper_TypeFunction(typeof(uint)); 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (uint)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/ints/CLS_Type_ULong.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_ULong : RegHelper_Type 8 | { 9 | public CLS_Type_ULong() 10 | : base(typeof(ulong), "ulong",false) 11 | { 12 | 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (ulong)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/Type/ints/CLS_Type_Ushort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | class CLS_Type_UShort : RegHelper_Type 8 | { 9 | public CLS_Type_UShort() 10 | : base(typeof(ushort), "ushort",false) 11 | { 12 | //function = new RegHelper_TypeFunction(typeof(uint)); 13 | } 14 | 15 | public override object ConvertTo(CLS_Content env, object src, CLType targetType) 16 | { 17 | bool convertSuccess = false; 18 | object convertedObject = NumericTypeUtils.TryConvertTo(src, targetType, out convertSuccess); 19 | if (convertSuccess) { 20 | return convertedObject; 21 | } 22 | 23 | return base.ConvertTo(env, src, targetType); 24 | } 25 | 26 | public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype) 27 | { 28 | bool math2ValueSuccess = false; 29 | object value = NumericTypeUtils.Math2Value(code, left, right, out returntype, out math2ValueSuccess); 30 | if (math2ValueSuccess) { 31 | return value; 32 | } 33 | 34 | return base.Math2Value(env, code, left, right, out returntype); 35 | } 36 | 37 | public override bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right) 38 | { 39 | bool mathLogicSuccess = false; 40 | bool value = NumericTypeUtils.MathLogic(code, left, right, out mathLogicSuccess); 41 | if (mathLogicSuccess) { 42 | return value; 43 | } 44 | 45 | return base.MathLogic(env, code, left, right); 46 | } 47 | 48 | public override object DefValue 49 | { 50 | get { return (ushort)0; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/_Interface/CLS_Expression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | //值 7 | 8 | 9 | //类型 10 | public interface ICLS_Value : ICLS_Expression 11 | { 12 | CLType type 13 | { 14 | get; 15 | } 16 | object value 17 | { 18 | get; 19 | } 20 | new int tokenBegin 21 | { 22 | get; 23 | set; 24 | } 25 | new int tokenEnd 26 | { 27 | get; 28 | set; 29 | } 30 | new int lineBegin 31 | { 32 | get; 33 | set; 34 | } 35 | new int lineEnd 36 | { 37 | get; 38 | set; 39 | } 40 | } 41 | //表达式是一个值 42 | public interface ICLS_Expression 43 | { 44 | 45 | List listParam 46 | { 47 | get; 48 | } 49 | CLS_Content.Value ComputeValue(CLS_Content content); 50 | 51 | int tokenBegin 52 | { 53 | get; 54 | } 55 | int tokenEnd 56 | { 57 | get; 58 | } 59 | int lineBegin 60 | { 61 | get; 62 | } 63 | int lineEnd 64 | { 65 | get; 66 | } 67 | } 68 | public interface ICLS_Environment 69 | { 70 | string version 71 | { 72 | get; 73 | } 74 | //bool useNamespace 75 | //{ 76 | // get; 77 | //} 78 | void RegType(ICLS_Type type); 79 | //void RegDeleType(ICLS_Type_Dele type); 80 | ICLS_Type GetType(CLType type); 81 | //ICLS_Type_Dele GetDeleTypeBySign(string sign); 82 | ICLS_Type GetTypeByKeyword(string keyword); 83 | ICLS_Type GetTypeByKeywordQuiet(string keyword); 84 | 85 | void RegFunction(ICLS_Function func); 86 | ICLS_Function GetFunction(string name); 87 | 88 | ICLS_Logger logger 89 | { 90 | get; 91 | } 92 | //public ICLS_Debugger debugger; 93 | ICLS_TokenParser tokenParser 94 | { 95 | get; 96 | } 97 | } 98 | public interface ICLS_Environment_Compiler 99 | { 100 | 101 | [Obsolete("use tokenParser.Parse instead.")] 102 | IList ParserToken(string code); 103 | 104 | ICLS_Expression Expr_CompileToken(IList listToken, bool SimpleExpression); 105 | 106 | [Obsolete("use Expr_CompileToken instead.")] 107 | ICLS_Expression Expr_CompilerToken(IList listToken, bool SimpleExpression); 108 | 109 | //CLS_Content contentGloabl = null; 110 | ICLS_Expression Expr_Optimize(ICLS_Expression old); 111 | 112 | CLS_Content CreateContent(); 113 | 114 | 115 | CLS_Content.Value Expr_Execute(ICLS_Expression expr, CLS_Content content); 116 | 117 | 118 | void Project_Compile(Dictionary> project, bool embDebugToken); 119 | 120 | void File_PreCompileToken(string filename, IList listToken); 121 | 122 | void File_CompileToken(string filename, IList listToken, bool embDebugToken); 123 | 124 | void Project_PacketToStream(Dictionary> project, System.IO.Stream outstream); 125 | 126 | Dictionary> Project_FromPacketStream(System.IO.Stream instream); 127 | } 128 | 129 | public interface ICLS_Expression_Compiler 130 | { 131 | ICLS_Expression Compile(IList tlist, ICLS_Environment content);//语句 132 | ICLS_Expression Compile_NoBlock(IList tlist, ICLS_Environment content);//表达式,一条语句 133 | ICLS_Expression Optimize(ICLS_Expression value, ICLS_Environment content); 134 | 135 | IList FileCompile(ICLS_Environment env, string filename, IList tlist, bool embDebugToken); 136 | IList FilePreCompile(ICLS_Environment env, string filename, IList tlist); 137 | 138 | } 139 | 140 | } -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/_Interface/CLS_Function.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSLE 6 | { 7 | public interface ICLS_Function 8 | { 9 | string keyword 10 | { 11 | get; 12 | } 13 | 14 | CLS_Content.Value Call(CLS_Content content, IList param); 15 | } 16 | 17 | public interface ICLS_Function_Member 18 | { 19 | string keyword 20 | { 21 | get; 22 | } 23 | CLS_Content.Value Call(CLS_Content content, object objthis, IList param); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/CSLightEvil/C#LE/_Interface/CLS_Loger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | namespace CSLE 5 | { 6 | 7 | public interface ICLS_Logger 8 | { 9 | void Log(string str); 10 | void Log_Warn(string str); 11 | void Log_Error(string str); 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /core/CSLightEvil/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // 有关程序集的常规信息通过以下特性集 7 | // 控制。更改这些特性值可修改 8 | // 与程序集关联的信息。 9 | [assembly: AssemblyTitle("CSLightEvil")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("CSLightEvil")] 14 | [assembly: AssemblyCopyright("版权所有(C) 2014")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: NeutralResourcesLanguage("zh-Hans")] 18 | 19 | // 程序集的版本信息由以下四个值组成: 20 | // 21 | // 主版本 22 | // 次版本 23 | // 生成号 24 | // 修订号 25 | // 26 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 27 | // 方法是按如下所示使用“*”: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /core/myjson/MyJson.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7e929b160847ab45ac5be18b56556f3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | 5 | namespace CSEvilTestor 6 | { 7 | public static class Program 8 | { 9 | /// 10 | /// 应用程序的主入口点。 11 | /// 12 | [STAThread] 13 | static void Main() 14 | { 15 | Application.EnableVisualStyles(); 16 | Application.SetCompatibleTextRenderingDefault(false); 17 | Application.Run(new Form1()); 18 | } 19 | public static void Trace(string txt) 20 | { 21 | Console.WriteLine(txt); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("CSEvilTestor")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CSEvilTestor")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("ea06c7c1-3d5b-4390-ab26-7f95f608ce96")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.34014 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CSEvilTestor.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CSEvilTestor.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.34014 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CSEvilTestor.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/TestDele.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | 7 | class TestDele 8 | { 9 | public static TestDele instance 10 | { 11 | get 12 | { 13 | if (g_this == null) 14 | g_this = new TestDele(); 15 | return g_this; 16 | } 17 | } 18 | static TestDele g_this = null; 19 | 20 | public event Action onUpdate; 21 | public void Run() 22 | { 23 | if (onUpdate != null) 24 | onUpdate(); 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/TestReg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Text; 5 | 6 | namespace CSEvilTestor 7 | { 8 | class TestReg 9 | { 10 | delegate void ma(int a, string b); 11 | 12 | public static void Reg(CSLE.ICLS_Environment env) 13 | { 14 | CSEvilTestor.testfunc.CSLEConvert.env = env; 15 | ////传统的注册方法,只适用于class,不支持注册委托 16 | //env.RegType(new CSLE.RegHelper_Type(typeof(Debug))); 17 | //env.RegType(new CSLE.RegHelper_Type(typeof(testfunc.CSLEConvert))); 18 | 19 | //env.RegType(new CSLE.RegHelper_Type(typeof(TestDele))); 20 | //env.RegType(new CSLE.RegHelper_Type(typeof(Program))); 21 | 22 | //新的注册方法,只适用于class,不支持注册委托 23 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Debug), null)); 24 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(testfunc.CSLEConvert), null)); 25 | 26 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(TestDele), null)); 27 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Program), null)); 28 | //新的注册方法,参数一样的, 29 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(MyJson), "MyJson")); 30 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(MyJson.JsonNode_ValueNumber), "MyJson.JsonNode_ValueNumber")); 31 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(MyJson.IJsonNode), "MyJson.IJsonNode")); 32 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(MyJson.JsonNode_ValueString), "MyJson.JsonNode_ValueString")); 33 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(MyJson.JsonNode_Object), "MyJson.JsonNode_Object")); 34 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(MyJson.JsonNode_Array), "MyJson.JsonNode_Array")); 35 | 36 | 37 | //显式区分注册class 和delegate,其实是一码事 38 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(MyClass2), "MyClass2")); 39 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Action), "Action")); 40 | 41 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(TestDele.myup), "TestDele.myup")); 42 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(TestDele.myup), "TestDele.myup")); 43 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Action), "Action")); 44 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Action), "Action")); 45 | 46 | //统一用make,不管是什么东西 47 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Action), "Action")); 48 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Color), "Color")); 49 | 50 | 51 | 52 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Color), "Color")); 53 | 54 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(KeyValuePair<,>), "KeyValuePair")); 55 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(HashSet), "HashSet")); 56 | 57 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(int[]), "int[]")); 58 | 59 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(config), "config")); 60 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Math), "Math")); 61 | 62 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(Exception), "Exception")); 63 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(NotSupportedException), "NotSupportedException")); 64 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(NotImplementedException), "NotImplementedException")); 65 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(TestClass), "TestClass")); 66 | env.RegType(CSLE.RegHelper_Type.MakeType(typeof(StateMgr), "StateMgr")); 67 | 68 | } 69 | 70 | } 71 | public class StateMgr 72 | { 73 | 74 | } 75 | public class MyClass2 76 | { 77 | 78 | } 79 | class config 80 | { 81 | public static int Cell(double i) 82 | { 83 | return (int)i; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/ScriptClass.cs: -------------------------------------------------------------------------------- 1 | //using CSEvilTestor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | class ScriptClass 7 | { 8 | public int i = 56; 9 | public int j; 10 | public int k; 11 | public float jj = -1.20f; 12 | static string fuck = null; 13 | static string fuck2 = null; 14 | 15 | public ScriptClass() 16 | { 17 | i = 3; 18 | j = 31; 19 | 20 | } 21 | public int GetI(int iii) 22 | { 23 | fuck = "abc"; 24 | scriptFun1 f1 = new scriptFun1(); 25 | f1.Update(0.3f); 26 | //TestDele.instance.onUpdate += Test; 27 | this.deleA += Test; 28 | this.Test(); 29 | int j = 0; 30 | string ist = null; 31 | //CSEvilTestor.Program.Trace(ist); 32 | CSEvilTestor.Program.Trace("j=" + this.j+":"+iii); 33 | 34 | return i + j + k; 35 | } 36 | 37 | Action deleA; 38 | public void Test() 39 | { 40 | j++; 41 | CSEvilTestor.Program.Trace("j=" + j); 42 | } 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/ScriptClass2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class scriptFun1 4 | { 5 | public void Update(float delta) 6 | { 7 | timer += delta; 8 | if (timer > 1.0f) 9 | speed = 180.0f * delta; 10 | else 11 | speed = 60.0f * delta; 12 | if (timer > 2.0f) 13 | { 14 | timer -= 2.0f; 15 | } 16 | } 17 | 18 | public float speed = 0; 19 | public float timer = 0; 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test01/Test01.cs: -------------------------------------------------------------------------------- 1 |  2 | using CSEvilTestor; 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | 7 | public class Script_TestConstructor 8 | { 9 | string abc = ("dd" as string).ToString(); 10 | private int[] a = new int[] { 1, 3, 4 }; 11 | public static int[] b = new int[234]; 12 | public static Dictionary objs = new Dictionary(); 13 | public static Dictionary dicHasBlock = new Dictionary(); 14 | 15 | public static HashSet objs2 = new HashSet(); 16 | public Script_TestConstructor() 17 | { 18 | Dictionary objs = new Dictionary(); 19 | Test(); 20 | //Debug.Log(null); 21 | Test2(); 22 | Test3(22, 33, 44); 23 | objs.Add("abb",this); 24 | objs2.Add(this); 25 | Script_TestConstructor thisislist= objs["abb"] as Script_TestConstructor; 26 | thisislist.LogtT(); 27 | } 28 | public int[] TTT(int[] ttt) 29 | { 30 | return ttt; 31 | } 32 | public void LogtT() 33 | { 34 | Debug.Log("LogtT"); 35 | } 36 | public static void Test3(int a, int b, int c) 37 | { 38 | ////// 这个是正确的. 39 | int v = (a * (b + 1)) * (c + 2); 40 | int value1 = config.Cell(v); 41 | Debug.Log("value1=>" + value1); 42 | 43 | ////// 发生运行时错误 => 找不到 CeilToInt 方法. 44 | int value2 = config.Cell((a * (b + 1)) * (c + 2)); 45 | Debug.Log("value2=>" + value2); 46 | } 47 | public bool Test() 48 | { 49 | return false; 50 | } 51 | 52 | public static void Test2() 53 | { 54 | for (int i = 0; i < 10; i++) 55 | { 56 | TestClass.instance.Log(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test01/test.txt: -------------------------------------------------------------------------------- 1 | //这个测试完成Helloworld. 2 | 3 | 4 | Script_TestConstructor tc= new Script_TestConstructor(); -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test02/Test02.cs: -------------------------------------------------------------------------------- 1 | using CSEvilTestor; 2 | //using CSEvilTestor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | class Test02 8 | { 9 | public static void Run() 10 | 11 | { 12 | 13 | Action t = (int a) => 14 | { 15 | //Debug.Log("a=" + a); 16 | }; 17 | 18 | TestDele.instance.onUpdateD = Test; 19 | Action deleTest = Test2; 20 | 21 | deleTest(13333); 22 | Test02.deleTest2 = deleTest; 23 | Test02.deleTest2(333); 24 | 25 | int config_citygrade = 0; 26 | TestDele.instance.ClearDele(); 27 | TestDele.instance.onUpdateD += () => 28 | { 29 | Debug.Log("direct."); 30 | }; 31 | TestDele.instance.onUpdateD = Test; 32 | //直接注册回调的用法,+=,-= 33 | TestDele.instance.onUpdate += Test; 34 | 35 | //用Delegate类型指向函数的语法 36 | TestDele.instance.onUpdate2 += deleTest; 37 | TestDele.instance.onUpdate3 += Test3; 38 | 39 | //函数作为参数的用法 40 | TestDele.instance.AddDele(Test2); 41 | //Action abc = Test2; 42 | TestDele.instance.AddDeleT3(Test4); 43 | 44 | 45 | TestDele.instance.AddDele(null); 46 | 47 | TestDele.instance.AddDele((ii) => 48 | { 49 | Debug.Log("Test lambda."); 50 | }); 51 | //TestDele.instance.AddDele(deleTest); 52 | 53 | Test02 ttt = new Test02(); 54 | ttt.deleTest3 = deleTest; 55 | ttt.deleTest3(3334); 56 | 57 | TestDele.instance.onUpdate2 += t; 58 | 59 | TestDele.instance.onUpdate2 += (b) => 60 | { 61 | Debug.Log("b=" + b); 62 | }; 63 | 64 | 65 | TestDele.instance.Run(); 66 | } 67 | static int i = 0; 68 | static Action deleTest2 = null; 69 | 70 | Action deleTest3; 71 | static void Test() 72 | { 73 | 74 | } 75 | static void Test2(int v) 76 | { 77 | Debug.Log("Test2 i=" + v); 78 | i--; 79 | } 80 | static void Test4(int v,string str) 81 | { 82 | Debug.Log("Test4 i=" + v+", s="+str); 83 | i--; 84 | } 85 | 86 | static void Test3(int v, string str) 87 | { 88 | Debug.Log("test3:" + v + ":" + str); 89 | } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test02/test.txt: -------------------------------------------------------------------------------- 1 | //这个测试完成Delegate. 2 | //脚本通过各种方式向程序中添加回调 3 | 4 | Test02.Run(); -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test03/Test03.cs: -------------------------------------------------------------------------------- 1 | using CSEvilTestor; 2 | //using CSEvilTestor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | class Test03 8 | { 9 | public static void Run() 10 | { 11 | List list1 = new List();//c#Light 不支持模板,所以这里要注意一下 12 | //List 可以 List < int > 有空格不可以 13 | list1.Add(1); 14 | list1.Add(2); 15 | list1.Add(3); 16 | List> list2 = new List>(); 17 | 18 | list2.Add(list1); 19 | List>> list3 = new List>>(); 20 | list3.Add(list2); 21 | } 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test03/test.txt: -------------------------------------------------------------------------------- 1 | //这个测试测试一些奇特的类型名 2 | //List 3 | //List> 4 | //List>> 5 | 6 | Test03.Run(); -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test04/Test04.cs: -------------------------------------------------------------------------------- 1 | using CSEvilTestor; 2 | //using CSEvilTestor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | class Test04 8 | { 9 | public static Dictionary objs = new Dictionary(); 10 | public static void Run() 11 | { 12 | IT4_Impl impl1 = new IT4_Impl(); 13 | 14 | impl1.Call1(); 15 | impl2 = new IT4_Impl(); 16 | Test04.impl2 = new IT4_Impl2(); 17 | Test04.impl2.Call1(); 18 | Test04 t4 = new Test04(); 19 | t4.Run1(); 20 | objs.Add("t1", impl1); 21 | objs.Add("t4", t4); 22 | Test04.IT4(); 23 | 24 | } 25 | static void IT4() 26 | { 27 | 28 | } 29 | void Run1() 30 | { 31 | 32 | impl1 = new IT4_Impl(); 33 | 34 | impl1.Call1(); 35 | this.impl1 = new IT4_Impl2(); 36 | this.impl1.Call1(); 37 | } 38 | static IT4 impl2; 39 | IT4 impl1; 40 | 41 | } 42 | interface IT4 43 | { 44 | void Call1(); 45 | void Call2(int i, string n); 46 | 47 | string name 48 | { 49 | get; 50 | set; 51 | } 52 | string readonlyname 53 | { 54 | get; 55 | } 56 | 57 | } 58 | class IT4_Impl : IT4 59 | { 60 | public IT4_Impl() 61 | { 62 | this.name = "IT4_Impl"; 63 | } 64 | 65 | public void Call1() 66 | { 67 | Debug.Log("IT4_Impl.Call1"); 68 | } 69 | 70 | public void Call2(int i, string n) 71 | { 72 | Debug.Log("IT4_Impl.Call2(" + i + "," + n + ")"); 73 | } 74 | 75 | public string name 76 | { 77 | get; 78 | set; 79 | } 80 | 81 | public string readonlyname 82 | { 83 | get; 84 | private set; 85 | } 86 | 87 | } 88 | 89 | class IT4_Impl2 : IT4 90 | { 91 | public IT4_Impl2() 92 | { 93 | this.name = "IT4_Impl2"; 94 | } 95 | 96 | public void Call1() 97 | { 98 | Debug.Log("IT4_Impl2.Call1"); 99 | } 100 | 101 | public void Call2(int i, string n) 102 | { 103 | Debug.Log("IT4_Impl2.Call2(" + i + "," + n + ")"); 104 | } 105 | 106 | public string name 107 | { 108 | get; 109 | set; 110 | } 111 | 112 | public string readonlyname 113 | { 114 | get; 115 | private set; 116 | } 117 | } -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test04/test.txt: -------------------------------------------------------------------------------- 1 | //这个测试测试接口继承 2 | 3 | Test04.Run(); -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test05/Test05.cs: -------------------------------------------------------------------------------- 1 | using CSEvilTestor; 2 | //using CSEvilTestor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | class Test05 8 | { 9 | public static void Run() 10 | { 11 | if (c5 == null) 12 | { 13 | c5 = new C5(); 14 | 15 | } 16 | try 17 | { 18 | 19 | 20 | throw new NotImplementedException("E2"); 21 | } 22 | catch (NotSupportedException err) 23 | { 24 | Debug.Log("not here."); 25 | } 26 | catch (NotImplementedException err) 27 | { 28 | Debug.Log("Got."); 29 | } 30 | catch (Exception err) 31 | { 32 | Debug.Log("Got 2."); 33 | } 34 | } 35 | static C5 c5 = null; 36 | } 37 | 38 | class C5 39 | { 40 | 41 | } 42 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test05/test.txt: -------------------------------------------------------------------------------- 1 | //这个测试测试try catch throw 2 | Test05.Run(); -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test06/Test06.cs: -------------------------------------------------------------------------------- 1 | using CSEvilTestor; 2 | //using CSEvilTestor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | public class ReturnClass 8 | { 9 | public static ReturnClass ins; 10 | } 11 | 12 | public class Block 13 | { 14 | public Block(string name, int blockType, int inLayer, bool canMove, string imgName) 15 | { 16 | blockName = name; 17 | type = blockType; 18 | layer = inLayer; 19 | move = canMove; 20 | spriteName = imgName; 21 | Dictionary> dic = new Dictionary>(); 22 | Action function = Function; 23 | dic.Add(1, function); 24 | ReturnClass.ins = FunReturnClas(); 25 | } 26 | 27 | public static void Function(MyClass2 i) 28 | { 29 | } 30 | 31 | public static ReturnClass FunReturnClas() 32 | { 33 | ReturnClass r = new ReturnClass(); 34 | Debug.Log("====+++++++++++++++"); 35 | return r; 36 | } 37 | 38 | public string blockName; 39 | public string spriteName; 40 | public int type; 41 | public int layer; 42 | public bool move; 43 | } 44 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test06/test.txt: -------------------------------------------------------------------------------- 1 | //这个测试测试 2 | 3 | 4 | Dictionary dicNameToBlock = new Dictionary(); 5 | Block b = new Block("gg1", 2, 3, true, "2"); 6 | dicNameToBlock.Add("1", b); 7 | 8 | foreach (var item in dicNameToBlock) 9 | { 10 | Debug.Log("key="+item.Key); 11 | Block bb = item.Value as Block; 12 | Debug.Log("bb.name="+bb.blockName); 13 | } 14 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test07/Test07.cs: -------------------------------------------------------------------------------- 1 | using CSEvilTestor; 2 | //using CSEvilTestor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | class Test07 8 | { 9 | public void Run() 10 | { 11 | Debug.Log("===-----------==="); 12 | Fun1(); 13 | } 14 | //static C5 c5 = null; 15 | 16 | public void Fun1() 17 | { 18 | Debug.Log("Fun1 in"); 19 | Fun2(); 20 | Debug.Log("Fun1 out"); 21 | } 22 | 23 | 24 | int _pix = int.MinValue; 25 | int _piy = int.MinValue; 26 | public void Fun2() 27 | { 28 | Debug.Log("Fun3 in"); // !!!!!!!!!!!!!!没有了 29 | int pix = 0; 30 | int piy = 0; 31 | if (pix == _pix && piy == _piy) 32 | { 33 | return; 34 | } 35 | 36 | Debug.Log("Fun3"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test07/test.txt: -------------------------------------------------------------------------------- 1 | //这个测试测试try catch throw 2 | Test07 t = new Test07(); 3 | t.Run(); -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test08/Test08.cs: -------------------------------------------------------------------------------- 1 | using CSEvilTestor; 2 | //using CSEvilTestor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Drawing; 6 | using System.Text; 7 | 8 | class T04 9 | { 10 | public void Test() 11 | { 12 | Debug.Log("tcall:" + name); 13 | } 14 | public string name; 15 | } 16 | class Test08 17 | { 18 | public Color vv; 19 | 20 | public static void F() 21 | { 22 | Test08 tt = new Test08(); 23 | tt.vv = Color.FromArgb(1); 24 | 25 | tlist = new List(); 26 | tlist.Add(new T04()); 27 | tlist[0].name="cool"; 28 | tlist.Add(new T04()); 29 | tlist[1].name = "fuck"; 30 | Debug.Log("tt:"+tlist[0].name); 31 | tlist[1].Test(); 32 | } 33 | /// 34 | /// T04 35 | /// 36 | static List tlist; 37 | } 38 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test08/test.txt: -------------------------------------------------------------------------------- 1 | //这个测试测试try catch throw 2 | 3 | 4 | Test08.F(); 5 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test09/Test09.cs: -------------------------------------------------------------------------------- 1 | using CSEvilTestor; 2 | using CSEvilTestor.testfunc; 3 | //using CSEvilTestor; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Drawing; 7 | using System.Text; 8 | 9 | 10 | class Like 11 | { 12 | public string name; 13 | public string desc; 14 | } 15 | class Love 16 | { 17 | public int id; 18 | } 19 | class TSave 20 | { 21 | public string name; 22 | public int age; 23 | public Love love; 24 | public List like; 25 | public List strs; 26 | } 27 | class Test09 28 | { 29 | public Color vv; 30 | 31 | public static void Test() 32 | { 33 | MyJson.JsonNode_Object objst = MyJson.Parse 34 | ("{\"love\":{\"id\":12345}\"name\":\"aname\",\"age\":123,\"like\":[{\"name\":\"aaa\",\"desc\":\"aaaaaa\"},{\"name\":\"bbb\",\"desc\":\"bbbbbb\"}],\"strs\":[\"aa\",\"bb\"]}") 35 | as MyJson.JsonNode_Object; 36 | 37 | TSave read = CSLEConvert.FromJson("TSave", objst) as TSave; 38 | 39 | Debug.Log("read.name=" + read.name); 40 | Debug.Log("read.like[0].name=" + read.like[0].name); 41 | Like l = read.like[0]; 42 | Debug.Log(l.name); 43 | 44 | Debug.Log("read.strs[1]=" + read.strs[1]); 45 | Debug.Log("read.love.id=" + read.love.id); 46 | Debug.Log("write" + CSLEConvert.ToJson(read).ToString()); 47 | } 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/script/test09/test.txt: -------------------------------------------------------------------------------- 1 | //这个测试测试try catch throw 2 | 3 | 4 | Test09.Test(); 5 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/testfunc/TestClass.cs: -------------------------------------------------------------------------------- 1 | using CSEvilTestor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | 8 | public class TestClass 9 | { 10 | 11 | public string name 12 | { 13 | get 14 | { 15 | return "hi"; 16 | } 17 | set 18 | { 19 | Debug.Log(value); 20 | } 21 | } 22 | public string ttc = "123"; 23 | 24 | private static TestClass g_this = null; 25 | public static TestClass instance 26 | { 27 | get 28 | { 29 | if(g_this==null) 30 | { 31 | g_this = new TestClass(); 32 | } 33 | return g_this; 34 | } 35 | } 36 | int i = 0; 37 | public void Log() 38 | { 39 | i++; 40 | Debug.Log("i=" + i); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /windows/CSEvilTestor/testfunc/TestDele.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | 6 | class TestDele 7 | { 8 | public static TestDele instance 9 | { 10 | get 11 | { 12 | if (g_this == null) 13 | g_this = new TestDele(); 14 | return g_this; 15 | } 16 | } 17 | static TestDele g_this = null; 18 | public delegate void myup(); 19 | public myup onUpdateD; 20 | 21 | public event myup onUpdate; 22 | public event Action onUpdate2; 23 | public event Action onUpdate3; 24 | 25 | public void Run() 26 | { 27 | if (onUpdateD != null) 28 | onUpdateD(); 29 | if (onUpdate != null) 30 | onUpdate(); 31 | if(onUpdate2!=null) 32 | { 33 | onUpdate2(12346); 34 | } 35 | if (onUpdate3 != null) 36 | { 37 | onUpdate3(123,"hello world."); 38 | } 39 | } 40 | public void AddDele(Action dele) 41 | { 42 | onUpdate2 += dele; 43 | } 44 | public void AddDeleT(Action dele) 45 | { 46 | if(dele is Action) 47 | { 48 | onUpdate2 += dele as Action; 49 | } 50 | } 51 | public void AddDeleT3(Action dele) 52 | { 53 | if (dele is Action) 54 | { 55 | onUpdate3 += dele as Action; 56 | } 57 | } 58 | public void ClearDele() 59 | { 60 | onUpdate = null; 61 | onUpdate2 = null; 62 | onUpdate3 = null; 63 | 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /windows/CSLightTestor/CLScriptExt/Country.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CLScriptExt 6 | { 7 | enum Country:ushort 8 | { 9 | Chinese, 10 | English, 11 | Japnese, 12 | }; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /windows/CSLightTestor/CLScriptExt/Student.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CLScriptExt 6 | { 7 | class P1 8 | { 9 | public static void t1() 10 | { 11 | 12 | } 13 | public static int t2; 14 | public static int t3 15 | { 16 | get; 17 | set; 18 | } 19 | } 20 | class P2 : P1 21 | { 22 | public static void TestS() 23 | { 24 | Console.WriteLine(typeof(T).ToString()); 25 | } 26 | public static void TestS2() 27 | { 28 | Console.WriteLine(typeof(T1).ToString() + "," + typeof(T2).ToString()); 29 | } 30 | } 31 | public class MyClass2 32 | { 33 | public static MyClass2 instance = new MyClass2(); 34 | 35 | public T GetComponent(MyClass2 obj, int deep) 36 | { 37 | return default(T); 38 | } 39 | } 40 | 41 | 42 | class Student : P2 43 | { 44 | public void Test(string str,int i=0) 45 | { 46 | Console.WriteLine("str=" + i); 47 | } 48 | public class StudentAss 49 | { 50 | public int size = 10; 51 | 52 | } 53 | public string name 54 | { 55 | get; 56 | set; 57 | } 58 | public static int page; 59 | public int age; 60 | public class S1 61 | { 62 | public int v; 63 | } 64 | public List vs = new List(); 65 | public int[] vs2 = new int[] { 1, 2, 3, 4 }; 66 | 67 | public void ToString2() 68 | { 69 | 70 | } 71 | public void ToString2(T obj) 72 | { 73 | Console.WriteLine(obj.ToString()); 74 | } 75 | 76 | 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /windows/CSLightTestor/CLScriptExt/Vector3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CLScriptExt 6 | { 7 | 8 | class Color32 9 | { 10 | public Color32(byte r,byte g,byte b,byte a) 11 | { 12 | this.r = r; 13 | this.g = g; 14 | this.b = b; 15 | this.a = a; 16 | } 17 | public byte r; 18 | public byte g; 19 | public byte b; 20 | public byte a; 21 | public override string ToString() 22 | { 23 | return r+","+g+","+b+","+a; 24 | } 25 | } 26 | struct Vector3 27 | { 28 | 29 | public Vector3(float x, float y, float z) 30 | { 31 | this.x = x; 32 | this.y = y; 33 | this.z = z; 34 | } 35 | public static Vector3 operator +(Vector3 left, Vector3 right) 36 | { 37 | return new Vector3(left.x + right.x, left.y + right.y, left.z + right.z); 38 | } 39 | public static Vector3 operator *(Vector3 left, float right) 40 | { 41 | return new Vector3(left.x * right, left.y * right, left.z * right); 42 | } 43 | 44 | public static Vector3 operator -(Vector3 left, Vector3 right) 45 | { 46 | return new Vector3(left.x - right.x, left.y - right.y, left.z - right.z); 47 | } 48 | public static bool operator ==(Vector3 left, Vector3 right) 49 | { 50 | return (left.x == right.x && left.y == right.y && left.z == right.z); 51 | } 52 | public static bool operator !=(Vector3 left, Vector3 right) 53 | { 54 | return !(left.x == right.x && left.y == right.y && left.z == right.z); 55 | } 56 | public override string ToString() 57 | { 58 | return "(" + x + "," + y + "," + z+")"; 59 | } 60 | public float x; 61 | public float y; 62 | public float z; 63 | 64 | public float len 65 | { 66 | get 67 | { 68 | return (float)Math.Sqrt(x * x + y * y + z * z); 69 | } 70 | 71 | } 72 | 73 | public Vector3 Normalized() 74 | { 75 | float _len = len; 76 | return new Vector3(x / _len, y / _len, z / _len); 77 | } 78 | 79 | public static Vector3 Cross(Vector3 left,Vector3 right) 80 | { 81 | return new Vector3(left.y * right.z - left.z * right.y, left.z * right.x - left.x * right.z, left.x * right.y - left.y * right.x); 82 | } 83 | public static Vector3 Cross(Vector3 left, float v=0) 84 | { 85 | return left; 86 | } 87 | public static float Dot(Vector3 left,Vector3 right) 88 | { 89 | return left.x * right.x + left.y * right.y + left.z * right.z; 90 | } 91 | public static Vector3 One 92 | { 93 | get 94 | { 95 | return new Vector3(1, 1, 1); 96 | } 97 | } 98 | public static Vector3 Zero 99 | { 100 | get 101 | { 102 | return new Vector3(0, 0, 0); 103 | } 104 | } 105 | public static string typetag; 106 | //测试支持性 107 | public static explicit operator int(Vector3 b) { return 0; } //这是一个显式转换 108 | public static implicit operator float(Vector3 a) { return 1; } //这是一个隐式转换 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /windows/CSLightTestor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | 5 | namespace CLScriptTestor 6 | { 7 | static class Program 8 | { 9 | 10 | /// 11 | /// 应用程序的主入口点。 12 | /// 13 | [STAThread] 14 | 15 | static void Main() 16 | { 17 | 18 | Application.EnableVisualStyles(); 19 | Application.SetCompatibleTextRenderingDefault(false); 20 | Application.Run(new Form1()); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /windows/CSLightTestor/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.34014 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CLScriptTestor.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CLScriptTestor.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /windows/CSLightTestor/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /windows/CSLightTestor/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.34014 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CLScriptTestor.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /windows/CSLightTestor/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /windows/CSLightTestor/UniLua.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightszero/cslightcore/28fb1118518066ee625736fe387e49997c494f68/windows/CSLightTestor/UniLua.dll -------------------------------------------------------------------------------- /windows/CSLightTestor/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_1001_expression.cls.txt: -------------------------------------------------------------------------------- 1 | //1001 _1001_expression 2 | return 1+2>3/4; 3 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_1002_expression.cls.txt: -------------------------------------------------------------------------------- 1 | //1002 _1002_expression 2 | 3 | int a = (int)(Math.Pow(1.4f, 5) * 5f); 4 | 5 | Vector3 v3 =new Vector3((252.0f / 255.0f), (207.0f / 255.0f), (20.0f / 255.0f)); 6 | 7 | return (2+55)*3434; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_1003_expression.cls.txt: -------------------------------------------------------------------------------- 1 | //1003 _1003_expression 2 | return 1+2*2+55*3434+(2-3)-(3-3)+5 -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_1004_expression.cls.txt: -------------------------------------------------------------------------------- 1 | //1004 _1004_expression 2 | string a = "abc"; 3 | string b = "abd"; 4 | 5 | return "str="+a+b; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_1005_expression.cls.txt: -------------------------------------------------------------------------------- 1 |  float s = 0.2f; 2 | if (s <= 0f || s >= 2f) { 3 | trace(1); 4 | } else { 5 | trace(2); 6 | } -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_2001_defineandset.cls.txt: -------------------------------------------------------------------------------- 1 | //2001 define and set. 2 | 3 | int inta; 4 | int intb=0; 5 | int intc=inta; 6 | bool boola; 7 | bool boolb=true; 8 | bool boolc=boola; 9 | string stra; 10 | string strb="oo中o"; 11 | string strc=stra; 12 | char ca ='d'; 13 | 14 | return; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_2002_defineandset.cls.txt: -------------------------------------------------------------------------------- 1 | int a; 2 | a=5; 3 | 4 | return a; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_2003_defineandset.cls.txt: -------------------------------------------------------------------------------- 1 | float b = (float) 1; 2 | var c; 3 | c =b; 4 | return c; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_3001_mathandlogic.cls.txt: -------------------------------------------------------------------------------- 1 | int i=4; 2 | int c=5; 3 | DateTime t1 =DateTime.Now; 4 | DateTime t2 =DateTime.Now; 5 | TimeSpan sp = t2-t1; 6 | bool b = (i<3||c<=5)&&1<2; 7 | return b; 8 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_3002_mathandlogic.cls.txt: -------------------------------------------------------------------------------- 1 | //3002 2 | 3 | byte b =12; 4 | byte bt = b+3; 5 | trace ("b="+b +" bt="+bt); 6 | 7 | sbyte sb= -12; 8 | sbyte sb2= bt+b; 9 | trace ("sb="+sb +" sb2="+sb2); 10 | 11 | short ssb=123; 12 | short ssb2= ssb+4; 13 | trace ("ssb="+ssb +" ssb2="+ssb2); 14 | 15 | Student s =new Student(); 16 | for(int i=0;i<10;i++) 17 | { 18 | s.age++; 19 | trace(s.age); 20 | } 21 | for(int i=0;i<10;i++) 22 | { 23 | Student.page++; 24 | trace(Student.page); 25 | } 26 | 27 | return 0; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_4001_loops.cls.txt: -------------------------------------------------------------------------------- 1 | //4001 loops 2 | 3 | int b=50; 4 | for(;b>0;) 5 | { 6 | b-=3; 7 | } 8 | for(int i=0;i<100;i++) 9 | { 10 | if(i%2==0) 11 | { 12 | continue; 13 | } 14 | trace("i="+i); 15 | b++; 16 | if(b>71) 17 | { 18 | break; 19 | } 20 | } 21 | List ints =new List(); 22 | ints.Add(1); 23 | ints.Add(2); 24 | ints.Add(3); 25 | for(int j=0;j ints =new List(); 4 | for(int i=0;i<100;i++) 5 | { 6 | ints.Add(i); 7 | } 8 | foreach(int k in ints) 9 | { 10 | if(k%3==0) 11 | testCallAdd(k,1); 12 | else 13 | testCallAdd(k,3); 14 | } 15 | testCallAdd(99,99); 16 | return "foreach"; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_4003_loops.cls.txt: -------------------------------------------------------------------------------- 1 | //4003 loops 2 | 3 | int i=0; 4 | 5 | while(i<10) 6 | { 7 | trace("i="+i); 8 | i++; 9 | } 10 | 11 | do 12 | { 13 | trace("i="+i); 14 | i++; 15 | }while(i<10); 16 | 17 | return 0; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_5001_function.cls.txt: -------------------------------------------------------------------------------- 1 | //5001 function 2 | //trace的两种用法 3 | int b=50; 4 | trace "this is trace";//trace 只有一个参数时可以用空格; 5 | trace "test sth" + b; 6 | trace ("test sth2",b);//trace 多个参数必须用函数调用语法 7 | 8 | return b; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_5002_function.cls.txt: -------------------------------------------------------------------------------- 1 | //5002 function 2 | //函数原型 testCallAdd(int a, int b) 3 | int b=testCallAdd(1,5); 4 | int c=testCallAdd(1,5.0f); 5 | int d=testCallAdd4(1,5.0f); 6 | trace ( b ,c,d); 7 | 8 | 9 | return; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_5003_function.cls.txt: -------------------------------------------------------------------------------- 1 | //5003 function 2 | //函数原型 int testCallAdd4(int a, int b, int c = 0, int d = 0) 3 | int b=testCallAdd4(1,5,1,1); 4 | int c=testCallAdd4(1,5.0f,2); 5 | int d=testCallAdd4(1,5.0f); 6 | trace ( b ,c,d); 7 | Form1.onact+=(aaa)=> 8 | { 9 | trace "hi noname"; 10 | }; 11 | Form1.Try(); 12 | Action callnoname = (abc)=> 13 | { 14 | //d is closeure 15 | trace("nonamecall abc="+abc+"d="+d); 16 | //throw "abc"; 17 | }; 18 | callnoname(44565); 19 | return; -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_6001_object.cls.txt: -------------------------------------------------------------------------------- 1 | //6001 object 2 | Vector3 vec= new Vector3(1,2,3)*0.5f; 3 | string str="abc,aaa,cccc"; 4 | string[] ss = str.Split(new char[]{','}); 5 | 6 | 7 | Student s =new Student(); 8 | s.Test("abc"); 9 | 10 | 11 | 12 | Vector3 vec2= new Vector3(1,2,3); 13 | Vector3 vec3= vec + vec2; 14 | trace (vec,vec2,vec3); 15 | bool b =vec==vec2; 16 | 17 | return "loading..." + b; 18 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_6002_object.cls.txt: -------------------------------------------------------------------------------- 1 | //6002 object 2 | //member set and get 3 | 4 | Vector3 vec= new Vector3(1,2,3); 5 | 6 | vec.x =15; 7 | 8 | float x1 = vec.x; 9 | trace (x1,vec); 10 | 11 | float x2 =vec.len; 12 | trace x2; 13 | 14 | Vector3 v3 =vec.Normalized(); 15 | trace v3; 16 | 17 | return; 18 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_6003_object.cls.txt: -------------------------------------------------------------------------------- 1 | //6003 object 2 | //static 3 | 4 | Vector3 vec=new Vector3(1,0,0); 5 | Vector3 vec2=Vector3.One; 6 | 7 | Vector3 cross =Vector3.Cross(vec,vec2); 8 | 9 | Vector3.typetag = "fff"; 10 | trace cross; 11 | 12 | trace Vector3.typetag; 13 | 14 | return; 15 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_6004_object.cls.txt: -------------------------------------------------------------------------------- 1 | //6004 object 2 | //array 3 | 4 | List list =new List(); 5 | 6 | Vector3 vec=new Vector3(1,0,0); 7 | Vector3 vec2=Vector3.One; 8 | 9 | 10 | Vector3 cross =Vector3.Cross(vec,vec2); 11 | 12 | List vecList = new List(); 13 | vecList.Add(vec); 14 | vecList.Add(vec2); 15 | vecList.Add(cross); 16 | vecList[1]= cross; 17 | trace cross; 18 | 19 | var v = vecList[1].y; 20 | 21 | trace v; 22 | 23 | return vecList.Count; 24 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_6005_enum.cls.txt: -------------------------------------------------------------------------------- 1 | //6005 object 2 | //enum 3 | 4 | Country c=Country.Chinese; 5 | Country c2=Country.English; 6 | Country c3=Country.Japnese; 7 | int i =(c3); 8 | trace(c,c2,c3); 9 | 10 | return c3; 11 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_6006_object.cls.txt: -------------------------------------------------------------------------------- 1 | //6006 object 2 | UserData.Instance().HeroDataMap.Clear(); 3 | UserData.Instance().HeroDataMap.Add("1","111"); 4 | UserData.Instance().HeroDataMap.Add("10","1111"); 5 | var data=UserData.Instance().HeroDataMap; 6 | string d = data["1"]; 7 | 8 | string d2=UserData.Instance().HeroDataMap["10"]; 9 | 10 | return "d="+d+",d2="+d2; 11 | 12 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_6007_object.cls.txt: -------------------------------------------------------------------------------- 1 | //6007 object 2 | MyJson.JsonNode_Object obj =new MyJson.JsonNode_Object(); 3 | obj["n"] = new MyJson.JsonNode_ValueString("fuck"); 4 | //outicon2.spriteName = view.values[ii] as MyJson.JsonNode_ValueString 5 | 6 | Student s =new Student(); 7 | string key ="n"; 8 | s.name = obj[key] as MyJson.JsonNode_ValueString; 9 | int i=s.vs2[1]; 10 | 11 | s.ToString2(22); 12 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_6008_object.cls.txt: -------------------------------------------------------------------------------- 1 | //6008 object 2 | 3 | Student.TestS2(); -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_7001_array.cls.txt: -------------------------------------------------------------------------------- 1 | //7001 array 2 | List < List> list =new List>(); 3 | list.Add(new List()); 4 | list.Add(new List()); 5 | trace("listc="+list.Count); 6 | list[0].Add(1); 7 | list[0].Add(2); 8 | list[0].Add(4); 9 | trace("i="+list[0][1]); 10 | 11 | 12 | int[] ints2=new int[3]; 13 | ints2[1]=44; 14 | trace("="+ints2[1]); 15 | 16 | int[] ints3=new int[]{55,55,55}; 17 | ints3[1]=44; 18 | trace("="+ints3[1]); -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_7002_array.cls.txt: -------------------------------------------------------------------------------- 1 | //7001 array 2 | 3 | string[] ints2=new string[]{"55","55","55"}; 4 | long i =1; 5 | ints2[i]="44"; 6 | trace("="+ints2[i]); 7 | -------------------------------------------------------------------------------- /windows/CSLightTestor/code/_7003_array.cls.txt: -------------------------------------------------------------------------------- 1 | //7003 array 2 | 3 | Dictionary hip =new Dictionary(); 4 | hip[3]="ff"; 5 | hip[5]="fff"; 6 | hip[6]="ffff"; 7 | 8 | foreach(var i in hip) 9 | { 10 | Dictionary dic2 =new Dictionary(); 11 | dic2[3]="ff"; 12 | dic2[5]="fff"; 13 | dic2[6]="ffff"; 14 | foreach(var j in dic2) 15 | { 16 | break; 17 | } 18 | } 19 | 20 | return 1; 21 | 22 | -------------------------------------------------------------------------------- /windows/CSLightTestor/ssharp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightszero/cslightcore/28fb1118518066ee625736fe387e49997c494f68/windows/CSLightTestor/ssharp.dll --------------------------------------------------------------------------------