include system/inclrtl when defined(nimPreviewSlimSystem): import std/formatfloat proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".} ## imported from typetraits proc distinctBase(T: typedesc, recursive: static bool = true): typedesc {.magic: "TypeTrait".} ## imported from typetraits proc rangeBase(T: typedesc): typedesc {.magic: "TypeTrait".} # skip one level of range; return the base type of a range type proc repr*(x: NimNode): string {.magic: "Repr", noSideEffect.} proc repr*(x: int): string = ## Same as $x $x proc repr*(x: int64): string = ## Same as $x $x proc repr*(x: uint64): string {.noSideEffect.} = ## Same as $x $x proc repr*(x: float): string = ## Same as $x $x proc repr*(x: bool): string {.magic: "BoolToStr", noSideEffect.} ## repr for a boolean argument. Returns `x` ## converted to the string "false" or "true". proc repr*(x: char): string {.noSideEffect, raises: [].} = ## repr for a character argument. Returns `x` ## converted to an escaped string. ## ## ```Nim ## assert repr('c') == "'c'" ## ``` result = "'" # Elides string creations if not needed if x in {'\\', '\0'..'\31', '\127'..'\255'}: result.add '\\' if x in {'\0'..'\31', '\127'..'\255'}: result.add $x.uint8 else: result.add x result.add '\'' proc repr*(x: string | cstring): string {.noSideEffect, raises: [].} = ## repr for a string argument. Returns `x` ## converted to a quoted and escaped string. result = "\"" for i in 0..