# aliases

Theme:

- Index

Search:
Group by:
Source Edit

Simple alias analysis for the HLO and the code generators.

# Imports

ast, astalgo, types, trees

# Types

    TAnalysisResult = enum
      arNo, arMaybe, arYes

  Source Edit

# Procs

    proc isPartOf(a, b: PNode): TAnalysisResult {.
        ...raises: [KeyError, Exception, ValueError, ERecoverableError],
        tags: [RootEffect], forbids: [].}

  checks if location `a` can be part of location `b`. We treat seqs and strings as pointers because the code gen often just passes them as such.

  Note: `a` can only be part of `b`, if `a`'s type can be part of `b`'s type. Since however type analysis is more expensive, we perform it only if necessary.

  cases:

  YES-cases:

      x    <| x   # for general trees
      x[]  <| x
      x[i] <| x
      x.f  <| x

  NO-cases:

      x           !<| y    # depending on type and symbol kind
      x[constA]   !<| x[constB]
      x.f         !<| x.g
      x.f         !<| y.f  iff x !<= y

  MAYBE-cases:

      x[] ?<| y[]   iff compatible type

      x[]  ?<| y  depending on type

  Source Edit