Skip to content

Commit 9eba9f1

Browse files
committed
Merge branch 'master' of https://github.com/yanghuan/CSharp.lua
2 parents 102b9b1 + 4e4a4da commit 9eba9f1

16 files changed

Lines changed: 498 additions & 85 deletions

‎CSharp.lua/CoreSystem.Lua/CoreSystem/String.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ function String.Split(this, strings, count, options)
360360
elseif type(strings) == "string" then
361361
strings = escape(strings)
362362
else
363-
string = schar(strings)
363+
strings = schar(strings)
364364
strings = escape(strings)
365365
end
366366

‎CSharp.lua/CoreSystem.Lua/Sample/test.lua‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ local function testNumCast()
204204
assert(System.toUInt64(-1) == 18446744073709551615)
205205
end
206206

207+
local function testSplit()
208+
local a = "a, b"
209+
local aa = a:Split(44 --[[',']])
210+
printList(aa)
211+
end
212+
207213
local function testConsole()
208214
print("enter your name")
209215
local name = System.Console.ReadLine()
@@ -231,6 +237,7 @@ test(testDelegate, "Delegate")
231237
test(testLinq, "Linq")
232238
test(testType, "Type")
233239
test(testNumCast, "NumCast")
240+
test(testSplit, "testSplit")
234241
--test(testConsole, "Console")
235242
--test(testIO, "IO")
236243

‎CSharp.lua/LuaAst/LuaLoopStatement.cs‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,18 @@ public LuaNumericalForStatementSyntax(
6868
LuaExpressionSyntax startExpression,
6969
LuaExpressionSyntax limitExpression,
7070
LuaExpressionSyntax stepExpression) {
71-
Identifier = identifier ?? throw new ArgumentNullException(nameof(identifier));
72-
StartExpression = startExpression ?? throw new ArgumentNullException(nameof(startExpression));
73-
LimitExpression = limitExpression ?? throw new ArgumentNullException(nameof(limitExpression));
71+
if (identifier == null) {
72+
throw new ArgumentNullException(nameof(identifier));
73+
}
74+
if (startExpression == null) {
75+
throw new ArgumentNullException(nameof(startExpression));
76+
}
77+
if (limitExpression == null) {
78+
throw new ArgumentNullException(nameof(limitExpression));
79+
}
80+
Identifier = identifier;
81+
StartExpression = startExpression;
82+
LimitExpression = limitExpression;
7483
StepExpression = stepExpression;
7584
}
7685

