Skip to content

Commit

Permalink
no ropes WIP (#20433)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Araq authored Sep 27, 2022
1 parent 8051868 commit ca1f3f3
Show file tree
Hide file tree
Showing 24 changed files with 1,059 additions and 1,003 deletions.
4 changes: 2 additions & 2 deletions compiler/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ const
mEqSet, mLeSet, mLtSet, mMulSet, mPlusSet, mMinusSet,
mConStrStr, mAppendStrCh, mAppendStrStr, mAppendSeqElem,
mInSet, mRepr, mOpenArrayToSeq}

generatedMagics* = {mNone, mIsolate, mFinished, mOpenArrayToSeq}
## magics that are generated as normal procs in the backend

Expand Down Expand Up @@ -1504,7 +1504,7 @@ proc mergeLoc(a: var TLoc, b: TLoc) =
if a.storage == low(typeof(a.storage)): a.storage = b.storage
a.flags.incl b.flags
if a.lode == nil: a.lode = b.lode
if a.r == nil: a.r = b.r
if a.r == "": a.r = b.r

proc newSons*(father: Indexable, length: int) =
setLen(father.sons, length)
Expand Down
10 changes: 6 additions & 4 deletions compiler/astalgo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
# the data structures here are used in various places of the compiler.

import
ast, hashes, intsets, strutils, options, lineinfos, ropes, idents, rodutils,
ast, hashes, intsets, options, lineinfos, ropes, idents, rodutils,
msgs

import strutils except addf

when defined(nimPreviewSlimSystem):
import std/assertions

Expand Down Expand Up @@ -258,7 +260,7 @@ proc makeYamlString*(s: string): Rope =
# this could trigger InternalError(111). See the ropes module for
# further information.
const MaxLineLength = 64
result = nil
result = ""
var res = "\""
for i in 0..<s.len:
if (i + 1) mod MaxLineLength == 0:
Expand All @@ -274,9 +276,9 @@ proc flagsToStr[T](flags: set[T]): Rope =
if flags == {}:
result = rope("[]")
else:
result = nil
result = ""
for x in items(flags):
if result != nil: result.add(", ")
if result != "": result.add(", ")
result.add(makeYamlString($x))
result = "[" & result & "]"

Expand Down
Loading

0 comments on commit ca1f3f3

Please sign in to comment.