compiler/sem/aliases

  Source   Edit

Simple alias analysis for the HLO.

Types

TAnalysisResult = enum
  arNo, arMaybe, arYes
  Source   Edit

Procs

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

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
proc isPartOf(a, b: PType): TAnalysisResult {.
    ...raises: [Exception, ERecoverableError], tags: [RootEffect].}
checks iff 'a' can be part of 'b'. Iterates over VALUE types!   Source   Edit