Skip to content

Commit

Permalink
Change compiler uses of intsets to ordsets
Browse files Browse the repository at this point in the history
  • Loading branch information
landerlo committed Oct 14, 2020
1 parent 8bf8c43 commit a012d35
Show file tree
Hide file tree
Showing 47 changed files with 128 additions and 125 deletions.
4 changes: 2 additions & 2 deletions compiler/aliases.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## Simple alias analysis for the HLO and the code generators.

import
ast, astalgo, types, trees, intsets
ast, astalgo, types, trees, ordsets

type
TAnalysisResult* = enum
Expand Down Expand Up @@ -59,7 +59,7 @@ proc isPartOfAux(a, b: PType, marker: var IntSet): TAnalysisResult =

proc isPartOf(a, b: PType): TAnalysisResult =
## checks iff 'a' can be part of 'b'. Iterates over VALUE types!
var marker = initIntSet()
var marker = initOrdSet[int]()
# watch out: parameters reversed because I'm too lazy to change the code...
result = isPartOfAux(b, a, marker)

Expand Down
8 changes: 4 additions & 4 deletions compiler/astalgo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# the data structures here are used in various places of the compiler.

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

proc hashNode*(p: RootRef): Hash
Expand Down Expand Up @@ -389,15 +389,15 @@ proc treeToYamlAux(conf: ConfigRef; n: PNode, marker: var IntSet, indent: int,
result.addf("$N$1}", [rspaces(indent)])

proc treeToYaml(conf: ConfigRef; n: PNode, indent: int = 0, maxRecDepth: int = - 1): Rope =
var marker = initIntSet()
var marker = initOrdSet[int]()
result = treeToYamlAux(conf, n, marker, indent, maxRecDepth)

proc typeToYaml(conf: ConfigRef; n: PType, indent: int = 0, maxRecDepth: int = - 1): Rope =
var marker = initIntSet()
var marker = initOrdSet[int]()
result = typeToYamlAux(conf, n, marker, indent, maxRecDepth)

proc symToYaml(conf: ConfigRef; n: PSym, indent: int = 0, maxRecDepth: int = - 1): Rope =
var marker = initIntSet()
var marker = initOrdSet[int]()
result = symToYamlAux(conf, n, marker, indent, maxRecDepth)

import tables
Expand Down
2 changes: 1 addition & 1 deletion compiler/ccgmerge.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import
ast, ropes, options, strutils, nimlexbase, cgendata, rodutils,
intsets, llstream, tables, modulegraphs, pathutils
ordsets, llstream, tables, modulegraphs, pathutils

# Careful! Section marks need to contain a tabulator so that they cannot
# be part of C string literals.
Expand Down
12 changes: 6 additions & 6 deletions compiler/ccgtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ proc getTypeDescWeak(m: BModule; t: PType; check: var IntSet; kind: TSymKind): R
result = getTypeDescAux(m, t, check, kind)

proc getSeqPayloadType(m: BModule; t: PType): Rope =
var check = initIntSet()
var check = initOrdSet[int]()
result = getTypeDescWeak(m, t, check, skParam) & "_Content"
#result = getTypeForward(m, t, hashType(t)) & "_Content"

Expand Down Expand Up @@ -587,7 +587,7 @@ proc getRecordFields(m: BModule, typ: PType, check: var IntSet): Rope =
proc fillObjectFields*(m: BModule; typ: PType) =
# sometimes generic objects are not consistently merged. We patch over
# this fact here.
var check = initIntSet()
var check = initOrdSet[int]()
discard getRecordFields(m, typ, check)

proc mangleDynLibProc(sym: PSym): Rope
Expand Down Expand Up @@ -931,7 +931,7 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet; kind: TSymKin
excl(check, t.id)

proc getTypeDesc(m: BModule, typ: PType; kind = skParam): Rope =
var check = initIntSet()
var check = initOrdSet[int]()
result = getTypeDescAux(m, typ, check, kind)

type
Expand All @@ -942,7 +942,7 @@ type

proc getClosureType(m: BModule, t: PType, kind: TClosureTypeKind): Rope =
assert t.kind == tyProc
var check = initIntSet()
var check = initOrdSet[int]()
result = getTempName(m)
var rettype, desc: Rope
genProcParams(m, t, rettype, desc, check, declareEnvironment=kind != clHalf)
Expand All @@ -958,7 +958,7 @@ proc getClosureType(m: BModule, t: PType, kind: TClosureTypeKind): Rope =

proc finishTypeDescriptions(m: BModule) =
var i = 0
var check = initIntSet()
var check = initOrdSet[int]()
while i < m.typeStack.len:
let t = m.typeStack[i]
if optSeqDestructors in m.config.globalOptions and t.skipTypes(abstractInst).kind == tySequence:
Expand Down Expand Up @@ -990,7 +990,7 @@ proc genProcHeader(m: BModule, prc: PSym, asPtr: bool = false): Rope =
result.add "static "
elif sfImportc notin prc.flags:
result.add "N_LIB_PRIVATE "
var check = initIntSet()
var check = initOrdSet[int]()
fillLoc(prc.loc, locProc, prc.ast[namePos], mangleName(m, prc), OnUnknown)
genProcParams(m, prc.typ, rettype, params, check)
# handle the 2 options for hotcodereloading codegen - function pointer
Expand Down
8 changes: 4 additions & 4 deletions compiler/cgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## This module implements the C code generator.

import
ast, astalgo, hashes, trees, platform, magicsys, extccomp, options, intsets,
ast, astalgo, hashes, trees, platform, magicsys, extccomp, options, ordsets,
nversion, nimsets, msgs, bitsets, idents, types,
ccgutils, os, ropes, math, passes, wordrecg, treetab, cgmeth,
rodutils, renderer, cgendata, ccgmerge, aliases,
Expand Down Expand Up @@ -976,7 +976,7 @@ proc getProcTypeCast(m: BModule, prc: PSym): Rope =
result = getTypeDesc(m, prc.loc.t)
if prc.typ.callConv == ccClosure:
var rettype, params: Rope
var check = initIntSet()
var check = initOrdSet[int]()
genProcParams(m, prc.typ, rettype, params, check)
result = "$1(*)$2" % [rettype, params]

Expand Down Expand Up @@ -1803,8 +1803,8 @@ proc rawNewModule(g: BModuleList; module: PSym, filename: AbsoluteFile): BModule
result.g = g
result.tmpBase = rope("TM" & $hashOwner(module) & "_")
result.headerFiles = @[]
result.declaredThings = initIntSet()
result.declaredProtos = initIntSet()
result.declaredThings = initOrdSet[int]()
result.declaredProtos = initOrdSet[int]()
result.cfilename = filename
result.filename = filename
result.typeCache = initTable[SigHash, Rope]()
Expand Down
4 changes: 2 additions & 2 deletions compiler/cgendata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## This module contains the data structures for the C code generation phase.

import
ast, ropes, options, intsets,
ast, ropes, options, ordsets,
tables, ndi, lineinfos, pathutils, modulegraphs, sets

type
Expand Down Expand Up @@ -201,7 +201,7 @@ proc newProc*(prc: PSym, module: BModule): BProc =

proc newModuleList*(g: ModuleGraph): BModuleList =
BModuleList(typeInfoMarker: initTable[SigHash, tuple[str: Rope, owner: PSym]](),
config: g.config, graph: g, nimtvDeclared: initIntSet())
config: g.config, graph: g, nimtvDeclared: initOrdSet[int]())

