Skip to content

Commit ca1f3f3

Browse files
authored
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
1 parent 8051868 commit ca1f3f3

24 files changed

+1059
-1003
lines changed

compiler/ast.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ const
745745
mEqSet, mLeSet, mLtSet, mMulSet, mPlusSet, mMinusSet,
746746
mConStrStr, mAppendStrCh, mAppendStrStr, mAppendSeqElem,
747747
mInSet, mRepr, mOpenArrayToSeq}
748-
748+
749749
generatedMagics* = {mNone, mIsolate, mFinished, mOpenArrayToSeq}
750750
## magics that are generated as normal procs in the backend
751751

@@ -1504,7 +1504,7 @@ proc mergeLoc(a: var TLoc, b: TLoc) =
15041504
if a.storage == low(typeof(a.storage)): a.storage = b.storage
15051505
a.flags.incl b.flags
15061506
if a.lode == nil: a.lode = b.lode
1507-
if a.r == nil: a.r = b.r
1507+
if a.r == "": a.r = b.r
15081508

15091509
proc newSons*(father: Indexable, length: int) =
15101510
setLen(father.sons, length)

compiler/astalgo.nim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
# the data structures here are used in various places of the compiler.
1313

1414
import
15-
ast, hashes, intsets, strutils, options, lineinfos, ropes, idents, rodutils,
15+
ast, hashes, intsets, options, lineinfos, ropes, idents, rodutils,
1616
msgs
1717

18+
import strutils except addf
19+
1820
when defined(nimPreviewSlimSystem):
1921
import std/assertions
2022

@@ -258,7 +260,7 @@ proc makeYamlString*(s: string): Rope =
258260
# this could trigger InternalError(111). See the ropes module for
259261
# further information.
260262
const MaxLineLength = 64
261-
result = nil
263+
result = ""
262264
var res = "\""
263265
for i in 0..<s.len:
264266
if (i + 1) mod MaxLineLength == 0:
@@ -274,9 +276,9 @@ proc flagsToStr[T](flags: set[T]): Rope =
274276
if flags == {}:
275277
result = rope("[]")
276278
else:
277-
result = nil
279+
result = ""
278280
for x in items(flags):
279-
if result != nil: result.add(", ")
281+
if result != "": result.add(", ")
280282
result.add(makeYamlString($x))
281283
result = "[" & result & "]"
282284

0 commit comments

Comments
 (0)