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