iterator cgenModules*(g: BModuleList): BModule =
for m in g.modulesClosed:
Expand Down
4 changes: 2 additions & 2 deletions compiler/cgmeth.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## This module implements code generation for methods.

import
intsets, options, ast, msgs, idents, renderer, types, magicsys,
ordsets, options, ast, msgs, idents, renderer, types, magicsys,
sempass2, strutils, modulegraphs, lineinfos

proc genConv(n: PNode, d: PType, downcast: bool; conf: ConfigRef): PNode =
Expand Down Expand Up @@ -286,7 +286,7 @@ proc genDispatcher(g: ModuleGraph; methods: seq[PSym], relevantCols: IntSet): PS
proc generateMethodDispatchers*(g: ModuleGraph): PNode =
result = newNode(nkStmtList)
for bucket in 0..<g.methods.len:
var relevantCols = initIntSet()
var relevantCols = initOrdSet[int]()
for col in 1..<g.methods[bucket].methods[0].typ.len:
if relevantCol(g.methods[bucket].methods, col): incl(relevantCols, col)
if optMultiMethods notin g.config.globalOptions:
Expand Down
4 changes: 2 additions & 2 deletions compiler/dfa.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
## "A Graph–Free Approach to Data–Flow Analysis" by Markus Mohnen.
## https://link.springer.com/content/pdf/10.1007/3-540-45937-5_6.pdf

import ast, types, intsets, lineinfos, renderer, asciitables
import ast, types, ordsets, lineinfos, renderer, asciitables

from patterns import sameTrees

