diff options
Diffstat (limited to 'lib/system.nim')
-rw-r--r-- | lib/system.nim | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/lib/system.nim b/lib/system.nim index 4ff1f1577..b2d19a885 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -77,17 +77,6 @@ type TNumber* = TInteger|TReal ## type class matching all number types - -type - ## helper types for writing implicitly generic procs - T1* = expr - T2* = expr - T3* = expr - T4* = expr - T5* = expr - type1* = typedesc - type2* = typedesc - type3* = typedesc proc defined*(x: expr): bool {.magic: "Defined", noSideEffect.} ## Special compile-time procedure that checks whether `x` is @@ -860,7 +849,7 @@ const ## a string that describes the application type. Possible values: ## "console", "gui", "lib". - seqShallowFlag = 1 shl (sizeof(int)*8-1) + seqShallowFlag = low(int) proc compileOption*(option: string): bool {. magic: "CompileOption", noSideEffect.} @@ -1009,6 +998,13 @@ type ## compiler supports. Currently this is ``float64``, but it is ## platform-dependant in general. +when defined(windows): + type clong* {.importc: "long", nodecl.} = int32 + ## This is the same as the type ``long`` in *C*. +else: + type clong* {.importc: "long", nodecl.} = int + ## This is the same as the type ``long`` in *C*. + type # these work for most platforms: cchar* {.importc: "char", nodecl.} = char ## This is the same as the type ``char`` in *C*. @@ -1020,8 +1016,6 @@ type # these work for most platforms: ## This is the same as the type ``int`` in *C*. csize* {.importc: "size_t", nodecl.} = int ## This is the same as the type ``size_t`` in *C*. - clong* {.importc: "long", nodecl.} = int - ## This is the same as the type ``long`` in *C*. clonglong* {.importc: "long long", nodecl.} = int64 ## This is the same as the type ``long long`` in *C*. cfloat* {.importc: "float", nodecl.} = float32 @@ -1797,7 +1791,7 @@ when defined(JS): elif hostOS != "standalone": {.push stack_trace:off, profiler:off.} - proc add*(x: var string, y: cstring) {.noStackFrame.} = + proc add*(x: var string, y: cstring) = var i = 0 while y[i] != '\0': add(x, y[i]) @@ -2509,7 +2503,7 @@ proc astToStr*[T](x: T): string {.magic: "AstToStr", noSideEffect.} ## converts the AST of `x` into a string representation. This is very useful ## for debugging. -proc InstantiationInfo*(index = -1, fullPaths = false): tuple[ +proc instantiationInfo*(index = -1, fullPaths = false): tuple[ filename: string, line: int] {. magic: "InstantiationInfo", noSideEffect.} ## provides access to the compiler's instantiation stack line information. ## @@ -2540,7 +2534,7 @@ proc InstantiationInfo*(index = -1, fullPaths = false): tuple[ ## testException(EInvalidIndex, tester(1)) ## # --> Test failure at example.nim:20 with 'tester(1)' -template CurrentSourcePath*: string = InstantiationInfo(-1, true).filename +template currentSourcePath*: string = instantiationInfo(-1, true).filename ## returns the full file-system path of the current source proc raiseAssert*(msg: string) {.noinline.} = @@ -2560,7 +2554,7 @@ template assert*(cond: bool, msg = "") = ## raises an ``EAssertionFailure`` exception. However, the compiler may ## not generate any code at all for ``assert`` if it is advised to do so. ## Use ``assert`` for debugging purposes only. - bind InstantiationInfo, hiddenRaiseAssert + bind instantiationInfo, hiddenRaiseAssert when compileOption("assertions"): {.line.}: if not cond: @@ -2569,8 +2563,8 @@ template assert*(cond: bool, msg = "") = template doAssert*(cond: bool, msg = "") = ## same as `assert` but is always turned on and not affected by the ## ``--assertions`` command line switch. - bind InstantiationInfo - {.line: InstantiationInfo().}: + bind instantiationInfo + {.line: instantiationInfo().}: if not cond: raiseAssert(astToStr(cond) & ' ' & msg) |