make addQuoted work on nimscript (#12717) [backport]
This commit is contained in:
parent
0996eb174f
commit
9ea55eccbb
3 changed files with 12 additions and 5 deletions
|
|
@ -3827,11 +3827,6 @@ elif defined(JS):
|
||||||
proc deallocShared(p: pointer) = discard
|
proc deallocShared(p: pointer) = discard
|
||||||
proc reallocShared(p: pointer, newsize: Natural): pointer = discard
|
proc reallocShared(p: pointer, newsize: Natural): pointer = discard
|
||||||
|
|
||||||
proc addInt*(result: var string; x: int64) =
|
|
||||||
result.add $x
|
|
||||||
|
|
||||||
proc addFloat*(result: var string; x: float) =
|
|
||||||
result.add $x
|
|
||||||
|
|
||||||
when defined(JS) and not defined(nimscript):
|
when defined(JS) and not defined(nimscript):
|
||||||
include "system/jssys"
|
include "system/jssys"
|
||||||
|
|
@ -3842,6 +3837,12 @@ elif defined(JS):
|
||||||
if x < y: return -1
|
if x < y: return -1
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
when defined(JS) or defined(nimscript):
|
||||||
|
proc addInt*(result: var string; x: int64) =
|
||||||
|
result.add $x
|
||||||
|
|
||||||
|
proc addFloat*(result: var string; x: float) =
|
||||||
|
result.add $x
|
||||||
|
|
||||||
proc quit*(errormsg: string, errorcode = QuitFailure) {.noreturn.} =
|
proc quit*(errormsg: string, errorcode = QuitFailure) {.noreturn.} =
|
||||||
## A shorthand for ``echo(errormsg); quit(errorcode)``.
|
## A shorthand for ``echo(errormsg); quit(errorcode)``.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
|
|
||||||
import exposed
|
import exposed
|
||||||
|
|
||||||
|
type NumberHolder = object
|
||||||
|
ival: int
|
||||||
|
fval: float
|
||||||
|
|
||||||
echo "top level statements are executed!"
|
echo "top level statements are executed!"
|
||||||
|
echo NumberHolder(ival: 10, fval: 2.0)
|
||||||
|
|
||||||
proc hostProgramRunsThis*(a, b: float): float =
|
proc hostProgramRunsThis*(a, b: float): float =
|
||||||
result = addFloats(a, b, 1.0)
|
result = addFloats(a, b, 1.0)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''top level statements are executed!
|
output: '''top level statements are executed!
|
||||||
|
(ival: 10, fval: 2.0)
|
||||||
2.0
|
2.0
|
||||||
my secret
|
my secret
|
||||||
11
|
11
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue