Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefine paramCount & paramStr in nimscript.nim for *.nims #12860

Merged
merged 4 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

- Added high-level `asyncnet.sendTo` and `asyncnet.recvFrom`. UDP functionality.

- `paramCount` & `paramStr` are now defined in os.nim instead of nimscript.nim for nimscript/nimble.
- `dollars.$` now works for unsigned ints with `nim js`

## Language changes
Expand Down
10 changes: 6 additions & 4 deletions compiler/scriptconfig.nim
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
setResult(a, options.existsConfigVar(conf, a.getString 0))
cbconf nimcacheDir:
setResult(a, options.getNimcacheDir(conf).string)
cbconf paramStr:
setResult(a, os.paramStr(int a.getInt 0))
cbconf paramCount:
setResult(a, os.paramCount())
result.registerCallback "stdlib.os." & astToStr(paramStr),
proc (a: VmArgs) =
setResult(a, os.paramStr(int a.getInt 0))
result.registerCallback "stdlib.os." & astToStr(paramCount),
proc (a: VmArgs) =
setResult(a, os.paramCount())
cbconf cmpIgnoreStyle:
setResult(a, strutils.cmpIgnoreStyle(a.getString 0, a.getString 1))
cbconf cmpIgnoreCase:
Expand Down
2 changes: 1 addition & 1 deletion koch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

const
NimbleStableCommit = "4007b2a778429a978e12307bf13a038029b4c4d9" # master
NimbleStableCommit = "6f2b1ace922e565f7f48a69648e16a002a5d15e3" # master

when not defined(windows):
const
Expand Down
18 changes: 17 additions & 1 deletion lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2707,7 +2707,23 @@ when defined(nimdoc):
## else:
## # Do something else!

elif defined(nintendoswitch) or weirdTarget:
elif defined(nimscript):
proc paramStr*(i: int): string =
## Retrieves the ``i``'th command line parameter.
discard

proc paramCount*(): int =
## Retrieves the number of command line parameters.
discard

elif defined(js):
proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} =
raise newException(OSError, "paramStr is not implemented on JavaScript")

proc paramCount*(): int {.tags: [ReadIOEffect].} =
raise newException(OSError, "paramCount is not implemented on JavaScript")

elif defined(nintendoswitch):
proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} =
raise newException(OSError, "paramStr is not implemented on Nintendo Switch")

Expand Down
8 changes: 0 additions & 8 deletions lib/system/nimscript.nim
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ proc rawExec(cmd: string): int {.tags: [ExecIOEffect], raises: [OSError].} =
proc warningImpl(arg, orig: string) = discard
proc hintImpl(arg, orig: string) = discard

proc paramStr*(i: int): string =
## Retrieves the ``i``'th command line parameter.
builtin

proc paramCount*(): int =
## Retrieves the number of command line parameters.
builtin

proc switch*(key: string, val="") =
## Sets a Nim compiler command line switch, for
## example ``switch("checks", "on")``.
Expand Down