module Bmdirc:Bombs-Must-Detonate: IR Compilersig..end
Bombs-Must-Detonate: IR Compiler Signature
Author(s): : Brian Go, : Brian Go
type instruction =
| |
Push |
|||
| |
Pop |
|||
| |
Read |
|||
| |
Print |
|||
| |
PrintLn |
|||
| |
Swap |
|||
| |
Stop |
|||
| |
Return |
|||
| |
Cons |
|||
| |
Car |
|||
| |
Cdr |
|||
| |
IsNull |
|||
| |
Nil |
|||
| |
GetElem |
|||
| |
SetElem |
|||
| |
And |
|||
| |
Or |
|||
| |
Add |
|||
| |
Sub |
|||
| |
Mul |
|||
| |
Div |
|||
| |
DivI |
|||
| |
RemI |
|||
| |
Concat |
|||
| |
Neg |
|||
| |
Frac |
|||
| |
Int |
|||
| |
Lt |
|||
| |
Gt |
|||
| |
Lte |
|||
| |
Gte |
|||
| |
Eq |
|||
| |
Neq |
|||
| |
ConstUninit |
|||
| |
Apply |
(* | 1-arity1-arity | *) |
| |
ConstInt of |
|||
| |
ConstFloat of |
|||
| |
ConstString of |
|||
| |
PushSf of |
|||
| |
Assign of |
|||
| |
Acc of |
|||
| |
Rev of |
|||
| |
MakeBlock of |
|||
| |
MakeBlockFilled of |
|||
| |
AllocFields of |
|||
| |
GetField of |
|||
| |
SetField of |
|||
| |
Call of |
|||
| |
Jmp of |
|||
| |
Jz of |
|||
| |
Jnz of |
|||
| |
RPC of |
|||
| |
Label of |
|||
| |
Comment of |
|||
| |
Annotation of |
|||
| |
GetElemStatic of |
|||
| |
SetElemStatic of |
(* | 2-arity2-arity | *) |
| |
MakeBlockStatic of |
type ir_instruction =
| |
Instruction of |
(* | Ir-SpecificIr-Specific | *) |
| |
GetVar of |
|||
| |
SetVar of |
|||
| |
NoteVar of |
|||
| |
NoteFunction of |
|||
| |
If of |
(* | test, then, elsetest, then, else | *) |
| |
For of |
(* | init, test, step, body | *) |
| |
While of |
(* | test, body | *) |
| |
DoWhile of |
(* | body, test | *) |
| |
Break |
|||
| |
Continue |
|||
| |
BeginScope |
|||
| |
EndScope |
|||
| |
EndScopeSf |
|||
| |
EndScopeSfRPC |
|||
| |
DeclareGlobal of |
typeir_buffer =ir_instruction list
val concat : string list -> stringexception Ircompile_error of string
val init_buffer : ir_instruction list Pervasives.refval raise_compile_error : string list -> 'aval repeat_list : 'a list -> int -> 'a listval label_id : int Pervasives.refval make_label : string -> string
Makes a label from the given string which has a unique prefix
val note_arg_list : ('a * string) list -> int -> ir_instruction listval compile_datatype_init : Ast.data_type -> ir_instruction listval compile_datatypes_pushing : Ast.data_type list -> ir_instruction listval compile_expression : Ast.expression -> ir_bufferval compile_expression_list : Ast.expression list -> ir_bufferval compile_variable_declaration : Ast.var_declare -> ir_bufferval compile_conditional : Ast.conditional -> ir_bufferval compile_continued_conditional : Ast.continued_conditional -> ir_bufferval compile_loop : Ast.loop -> ir_bufferval compile_value : Ast.value -> ir_bufferval compile_value_producer : Ast.value_producer -> ir_bufferval compile_value_producer_list_pushing : Ast.value_producer list -> ir_instruction listval compile_list_value_producer : Ast.list_value_producer -> ir_bufferval compile_variable_assignment : Ast.var_assign -> ir_bufferval compile_set_variable_identifier : Ast.var_ident -> ir_instruction listval compile_get_variable_identifier : Ast.var_ident -> ir_bufferval compile_binary_operation : Ast.value_producer -> Ast.binop -> Ast.value_producer -> ir_bufferval compile_prefix_unary_operation : Ast.pre_unop -> Ast.value_producer -> ir_bufferval compile_function_call : Ast.function_call -> ir_bufferval compile_return : Ast.return_statement -> ir_bufferval compile_function_definition : string ->
('a * string) list -> Ast.expression list -> ir_instruction listval compile_global_expression : Ast.global_expression -> ir_instruction listval compile_global_expression_list : Ast.global_expression list -> ir_instruction listval compile_ir : Ast.global_expression list -> ir_instruction list
Compiles the AST to a list of IR instructions
val string_of_instruction : instruction -> string
Gets the string representation of a given IR instruction
val string_of_ir_instruction : ir_instruction -> stringval string_of_ir_buffer : ir_buffer -> stringval print_ir_buffer : Pervasives.out_channel -> ir_buffer -> unit
Writes the IR buffer to the given output channel