This commit is contained in:
parent
f94ec363ab
commit
bab5e30972
6 changed files with 25 additions and 17 deletions
|
|
@ -425,7 +425,7 @@ proc value(this: var DebugPrinter; value: string) =
|
||||||
proc value(this: var DebugPrinter; value: BiggestInt) =
|
proc value(this: var DebugPrinter; value: BiggestInt) =
|
||||||
if this.useColor:
|
if this.useColor:
|
||||||
this.res.add numberStyle
|
this.res.add numberStyle
|
||||||
this.res.add value
|
this.res.addInt value
|
||||||
if this.useColor:
|
if this.useColor:
|
||||||
this.res.add resetStyle
|
this.res.add resetStyle
|
||||||
|
|
||||||
|
|
@ -460,7 +460,7 @@ template earlyExit(this: var DebugPrinter; n: PType | PNode | PSym) =
|
||||||
if this.useColor:
|
if this.useColor:
|
||||||
this.res.add backrefStyle
|
this.res.add backrefStyle
|
||||||
this.res.add "<defined "
|
this.res.add "<defined "
|
||||||
this.res.add(this.currentLine - index)
|
this.res.addInt(this.currentLine - index)
|
||||||
this.res.add " lines upwards>"
|
this.res.add " lines upwards>"
|
||||||
if this.useColor:
|
if this.useColor:
|
||||||
this.res.add resetStyle
|
this.res.add resetStyle
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ proc cgFormatValue(result: var string; value: string): void =
|
||||||
result.add value
|
result.add value
|
||||||
|
|
||||||
proc cgFormatValue(result: var string; value: BiggestInt): void =
|
proc cgFormatValue(result: var string; value: BiggestInt): void =
|
||||||
result.add value
|
result.addInt value
|
||||||
|
|
||||||
# TODO: please document
|
# TODO: please document
|
||||||
macro ropecg(m: BModule, frmt: static[FormatStr], args: untyped): Rope =
|
macro ropecg(m: BModule, frmt: static[FormatStr], args: untyped): Rope =
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ proc codeListing(c: ControlFlowGraph, result: var string, start=0; last = -1) =
|
||||||
result.add renderTree(c[i].n)
|
result.add renderTree(c[i].n)
|
||||||
of goto, fork, join:
|
of goto, fork, join:
|
||||||
result.add "L"
|
result.add "L"
|
||||||
result.add c[i].dest+i
|
result.addInt c[i].dest+i
|
||||||
result.add("\t#")
|
result.add("\t#")
|
||||||
result.add(debugInfo(c[i].n.info))
|
result.add(debugInfo(c[i].n.info))
|
||||||
result.add("\n")
|
result.add("\n")
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ type
|
||||||
|
|
||||||
proc doWrite(f: var NdiFile; s: PSym; conf: ConfigRef) =
|
proc doWrite(f: var NdiFile; s: PSym; conf: ConfigRef) =
|
||||||
f.buf.setLen 0
|
f.buf.setLen 0
|
||||||
f.buf.add s.info.line.int
|
f.buf.addInt s.info.line.int
|
||||||
f.buf.add "\t"
|
f.buf.add "\t"
|
||||||
f.buf.add s.info.col.int
|
f.buf.addInt s.info.col.int
|
||||||
f.f.write(s.name.s, "\t")
|
f.f.write(s.name.s, "\t")
|
||||||
f.f.writeRope(s.loc.r)
|
f.f.writeRope(s.loc.r)
|
||||||
f.f.writeLine("\t", toFullPath(conf, s.info), "\t", f.buf)
|
f.f.writeLine("\t", toFullPath(conf, s.info), "\t", f.buf)
|
||||||
|
|
|
||||||
|
|
@ -692,12 +692,12 @@ proc toPretty(result: var string, node: JsonNode, indent = 2, ml = true,
|
||||||
of JInt:
|
of JInt:
|
||||||
if lstArr: result.indent(currIndent)
|
if lstArr: result.indent(currIndent)
|
||||||
when defined(js): result.add($node.num)
|
when defined(js): result.add($node.num)
|
||||||
else: result.add(node.num)
|
else: result.addInt(node.num)
|
||||||
of JFloat:
|
of JFloat:
|
||||||
if lstArr: result.indent(currIndent)
|
if lstArr: result.indent(currIndent)
|
||||||
# Fixme: implement new system.add ops for the JS target
|
# Fixme: implement new system.add ops for the JS target
|
||||||
when defined(js): result.add($node.fnum)
|
when defined(js): result.add($node.fnum)
|
||||||
else: result.add(node.fnum)
|
else: result.addFloat(node.fnum)
|
||||||
of JBool:
|
of JBool:
|
||||||
if lstArr: result.indent(currIndent)
|
if lstArr: result.indent(currIndent)
|
||||||
result.add(if node.bval: "true" else: "false")
|
result.add(if node.bval: "true" else: "false")
|
||||||
|
|
@ -773,10 +773,10 @@ proc toUgly*(result: var string, node: JsonNode) =
|
||||||
node.str.escapeJson(result)
|
node.str.escapeJson(result)
|
||||||
of JInt:
|
of JInt:
|
||||||
when defined(js): result.add($node.num)
|
when defined(js): result.add($node.num)
|
||||||
else: result.add(node.num)
|
else: result.addInt(node.num)
|
||||||
of JFloat:
|
of JFloat:
|
||||||
when defined(js): result.add($node.fnum)
|
when defined(js): result.add($node.fnum)
|
||||||
else: result.add(node.fnum)
|
else: result.addFloat(node.fnum)
|
||||||
of JBool:
|
of JBool:
|
||||||
result.add(if node.bval: "true" else: "false")
|
result.add(if node.bval: "true" else: "false")
|
||||||
of JNull:
|
of JNull:
|
||||||
|
|
|
||||||
|
|
@ -40,14 +40,14 @@ proc hashString(s: string): int {.compilerproc.} =
|
||||||
h = h +% h shl 15
|
h = h +% h shl 15
|
||||||
result = h
|
result = h
|
||||||
|
|
||||||
proc add*(result: var string; x: int64) =
|
proc addInt*(result: var string; x: int64) =
|
||||||
## Converts integer to its string representation and appends it to `result`.
|
## Converts integer to its string representation and appends it to `result`.
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
## var
|
## var
|
||||||
## a = "123"
|
## a = "123"
|
||||||
## b = 45
|
## b = 45
|
||||||
## a.add(b) # a <- "12345"
|
## a.addInt(b) # a <- "12345"
|
||||||
let base = result.len
|
let base = result.len
|
||||||
setLen(result, base + sizeof(x)*4)
|
setLen(result, base + sizeof(x)*4)
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
@ -66,18 +66,22 @@ proc add*(result: var string; x: int64) =
|
||||||
for j in 0..i div 2 - 1:
|
for j in 0..i div 2 - 1:
|
||||||
swap(result[base+j], result[base+i-j-1])
|
swap(result[base+j], result[base+i-j-1])
|
||||||
|
|
||||||
|
proc add*(result: var string; x: int64) {.deprecated:
|
||||||
|
"Deprecated since v0.20, use 'addInt'".} =
|
||||||
|
addInt(result, x)
|
||||||
|
|
||||||
proc nimIntToStr(x: int): string {.compilerRtl.} =
|
proc nimIntToStr(x: int): string {.compilerRtl.} =
|
||||||
result = newStringOfCap(sizeof(x)*4)
|
result = newStringOfCap(sizeof(x)*4)
|
||||||
result.add x
|
result.addInt x
|
||||||
|
|
||||||
proc add*(result: var string; x: float) =
|
proc addFloat*(result: var string; x: float) =
|
||||||
## Converts float to its string representation and appends it to `result`.
|
## Converts float to its string representation and appends it to `result`.
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
## var
|
## var
|
||||||
## a = "123"
|
## a = "123"
|
||||||
## b = 45.67
|
## b = 45.67
|
||||||
## a.add(b) # a <- "12345.67"
|
## a.addFloat(b) # a <- "12345.67"
|
||||||
when nimvm:
|
when nimvm:
|
||||||
result.add $x
|
result.add $x
|
||||||
else:
|
else:
|
||||||
|
|
@ -113,9 +117,13 @@ proc add*(result: var string; x: float) =
|
||||||
result.add buf[i]
|
result.add buf[i]
|
||||||
inc i
|
inc i
|
||||||
|
|
||||||
|
proc add*(result: var string; x: float) {.deprecated:
|
||||||
|
"Deprecated since v0.20, use 'addFloat'".} =
|
||||||
|
addFloat(result, x)
|
||||||
|
|
||||||
proc nimFloatToStr(f: float): string {.compilerproc.} =
|
proc nimFloatToStr(f: float): string {.compilerproc.} =
|
||||||
result = newStringOfCap(8)
|
result = newStringOfCap(8)
|
||||||
result.add f
|
result.addFloat f
|
||||||
|
|
||||||
proc c_strtod(buf: cstring, endptr: ptr cstring): float64 {.
|
proc c_strtod(buf: cstring, endptr: ptr cstring): float64 {.
|
||||||
importc: "strtod", header: "<stdlib.h>", noSideEffect.}
|
importc: "strtod", header: "<stdlib.h>", noSideEffect.}
|
||||||
|
|
@ -284,7 +292,7 @@ proc nimParseBiggestFloat(s: string, number: var BiggestFloat,
|
||||||
|
|
||||||
proc nimInt64ToStr(x: int64): string {.compilerRtl.} =
|
proc nimInt64ToStr(x: int64): string {.compilerRtl.} =
|
||||||
result = newStringOfCap(sizeof(x)*4)
|
result = newStringOfCap(sizeof(x)*4)
|
||||||
result.add x
|
result.addInt x
|
||||||
|
|
||||||
proc nimBoolToStr(x: bool): string {.compilerRtl.} =
|
proc nimBoolToStr(x: bool): string {.compilerRtl.} =
|
||||||
return if x: "true" else: "false"
|
return if x: "true" else: "false"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue