diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2021-01-14 17:30:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-14 17:30:41 +0100 |
commit | 1fd4c666dc676e77ce875c835a7372077c40f23e (patch) | |
tree | be5555c7dad55f3a5e04e8607e042c4fe2fa6cfd /compiler/ic/packed_ast.nim | |
parent | ef9027c29028b1ec93d14c148406d409bc1701d4 (diff) | |
download | Nim-1fd4c666dc676e77ce875c835a7372077c40f23e.tar.gz |
IC: next steps (#16705)
* code cleanups * refactorings for IC * more refactorings for IC * IC: attach the 'nil' type to its module * IC: refactorings and improvements * IC: progress * IC: more serialization fixes * IC: embarrassing omission * code cleanups
Diffstat (limited to 'compiler/ic/packed_ast.nim')
-rw-r--r-- | compiler/ic/packed_ast.nim | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/compiler/ic/packed_ast.nim b/compiler/ic/packed_ast.nim index 0758d3b98..708761764 100644 --- a/compiler/ic/packed_ast.nim +++ b/compiler/ic/packed_ast.nim @@ -12,7 +12,7 @@ ## use this representation directly in all the transformations, ## it is superior. -import std / [hashes, tables, strtabs, md5] +import std / [hashes, tables, strtabs] import bitabs import ".." / [ast, options] @@ -27,8 +27,6 @@ type module*: LitId # 0 if it's this module item*: int32 # same as the in-memory representation - TypeId* = PackedItemId - const nilItemId* = PackedItemId(module: LitId(0), item: -1.int32) @@ -51,7 +49,7 @@ type PackedSym* = object kind*: TSymKind name*: LitId - typ*: TypeId + typ*: PackedItemId flags*: TSymFlags magic*: TMagic info*: PackedLineInfo @@ -74,7 +72,7 @@ type callConv*: TCallingConvention #nodekind*: TNodeKind flags*: TTypeFlags - types*: seq[TypeId] + types*: seq[PackedItemId] n*: NodeId methods*: seq[(int, PackedItemId)] #nodeflags*: TNodeFlags @@ -86,7 +84,7 @@ type paddingAtEnd*: int16 lockLevel*: TLockLevel # lock level as required for deadlock checking # not serialized: loc*: TLoc because it is backend-specific - typeInst*: TypeId + typeInst*: PackedItemId nonUniqueId*: int32 PackedNode* = object # 20 bytes @@ -96,17 +94,9 @@ type # for kind in {nkStrLit, nkIdent, nkNumberLit}: LitId # for kind in nkInt32Lit: direct value # for non-atom kinds: the number of nodes (for easy skipping) - typeId*: TypeId + typeId*: PackedItemId info*: PackedLineInfo - ModulePhase* = enum - preLookup, lookedUpTopLevelStmts - - GenericKey* = object - module*: int32 - name*: string - types*: seq[MD5Digest] # is this a joke? - PackedTree* = object ## usually represents a full Nim module nodes*: seq[PackedNode] #sh*: Shared @@ -121,18 +111,11 @@ type floats*: BiTable[BiggestFloat] #config*: ConfigRef -proc hash*(key: GenericKey): Hash = - var h: Hash = 0 - h = h !& hash(key.module) - h = h !& hash(key.name) - h = h !& hash(key.types) - result = !$h - proc `==`*(a, b: SymId): bool {.borrow.} proc hash*(a: SymId): Hash {.borrow.} proc `==`*(a, b: NodePos): bool {.borrow.} -#proc `==`*(a, b: TypeId): bool {.borrow.} +#proc `==`*(a, b: PackedItemId): bool {.borrow.} proc `==`*(a, b: NodeId): bool {.borrow.} proc newTreeFrom*(old: PackedTree): PackedTree = @@ -197,7 +180,7 @@ when false: result = PatchPos tree.nodes.len tree.nodes.add PackedNode(kind: kind, operand: 0, info: info) -proc prepare*(tree: var PackedTree; kind: TNodeKind; flags: TNodeFlags; typeId: TypeId; info: PackedLineInfo): PatchPos = +proc prepare*(tree: var PackedTree; kind: TNodeKind; flags: TNodeFlags; typeId: PackedItemId; info: PackedLineInfo): PatchPos = result = PatchPos tree.nodes.len tree.nodes.add PackedNode(kind: kind, flags: flags, operand: 0, info: info, typeId: typeId) |