compiler/ast/trees

  Source   Edit

tree helper routines

Procs

proc cyclicTree(n: PNode): bool {....raises: [], tags: [].}
  Source   Edit
proc dontInlineConstant(orig, cnst: PNode): bool {.inline, ...raises: [], tags: [].}
  Source   Edit
proc effectSpec(n: PNode; effectType: TSpecialWord): PNode {....raises: [],
    tags: [].}
  Source   Edit
proc exprStructuralEquivalent(a, b: PNode): bool {....raises: [], tags: [].}
  Source   Edit
proc exprStructuralEquivalentStrictSym(a, b: PNode): bool {....raises: [], tags: [].}
  Source   Edit
proc exprStructuralEquivalentStrictSymAndComm(a, b: PNode): bool {.
    ...raises: [KeyError], tags: [].}
  Source   Edit
proc extractRange(k: TNodeKind; n: PNode; a, b: int): PNode {....raises: [],
    tags: [].}
  Source   Edit
proc findPragma(n: PNode; which: TSpecialWord): PNode {....raises: [], tags: [].}
  Source   Edit
proc flattenExpr(expr: PNode; stmts: var seq[PNode]): PNode {....raises: [],
    tags: [].}
Applies the following transformations to the expression expr:
1.) transform an AST like: (A (StmtListExpr (x) (y)) (z)) into
(StmtListExpr (x) (A (y) (z)))
2.) add all statements from a statement list expression to stmts and
pass on the last node

The result of #2 is passed back to step #1 and the process is repeated until none of the two transformations apply anymore. Together, these transformations make processing easier for the following analysis steps, and the generated AST a bit less nested.

  Source   Edit
proc flattenStmts(n: PNode): PNode {....raises: [], tags: [].}
  Source   Edit
proc getMagic(op: PNode): TMagic {....raises: [], tags: [].}
  Source   Edit
proc getRoot(n: PNode): PSym {....raises: [], tags: [].}
getRoot takes a path n. A path is an lvalue expression like obj.x[i].y. The root of a path is the symbol that can be determined as the owner; obj in the example.   Source   Edit
proc isCaseObj(n: PNode): bool {....raises: [], tags: [].}
  Source   Edit
proc isConstExpr(n: PNode): bool {....raises: [], tags: [].}
  Source   Edit
proc isDeepConstExpr(n: PNode; preventInheritance = false): bool {....raises: [],
    tags: [].}
  Source   Edit
proc isNoSideEffectPragma(n: PNode): bool {....raises: [], tags: [].}
  Source   Edit
proc isRange(n: PNode): bool {.inline, ...raises: [], tags: [].}
  Source   Edit
proc isTrue(n: PNode): bool {....raises: [], tags: [].}
  Source   Edit
proc stupidStmtListExpr(n: PNode): bool {....raises: [], tags: [].}
  Source   Edit
proc whichPragma(n: PNode): TSpecialWord {....raises: [], tags: [].}
  Source   Edit

Templates

template makeTreeEquivalenceProc(name, relaxedKindCheck, symCheck, floatCheck,
                                 typeCheck, commentCheck) {.dirty.}
Defines a tree equivalence checking procedure. This skeleton is shared between all recursive PNode equivalence checks in the compiler code base It might be possible to unify more of them with each other.   Source   Edit