fixes JS semicolon omissions (#23896)

This commit is contained in:
ringabout
2024-07-27 02:45:52 +08:00
committed by GitHub
parent bd063113ec
commit 39629a1adc
7 changed files with 11 additions and 11 deletions

View File

@@ -243,7 +243,7 @@ since (1, 5, 1):
else:
type A = impl(onSuccess(default(T)))
var ret: A
{.emit: "`ret` = `future`.then(`onSuccess`, `onReject`)".}
{.emit: "`ret` = `future`.then(`onSuccess`, `onReject`);".}
return ret
proc catch*[T](future: Future[T], onReject: OnReject): Future[void] =
@@ -266,4 +266,4 @@ since (1, 5, 1):
discard main()
{.emit: "`result` = `future`.catch(`onReject`)".}
{.emit: "`result` = `future`.catch(`onReject`);".}

View File

@@ -190,7 +190,7 @@ proc hashData*(data: pointer, size: int): Hash =
var h: Hash = 0
when defined(js):
var p: cstring
{.emit: """`p` = `Data`""".}
{.emit: """`p` = `Data`;""".}
else:
var p = cast[cstring](data)
var i = 0

View File

@@ -1007,7 +1007,7 @@ when defined(js):
{.emit: """for (var property in `x`) {
if (`x`.hasOwnProperty(property)) {
""".}
var nimProperty: cstring
var nimValue: JsObject
{.emit: "`nimProperty` = property; `nimValue` = `x`[property];".}

View File

@@ -225,7 +225,7 @@ when defined(js):
return (num & ~(1 << bitPos)) | (bitVal << bitPos);
}
`b`[1] = updateBit(`b`[1], 31, `sgn`);
`result` = `a`[0]
`result` = `a`[0];
""".}
proc signbit*(x: SomeFloat): bool {.inline, since: (1, 5, 1).} =

View File

@@ -109,11 +109,11 @@ when defined(js):
return n.toString().match(/^-?\d+$/);
}
if (Number.isSafeInteger(`a`))
`result` = `a` === 0 && 1 / `a` < 0 ? "-0.0" : `a`+".0"
`result` = `a` === 0 && 1 / `a` < 0 ? "-0.0" : `a`+".0";
else {
`result` = `a`+""
`result` = `a`+"";
if(nimOnlyDigitsOrMinus(`result`)){
`result` = `a`+".0"
`result` = `a`+".0";
}
}
""".}

View File

@@ -324,7 +324,7 @@ proc `==`*[T](x, y: seq[T]): bool {.noSideEffect.} =
return true
else:
var sameObject = false
{.emit: """`sameObject` = `x` === `y`""".}
{.emit: """`sameObject` = `x` === `y`;""".}
if sameObject: return true
if x.len != y.len:

View File

@@ -29,7 +29,7 @@ proc reprBool(x: bool): string {.compilerRtl.} =
proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} =
var tmp: bool
let item = typ.node.sons[e]
{.emit: "`tmp` = `item` !== undefined".}
{.emit: "`tmp` = `item` !== undefined;".}
if tmp:
result = makeNimstrLit(item.name)
else:
@@ -136,7 +136,7 @@ proc reprArray(a: pointer, typ: PNimType,
add(result, "]")
proc isPointedToNil(p: pointer): bool =
{. emit: "if (`p` === null) {`result` = true};\n" .}
{. emit: "if (`p` === null) {`result` = true;}\n" .}
proc reprRef(result: var string, p: pointer, typ: PNimType,
cl: var ReprClosure) =