index.mli 1.1 KB

12345678910111213141516171819202122
  1. (** Tag variable declarations with stack frame indices. *)
  2. (** The assembly phase needs to know indices of variables in the current stack
  3. frame to be pass to [load|store] instructions. This phase traverses the AST
  4. and adds [Index] annotations based on a counter that is increased when
  5. declaration is encountered.
  6. A problem, however, is that uses of these declarations do not inherit these
  7. annotations, since the declaration annotations are not references.
  8. Therefore, this phase first strips all context analysis by replacing
  9. variable/function uses with the original [Var|Assign|FunCall] nodes. Then,
  10. index analysis is performed on declarations. Finally, the
  11. {!Context.analyse_context} traversal is re-run to carry the [Index]
  12. annotations to the variable/function uses.
  13. Note that we can safely assume that no errors will occur during this context
  14. analysis, since incorrect uses would have been spotted by the earlier
  15. context analysis already.
  16. *)
  17. (** Main phase function, called by {!Main}. *)
  18. val phase : Main.phase_func