mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-20 07:51:32 +00:00
next steps in getting symbol files to work again
This commit is contained in:
@@ -725,8 +725,8 @@ type
|
||||
s*: TStorageLoc
|
||||
flags*: TLocFlags # location's flags
|
||||
t*: PType # type of location
|
||||
r*: Rope # rope value of location (code generators)
|
||||
heapRoot*: Rope # keeps track of the enclosing heap object that
|
||||
r*: Rope # rope value of location (code generators)
|
||||
heapRoot*: Rope # keeps track of the enclosing heap object that
|
||||
# owns this location (required by GC algorithms
|
||||
# employing heap snapshots or sliding views)
|
||||
|
||||
@@ -746,10 +746,6 @@ type
|
||||
TInstantiation* = object
|
||||
sym*: PSym
|
||||
concreteTypes*: seq[PType]
|
||||
usedBy*: seq[int32] # list of modules using the generic
|
||||
# needed in caas mode for purging the cache
|
||||
# XXX: it's possible to switch to a
|
||||
# simple ref count here
|
||||
compilesId*: CompilesId
|
||||
|
||||
PInstantiation* = ref TInstantiation
|
||||
@@ -767,7 +763,6 @@ type
|
||||
case kind*: TSymKind
|
||||
of skType, skGenericParam:
|
||||
typeInstCache*: seq[PType]
|
||||
typScope*: PScope
|
||||
of routineKinds:
|
||||
procInstCache*: seq[PInstantiation]
|
||||
gcUnsafetyReason*: PSym # for better error messages wrt gcsafe
|
||||
|
||||
@@ -1020,7 +1020,7 @@ proc genInitCode(m: BModule) =
|
||||
var procname = makeCString(m.module.name.s)
|
||||
add(prc, initFrame(m.initProc, procname, m.module.info.quotedFilename))
|
||||
else:
|
||||
add(prc, ~"\tTFrame F; FR.len = 0;$N")
|
||||
add(prc, ~"\tTFrame FR; FR.len = 0;$N")
|
||||
|
||||
add(prc, genSectionStart(cpsInit))
|
||||
add(prc, m.preInitProc.s(cpsInit))
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
const
|
||||
MaxSetElements* = 1 shl 16 # (2^16) to support unicode character sets?
|
||||
VersionAsString* = system.NimVersion
|
||||
RodFileVersion* = "1216" # modify this if the rod-format changes!
|
||||
RodFileVersion* = "1218" # modify this if the rod-format changes!
|
||||
|
||||
|
||||
@@ -572,11 +572,13 @@ proc deprecatedStmt(c: PContext; pragma: PNode) =
|
||||
for n in pragma:
|
||||
if n.kind in {nkExprColonExpr, nkExprEqExpr}:
|
||||
let dest = qualifiedLookUp(c, n[1], {checkUndeclared})
|
||||
assert dest != nil
|
||||
let src = considerQuotedIdent(n[0])
|
||||
let alias = newSym(skAlias, src, dest, n[0].info)
|
||||
incl(alias.flags, sfExported)
|
||||
if sfCompilerProc in dest.flags: markCompilerProc(alias)
|
||||
addInterfaceDecl(c, alias)
|
||||
n.sons[1] = newSymNode(dest)
|
||||
else:
|
||||
localError(n.info, "key:value pair expected")
|
||||
|
||||
|
||||
@@ -145,13 +145,7 @@ type
|
||||
|
||||
PRodReader* = ref TRodReader
|
||||
|
||||
var rodCompilerprocs*: TStrTable
|
||||
|
||||
proc handleSymbolFile*(module: PSym): PRodReader
|
||||
# global because this is needed by magicsys
|
||||
proc loadInitSection*(r: PRodReader): PNode
|
||||
|
||||
# implementation
|
||||
var rodCompilerprocs*: TStrTable # global because this is needed by magicsys
|
||||
|
||||
proc rawLoadStub(s: PSym)
|
||||
|
||||
@@ -206,7 +200,7 @@ proc decodeNodeLazyBody(r: PRodReader, fInfo: TLineInfo,
|
||||
var id = decodeVInt(r.s, r.pos)
|
||||
result.typ = rrGetType(r, id, result.info)
|
||||
case result.kind
|
||||
of nkCharLit..nkInt64Lit:
|
||||
of nkCharLit..nkUInt64Lit:
|
||||
if r.s[r.pos] == '!':
|
||||
inc(r.pos)
|
||||
result.intVal = decodeVBiggestInt(r.s, r.pos)
|
||||
@@ -324,6 +318,29 @@ proc decodeType(r: PRodReader, info: TLineInfo): PType =
|
||||
result.align = decodeVInt(r.s, r.pos).int16
|
||||
else:
|
||||
result.align = 2
|
||||
|
||||
if r.s[r.pos] == '\14':
|
||||
inc(r.pos)
|
||||
result.lockLevel = decodeVInt(r.s, r.pos).TLockLevel
|
||||
else:
|
||||
result.lockLevel = UnspecifiedLockLevel
|
||||
|
||||
if r.s[r.pos] == '\15':
|
||||
inc(r.pos)
|
||||
result.destructor = rrGetSym(r, decodeVInt(r.s, r.pos), info)
|
||||
if r.s[r.pos] == '\16':
|
||||
inc(r.pos)
|
||||
result.deepCopy = rrGetSym(r, decodeVInt(r.s, r.pos), info)
|
||||
if r.s[r.pos] == '\17':
|
||||
inc(r.pos)
|
||||
result.assignment = rrGetSym(r, decodeVInt(r.s, r.pos), info)
|
||||
while r.s[r.pos] == '\18':
|
||||
inc(r.pos)
|
||||
let x = decodeVInt(r.s, r.pos)
|
||||
doAssert r.s[r.pos] == '\19'
|
||||
inc(r.pos)
|
||||
let y = rrGetSym(r, decodeVInt(r.s, r.pos), info)
|
||||
result.methods.safeAdd((x, y))
|
||||
decodeLoc(r, result.loc, info)
|
||||
while r.s[r.pos] == '^':
|
||||
inc(r.pos)
|
||||
@@ -349,6 +366,22 @@ proc decodeLib(r: PRodReader, info: TLineInfo): PLib =
|
||||
inc(r.pos)
|
||||
result.path = decodeNode(r, info)
|
||||
|
||||
proc decodeInstantiations(r: PRodReader; info: TLineInfo;
|
||||
s: var seq[PInstantiation]) =
|
||||
while r.s[r.pos] == '\15':
|
||||
inc(r.pos)
|
||||
var ii: PInstantiation
|
||||
new ii
|
||||
ii.sym = rrGetSym(r, decodeVInt(r.s, r.pos), info)
|
||||
ii.concreteTypes = @[]
|
||||
while r.s[r.pos] == '\17':
|
||||
inc(r.pos)
|
||||
ii.concreteTypes.add rrGetType(r, decodeVInt(r.s, r.pos), info)
|
||||
if r.s[r.pos] == '\20':
|
||||
inc(r.pos)
|
||||
ii.compilesId = decodeVInt(r.s, r.pos)
|
||||
s.safeAdd ii
|
||||
|
||||
proc decodeSym(r: PRodReader, info: TLineInfo): PSym =
|
||||
var
|
||||
id: int
|
||||
@@ -423,6 +456,27 @@ proc decodeSym(r: PRodReader, info: TLineInfo): PSym =
|
||||
if r.s[r.pos] == '#':
|
||||
inc(r.pos)
|
||||
result.constraint = decodeNode(r, unknownLineInfo())
|
||||
case result.kind
|
||||
of skType, skGenericParam:
|
||||
while r.s[r.pos] == '\14':
|
||||
inc(r.pos)
|
||||
result.typeInstCache.safeAdd rrGetType(r, decodeVInt(r.s, r.pos), result.info)
|
||||
of routineKinds:
|
||||
decodeInstantiations(r, result.info, result.procInstCache)
|
||||
if r.s[r.pos] == '\16':
|
||||
inc(r.pos)
|
||||
result.gcUnsafetyReason = rrGetSym(r, decodeVInt(r.s, r.pos), result.info)
|
||||
of skModule, skPackage:
|
||||
decodeInstantiations(r, result.info, result.usedGenerics)
|
||||
of skLet, skVar, skField, skForVar:
|
||||
if r.s[r.pos] == '\18':
|
||||
inc(r.pos)
|
||||
result.guard = rrGetSym(r, decodeVInt(r.s, r.pos), result.info)
|
||||
if r.s[r.pos] == '\19':
|
||||
inc(r.pos)
|
||||
result.bitsize = decodeVInt(r.s, r.pos).int16
|
||||
else: discard
|
||||
|
||||
if r.s[r.pos] == '(':
|
||||
if result.kind in routineKinds:
|
||||
result.ast = decodeNodeLazyBody(r, result.info, result)
|
||||
@@ -766,7 +820,7 @@ proc rrGetSym(r: PRodReader, id: int, info: TLineInfo): PSym =
|
||||
result = decodeSymSafePos(r, d, info)
|
||||
if result != nil and result.kind == skStub: rawLoadStub(result)
|
||||
|
||||
proc loadInitSection(r: PRodReader): PNode =
|
||||
proc loadInitSection*(r: PRodReader): PNode =
|
||||
if r.initIdx == 0 or r.dataIdx == 0: internalError("loadInitSection")
|
||||
var oldPos = r.pos
|
||||
r.pos = r.initIdx
|
||||
@@ -850,7 +904,7 @@ proc checkDep(fileIdx: int32): TReasonForRecompile =
|
||||
gMods[fileIdx].rd = r
|
||||
gMods[fileIdx].reason = result # now we know better
|
||||
|
||||
proc handleSymbolFile(module: PSym): PRodReader =
|
||||
proc handleSymbolFile*(module: PSym): PRodReader =
|
||||
let fileIdx = module.fileIdx
|
||||
if optSymbolFiles notin gGlobalOptions:
|
||||
module.id = getID()
|
||||
@@ -926,7 +980,7 @@ proc writeNode(f: File; n: PNode) =
|
||||
f.write('^')
|
||||
f.write(n.typ.id)
|
||||
case n.kind
|
||||
of nkCharLit..nkInt64Lit:
|
||||
of nkCharLit..nkUInt64Lit:
|
||||
if n.intVal != 0:
|
||||
f.write('!')
|
||||
f.write(n.intVal)
|
||||
|
||||
@@ -16,8 +16,6 @@ import
|
||||
condsyms, ropes, idents, securehash, rodread, passes, importer, idgen,
|
||||
rodutils
|
||||
|
||||
# implementation
|
||||
|
||||
type
|
||||
TRodWriter = object of TPassContext
|
||||
module: PSym
|
||||
@@ -223,6 +221,28 @@ proc encodeType(w: PRodWriter, t: PType, result: var string) =
|
||||
if t.align != 2:
|
||||
add(result, '=')
|
||||
encodeVInt(t.align, result)
|
||||
if t.lockLevel.ord != UnspecifiedLockLevel.ord:
|
||||
add(result, '\14')
|
||||
encodeVInt(t.lockLevel.int16, result)
|
||||
|
||||
if t.destructor != nil:
|
||||
add(result, '\15')
|
||||
encodeVInt(t.destructor.id, result)
|
||||
pushSym(w, t.destructor)
|
||||
if t.deepCopy != nil:
|
||||
add(result, '\16')
|
||||
encodeVInt(t.deepcopy.id, result)
|
||||
pushSym(w, t.deepcopy)
|
||||
if t.assignment != nil:
|
||||
add(result, '\17')
|
||||
encodeVInt(t.assignment.id, result)
|
||||
pushSym(w, t.assignment)
|
||||
for i, s in items(t.methods):
|
||||
add(result, '\18')
|
||||
encodeVInt(i, result)
|
||||
add(result, '\19')
|
||||
encodeVInt(s.id, result)
|
||||
pushSym(w, s)
|
||||
encodeLoc(w, t.loc, result)
|
||||
for i in countup(0, sonsLen(t) - 1):
|
||||
if t.sons[i] == nil:
|
||||
@@ -240,6 +260,19 @@ proc encodeLib(w: PRodWriter, lib: PLib, info: TLineInfo, result: var string) =
|
||||
add(result, '|')
|
||||
encodeNode(w, info, lib.path, result)
|
||||
|
||||
proc encodeInstantiations(w: PRodWriter; s: seq[PInstantiation];
|
||||
result: var string) =
|
||||
for t in s:
|
||||
result.add('\15')
|
||||
encodeVInt(t.sym.id, result)
|
||||
pushSym(w, t.sym)
|
||||
for tt in t.concreteTypes:
|
||||
result.add('\17')
|
||||
encodeVInt(tt.id, result)
|
||||
pushType(w, tt)
|
||||
result.add('\20')
|
||||
encodeVInt(t.compilesId, result)
|
||||
|
||||
proc encodeSym(w: PRodWriter, s: PSym, result: var string) =
|
||||
if s == nil:
|
||||
# nil nodes have to be stored too:
|
||||
@@ -285,6 +318,31 @@ proc encodeSym(w: PRodWriter, s: PSym, result: var string) =
|
||||
if s.constraint != nil:
|
||||
add(result, '#')
|
||||
encodeNode(w, unknownLineInfo(), s.constraint, result)
|
||||
case s.kind
|
||||
of skType, skGenericParam:
|
||||
for t in s.typeInstCache:
|
||||
result.add('\14')
|
||||
encodeVInt(t.id, result)
|
||||
pushType(w, t)
|
||||
of routineKinds:
|
||||
encodeInstantiations(w, s.procInstCache, result)
|
||||
if s.gcUnsafetyReason != nil:
|
||||
result.add('\16')
|
||||
encodeVInt(s.gcUnsafetyReason.id, result)
|
||||
pushSym(w, s.gcUnsafetyReason)
|
||||
of skModule, skPackage:
|
||||
encodeInstantiations(w, s.usedGenerics, result)
|
||||
# we don't serialize:
|
||||
#tab*: TStrTable # interface table for modules
|
||||
of skLet, skVar, skField, skForVar:
|
||||
if s.guard != nil:
|
||||
result.add('\18')
|
||||
encodeVInt(s.guard.id, result)
|
||||
pushSym(w, s.guard)
|
||||
if s.bitsize != 0:
|
||||
result.add('\19')
|
||||
encodeVInt(s.bitsize, result)
|
||||
else: discard
|
||||
# lazy loading will soon reload the ast lazily, so the ast needs to be
|
||||
# the last entry of a symbol:
|
||||
if s.ast != nil:
|
||||
@@ -292,16 +350,6 @@ proc encodeSym(w: PRodWriter, s: PSym, result: var string) =
|
||||
# it is not necessary, but Nim's heavy compile-time evaluation features
|
||||
# make that unfeasible nowadays:
|
||||
encodeNode(w, s.info, s.ast, result)
|
||||
when false:
|
||||
var codeAst: PNode = nil
|
||||
if not astNeeded(s):
|
||||
codeAst = s.ast.sons[codePos]
|
||||
# ugly hack to not store the AST:
|
||||
s.ast.sons[codePos] = ast.emptyNode
|
||||
encodeNode(w, s.info, s.ast, result)
|
||||
if codeAst != nil:
|
||||
# resore the AST:
|
||||
s.ast.sons[codePos] = codeAst
|
||||
|
||||
proc addToIndex(w: var TIndex, key, val: int) =
|
||||
if key - w.lastIdxKey == 1:
|
||||
|
||||
@@ -1831,9 +1831,6 @@ const
|
||||
NimVersion*: string = $NimMajor & "." & $NimMinor & "." & $NimPatch
|
||||
## is the version of Nim as a string.
|
||||
|
||||
{.deprecated: [TEndian: Endianness, NimrodVersion: NimVersion,
|
||||
NimrodMajor: NimMajor, NimrodMinor: NimMinor, NimrodPatch: NimPatch].}
|
||||
|
||||
# GC interface:
|
||||
|
||||
when not defined(nimscript) and hasAlloc:
|
||||
@@ -3681,4 +3678,4 @@ when defined(nimconfig):
|
||||
when defined(windows) and appType == "console" and not defined(nimconfig):
|
||||
proc setConsoleOutputCP(codepage: cint): cint {.stdcall, dynlib: "kernel32",
|
||||
importc: "SetConsoleOutputCP".}
|
||||
discard setConsoleOutputCP(65001) # 65001 - utf-8 codepage
|
||||
discard setConsoleOutputCP(65001) # 65001 - utf-8 codepage
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import
|
||||
cairo, glib2, gtk2
|
||||
|
||||
proc destroy(widget: pWidget, data: pgpointer) {.cdecl.} =
|
||||
proc destroy(widget: PWidget, data: Pgpointer) {.cdecl.} =
|
||||
main_quit()
|
||||
|
||||
var
|
||||
window: pWidget
|
||||
nimrod_init()
|
||||
window: PWidget
|
||||
nim_init()
|
||||
window = window_new(WINDOW_TOPLEVEL)
|
||||
discard signal_connect(window, "destroy",
|
||||
SIGNAL_FUNC(gtkex1.destroy), nil)
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
import
|
||||
glib2, gtk2
|
||||
|
||||
proc destroy(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
proc destroy(widget: PWidget, data: Pgpointer){.cdecl.} =
|
||||
main_quit()
|
||||
|
||||
var
|
||||
window: PWidget
|
||||
button: PWidget
|
||||
|
||||
nimrod_init()
|
||||
nim_init()
|
||||
window = window_new(WINDOW_TOPLEVEL)
|
||||
button = button_new("Click me")
|
||||
set_border_width(PContainer(Window), 5)
|
||||
set_border_width(PContainer(window), 5)
|
||||
add(PContainer(window), button)
|
||||
discard signal_connect(window, "destroy",
|
||||
SIGNAL_FUNC(gtkex2.destroy), nil)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
{.overflowchecks: on.}
|
||||
|
||||
converter uglyToBool*(x: int): bool =
|
||||
{.Breakpoint.}
|
||||
result = x != 0
|
||||
|
||||
|
||||
|
||||
@@ -369,9 +369,8 @@ proc `&?.`(a, b: string): string =
|
||||
proc processCategory(r: var TResults, cat: Category, options: string, fileGlob: string = "t*.nim") =
|
||||
case cat.string.normalize
|
||||
of "rodfiles":
|
||||
discard # Disabled for now
|
||||
#compileRodFiles(r, cat, options)
|
||||
#runRodFiles(r, cat, options)
|
||||
compileRodFiles(r, cat, options)
|
||||
runRodFiles(r, cat, options)
|
||||
of "js":
|
||||
# XXX JS doesn't need to be special anymore
|
||||
jsTests(r, cat, options)
|
||||
|
||||
Reference in New Issue
Block a user