IC: added converter test case (#17688)
* IC: added converter test case * IC: make converter example work
This commit is contained in:
parent
8aa5991bea
commit
1822ed384a
4 changed files with 30 additions and 3 deletions
|
|
@ -163,14 +163,17 @@ proc addImport(c: PContext; im: sink ImportedModule) =
|
|||
c.imports.add im
|
||||
|
||||
template addUnnamedIt(c: PContext, fromMod: PSym; filter: untyped) {.dirty.} =
|
||||
for it in c.graph.ifaces[fromMod.position].converters:
|
||||
for it in mitems c.graph.ifaces[fromMod.position].converters:
|
||||
if filter:
|
||||
loadPackedSym(c.graph, it)
|
||||
addConverter(c, it)
|
||||
for it in c.graph.ifaces[fromMod.position].patterns:
|
||||
for it in mitems c.graph.ifaces[fromMod.position].patterns:
|
||||
if filter:
|
||||
loadPackedSym(c.graph, it)
|
||||
addPattern(c, it)
|
||||
for it in c.graph.ifaces[fromMod.position].pureEnums:
|
||||
for it in mitems c.graph.ifaces[fromMod.position].pureEnums:
|
||||
if filter:
|
||||
loadPackedSym(c.graph, it)
|
||||
importPureEnumFields(c, it.sym, it.sym.typ)
|
||||
|
||||
proc importAllSymbolsExcept(c: PContext, fromMod: PSym, exceptSet: IntSet) =
|
||||
|
|
|
|||
|
|
@ -326,6 +326,10 @@ proc loadCompilerProc*(g: ModuleGraph; name: string): PSym =
|
|||
strTableAdd(g.compilerprocs, result)
|
||||
return result
|
||||
|
||||
proc loadPackedSym*(g: ModuleGraph; s: var LazySym) =
|
||||
if s.sym == nil:
|
||||
s.sym = loadSymFromId(g.config, g.cache, g.packed, s.id.module, s.id.packed)
|
||||
|
||||
proc `$`*(u: SigHash): string =
|
||||
toBase64a(cast[cstring](unsafeAddr u), sizeof(u))
|
||||
|
||||
|
|
|
|||
2
tests/ic/mdefconverter.nim
Normal file
2
tests/ic/mdefconverter.nim
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
converter toBool*(x: int): bool = x != 0
|
||||
18
tests/ic/tconverter.nim
Normal file
18
tests/ic/tconverter.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
discard """
|
||||
output: "yes"
|
||||
"""
|
||||
|
||||
import mdefconverter
|
||||
|
||||
echo "yes"
|
||||
|
||||
#!EDIT!#
|
||||
|
||||
discard """
|
||||
output: "converted int to bool"
|
||||
"""
|
||||
|
||||
import mdefconverter
|
||||
|
||||
if 4:
|
||||
echo "converted int to bool"
|
||||
Loading…
Add table
Add a link
Reference in a new issue