Expand Down Expand Up @@ -64,7 +64,7 @@ type
proc codeListing(c: ControlFlowGraph, start = 0; last = -1): string =
# for debugging purposes
# first iteration: compute all necessary labels:
var jumpTargets = initIntSet()
var jumpTargets = initOrdSet[int]()
let last = if last < 0: c.len-1 else: min(last, c.len-1)
for i in start..last:
if c[i].kind in {goto, fork}:
Expand Down
4 changes: 2 additions & 2 deletions compiler/docgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import
wordrecg, syntaxes, renderer, lexer, packages/docutils/rstast,
packages/docutils/rst, packages/docutils/rstgen,
json, xmltree, cgi, trees, types,
typesrenderer, astalgo, lineinfos, intsets,
typesrenderer, astalgo, lineinfos, ordsets,
pathutils, trees, tables, nimpaths, renderverbatim, osproc

from std/private/globs import nativeToUnixPath
Expand Down Expand Up @@ -229,7 +229,7 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
let (output, gotten) = execCmdEx(cmd)
if gotten != status:
rawMessage(conf, errGenerated, "snippet failed: cmd: '$1' status: $2 expected: $3 output: $4" % [cmd, $gotten, $status, output])
result.emitted = initIntSet()
result.emitted = initOrdSet[int]()
result.destFile = getOutFile2(conf, presentationPath(conf, filename), outExt, false)
result.thisDir = result.destFile.splitFile.dir

Expand Down
4 changes: 2 additions & 2 deletions compiler/idgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const
debugIds* = false

when debugIds:
import intsets
import ordsets

var usedIds = initIntSet()
var usedIds = initOrdSet[int]()

proc registerID*(id: PIdObj) =
when debugIds:
Expand Down
4 changes: 2 additions & 2 deletions compiler/importer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
## This module implements the symbol importing mechanism.

import
intsets, ast, astalgo, msgs, options, idents, lookups,
ordsets, ast, astalgo, msgs, options, idents, lookups,
semdata, modulepaths, sigmatch, lineinfos, sets

proc readExceptSet*(c: PContext, n: PNode): IntSet =
assert n.kind in {nkImportExceptStmt, nkExportExceptStmt}
result = initIntSet()
result = initOrdSet[int]()
for i in 1..<n.len:
let ident = lookups.considerQuotedIdent(c, n[i])
result.incl(ident.id)
Expand Down
6 changes: 3 additions & 3 deletions compiler/incremental.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const nimIncremental* = defined(nimIncremental)
import options, lineinfos

when nimIncremental:
import ast, msgs, intsets, btrees, db_sqlite, std / sha1, pathutils
import ast, msgs, ordsets, btrees, db_sqlite, std / sha1, pathutils
from strutils import parseInt
from os import isAbsolute

Expand All @@ -39,8 +39,8 @@ when nimIncremental:
proc init*(incr: var IncrementalCtx) =
incr.w.sstack = @[]
incr.w.tstack = @[]
incr.w.tmarks = initIntSet()
incr.w.smarks = initIntSet()
incr.w.tmarks = initOrdSet[int]()
incr.w.smarks = initOrdSet[int]()
incr.w.forwardedSyms = @[]
incr.r.syms = initBTree[int, PSym]()
incr.r.types = initBTree[int, PType]()
Expand Down
10 changes: 5 additions & 5 deletions compiler/injectdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
## See doc/destructors.rst for a spec of the implemented rewrite rules

