Skip to content

Commit 8bd64a2

Browse files
committed
typescript: 4.7.4 → 5.5.4
1 parent f79391c commit 8bd64a2

File tree

7 files changed

+35
-28
lines changed

7 files changed

+35
-28
lines changed

Diff for: NOTICE

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ under the licensing terms detailed in LICENSE:
5757
* Bach Le <bach@bullno1.com>
5858
* Xinquan Xu <xinquan0203@163.com>
5959
* Matt Johnson-Pint <mattjohnsonpint@gmail.com>
60+
* Fabián Heredia Montiel <fabianhjr@users.noreply.github.com>
6061

6162
Portions of this software are derived from third-party works licensed under
6263
the following terms:

Diff for: package-lock.json

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"esbuild": "^0.19.4",
3737
"eslint": "^8.33.0",
3838
"glob": "^10.3.0",
39-
"typescript": "~4.7.4"
39+
"typescript": "^5.5.4"
4040
},
4141
"type": "module",
4242
"exports": {

Diff for: src/builtins.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ function builtin_max(ctx: BuiltinFunctionContext): ExpressionRef {
16231623
} else {
16241624
arg1 = compiler.compileExpression(operands[1], type, Constraints.ConvImplicit | Constraints.MustWrap);
16251625
}
1626-
let op: BinaryOp = -1;
1626+
let op: BinaryOp | null = null;
16271627
switch (type.kind) {
16281628
case TypeKind.I8:
16291629
case TypeKind.I16:
@@ -1639,14 +1639,14 @@ function builtin_max(ctx: BuiltinFunctionContext): ExpressionRef {
16391639
case TypeKind.F32: return module.binary(BinaryOp.MaxF32, arg0, arg1);
16401640
case TypeKind.F64: return module.binary(BinaryOp.MaxF64, arg0, arg1);
16411641
}
1642-
if (op as i32 != -1) {
1642+
if (op) {
16431643
let flow = compiler.currentFlow;
16441644
let typeRef = type.toRef();
16451645
let temp1 = flow.getTempLocal(type);
16461646
flow.setLocalFlag(temp1.index, LocalFlags.Wrapped);
16471647
let temp2 = flow.getTempLocal(type);
16481648
flow.setLocalFlag(temp2.index, LocalFlags.Wrapped);
1649-
let ret = module.select(
1649+
return module.select(
16501650
module.local_tee(temp1.index, arg0, false), // numeric
16511651
module.local_tee(temp2.index, arg1, false), // numeric
16521652
module.binary(op,
@@ -1655,7 +1655,6 @@ function builtin_max(ctx: BuiltinFunctionContext): ExpressionRef {
16551655
),
16561656
typeRef
16571657
);
1658-
return ret;
16591658
}
16601659
}
16611660
compiler.error(
@@ -1691,7 +1690,7 @@ function builtin_min(ctx: BuiltinFunctionContext): ExpressionRef {
16911690
} else {
16921691
arg1 = compiler.compileExpression(operands[1], type, Constraints.ConvImplicit | Constraints.MustWrap);
16931692
}
1694-
let op: BinaryOp = -1;
1693+
let op: BinaryOp | null = null;
16951694
switch (type.kind) {
16961695
case TypeKind.I8:
16971696
case TypeKind.I16:
@@ -1707,14 +1706,14 @@ function builtin_min(ctx: BuiltinFunctionContext): ExpressionRef {
17071706
case TypeKind.F32: return module.binary(BinaryOp.MinF32, arg0, arg1);
17081707
case TypeKind.F64: return module.binary(BinaryOp.MinF64, arg0, arg1);
17091708
}
1710-
if (op as i32 != -1) {
1709+
if (op) {
17111710
let flow = compiler.currentFlow;
17121711
let typeRef = type.toRef();
17131712
let temp1 = flow.getTempLocal(type);
17141713
flow.setLocalFlag(temp1.index, LocalFlags.Wrapped);
17151714
let temp2 = flow.getTempLocal(type);
17161715
flow.setLocalFlag(temp2.index, LocalFlags.Wrapped);
1717-
let ret = module.select(
1716+
return module.select(
17181717
module.local_tee(temp1.index, arg0, false), // numeric
17191718
module.local_tee(temp2.index, arg1, false), // numeric
17201719
module.binary(op,
@@ -1723,7 +1722,6 @@ function builtin_min(ctx: BuiltinFunctionContext): ExpressionRef {
17231722
),
17241723
typeRef
17251724
);
1726-
return ret;
17271725
}
17281726
}
17291727
compiler.error(

Diff for: src/tokenizer.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,10 @@ export class Tokenizer extends DiagnosticEmitter {
463463
end: i32 = 0;
464464

465465
pos: i32 = 0;
466-
token: Token = -1;
466+
token: Token | null = null;
467467
tokenPos: i32 = 0;
468468

469-
nextToken: Token = -1;
469+
nextToken: Token | null = null;
470470
nextTokenPos: i32 = 0;
471471
nextTokenOnNewLine: OnNewLine = OnNewLine.Unknown;
472472

@@ -969,21 +969,26 @@ export class Tokenizer extends DiagnosticEmitter {
969969
identifierHandling: IdentifierHandling = IdentifierHandling.Default,
970970
maxCompoundLength: i32 = i32.MAX_VALUE
971971
): Token {
972-
let nextToken = this.nextToken;
973-
if (nextToken < 0) {
972+
if (this.nextToken) {
973+
return this.nextToken;
974+
} else {
975+
let nextToken: Token;
974976
let posBefore = this.pos;
975977
let tokenBefore = this.token;
976978
let tokenPosBefore = this.tokenPos;
977-
do nextToken = this.unsafeNext(identifierHandling, maxCompoundLength);
979+
980+
do
981+
nextToken = this.unsafeNext(identifierHandling, maxCompoundLength);
978982
while (nextToken == Token.Invalid);
983+
979984
this.nextToken = nextToken;
980985
this.nextTokenPos = this.tokenPos;
981986
this.nextTokenOnNewLine = OnNewLine.Unknown;
982987
this.pos = posBefore;
983988
this.token = tokenBefore;
984989
this.tokenPos = tokenPosBefore;
990+
return nextToken;
985991
}
986-
return nextToken;
987992
}
988993

989994
peekOnNewLine(): bool {
@@ -1032,13 +1037,15 @@ export class Tokenizer extends DiagnosticEmitter {
10321037

10331038
mark(): State {
10341039
let state = reusableState;
1035-
if (state) {
1040+
if (state && this.token) {
10361041
reusableState = null;
10371042
state.pos = this.pos;
10381043
state.token = this.token;
10391044
state.tokenPos = this.tokenPos;
1040-
} else {
1045+
} else if (this.token) {
10411046
state = new State(this.pos, this.token, this.tokenPos);
1047+
} else {
1048+
state = new State(this.pos, Token.Invalid, this.tokenPos);
10421049
}
10431050
return state;
10441051
}
@@ -1055,7 +1062,7 @@ export class Tokenizer extends DiagnosticEmitter {
10551062
}
10561063

10571064
clearNextToken(): void {
1058-
this.nextToken = -1;
1065+
this.nextToken = null;
10591066
this.nextTokenPos = 0;
10601067
this.nextTokenOnNewLine = OnNewLine.Unknown;
10611068
}

Diff for: tests/compiler/std/string-encoding.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ testUTF8Decode();
118118
function testUTF8DecodeNullTerminated(): void {
119119
var buf = String.UTF8.encode(str, true);
120120
assert(String.UTF8.decode(buf, true) == str);
121-
var str2 = "123\0456";
121+
var str2 = "123\x00456";
122122
assert(String.UTF8.byteLength(str2, true) == 4);
123123
var buf2 = String.UTF8.encode(str2, true);
124124
assert(buf2.byteLength == 4);

Diff for: tests/compiler/std/string.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ assert(String.fromCharCode(65600) == "@");
2727
assert(String.fromCharCode(54) == "6");
2828
assert(String.fromCharCode(0x10000 + 54) == "6");
2929
assert(String.fromCharCode(0xD800, 0xDF00) == "𐌀");
30-
assert(String.fromCharCodes([0, 54]) == "\06");
30+
assert(String.fromCharCodes([0, 54]) == "\x006");
3131
assert(String.fromCharCodes([65, 66, 67]) == "ABC");
3232
assert(String.fromCharCodes([0xD834, 0xDF06, 0x61, 0xD834, 0xDF07]) == "\uD834\uDF06a\uD834\uDF07");
3333

0 commit comments

Comments
 (0)