cps/normalizedast

Search:
Group by:
Source   Edit  

Types

Call = distinct NormNode
opaque sum: call node of some variety, see macros.CallNodes and macros.nnkCallKinds Source   Edit  
CallKind = Call
opaque sum: call node of some variety, see macros.nnkCallKinds, this is an alias as it's not really useful to distinguish the two. Source   Edit  
Conv = distinct NormNode
an nnkConv node Source   Edit  
DefLike = IdentDefLike | DefVarLet | TupleDefVarLet
abstract over any IdentDef or VarTuple from a VarLet or a RoutineParam Source   Edit  
DotExpr = distinct NormNode
nnkDotExpr Source   Edit  
ExprLike = Name | NormNode
abstract over any nim value expression Source   Edit  
FormalParams = distinct NormNode
formal params for a routine, includes return param, then calling params Source   Edit  
Ident = distinct Name
nnkIdent Source   Edit  
IdentDef = distinct NormNode
currently this is nnkIdentDefs mostly in a var let section, in reality these are also for routine and generic param definitions. A normalized IdentDef should only have one identifier. Source   Edit  
IdentDefLet = distinct IdentDefVarLet
opaque sum: identdef defintion from a let section Source   Edit  
IdentDefLike = IdentDef | RoutineParam | IdentDefVarLet | IdentDefLet |
    IdentDefVar
abstract over a single var or let sections IdentDef, or a routine param definition Source   Edit  
IdentDefVar = distinct IdentDefVarLet
opaque sum: identdef defintion from a var section Source   Edit  
IdentDefVarLet = distinct DefVarLet
opaque sum: identdef defintion from a var or let section Source   Edit  
LetIdentDef = distinct VarLetIdentDef
a let section with a single nnkIdentDefs, never a vartuple Source   Edit  
LetSection = distinct VarLet
a let section, with a single nnkIdentDefs or vartuple Source   Edit  
LetSectionLike = LetSection | IdentDefLet
abstract over various forms of let sections, used to define operations over or allow abstracting over this type class further Source   Edit  
Name = distinct NormNode
opaque sum: Ident | Sym This lets you query and use name like things, which is often required as transformations need to resym, desym, bind, all over the place Source   Edit  
Pragma = distinct NormNode
opaque sum: PragmaStmt, PragmaBlock, and PragmaExpr Source   Edit  
PragmaAtom = distinct NormNode
opaque sum: a single pragma expressions (eg: atom, colon, call, ...) Source   Edit  
PragmaBlock = distinct Pragma
an nnkPragmaBlock, like {.cast(noSideEffect).}: ... Source   Edit  
PragmaExpr = distinct Pragma
an nnkPragmaExpr, such as foo{.praggy, maggy.} Source   Edit  
PragmaHaver = RoutineDef | ProcDef | Call | TypeExprObj | TypeExprRef | TypeDef
abstract over things that have pragmas to provide a uniform interface Source   Edit  
PragmaLike = PragmaBlock | PragmaExpr | PragmaStmt
abstract over any pragma like thing and provide common operations Source   Edit  
PragmaStmt = distinct Pragma
an nnkPragma node, contains 0 or more child PragmaAtom Source   Edit  
ProcDef = distinct RoutineDef
an nnkProcDef node which has been normalized Source   Edit  
RoutineDef = distinct NormNode
any kind under macros.RoutineNodes which has been normalized Source   Edit  
RoutineParam = distinct IdentDef
each calling params of proc/func/etc definition is an nnkIdentDefs Source   Edit  
Sym = distinct Name
nnkSym Source   Edit  
TupleDefVarLet = distinct DefVarLet
opaque sum: tuple defintion from a var or let section Source   Edit  
TypeDef = distinct NormNode
nnkTypeDef Source   Edit  
TypeExpr = distinct NormNode
opaque sum: see TypeExprKinds the type part of a let or var definition, routine param, or type def or section. Source   Edit  
TypeExprLike = Name | TypeExpr
Any expression that could go into the type part of a routine parameter, the identdef of a var or let section, etc. Source   Edit  
TypeExprObj = distinct TypeExpr
nnkObjTy Source   Edit  
TypeExprRef = distinct TypeExpr
nnkRefTy Source   Edit  
TypeSection = distinct NormNode
nnkTypeSection Source   Edit  
VarIdentDef = distinct VarLetIdentDef
a var section with a single nnkIdentDefs, never a vartuple Source   Edit  
VarLet = distinct NormNode
opqaue sum: a var or let section, with a single define ident or tuple Source   Edit  
VarLetIdentDef = distinct VarLet
opaque sum: a var or let section, but with a single identdefs, eg: var a: int = 10 Source   Edit  
VarLetIdentDefLike = VarLetIdentDef
abstract over let or var sections with identdefs within Source   Edit  
VarLetLike = VarLet | VarLetTuple | VarLetIdentDef | LetSectionLike |
    VarSectionLike
