the new feature's name is hotCodeReloading

This commit is contained in:
Andreas Rumpf 2018-04-13 23:48:56 +02:00
commit 9e884c31dd
6 changed files with 14 additions and 13 deletions

View file

@ -67,7 +67,7 @@
order to support more complex computations at compile-time. order to support more complex computations at compile-time.
- Support for hot code reloading has been implemented for the JavaScript - 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. helper library such as LiveReload or BrowserSync.
- Added ``macros.getProjectPath`` and ``ospaths.putEnv`` procs to Nim's virtual - Added ``macros.getProjectPath`` and ``ospaths.putEnv`` procs to Nim's virtual

View file

@ -473,10 +473,10 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
processOnOffSwitch({optMemTracker}, arg, pass, info) processOnOffSwitch({optMemTracker}, arg, pass, info)
if optMemTracker in gOptions: defineSymbol("memtracker") if optMemTracker in gOptions: defineSymbol("memtracker")
else: undefSymbol("memtracker") else: undefSymbol("memtracker")
of "hotreloading": of "hotcodereloading":
processOnOffSwitch({optHotReloading}, arg, pass, info) processOnOffSwitch({optHotCodeReloading}, arg, pass, info)
if optHotReloading in gOptions: defineSymbol("hotreloading") if optHotCodeReloading in gOptions: defineSymbol("hotcodereloading")
else: undefSymbol("hotreloading") else: undefSymbol("hotcodereloading")
of "oldnewlines": of "oldnewlines":
case arg.normalize case arg.normalize
of "on": of "on":

View file

@ -255,7 +255,7 @@ proc mangleName(m: BModule, s: PSym): Rope =
inc i inc i
result = rope(x) result = rope(x)
if s.name.s != "this" and s.kind != skField: 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 # When hot reloading is enabled, we must ensure that the names
# of functions and types will be preserved across rebuilds: # of functions and types will be preserved across rebuilds:
add(result, idOrSig(s, m.module.name.s, m.sigConflicts)) add(result, idOrSig(s, m.module.name.s, m.sigConflicts))
@ -1584,7 +1584,7 @@ proc genVarInit(p: PProc, v: PSym, n: PNode) =
s: Rope s: Rope
varCode: string varCode: string
varName = mangleName(p.module, v) 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 v.constraint.isNil:
if useReloadingGuard: if useReloadingGuard:
@ -2208,7 +2208,7 @@ proc genProc(oldProc: PProc, prc: PSym): Rope =
else: else:
result = ~tnl result = ~tnl
if optHotReloading in gOptions: if optHotCodeReloading in gOptions:
# Here, we introduce thunks that create the equivalent of a jump table # Here, we introduce thunks that create the equivalent of a jump table
# for all global functions, because references to them may be stored # for all global functions, because references to them may be stored
# in JavaScript variables. The added indirection ensures that such # in JavaScript variables. The added indirection ensures that such

View file

@ -37,7 +37,7 @@ type # please make sure we have under 32 options
# evaluation # evaluation
optPatterns, # en/disable pattern matching optPatterns, # en/disable pattern matching
optMemTracker, optMemTracker,
optHotReloading optHotCodeReloading
TOptions* = set[TOption] TOptions* = set[TOption]
TGlobalOption* = enum # **keep binary compatible** TGlobalOption* = enum # **keep binary compatible**

View file

@ -60,7 +60,8 @@ Advanced options:
--implicitStatic:on|off turn implicit compile time evaluation on|off --implicitStatic:on|off turn implicit compile time evaluation on|off
--patterns:on|off turn pattern matching on|off --patterns:on|off turn pattern matching on|off
--memTracker:on|off turn memory tracker 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 --excessiveStackTrace:on|off
stack traces use full file paths stack traces use full file paths
--oldNewlines:on|off turn on|off the old behaviour of "\n" --oldNewlines:on|off turn on|off the old behaviour of "\n"

View file

@ -330,13 +330,13 @@ Hot code reloading
**Note:** At the moment hot code reloading is supported only in **Note:** At the moment hot code reloading is supported only in
JavaScript projects. 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 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, 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 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 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 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 .. code-block:: Nim
var settings = initTable[string, string]() var settings = initTable[string, string]()
@ -357,7 +357,7 @@ re-assign a value anywhere within the top-level code:
resetProgramState() resetProgramState()
**Known limitations:** In the JavaScript target, global variables using the **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. initialization with a `once` block to work-around this.
**Usage in JavaScript projects:** **Usage in JavaScript projects:**