no ropes WIP (#20433)

* refactorings in preparation for ropes elimination of the C code generator; mostly the usual ': Rope' -> 'result: var Rope' rewrite
* rewrote ccgcalls.nim
* refactored ccgexprs.nim
* ccgliterals: refactoring
* refactoring: code dealing with name mangling
* refactoring: getRecordFieldsAux
* ropes are strings (insert obscene joke here)
* optimize JS code gen
* optimizations and code improvements
* more optimizations
* final cleanups
This commit is contained in:
Andreas Rumpf 2022-09-27 10:57:47 +02:00 • committed by GitHub
commit ca1f3f36b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 1058 additions and 1002 deletions

View file

@ -10,7 +10,9 @@
import
std/[strutils, os, tables, terminal, macros, times],
std/private/miscdollars,
options, ropes, lineinfos, pathutils, strutils2
options, lineinfos, pathutils, strutils2
import ropes except `%`
when defined(nimPreviewSlimSystem):
import std/[syncio, assertions]
@ -43,18 +45,16 @@ proc toCChar*(c: char; result: var string) {.inline.} =
result.add c
proc makeCString*(s: string): Rope =
result = nil
var res = newStringOfCap(int(s.len.toFloat * 1.1) + 1)
res.add("\"")
result = newStringOfCap(int(s.len.toFloat * 1.1) + 1)
result.add("\"")
for i in 0..<s.len:
# line wrapping of string litterals in cgen'd code was a bad idea, e.g. causes: bug #16265
# It also makes reading c sources or grepping harder, for zero benefit.
# const MaxLineLength = 64
# if (i + 1) mod MaxLineLength == 0:
# res.add("\"\L\"")
toCChar(s[i], res)
res.add('\"')
result.add(rope(res))
toCChar(s[i], result)
result.add('\"')
proc newFileInfo(fullPath: AbsoluteFile, projPath: RelativeFile): TFileInfo =
result.fullPath = fullPath