compiler/vm/vmchecks

  Source   Edit

This module implements the handle validation logic.

After making making sure that the handle references a valid cell (it's an error otherwise), the layout of cell is traversed in order to verify that there exists a valid location of the handle's type at the offset relative to the start of the cell.

Special handling is required for variant objects, since whether a sub-location is valid depends on the run-time value of the respective disciminator(s) there.

Procs

func checkValid(al: VmAllocator; h: LocHandle): AccessViolationReason {.
    ...raises: [Exception], tags: [RootEffect].}
Tests and returns whether the handle h is valid. That is, whether it points to a valid memory cell and location and whether the handle's type is compatible with that of the location.   Source   Edit