ast2nif

Search:
Group by:
Source   Edit  

AST to NIF bridge.

Types

DecodeContext = object
Source   Edit  
ParsedSymName = object
  name*: string
  module*: string
  count*: int
Source   Edit  

Procs

proc cachedModuleSuffix(config: ConfigRef; fileIdx: FileIndex): string {.
    ...raises: [Exception, OSError], tags: [RootEffect], forbids: [].}
Gets or computes the module suffix for a FileIndex. For NIF modules, the suffix is already stored in the file info. For source files, computes it from the path. Source   Edit  
proc createDecodeContext(config: ConfigRef; cache: IdentCache): DecodeContext {.
    ...raises: [], tags: [], forbids: [].}
Supposed to be a global variable Source   Edit  
proc firstSon(n: Cursor): Cursor {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc isStub(s: PSym): bool {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc isStub(t: PType): bool {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc loadNifModule(c: var DecodeContext; f: FileIndex;
                   interf, interfHidden: var TStrTable;
                   hooks: var Table[SymId, HooksPerType];
                   converters: var seq[(string, string)];
                   classes: var seq[ClassIndexEntry]): PNode {.
    ...raises: [Exception, OSError, ValueError, KeyError, IOError], tags: [
    RootEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect],
    forbids: [].}
Source   Edit  
proc loadSym(c: var DecodeContext; s: PSym) {.
    ...raises: [KeyError, ValueError, IOError, Exception, OSError], tags: [
    WriteIOEffect, ReadDirEffect, RootEffect, ReadEnvEffect, ReadIOEffect],
    forbids: [].}
Source   Edit  
proc loadType(c: var DecodeContext; t: PType) {.
    ...raises: [KeyError, ValueError, IOError, OSError, Exception], tags: [
    WriteIOEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc parseSymName(s: string): ParsedSymName {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc parseTypeSymIdToItemId(c: var DecodeContext; symId: nifstreams.SymId): ItemId {.
    ...raises: [OSError, ValueError, KeyError],
    tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect], forbids: [].}
Parses a type SymId (format: "`tN.modulesuffix") to extract ItemId.
Source   Edit  
proc resolveHookSym(c: var DecodeContext; symId: nifstreams.SymId): PSym {.
    ...raises: [OSError, ValueError, KeyError],
    tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect], forbids: [].}
Resolves a hook SymId to PSym. Source   Edit  
proc toAttachedOp(op: TTypeAttachedOp): AttachedOp {....raises: [], tags: [],
    forbids: [].}
Maps Nim compiler's TTypeAttachedOp to nimony's AttachedOp. Returns attachedDestroy for attachedDeepCopy (caller should skip it). Source   Edit  
proc toClassSymId(config: ConfigRef; typeId: ItemId): nifstreams.SymId {.
    ...raises: [Exception, OSError], tags: [RootEffect], forbids: [].}
Converts a type ItemId to its SymId for the class index. Source   Edit  
proc toConverterIndexEntry(config: ConfigRef; converterSym: PSym): (
    nifstreams.SymId, nifstreams.SymId) {....raises: [Exception, OSError],
    tags: [RootEffect], forbids: [].}
Converts a converter symbol to an index entry (destType, converterSym). Returns the destination type's SymId and the converter's SymId. Source   Edit  
proc toHookIndexEntry(config: ConfigRef; typeId: ItemId; hookSym: PSym): HookIndexEntry {.
    ...raises: [Exception, OSError], tags: [RootEffect], forbids: [].}
Converts a type ItemId and hook symbol to a HookIndexEntry for the NIF index. Source   Edit  
proc toMethodIndexEntry(config: ConfigRef; methodSym: PSym; signature: string): MethodIndexEntry {.
    ...raises: [Exception, OSError], tags: [RootEffect], forbids: [].}
Converts a method symbol to a MethodIndexEntry. Source   Edit  
proc toNifFilename(conf: ConfigRef; f: FileIndex): string {.
    ...raises: [Exception, OSError],
    tags: [RootEffect, ReadEnvEffect, ReadIOEffect], forbids: [].}
Source   Edit  
proc toNifIndexFilename(conf: ConfigRef; f: FileIndex): string {.
    ...raises: [Exception, OSError],
    tags: [RootEffect, ReadEnvEffect, ReadIOEffect], forbids: [].}
Source   Edit  
proc toTTypeAttachedOp(op: AttachedOp): TTypeAttachedOp {....raises: [], tags: [],
    forbids: [].}
Maps nimony's AttachedOp back to Nim compiler's TTypeAttachedOp. Source   Edit  
proc writeNifModule(config: ConfigRef; thisModule: int32; n: PNode;
                    hooks: array[AttachedOp, seq[HookIndexEntry]];
                    converters: seq[(nifstreams.SymId, nifstreams.SymId)];
                    classes: seq[ClassIndexEntry];
                    replayActions: seq[PNode] = @[]) {.
    ...raises: [KeyError, Exception, OSError, IOError, ValueError], tags: [
    RootEffect, ReadEnvEffect, ReadIOEffect, WriteDirEffect, ReadDirEffect,
    WriteIOEffect], forbids: [].}
Source   Edit