mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-20 13:50:56 +00:00
make addQuoted work on nimscript (#12717) [backport]
(cherry picked from commit 9ea55eccbb)
This commit is contained in:
committed by
narimiran
parent
3f6a08d5b0
commit
5129a1e88d
@@ -3870,6 +3870,12 @@ elif defined(JS):
|
||||
if x < y: 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.} =
|
||||
## A shorthand for ``echo(errormsg); quit(errorcode)``.
|
||||
@@ -4551,12 +4557,12 @@ type
|
||||
|
||||
when defined(genode):
|
||||
var componentConstructHook*: proc (env: GenodeEnv) {.nimcall.}
|
||||
## Hook into the Genode component bootstrap process.
|
||||
##
|
||||
## This hook is called after all globals are initialized.
|
||||
## When this hook is set the component will not automatically exit,
|
||||
## call ``quit`` explicitly to do so. This is the only available method
|
||||
## of accessing the initial Genode environment.
|
||||
## Hook into the Genode component bootstrap process.
|
||||
##
|
||||
## This hook is called after all globals are initialized.
|
||||
## When this hook is set the component will not automatically exit,
|
||||
## call ``quit`` explicitly to do so. This is the only available method
|
||||
## of accessing the initial Genode environment.
|
||||
|
||||
proc nim_component_construct(env: GenodeEnv) {.exportc.} =
|
||||
## Procedure called during ``Component::construct`` by the loader.
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
|
||||
import exposed
|
||||
|
||||
type NumberHolder = object
|
||||
ival: int
|
||||
fval: float
|
||||
|
||||
echo "top level statements are executed!"
|
||||
echo NumberHolder(ival: 10, fval: 2.0)
|
||||
|
||||
proc hostProgramRunsThis*(a, b: float): float =
|
||||
result = addFloats(a, b, 1.0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
discard """
|
||||
output: '''top level statements are executed!
|
||||
(ival: 10, fval: 2.0)
|
||||
2.0
|
||||
my secret
|
||||
11
|
||||
|
||||
Reference in New Issue
Block a user