Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
13
Task/Reflection-Get-source/Nim/reflection-get-source.nim
Normal file
13
Task/Reflection-Get-source/Nim/reflection-get-source.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import macros, strformat
|
||||
|
||||
proc f(arg: int): int = arg+1
|
||||
|
||||
macro getSource(source: static[string]) =
|
||||
let module = parseStmt(source)
|
||||
for node in module.children:
|
||||
if node.kind == nnkProcDef:
|
||||
echo(&"source of procedure {node.name} is:\n{toStrLit(node).strVal}")
|
||||
|
||||
proc g(arg: float): float = arg*arg
|
||||
|
||||
getSource(staticRead(currentSourcePath()))
|
||||
Loading…
Add table
Add a link
Reference in a new issue