mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-20 16:01:29 +00:00
the new feature's name is hotCodeReloading
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
order to support more complex computations at compile-time.
|
||||
|
||||
- Support for hot code reloading has been implemented for the JavaScript
|
||||
target. To use it, compile your code with `--hotReloading:on` and use a
|
||||
target. To use it, compile your code with `--hotCodeReloading:on` and use a
|
||||
helper library such as LiveReload or BrowserSync.
|
||||
|
||||
- Added ``macros.getProjectPath`` and ``ospaths.putEnv`` procs to Nim's virtual
|
||||
|
||||
@@ -473,10 +473,10 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||
processOnOffSwitch({optMemTracker}, arg, pass, info)
|
||||
if optMemTracker in gOptions: defineSymbol("memtracker")
|
||||
else: undefSymbol("memtracker")
|
||||
of "hotreloading":
|
||||
processOnOffSwitch({optHotReloading}, arg, pass, info)
|
||||
if optHotReloading in gOptions: defineSymbol("hotreloading")
|
||||
else: undefSymbol("hotreloading")
|
||||
of "hotcodereloading":
|
||||
processOnOffSwitch({optHotCodeReloading}, arg, pass, info)
|
||||
if optHotCodeReloading in gOptions: defineSymbol("hotcodereloading")
|
||||
else: undefSymbol("hotcodereloading")
|
||||
of "oldnewlines":
|
||||
case arg.normalize
|
||||
of "on":
|
||||
|
||||
@@ -255,7 +255,7 @@ proc mangleName(m: BModule, s: PSym): Rope =
|
||||
inc i
|
||||
result = rope(x)
|
||||
if s.name.s != "this" and s.kind != skField:
|
||||
if optHotReloading in gOptions:
|
||||
if optHotCodeReloading in gOptions:
|
||||
# When hot reloading is enabled, we must ensure that the names
|
||||
# of functions and types will be preserved across rebuilds:
|
||||
add(result, idOrSig(s, m.module.name.s, m.sigConflicts))
|
||||
@@ -1584,7 +1584,7 @@ proc genVarInit(p: PProc, v: PSym, n: PNode) =
|
||||
s: Rope
|
||||
varCode: string
|
||||
varName = mangleName(p.module, v)
|
||||
useReloadingGuard = sfGlobal in v.flags and optHotReloading in gOptions
|
||||
useReloadingGuard = sfGlobal in v.flags and optHotCodeReloading in gOptions
|
||||
|
||||
if v.constraint.isNil:
|
||||
if useReloadingGuard:
|
||||
@@ -2208,7 +2208,7 @@ proc genProc(oldProc: PProc, prc: PSym): Rope =
|
||||
else:
|
||||
result = ~tnl
|
||||
|
||||
if optHotReloading in gOptions:
|
||||
if optHotCodeReloading in gOptions:
|
||||
# Here, we introduce thunks that create the equivalent of a jump table
|
||||
# for all global functions, because references to them may be stored
|
||||
# in JavaScript variables. The added indirection ensures that such
|
||||
|
||||
@@ -37,7 +37,7 @@ type # please make sure we have under 32 options
|
||||
# evaluation
|
||||
optPatterns, # en/disable pattern matching
|
||||
optMemTracker,
|
||||
optHotReloading
|
||||
optHotCodeReloading
|
||||
|
||||
TOptions* = set[TOption]
|
||||
TGlobalOption* = enum # **keep binary compatible**
|
||||
|
||||
@@ -60,7 +60,8 @@ Advanced options:
|
||||
--implicitStatic:on|off turn implicit compile time evaluation on|off
|
||||
--patterns:on|off turn pattern matching on|off
|
||||
--memTracker:on|off turn memory tracker on|off
|
||||
--hotReloading:on|off turn support for hot code reloading on|off
|
||||
--hotCodeReloading:on|off
|
||||
turn support for hot code reloading on|off
|
||||
--excessiveStackTrace:on|off
|
||||
stack traces use full file paths
|
||||
--oldNewlines:on|off turn on|off the old behaviour of "\n"
|
||||
|
||||
@@ -330,13 +330,13 @@ Hot code reloading
|
||||
**Note:** At the moment hot code reloading is supported only in
|
||||
JavaScript projects.
|
||||
|
||||
The `hotReloading` option enables special compilation mode where changes in
|
||||
The `hotCodeReloading`:idx: option enables special compilation mode where changes in
|
||||
the code can be applied automatically to a running program. The code reloading
|
||||
happens at the granularity of an individual module. When a module is reloaded,
|
||||
Nim will preserve the state of all global variables which are initialized with
|
||||
a standard variable declaration in the code. All other top level code will be
|
||||
executed repeatedly on each reload. If you want to prevent this behavior, you
|
||||
can guard a block of code with the `once` construct:
|
||||
can guard a block of code with the ``once`` construct:
|
||||
|
||||
.. code-block:: Nim
|
||||
var settings = initTable[string, string]()
|
||||
@@ -357,7 +357,7 @@ re-assign a value anywhere within the top-level code:
|
||||
resetProgramState()
|
||||
|
||||
**Known limitations:** In the JavaScript target, global variables using the
|
||||
`codegenDecl` pragma will be re-initialized on each reload. Please guard the
|
||||
``codegenDecl`` pragma will be re-initialized on each reload. Please guard the
|
||||
initialization with a `once` block to work-around this.
|
||||
|
||||
**Usage in JavaScript projects:**
|
||||
|
||||
Reference in New Issue
Block a user