summary refs log tree commit diff stats
path: root/compiler/rodread.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2016-08-16 20:04:27 +0200
committerAraq <rumpf_a@web.de>2016-08-16 20:04:27 +0200
commita13cb26c4084d83df1d4627e5b842c050ed69177 (patch)
tree87d439fcb03c2c2bcf60e895be033028ca646e9f /compiler/rodread.nim
parent8fca04027fe03109657b753b95ded86d2f65e6f3 (diff)
downloadNim-a13cb26c4084d83df1d4627e5b842c050ed69177.tar.gz
next steps in getting symbol files to work again
Diffstat (limited to 'compiler/rodread.nim')
-rw-r--r--compiler/rodread.nim76
1 files changed, 65 insertions, 11 deletions
diff --git a/compiler/rodread.nim b/compiler/rodread.nim
index e1fd46bf4..679e7ba15 100644
--- a/compiler/rodread.nim
+++ b/compiler/rodread.nim
@@ -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)