cps/rewrites

Search:
Group by:
Source   Edit  

Types

Matcher = proc (n: NimNode): bool
A proc that returns whether a NimNode should be replaced Source   Edit  
NodeFilter = proc (n: NimNode): NimNode
Source   Edit  
NormalizingFilter = proc (n: NimNode): NormNode
variant of NodeFilter but normalizes the node Source   Edit  
NormFilter = proc (n: NormNode): NormNode
variant of NodeFilter but normalizes the node Source   Edit  
NormMatcher = proc (n: NormNode): bool {.noSideEffect.}
A proc that returns whether a NimNode should be replaced Source   Edit  
NormNode = distinct NimNode
a normalized node, but this should not be useed directly, use a specialized type instead, see the normalizedast module. Source   Edit  

Consts

NormalCallNodes = {nnkCommand..nnkPostfix}
Source   Edit  

Procs

proc addInitializationToDefault(n: NimNode): NimNode {....raises: [], tags: [],
    forbids: [].}
Turn an IdentDefs as in var x: Foo into var x: Foo = default Foo; this ensures a reset of the field in the environment occurs when the scope is re-entrant for any reason. Source   Edit  
proc childCallToRecoverResult(n, sym, field: NormNode): NormNode {.borrow,
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
this is used to rewrite continuation calls into their results Source   Edit  
proc childCallToRecoverResult(n: NimNode; sym: NimNode; field: NimNode): NimNode {.
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
this is used to rewrite continuation calls into their results Source   Edit  
proc desym(n: NimNode): NimNode {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc errorAst(n: NimNode | NormNode; s = "creepy ast"): NormNode
embed an error with a message, the line info is copied from the node Source   Edit  
proc errorAst(s: string; info: NimNode = nil): NormNode {....raises: [], tags: [],
    forbids: [].}

produce {.error: s.} in order to embed errors in the ast

optionally take a node to set the error line information

Source   Edit  
proc filter(n: NimNode; f: NodeFilter): NimNode {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
rewrites a node and its children by passing each node to the filter; if the filter yields nil, the node is simply copied. otherwise, the node is replaced. Source   Edit  
proc filter(n: NimNode; f: NormalizingFilter): NormNode {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
rewrites a node and its children by passing each node to the filter; if the filter yields nil, the node is simply copied. otherwise, the node is replaced. Source   Edit  
proc filter(n: NormNode; f: NormFilter): NormNode {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
rewrites a node and its children by passing each node to the filter; if the filter yields nil, the node is simply copied. otherwise, the node is replaced. Source   Edit  
func isEmpty(n: NimNode): bool {....raises: [], tags: [], forbids: [].}
true if the node n is Empty Source   Edit  
proc multiReplace(n: NimNode; replacements: varargs[(Matcher, NimNode)]): NimNode {.
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
Replace any node in n that is matched by a matcher in replacements with a copy of the accompanying NimNode. Source   Edit  
proc multiReplace(n: NormNode; replacements: varargs[(Matcher, NormNode)]): NormNode {.
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
Replace any node in n that is matched by a matcher in replacements with a copy of the accompanying NimNode. Source   Edit  
proc multiReplace(n: NormNode; replacements: varargs[(NormMatcher, NormNode)]): NormNode {.
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
Replace any node in n that is matched by a matcher in replacements with a copy of the accompanying NimNode. Source   Edit  
proc normalizingRewrites(n: NimNode): NormNode {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
Rewrite AST into a safe form for manipulation without removing semantic data. Source   Edit  
proc replace(n: NimNode | NormNode; match: NormMatcher; replacement: NormNode): NormNode
Replace any node in n that is matched by match with a copy of replacement Source   Edit  
proc replace(n: NimNode; match: Matcher; replacement: NimNode): NimNode {.
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
Replace any node in n that is matched by match with a copy of replacement Source   Edit  
proc replacedSymsWithIdents(n: NimNode): NimNode {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc resym(n, sym, field: NormNode): NormNode {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc resym(n: NimNode; sym: NimNode; field: NimNode): NimNode {.
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
seems we only use this for rewriting local symbols into symbols in the env, so we'll do custom handling of identDefs here also Source   Edit  
proc workaroundRewrites(n: NormNode): NormNode {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
Source   Edit  

Templates

template replace(n, noob: NimNode; body: untyped): NimNode {.dirty.}
requires --define:nimWorkaround14447 so... yeah. Source   Edit  
template replace(n, noob: NormNode; body: untyped): NormNode {.dirty.}
requires --define:nimWorkaround14447 so... yeah. Source   Edit