|
@@ -168,7 +168,7 @@ type instr =
|
|
|
|
|
|
|
|
| Load of ctype * stack_scope * int (** [[ifb]load[ gn] G] *)
|
|
| Load of ctype * stack_scope * int (** [[ifb]load[ gn] G] *)
|
|
|
| LoadConst of ctype * int (** [[ifb]loadc C] *)
|
|
| LoadConst of ctype * int (** [[ifb]loadc C] *)
|
|
|
- | LoadImm of const (** [[ifb]loadc_[01tf]] *)
|
|
|
|
|
|
|
+ | LoadImm of const (** [[ifb]loadc_[01tf] | iloadc_m1] *)
|
|
|
|
|
|
|
|
(* Operators ] *)
|
|
(* Operators ] *)
|
|
|
| Op of operator * ctype
|
|
| Op of operator * ctype
|
|
@@ -198,32 +198,54 @@ type instr =
|
|
|
|
|
|
|
|
| EmptyLine (** Empty line, added in between functions for readability. *)
|
|
| EmptyLine (** Empty line, added in between functions for readability. *)
|
|
|
|
|
|
|
|
-(** {2 General} *)
|
|
|
|
|
|
|
+(** {2 Global} *)
|
|
|
|
|
|
|
|
-(* Intermediate representations between phases *)
|
|
|
|
|
|
|
+(** Intermediate representations, passed from phase to phase. *)
|
|
|
type intermediate =
|
|
type intermediate =
|
|
|
| Empty
|
|
| Empty
|
|
|
|
|
+ (** For phases without input/output (first and last phase). *)
|
|
|
| FileContent of string * string
|
|
| FileContent of string * string
|
|
|
|
|
+ (** Input file content. *)
|
|
|
| Ast of node
|
|
| Ast of node
|
|
|
|
|
+ (** Abstract Syntax Tree. *)
|
|
|
| Assembly of instr list
|
|
| Assembly of instr list
|
|
|
|
|
+ (** List of assembly instructions. *)
|
|
|
|
|
|
|
|
(** Container for command-line arguments. *)
|
|
(** Container for command-line arguments. *)
|
|
|
type args_record = {
|
|
type args_record = {
|
|
|
mutable infile : string option;
|
|
mutable infile : string option;
|
|
|
|
|
+ (** Input filename. *)
|
|
|
mutable outfile : string option;
|
|
mutable outfile : string option;
|
|
|
|
|
+ (** Output filename. *)
|
|
|
mutable verbose : int;
|
|
mutable verbose : int;
|
|
|
|
|
+ (** Verbosity level. *)
|
|
|
mutable cpp : bool;
|
|
mutable cpp : bool;
|
|
|
|
|
+ (** Run C preprocessor? *)
|
|
|
mutable optimize : bool;
|
|
mutable optimize : bool;
|
|
|
|
|
+ (** Run {!Constprop} and {!Peephole} phases? *)
|
|
|
mutable endphase : string;
|
|
mutable endphase : string;
|
|
|
|
|
+ (** Stop at the phase which has the given identifier (see {!Main.phases}). *)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
(** {2 Exceptions} *)
|
|
(** {2 Exceptions} *)
|
|
|
|
|
|
|
|
|
|
+(** Error occurred at a certain location in an input file. *)
|
|
|
exception LocError of location * string
|
|
exception LocError of location * string
|
|
|
|
|
+
|
|
|
|
|
+(** Error occurred at a certain AST node, to be transformed to {!LocError} using
|
|
|
|
|
+ {!Util.locof}. *)
|
|
|
exception NodeError of node * string
|
|
exception NodeError of node * string
|
|
|
|
|
+
|
|
|
|
|
+(** General compilation error message (caught by main function). *)
|
|
|
exception CompileError of string
|
|
exception CompileError of string
|
|
|
|
|
+
|
|
|
|
|
+(** Error without message, just makes the compiler fail with non-zero return
|
|
|
|
|
+ value. *)
|
|
|
exception EmptyError
|
|
exception EmptyError
|
|
|
|
|
|
|
|
|
|
+(** Catch-all error for traversals that accept a limit set of node types. *)
|
|
|
exception InvalidNode
|
|
exception InvalidNode
|
|
|
|
|
+
|
|
|
|
|
+(** Error raised when a phase receives an unsupported {!intermediate} type. *)
|
|
|
exception InvalidInput of string
|
|
exception InvalidInput of string
|
|
|
|
|
|