Skip to content

Commit 98baeeb

Browse files
author
Alex D
committed
fixes to support JSLib
1 parent 2e6d01e commit 98baeeb

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

experiments/jslib/Array.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,15 @@ module JS {
329329
return retArr;
330330
}
331331

332-
public slice(begin?: number, end?: number): T[] {
332+
public slice(begin?: number, _end?: number): T[] {
333333
const retArr = new Array<T>();
334334

335335
const from = begin || 0;
336336
if (from < 0) {
337337
throw new Error(`Index out of bounds: ${from}`);
338338
}
339339

340-
let to = end || this.length;
340+
let to = _end || this.length;
341341
if (to > this.length) {
342342
to = this.length;
343343
}

experiments/jslib/String.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ module JS {
6565
return string.sub(this, (begin || 0) + 1, (begin || 0) + (len || string.len(this)));
6666
}
6767

68-
public static substring(this: string, begin?: number, end?: number): string {
69-
if (begin == end && end == null || begin === end) {
68+
public static substring(this: string, begin?: number, _end?: number): string {
69+
if (begin == _end && _end == null || begin === _end) {
7070
return '';
7171
}
7272

73-
return string.sub(this, (begin || 0) + 1, end != undefined ? end : null);
73+
return string.sub(this, (begin || 0) + 1, _end != undefined ? _end : null);
7474
}
7575

76-
public static slice(this: string, start?: number, end?: number): string {
77-
return string.sub(this, (start || 0) + 1, end != undefined ? end : null);
76+
public static slice(this: string, start?: number, _end?: number): string {
77+
return string.sub(this, (start || 0) + 1, _end != undefined ? _end : null);
7878
}
7979

8080
public static indexOf(this: string, pattern: string, begin?: number): number {
@@ -175,9 +175,9 @@ module JS {
175175
return new String(this.constString.substr(begin, len));
176176
}
177177

178-
public substring(begin?: number, end?: number): String {
178+
public substring(begin?: number, _end?: number): String {
179179
// tslint:disable-next-line:no-construct
180-
return new String(this.constString.substring(begin, end));
180+
return new String(this.constString.substring(begin, _end));
181181
}
182182

183183
public indexOf(pattern: string, begin?: number): number {
@@ -188,9 +188,9 @@ module JS {
188188
return this.constString.split(separator);
189189
}
190190

191-
public slice(start?: number, end?: number): String {
191+
public slice(start?: number, _end?: number): String {
192192
// tslint:disable-next-line:no-construct
193-
return new String(this.constString.substring(start, end));
193+
return new String(this.constString.substring(start, _end));
194194
}
195195

196196
public toLowerCase(): String {

src/emitterlua.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class EmitterLua {
5050
this.ops[ts.SyntaxKind.PlusToken] = '+';
5151
this.ops[ts.SyntaxKind.MinusToken] = '-';
5252
this.ops[ts.SyntaxKind.AsteriskToken] = '*';
53-
this.ops[ts.SyntaxKind.AsteriskAsteriskToken] = '**';
53+
this.ops[ts.SyntaxKind.AsteriskAsteriskToken] = '^';
5454
this.ops[ts.SyntaxKind.PercentToken] = '%';
5555
this.ops[ts.SyntaxKind.CaretToken] = '~';
5656
this.ops[ts.SyntaxKind.SlashToken] = '/';
@@ -2440,7 +2440,7 @@ export class EmitterLua {
24402440
}
24412441

24422442
private processStringLiteral(node: ts.StringLiteral): void {
2443-
this.functionContext.textCode.push("\"" + node.text.replace(/(\r?\n)/g, "\\$1") + "\"");
2443+
this.functionContext.textCode.push("\"" + node.text.replace(/\\/g, "\\\\").replace(/(\r?\n)/g, "\\$1") + "\"");
24442444
}
24452445

24462446
private processNoSubstitutionTemplateLiteral(node: ts.NoSubstitutionTemplateLiteral): void {

0 commit comments

Comments
 (0)