abstract over various let or var sections types Source   Edit  
VarLetTuple = distinct VarLet
opaque sum: a var or let section, but with a tuple defintion within Source   Edit  
VarSection = distinct VarLet
a var section, with a single nnkIdentDefs or vartuple Source   Edit  
VarSectionLike = VarSection | IdentDefVar
abstract over various var sections types Source   Edit  

Consts

AccessNodes = {nnkNone..nnkNilLit, nnkBracketExpr, nnkDotExpr, nnkDerefExpr,
               nnkHiddenAddr..nnkHiddenDeref}
AST nodes for operations accessing a resource Source   Edit  
ConstructNodes = {nnkBracket, nnkObjConstr, nnkTupleConstr}
AST nodes for construction operations Source   Edit  
ConvNodes = {nnkHiddenStdConv..nnkConv}
Conversion nodes in typed AST Source   Edit  
HiddenNodes = {nnkHiddenCallConv, nnkHiddenStdConv, nnkHiddenSubConv,
               nnkHiddenAddr, nnkHiddenDeref}
"Hidden" AST nodes Source   Edit  
NilNimNode = nil
Source   Edit  
NilNormNode = nil
Source   Edit  

Procs

func `$`(a: Name): string {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc `$`(n: NormNode): string {....raises: [], tags: [], forbids: [].}
to string Source   Edit  
func `==`(a, b: Name): bool {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc `==`(a, b: TypeExpr): bool {.borrow, ...raises: [], tags: [], forbids: [].}
compare two TypeEpxrs and see if they're equal Source   Edit  
func `==`(a: NimNode; b: Name): bool {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc `[]`[R: RecursiveNode; T, U](n: R; x: HSlice[T, U]): seq[R]
grab an inclusive n slice of normalized children Source   Edit  
proc `[]`[T: RecursiveNode](n: T; i: BackwardsIndex): T
grab the i'th child of a normalized node should be normalized itself Source   Edit  
proc `[]`[T: RecursiveNode](n: T; i: int): T
grab the i'th child of a normalized node should be normalized itself Source   Edit  
proc `[]=`(n: NormNode; i: BackwardsIndex; child: NormNode) {.borrow,
    ...raises: [], tags: [], forbids: [].}
set the i'th child of a normalized node to a normalized child Source   Edit  
proc `[]=`(n: NormNode; i: int; child: NormNode) {.borrow, ...raises: [], tags: [],
    forbids: [].}
set the i'th child of a normalized node to a normalized child Source   Edit  
proc add(f: NimNode; c: NormNode): NormNode {.discardable, ...raises: [], tags: [],
    forbids: [].}
add a child node, and return the parent for further chaining. created in order to fix ambiguous call issues ... again. Source   Edit  
proc add(f: NormNode; c: NormNode): NormNode {.discardable, ...raises: [],
    tags: [], forbids: [].}
add a child node, and return the parent for further chaining. created in order to fix ambiguous call issues Source   Edit  
proc add[T: RecursiveNode](f: T; cs: NormalizedVarargs): T {.discardable.}
add a child node, and return the parent for further chaining. created in order to fix ambiguous call issues Source   Edit  
proc addPragma(n: RoutineDefLike; prag: Name)
add a pragma (prag) to the definition: {.prag.} Source   Edit  
proc addPragma(n: RoutineDefLike; prag: Name; pragArg: Name)
adds a pragma as follows {.prag: pragArg.} in a colon expression Source   Edit  
proc addPragma(n: RoutineDefLike; prag: Name; pragArg: NimNode)
adds a pragma as follows {.prag: pragArg.} in a colon expression Source   Edit  
proc addPragma(n: RoutineDefLike; prag: Name; pragArgs: openArray[Name])
add pragmas of the form {.raise: [IOError, OSError].} Source   Edit  
proc addPragma(n: RoutineDefLike; prag: string)
add the pragma (prag) as an ident to this definition Source   Edit  
func asCall(n`gensym107: NormNode): Call {....raises: [], tags: [], forbids: [].}
coerces a node n or errors out Source   Edit  
func asCallKind(n`gensym105: NormNode): CallKind {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
func asConv(n`gensym110: NormNode): Conv {....raises: [], tags: [], forbids: [].}
coerces a node n or errors out Source   Edit  
proc asIdentDefs(n: NimNode): IdentDef {....raises: [], tags: [], forbids: [].}
return an IdentDef or error out Source   Edit  
func asName(n: NimNode): Name {....raises: [], tags: [], forbids: [].}
coerce to Name Source   Edit  
proc asName(n: string; info: NormNode = NilNormNode): Name {....raises: [],
    tags: [], forbids: [].}
nnkIdent as Name Source   Edit  
proc asName(n: TypeExpr): Name {....raises: [], tags: [], forbids: [].}
coerce to a Name, or error Source   Edit  
func asName(n`gensym51: NormNode): Name {....raises: [], tags: [], forbids: [].}
coerces a node n or errors out Source   Edit  
func asNameAllowEmpty(n: NimNode): Name {....raises: [], tags: [], forbids: [].}
coerce to Name, allow nnkEmpty, error out otherwise Source   Edit  
func asNameAllowEmpty(n`gensym53: NormNode): Name {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
proc asPragmaAtom(n: Name): PragmaAtom {....raises: [], tags: [], forbids: [].}
convert a Name to a PragmaAtom Source   Edit  
func asPragmaBlock(n`gensym103: NormNode): PragmaBlock {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
proc asPragmaStmt(n: Name): PragmaStmt {....raises: [], tags: [], forbids: [].}
validate and coerce into a PragmaStmt Source   Edit  
func asPragmaStmt(n`gensym101: NormNode): PragmaStmt {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
func asProcDef(n`gensym114: NormNode): ProcDef {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
func asRoutineDef(n`gensym112: NormNode): RoutineDef {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
func asSym(n`gensym62: NormNode): Sym {....raises: [], tags: [], forbids: [].}
coerces a node n or errors out Source   Edit  
func asTypeDef(n`gensym70: NormNode): TypeDef {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
func asTypeExpr(n`gensym72: NormNode): TypeExpr {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
func asTypeExprAllowEmpty(n`gensym74: NormNode): TypeExpr {....raises: [],
    tags: [], forbids: [].}
coerces a node n or errors out Source   Edit  
func asTypeExprObj(n`gensym76: NormNode): TypeExprObj {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
func asTypeExprRef(n`gensym78: NormNode): TypeExprRef {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
func asTypeSection(n`gensym68: NormNode): TypeSection {....raises: [], tags: [],
    forbids: [].}
coerces a node n or errors out Source   Edit  
proc asVarLet(n: NimNode): VarLet {....raises: [], tags: [], forbids: [].}
return a VarLet if this is a var or let section, otherwise error out Source   Edit  
proc asVarLetIdentDef(n: VarLet): VarLetIdentDef {....raises: [], tags: [],
    forbids: [].}
return a VarLetIdentDef if the def is an IdentDef, otherwise error out Source   Edit  
proc asVarLetTuple(n: VarLet): VarLetTuple {....raises: [], tags: [], forbids: [].}
return a VarLetTuple if the def is a VarTuple, otherwise error out Source   Edit  
proc bindName(n: static string): Name
bindSym the string as a Name Source   Edit  
proc bindName(n: static string; rule: static BindSymRule): Name
bindSym the string as a Name and specified bind sym rule Source   Edit  
proc body(n: RoutineDef): NormNode {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc body=(n: RoutineDef; b: NormNode) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc childCallToRecoverResult(n: Call; sym, field: NormNode): Call {.
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
this is used to rewrite continuation calls into their results Source   Edit  
proc clone(n: ProcDef; body: NimNode = NilNimNode): ProcDef {....raises: [],
    tags: [], forbids: [].}
create a copy of a typed proc which satisfies the compiler Source   Edit  
func clone(n: VarLet; value: NimNode = NilNimNode): VarLet {....raises: [],
    tags: [], forbids: [].}
clone a VarLet but with value changed Source   Edit  
proc copy(n: NormNode): NormNode {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc copyLineInfo(arg, info: NormNode) {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc copyLineInfo(arg: NormNode; info: NimNode) {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc copyNimNode(n: NormNode): NormNode {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc copyNimTree(n: NormNode): NormNode {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func def(n: VarLetLike): DefVarLet | TupleDefVarLet
an IdentDef or VarTuple as a not very specific type DefVarLet for VarLetTuple a more specific type TupleDefVarLet is returned Source   Edit  
proc desym(n: Call) {....raises: [], tags: [], forbids: [].}
desyms the callee name Source   Edit  
proc desym(n: Name): Name {.borrow, ...raises: [], tags: [], forbids: [].}
ensures that Name is an nnkIdent Source   Edit  
proc desym[T: Desymable](n: T; sym: NimNode | Name): T
desym all occurences of a specific sym Source   Edit  
func eqIdent(a: Name | NimNode; b: distinct Name | NimNode): bool
bridge eqIdent from macros Source   Edit  
func eqIdent(a: Name | NimNode; b: string): bool
bridge eqIdent from macros Source   Edit  
func eqIdent(a: NormNode; b: Name): bool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func errorGot(msg: string; n: NormNode; got = treeRepr(NimNode(n))) {.
    ...raises: [], tags: [], forbids: [].}
useful for error messages Source   Edit  
proc expr(n: Conv): NormNode {....raises: [], tags: [], forbids: [].}
the expression being converted Source   Edit  
proc findChildRecursive(n: NormNode; cmp: proc (n: NormNode): bool): NormNode {.
    ...raises: [Exception], tags: [RootEffect], forbids: [].}

finds the first child node where cmp(node) returns true, recursively

returns nil if none found

Source   Edit  
proc firstCallParam(n: RoutineDef): RoutineParam {....raises: [], tags: [],
    forbids: [].}
returns the first call param for this proc def, useful due to CPS proc often just have one continuation parameter that we access often. Source   Edit  
func formalParams(n: RoutineDef): FormalParams {....raises: [], tags: [],
    forbids: [].}
fetch the formal params, first one is the return param Source   Edit  
proc formalParams=(n: RoutineDef; f: FormalParams) {....raises: [], tags: [],
    forbids: [].}
set the formal params for this routine, first one is the return param Source   Edit  
proc genField(ident = ""): Name {....deprecated: "pending https://github.com/nim-lang/Nim/issues/17851",
                                  raises: [], tags: [], forbids: [].}
Deprecated: pending https://github.com/nim-lang/Nim/issues/17851
generate a unique field to put inside an object definition Source   Edit  
proc genProcName(a, b: string; info = NilNormNode): Name {....raises: [ValueError],
    tags: [], forbids: [].}
Source   Edit  
proc genProcName(a: string; info = NilNormNode): Name {....deprecated,
    raises: [ValueError], tags: [], forbids: [].}
Deprecated
Source   Edit  
proc genSymField(n: string; info: NormNode = NilNormNode): Name {....raises: [],
    tags: [], forbids: [].}
genSym an nskField Source   Edit  
proc genSymLet(n: string = ""; info: NormNode = NilNormNode): Name {....raises: [],
    tags: [], forbids: [].}
genSym an nskLet Source   Edit  
proc genSymProc(n: string; info: NormNode = NilNormNode): Name {....raises: [],
    tags: [], forbids: [].}
genSym an nskProc Source   Edit  
proc genSymType(n: string; info: NormNode = NilNormNode): Name {....raises: [],
    tags: [], forbids: [].}
genSym an nskType Source   Edit  
proc genSymUnknown(n: string; info: NormNode = NilNormNode): Name {....raises: [],
    tags: [], forbids: [].}
genSym an nskUnknown Source   Edit  
proc genSymVar(n: string = ""; info: NormNode = NilNormNode): Name {....raises: [],
    tags: [], forbids: [].}
genSym an nskVar Source   Edit  
proc genTypeName(a, b: string; info = NilNormNode): Name {....raises: [ValueError],
    tags: [], forbids: [].}
Source   Edit  
proc getImpl(n: NormNode): NormNode {.borrow, ...raises: [], tags: [], forbids: [].}
the implementaiton of a normalized node should be normalized itself Source   Edit  
proc getPragmaName(n: NimNode): NimNode {.
    ...deprecated: "Replace with Pragma version", raises: [], tags: [], forbids: [].}
Deprecated: Replace with Pragma version
retrieve the symbol/identifier from the child node of a nnkPragma Source   Edit  
proc getPragmaName(n: PragmaAtom): Name {....raises: [], tags: [], forbids: [].}
retrieve the symbol/identifier from the child node of a PragmaAtom, or if it's an atom then return itself. Source   Edit  
proc getTypeInst(n: NormNode): TypeExpr {.borrow, ...raises: [], tags: [],
    forbids: [].}
return the type instance, via getTypeInst of a NimNode Source   Edit  
func hasImpl(n: Call): bool {....raises: [], tags: [], forbids: [].}
the callee's name is a symbol and a routine impl is present Source   Edit  
proc hasPragma(n: NormNode; s: static[string]): bool
true if the n holds the pragma s Source   Edit  
func hasPragma(n: PragmaHaver; s: static[string]): bool
true if the n holds the pragma s Source   Edit  
func hasPragma(n: PragmaLike; s: static[string]): bool
true if the n holds the pragma s Source   Edit  
func hasType(n: DefLike): bool
has a non-Empty type (typ) defined Source   Edit  
func hasValue(n: DefLike): bool
has a non-Empty initial value defined for the ident, sym or tuple Yes, proc, you ARE a good proc. You have value, hasValue, in fact. Source   Edit  
func hasValue(n: VarLetLike): bool
whether an initial value has been specified Source   Edit  
func identdef(n: VarLetIdentDefLike): IdentDef {....raises: [], tags: [],
    forbids: [].}
retrieve the inner IdentDef Source   Edit  
func impl(n: Call): RoutineDef {....raises: [], tags: [], forbids: [].}
return the RoutineDef associated to this Call n Source   Edit  
func inferTypFromImpl(n: DefLike): TypeExpr
returns the typ if specified or uses macro.getTypeImpl to infer it Source   Edit  
func inferTypFromImpl(n: VarLetIdentDefLike): TypeExpr {....raises: [], tags: [],
    forbids: [].}
returns the typ if specified or uses macro.getTypeImpl to infer it Source   Edit  
func isExported(n: Name): bool {....raises: [], tags: [], forbids: [].}
true if this has been exported Source   Edit  
func isNil(n: Name): bool {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
func isNil(n: TypeExpr): bool {.borrow, ...raises: [], tags: [], forbids: [].}
true if nil Source   Edit  
func isSymbol(n: Name): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
func isTuple(n: VarLetLike): bool
Source   Edit  
func kind(n: NormNode): NimNodeKind {.borrow, ...raises: [], tags: [], forbids: [].}
the kind (NimNodeKind) of the underlying NimNode Source   Edit  
func kind(n: VarLetLike): NimNodeKind
Source   Edit  
func last[T: RecursiveNode](n: T): T
last child Source   Edit  
func len(n: NormNode): int {.borrow, ...raises: [], tags: [], forbids: [].}
number of children Source   Edit  
func name(n: Call): Name {....raises: [], tags: [], forbids: [].}
callee name Source   Edit  
func name(n: IdentDefLike): Name
retrieve the name of this IdentDefLike Source   Edit  
func name(n: PragmaExpr): Name {....raises: [], tags: [], forbids: [].}
Source   Edit  
func name(n: RoutineDef): Name {....raises: [], tags: [], forbids: [].}
get the name of this RoutineDef Source   Edit  
func name(n: VarLetIdentDefLike): Name {....raises: [], tags: [], forbids: [].}
Name (ident|sym) of the identifer, as we only have a single identdefs it will have the name Source   Edit  
proc name=(callee: Call; newName: Name) {....raises: [], tags: [], forbids: [].}
set the callee's name to newName Source   Edit  
proc name=(n: RoutineDef; name: Name) {....raises: [], tags: [], forbids: [].}
set the name of this RoutineDef Source   Edit  
proc newAssignment(l`gensym67: ExprLike; r`gensym67: distinct ExprLike): NormNode
Source   Edit  
proc newCall(n: Name; args: AnyNodeVarargs): Call {....raises: [], tags: [],
    forbids: [].}
create a new call, with n as name some args Source   Edit  
proc newCall(n: NormNode; args: AnyNodeVarargs): Call {....raises: [], tags: [],
    forbids: [].}
create a new call, with n as name some args Source   Edit  
proc newCall(n: string; args: AnyNodeVarargs): Call {....raises: [], tags: [],
    forbids: [].}
create a new call, with n as and ident name, and a single arg Source   Edit  
proc newColonExpr(l`gensym66: ExprLike; r`gensym66: distinct ExprLike): NormNode
Source   Edit  
proc newDotExpr(l`gensym65: ExprLike; r`gensym65: distinct ExprLike): NormNode
Source   Edit  
proc newEmptyNormNode(): NormNode {....raises: [], tags: [], forbids: [].}
create a new empty node (nnkEmpty) Source   Edit  
proc newFormalParams(ret: TypeExpr; ps: varargs[IdentDef]): FormalParams {.
    ...raises: [], tags: [], forbids: [].}
create new formal params, with a return of ret, and calling params ps Source   Edit  
proc newIdentDef(n: Name; t: TypeExprLike; val = newEmptyNode()): IdentDef
create a single assignment nnkIdentDefs, we drop the plural to indicate the singleton nature Source   Edit  
proc newIdentDef(n: Name; val: NormNode): IdentDef {....raises: [], tags: [],
    forbids: [].}
create a single assignment nnkIdentDefs, we drop the plural to indicate the singleton nature Source   Edit  
proc newIdentDef(n: string; t: TypeExprLike; val = newEmptyNode()): IdentDef
create a single assignment nnkIdentDefs, we drop the plural to indicate the singleton nature Source   Edit  
proc newIdentDefVar(i: IdentDef): IdentDefVar {....raises: [], tags: [],
    forbids: [].}
create a var section with an identdef ie: newVarSection(i), where i is 'foo: int = 2` -> var foo: int = 2 Source   Edit  
proc newIdentDefVar(n: Name; t: TypeExprLike; val = newEmptyNode()): IdentDefVar
create a var section with an identdef, eg: n: t = val Source   Edit  
proc newLetIdentDef(i: IdentDef): LetIdentDef {....raises: [], tags: [],
    forbids: [].}
create a let section with an identdef ie: newLetSection(i), where i is 'foo: int = 2` -> let foo: int = 2 Source   Edit  
proc newLetIdentDef(n: Name; t: TypeExprLike; val = newEmptyNode()): LetIdentDef
create a let section with an identdef, eg: n: t = val Source   Edit  
proc newLetIdentDef(n: Name; val: NormNode): LetIdentDef {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc newPragmaColonExpr(n: static[string]; r: NormNode): PragmaAtom
create a new PragmaAtom that's a colon expression Source   Edit  
proc newPragmaStmt(es: varargs[PragmaAtom]): PragmaStmt {....raises: [], tags: [],
    forbids: [].}
create a new PragmaStmt node with es pragma exprs, but returns an empty node if none are provided. Source   Edit  
proc newPragmaStmt(n: Name): PragmaStmt {....raises: [], tags: [], forbids: [].}
create a new PragmaStmt node with n as a PragmaAtom Source   Edit  
proc newPragmaStmtWithInfo(inf: NormNode; es: varargs[PragmaAtom]): PragmaStmt {.
    ...raises: [], tags: [], forbids: [].}
create a new PragmaStmt node with es pragma exprs, but returns an empty node if none are provided, and sets the line info Source   Edit  
proc newProcDef(name: Name; retType: TypeExpr; callParams: varargs[IdentDef]): ProcDef {.
    ...raises: [], tags: [], forbids: [].}
create a new proc def with name, returnt type, and calling params and an empty body (nnkStmtList) Source   Edit  
proc newRefType(n: Name): TypeExprRef {....raises: [], tags: [], forbids: [].}
create a new ref type from n Source   Edit  
proc newStmtList(stmts: AnyNodeVarargs): NormNode {....raises: [], tags: [],
    forbids: [].}
create a new normalized statement Source   Edit  
proc newTree(kind: NimNodeKind; n: AnyNodeVarargs): NormNode {....raises: [],
    tags: [], forbids: [].}
creates a new tree (newTree) of kind, with child n Source   Edit  
proc newVarIdentDef(i: IdentDef): VarIdentDef {....raises: [], tags: [],
    forbids: [].}
create a var section with an identdef ie: newVarSection(i), where i is 'foo: int = 2` -> var foo: int = 2 Source   Edit  
proc newVarLetIdentDef(kind: NimNodeKind; i: IdentDef): VarLetIdentDef {.
    ...raises: [], tags: [], forbids: [].}
create a new VarLetIdentDef Source   Edit  
proc newVarLetIdentDef(kind: NimNodeKind; name: Name; typ: TypeExprLike;
                       val: NimNode): VarLetIdentDef
create a new VarLetIdentDef Source   Edit  
proc newVarSection(i: IdentDef): VarSection {....raises: [], tags: [], forbids: [].}
create a var section with an identdef ie: newVarSection(i), where i is 'foo: int = 2` -> var foo: int = 2 Source   Edit  
proc newVarSection(n: Name; t: TypeExprLike; val = newEmptyNode()): VarSection
create a var section with an identdef, eg: n: t = val Source   Edit  
proc normalizeCall(n: NimNode): Call {....raises: [Exception], tags: [RootEffect],
                                       forbids: [].}
ensure this is a normalized procd definition Source   Edit  
proc normalizeProcDef(n: NimNode): ProcDef {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
ensure this is a normalized procd definition Source   Edit  
proc onlyNormalizedNode[T: distinct](n: T): NormNode
used for conversion in an vararg scenarios primarily Source   Edit  
proc postfix(n: Name; op: string): Name {....raises: [], tags: [], forbids: [].}
Source   Edit  
func pragma(n: PragmaHaver): PragmaLike
fetch all pragma declared on this routine definition or a callee Source   Edit  
proc pragma=(n: ProcDef; p: PragmaStmt) {....raises: [], tags: [], forbids: [].}
set the pragma Source   Edit  
proc pragma=(n: RoutineDef; p: PragmaStmt) {....raises: [], tags: [], forbids: [].}
set the pragma for this routine, replace the previous one entirely Source   Edit  
proc prependArg(n: Call; arg: NormNode) {....raises: [], tags: [], forbids: [].}
add an argument to the call in the first position of the call Source   Edit  
proc resym(fragment: NormNode; sym, replacement: Name): NormNode {.borrow,
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
replace sym in the AST fragment with the replacement Source   Edit  
func returnParam(n: ProcDef): TypeExpr {....raises: [], tags: [], forbids: [].}
the return param or empty if void Source   Edit  
proc returnParam=(n: ProcDef; ret: Name) {....raises: [], tags: [], forbids: [].}
set the return param Source   Edit  
proc sameType(a, b: TypeExpr): bool {.borrow, ...raises: [], tags: [], forbids: [].}
compare the type associated with the TypeExprs and see if they're equal Source   Edit  
proc sinkAnnotated(n: NormNode): TypeExpr {....raises: [], tags: [], forbids: [].}
create a sink annotated type expression from n Source   Edit  
func smartSniffer(n: VarLetLike): TypeExpr
perform some type-fu for tuple type sniffing Source   Edit  
func strVal(n: Name): string {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc typ(n: Conv): TypeExpr {....raises: [], tags: [], forbids: [].}
the type being converted to Source   Edit  
func typ(n: DefLike): TypeExpr
get the type of this identdef or vartuple Source   Edit  
func typ(n: VarLetLike): TypeExpr
the type of this definition (IdentDef or VarTuple) Source   Edit  
func typeInst(n: Name): TypeExpr {....deprecated: "A Name can be a bare ident and entirely untyped",
                                   raises: [], tags: [], forbids: [].}
Deprecated: A Name can be a bare ident and entirely untyped
gets the type via getTypeInst Source   Edit  
func typeInst(n: Sym): TypeExpr {....raises: [], tags: [], forbids: [].}
gets the type via getTypeInst Source   Edit  
proc typeKind(n: TypeExpr): NimTypeKind {.borrow, ...raises: [], tags: [],
    forbids: [].}
get the type kind of a type expr Source   Edit  
proc upgradeToNormalizedNode[T](n: T): NormNode
used for conversion in varargs, will convert NimNode to NormNode Source   Edit  
func val(n: DefLike): NormNode
get the value of this identdef or vartuple Source   Edit  
func val(n: VarLetLike): NormNode
the ident or sym being defined, or tuple being defined Source   Edit  
proc wrap(kind: NimNodeKind; n: NormNode): NormNode {....raises: [], tags: [],
    forbids: [].}
wraps a node n within a new node of kind Source   Edit  

Iterators

iterator callingParams(n: ProcDef): RoutineParam {....raises: [], tags: [],
    forbids: [].}
iterate over formal parameters used to call this routine, excludes the return parameter. Source   Edit  
iterator indexNamePairs(n: VarLetTuple): (int, Name) {....raises: [], tags: [],
    forbids: [].}
return the names of fields on the lhs of a var/let tuple assignment Source   Edit  
iterator items(n: NormNode): NormNode {....raises: [], tags: [], forbids: [].}
iterate through the kiddos Source   Edit  
iterator items(n: PragmaLike): PragmaAtom
fetch the individual atoms Source   Edit  
iterator pairs(n: NormNode): (int, NormNode) {....raises: [], tags: [], forbids: [].}
iterate through the kiddos, but also get their index Source   Edit  

Converters

converter cCallToNormNode(n`gensym26: Call): NormNode {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
converter cConvToNormNode(n`gensym27: Conv): NormNode {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
converter cDefVarLetToNormNode(n`gensym40: DefVarLet): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cFormalParamsToNormNode(n`gensym33: FormalParams): NormNode {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cIdentDefLetToIdentDef(n`gensym43: IdentDefLet): IdentDef {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cIdentDefLetToNormNode(n`gensym41: IdentDefLet): NormNode {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cIdentDefToNimNode(n`gensym1: IdentDef): NimNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cIdentDefToNormNode(n`gensym30: IdentDef): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cIdentDefVarToIdentDef(n`gensym44: IdentDefVar): IdentDef {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cIdentToNimNode(n`gensym2: Ident): NimNode {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
converter cLetIdentDefToVarLetIdentDef(n`gensym46: LetIdentDef): VarLetIdentDef {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cLetSectionToNormNode(n`gensym36: LetSection): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cNameToNormNode(n`gensym24: Name): NormNode {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
converter cNormNodeToNimNode(n`gensym0: NormNode): NimNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cPragmaAtomToNormNode(n`gensym29: PragmaAtom): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cPragmaStmtToNormNode(n`gensym28: PragmaStmt): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cProcDefToNormNode(n`gensym32: ProcDef): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cProcDefToRoutineDef(n`gensym48: ProcDef): RoutineDef {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cRoutineDefToNimNode(n`gensym4: RoutineDef): NimNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cRoutineDefToNormNode(n`gensym31: RoutineDef): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cRoutineParamToIdentDef(n`gensym45: RoutineParam): IdentDef {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cRoutineParamToNormNode(n`gensym34: RoutineParam): NormNode {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cSymToName(n`gensym64: Sym): Name {....raises: [], tags: [], forbids: [].}
Source   Edit  
converter cSymToNormNode(n`gensym42: Sym): NormNode {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
converter cTypeExprRefToTypeExpr(n`gensym49: TypeExprRef): TypeExpr {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cTypeExprToNormNode(n`gensym25: TypeExpr): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cVarIdentDefToVarLetIdentDef(n`gensym47: VarIdentDef): VarLetIdentDef {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cVarLetIdentDefToNormNode(n`gensym38: VarLetIdentDef): NormNode {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cVarLetToNormNode(n`gensym37: VarLet): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cVarLetTupleToNormNode(n`gensym39: VarLetTuple): NormNode {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
converter cVarSectionToNimNode(n`gensym3: VarSection): NimNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter cVarSectionToNormNode(n`gensym35: VarSection): NormNode {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
converter seqNormalizedToSeqNimNode(n: seq[NormNode]): seq[NimNode] {.
    ...raises: [], tags: [], forbids: [].}
convert a seq[NormNode] to seq[NimNode] for ease of use Source   Edit  

Templates

template copyNodeAndTransformIt(n: NimNode; body: untyped): untyped
copies a node n into it, transforms it with body, and provides it as the expression result. Assumes n and it are Normalized. Source   Edit  
template dot(a, b: NormNode): NormNode
for constructing foo.bar Source   Edit  
template dot(a: NormNode; b: string): NormNode
for constructing .(foo, "bar") Source   Edit  
template findChild(n: NormNode; cond: untyped): NormNode
finds the first child node matching the condition or nil Source   Edit  
template hash(n: Name): Hash
hash Name nodes, necessary for what we do in environment Source   Edit  
template hash(n: NormNode): Hash
hash NormNode, necessary for what we do in environment Source   Edit  
template ifCallKindThenIt(n: NormNode; body: untyped)
if n is a nnCallKinds then run the body with it as Call Source   Edit  
template ifCallThenIt(n: NormNode; body: untyped)
if n is a CallNodes then run the body with it as Call Source   Edit  
template newNodeAndTransformIt(n: NimNode; body: untyped): untyped
creates a node it, transformed by the body, and provides the result. Info and kind of node are derived from n. This proc is useful for when type information of n needs to be wiped, otherwise use copyNodeAndTransformIt. Assumes n and it are Normalized. Source   Edit