@@ -107,7 +116,10 @@ public sealed class LuaRepeatStatementSyntax : LuaStatementSyntax {
107116
public LuaBlockSyntax Body { get; } = new LuaBlockSyntax();
108117

109118
public LuaRepeatStatementSyntax(LuaExpressionSyntax condition) {
110-
Condition = condition ?? throw new ArgumentNullException(nameof(condition));
119+
if (condition == null) {
120+
throw new ArgumentNullException(nameof(condition));
121+
}
122+
Condition = condition;
111123
}
112124

113125
internal override void Render(LuaRenderer renderer) {

‎README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Options
7171
[CSharp.lua.1.0.0.0.zip](https://raw.githubusercontent.com/yanghuan/CSharp.lua/master/download/CSharp.lua.1.0.0.0.zip)
7272

7373
## CoreSystem.lua
74-
[CoreSystem.lua library](https://github.com/yanghuan/CSharp.lua/tree/master/CSharp.lua/CoreSystem.Lua/CoreSystem) that implements most of the [.net framework core classes](http://referencesource.microsoft.com/), including support for basic type, delegate, generic collection classes & linq. The Converted lua code, need to reference it
74+
[CoreSystem.lua library](https://github.com/yanghuan/CSharp.lua/tree/master/CSharp.lua/CoreSystem.Lua/CoreSystem) that implements most of the [.NET Framework core classes](http://referencesource.microsoft.com/), including support for basic type, delegate, generic collection classes & linq. The Converted lua code, need to reference it
7575
- Download [CoreSysrem.lua.zip](https://raw.githubusercontent.com/yanghuan/CSharp.lua/master/download/CoreSystem.lua.zip)
7676

7777
## Example
@@ -82,3 +82,9 @@ https://github.com/yanghuan/CSharp.lua/wiki
8282

8383
## *License*
8484
[Apache 2.0 license](https://raw.githubusercontent.com/yanghuan/CSharp.lua/master/LICENSE).
85+
86+
## *Acknowledgements*
87+
- [Bridge.NET](http://bridge.net/)
88+
- [WootzJs](https://github.com/kswoll/WootzJs)
89+
- [.NET referencesource](http://referencesource.microsoft.com/)
90+

‎test/self-compiling/selfout/LuaAst/LuaExpressionSyntax.lua‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
188188
return ")" --[[Tokens.CloseParentheses]]
189189
end
190190
Render = function (this, renderer)
191-
renderer:Render52(this)
191+
renderer:Render53(this)
192192
end
193193
return {
194194
__inherits__ = function (global)
@@ -212,7 +212,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
212212
CSharpLuaLuaAst.LuaExpressionSyntax.__ctor__(this)
213213
end
214214
Render = function (this, renderer)
215-
renderer:Render56(this)
215+
renderer:Render57(this)
216216
end
217217
return {
218218
__inherits__ = function (global)

‎test/self-compiling/selfout/LuaAst/LuaIfStatementSyntax.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
194194
Render = function (this, renderer)
195195
CheckHasCaseLabel(this)
196196
CheckHasDefaultLabel(this)
197-
renderer:Render46(this)
197+
renderer:Render47(this)
198198
end
199199
return {
200200
__inherits__ = function (global)

‎test/self-compiling/selfout/LuaAst/LuaLiteralExpressionSyntax.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
9999
setText(this, text)
100100
this.EqualsCount = equalsCount
101101
end
102-
getText, setText = System.property("Text")
102+
getText, setText = System.property("Text1")
103103
getOpenBracket = function (this)
104104
return "[" --[[Tokens.OpenBracket]]
105105
end

‎test/self-compiling/selfout/LuaAst/LuaLoopStatement.lua‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,52 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
5050
__ctor__ = __ctor__
5151
}
5252
end)
53+
namespace.class("LuaNumericalForStatementSyntax", function (namespace)
54+
local getForKeyword, getEqualsToken, Render, __init__, __ctor__
55+
__init__ = function (this)
56+
this.Body = System.create(CSharpLuaLuaAst.LuaBlockSyntax(), function (default)
57+
default.OpenBraceToken = "do" --[[Keyword.Do]]
58+
default.CloseBraceToken = "end" --[[Keyword.End]]
59+
end)
60+
end
61+
__ctor__ = function (this, identifier, startExpression, limitExpression, stepExpression)
62+
__init__(this)
63+
CSharpLuaLuaAst.LuaStatementSyntax.__ctor__(this)
64+
if identifier == nil then
65+
System.throw(System.ArgumentNullException("identifier" --[[nameof(identifier)]]))
66+
end
67+
if startExpression == nil then
68+
System.throw(System.ArgumentNullException("startExpression" --[[nameof(startExpression)]]))
69+
end
70+
if limitExpression == nil then
71+
System.throw(System.ArgumentNullException("limitExpression" --[[nameof(limitExpression)]]))
72+
end
73+
this.Identifier = identifier
74+
this.StartExpression = startExpression
75+
this.LimitExpression = limitExpression
76+
this.StepExpression = stepExpression
77+
end
78+
getForKeyword = function (this)
79+
return "for" --[[Keyword.For]]
80+
end
81+
getEqualsToken = function (this)
82+
return "=" --[[Tokens.Equals]]
83+
end
84+
Render = function (this, renderer)
85+
renderer:Render44(this)
86+
end
87+
return {
88+
__inherits__ = function (global)
89+
return {
90+
global.CSharpLua.LuaAst.LuaStatementSyntax
91+
}
92+
end,
93+
getForKeyword = getForKeyword,
94+
getEqualsToken = getEqualsToken,
95+
Render = Render,
96+
__ctor__ = __ctor__
97+
}
98+
end)
5399
namespace.class("LuaWhileStatementSyntax", function (namespace)
54100
local getWhileKeyword, Render, __init__, __ctor__
55101
__init__ = function (this)
@@ -70,7 +116,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
70116
return "while" --[[Keyword.While]]
71117
end
72118
Render = function (this, renderer)
73-
renderer:Render44(this)
119+
renderer:Render45(this)
74120
end
75121
return {
76122
__inherits__ = function (global)
@@ -103,7 +149,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
103149
return "until" --[[Keyword.Until]]
104150
end
105151
Render = function (this, renderer)
106-
renderer:Render45(this)
152+
renderer:Render46(this)
107153
end
108154
return {
109155
__inherits__ = function (global)

‎test/self-compiling/selfout/LuaAst/LuaMemberAccessExpressionSyntax.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
8484
return clone
8585
end
8686
Render = function (this, renderer)
87-
renderer:Render57(this)
87+
renderer:Render58(this)
8888
end
8989
return {
9090
__inherits__ = function (global)

‎test/self-compiling/selfout/LuaAst/LuaStatementSyntax.lua‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
155155
return "break" --[[Keyword.Break]]
156156
end
157157
Render = function (this, renderer)
158-
renderer:Render47(this)
158+
renderer:Render48(this)
159159
end
160160
return {
161161
__inherits__ = function (global)
@@ -183,7 +183,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
183183
return CSharpLuaLuaAst.LuaBreakStatementSyntax.Statement
184184
end
185185
Render = function (this, renderer)
186-
renderer:Render48(this)
186+
renderer:Render49(this)
187187
end
188188
return {
189189
__inherits__ = function (global)
@@ -208,7 +208,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
208208
this.Count = count
209209
end
210210
Render = function (this, renderer)
211-
renderer:Render49(this)
211+
renderer:Render50(this)
212212
end
213213
return {
214214
__inherits__ = function (global)
@@ -232,7 +232,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
232232
return "--" --[[Tokens.ShortComment]]
233233
end
234234
Render = function (this, renderer)
235-
renderer:Render50(this)
235+
renderer:Render51(this)
236236
end
237237
return {
238238
__inherits__ = function (global)
@@ -258,7 +258,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
258258
return "--]]" --[[Tokens.CloseLongComment]]
259259
end
260260
Render = function (this, renderer)
261-
renderer:Render51(this)
261+
renderer:Render52(this)
262262
end
263263
return {
264264
__inherits__ = function (global)
@@ -285,7 +285,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
285285
return "goto" --[[Keyword.Goto]]
286286
end
287287
Render = function (this, renderer)
288-
renderer:Render53(this)
288+
renderer:Render54(this)
289289
end
290290
return {
291291
__inherits__ = function (global)
@@ -311,7 +311,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
311311
this.GotoStatement = CSharpLuaLuaAst.LuaGotoStatement(identifier)
312312
end
313313
Render = function (this, renderer)
314-
renderer:Render55(this)
314+
renderer:Render56(this)
315315
end
316316
return {
317317
__inherits__ = function (global)
@@ -340,7 +340,7 @@ System.namespace("CSharpLua.LuaAst", function (namespace)
340340
return "::" --[[Tokens.Label]]
341341
end
342342
Render = function (this, renderer)
343-
renderer:Render54(this)
343+
renderer:Render55(this)
344344
end
345345
return {
346346
__inherits__ = function (global)

0 commit comments

Comments
 (0)