import
intsets, strtabs, ast, astalgo, msgs, renderer, magicsys, types, idents,
ordsets, strtabs, ast, astalgo, msgs, renderer, magicsys, types, idents,
strutils, options, dfa, lowerings, tables, modulegraphs, msgs,
lineinfos, parampatterns, sighashes, liftdestructors, optimizer,
varpartitions
Expand Down Expand Up @@ -200,8 +200,8 @@ proc initialized(code: ControlFlowGraph; pc: int,
of goto:
pc += code[pc].dest
of fork:
var initA = initIntSet()
var initB = initIntSet()
var initA = initOrdSet[int]()
var initB = initOrdSet[int]()
var variantA = pc + 1
var variantB = pc + code[pc].dest
while variantA != variantB:
Expand Down Expand Up @@ -987,8 +987,8 @@ proc moveOrCopy(dest, ri: PNode; c: var Con; s: var Scope, isDecl = false): PNod
proc computeUninit(c: var Con) =
if not c.uninitComputed:
c.uninitComputed = true
c.uninit = initIntSet()
var init = initIntSet()
c.uninit = initOrdSet[int]()
var init = initOrdSet[int]()
discard initialized(c.g, pc = 0, init, c.uninit, int.high)

proc injectDefaultCalls(n: PNode, c: var Con) =
Expand Down
4 changes: 2 additions & 2 deletions compiler/isolation_check.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## https://github.com/nim-lang/RFCs/issues/244 for more details.

import
ast, types, renderer, idents, intsets
ast, types, renderer, idents, ordsets

proc canAlias(arg, ret: PType; marker: var IntSet): bool

Expand Down Expand Up @@ -65,7 +65,7 @@ proc canAlias(arg, ret: PType; marker: var IntSet): bool =
result = false

proc canAlias*(arg, ret: PType): bool =
var marker = initIntSet()
var marker = initOrdSet[int]()
result = canAlias(arg, ret, marker)

proc checkIsolate*(n: PNode): bool =
Expand Down
10 changes: 5 additions & 5 deletions compiler/jsgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import
ast, strutils, trees, magicsys, options,
nversion, msgs, idents, types, tables,
ropes, math, passes, ccgutils, wordrecg, renderer,
intsets, cgmeth, lowerings, sighashes, modulegraphs, lineinfos, rodutils,
ordsets, cgmeth, lowerings, sighashes, modulegraphs, lineinfos, rodutils,
transf, injectdestructors, sourcemap, json, sets


Expand Down Expand Up @@ -133,8 +133,8 @@ template nested(p, body) =
proc newGlobals(): PGlobals =
new(result)
result.forwarded = @[]
result.generatedSyms = initIntSet()
result.typeInfoGenerated = initIntSet()
result.generatedSyms = initOrdSet[int]()
result.typeInfoGenerated = initOrdSet[int]()

proc initCompRes(r: var TCompRes) =
r.address = nil
Expand Down Expand Up @@ -1705,7 +1705,7 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope =
if indirect: result = "[$1]" % [result]
of tyObject:
var initList: Rope
createObjInitList(p, t, initIntSet(), initList)
createObjInitList(p, t, initOrdSet[int](), initList)
result = ("({$1})") % [initList]
if indirect: result = "[$1]" % [result]
of tyVar, tyPtr, tyLent, tyRef, tyPointer:
Expand Down Expand Up @@ -2163,7 +2163,7 @@ proc genObjConstr(p: PProc, n: PNode, r: var TCompRes) =
var a: TCompRes
r.kind = resExpr
var initList : Rope
var fieldIDs = initIntSet()
var fieldIDs = initOrdSet[int]()
for i in 1..<n.len:
if i > 1: initList.add(", ")
var it = n[i]
Expand Down
8 changes: 4 additions & 4 deletions compiler/lambdalifting.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# This file implements lambda lifting for the transformator.

import
intsets, strutils, options, ast, astalgo, msgs,
ordsets, strutils, options, ast, astalgo, msgs,
idents, renderer, types, magicsys, lowerings, tables, modulegraphs, lineinfos,
transf, liftdestructors

Expand Down Expand Up @@ -307,8 +307,8 @@ type
graph: ModuleGraph

proc initDetectionPass(g: ModuleGraph; fn: PSym): DetectionPass =
result.processed = initIntSet()
result.capturedVars = initIntSet()
result.processed = initOrdSet[int]()
result.capturedVars = initOrdSet[int]()
result.ownerToType = initTable[int, PType]()
result.processed.incl(fn.id)
result.graph = g
Expand Down Expand Up @@ -513,7 +513,7 @@ type
unownedEnvVars: Table[int, PNode] # only required for --newruntime

proc initLiftingPass(fn: PSym): LiftingPass =
result.processed = initIntSet()
result.processed = initOrdSet[int]()
result.processed.incl(fn.id)
result.envVars = initTable[int, PNode]()

Expand Down
4 changes: 2 additions & 2 deletions compiler/lookups.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# This module implements lookup helpers.

import
intsets, ast, astalgo, idents, semdata, types, msgs, options,
ordsets, ast, astalgo, idents, semdata, types, msgs, options,
renderer, nimfix/prettybase, lineinfos, strutils

proc ensureNoMissingOrUnusedSymbols(c: PContext; scope: PScope)
Expand Down Expand Up @@ -420,7 +420,7 @@ proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym =
o.mode = oimDone
return nil
o.symChoiceIndex = 1
o.inSymChoice = initIntSet()
o.inSymChoice = initOrdSet[int]()
incl(o.inSymChoice, result.id)
else: discard
when false:
Expand Down
Loading

0 comments on commit a012d35

Please sign in to comment.