diff --git a/changelog.md b/changelog.md index 12297de412..30d9c6f2ba 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/compiler/commands.nim b/compiler/commands.nim index 5b8f569ac3..20727966b4 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -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": diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 6841482cdb..da5267b93b 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -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 diff --git a/compiler/options.nim b/compiler/options.nim index d1428312bd..40e97e94fd 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -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** diff --git a/doc/advopt.txt b/doc/advopt.txt index 7d8d81c4f9..345e20fe40 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -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" diff --git a/doc/nimc.rst b/doc/nimc.rst index fe414b6432..b275438eaa 100644 --- a/doc/nimc.rst +++ b/doc/nimc.rst @@ -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:**