source: Deliverables/D2.2/8051/src/cminor/cminor.mli @ 486

Last change on this file since 486 was 486, checked in by ayache, 8 years ago

Deliverable D2.2

File size: 2.3 KB
Line 
1
2(** This module defines the abstract syntax tree of [Cminor]. *)
3
4(* This file describes the abstract syntax of the Cminor language.
5   Only types are: int8, int16, int32, float32, float64 and void. *)
6
7type expression = 
8  | Id of AST.ident
9  | Cst of AST.cst
10  | Op1 of AST.op1 * expression
11  | Op2 of AST.op2 * expression * expression
12  | Mem of Memory.memory_q * expression          (* Memory read *)
13  | Cond of expression * expression * expression (* Ternary expression *)
14  | Exp_cost of CostLabel.t * expression         (* Labelled expression *)
15
16type statement =
17  | St_skip
18  | St_assign of AST.ident * expression
19  | St_store of Memory.memory_q * expression * expression
20
21  (* Function call. Parameters are an optional variable to store the
22     result of the function, the name of the function, the arguments,
23     and finally its signature. *)
24  | St_call of AST.ident option * expression * expression list * AST.signature
25
26  (* Tail call to a function, that is, a call to a function following
27     by a return statement. Parameters are the name of the function,
28     the arguments and its signature. *)
29  | St_tailcall of expression * expression list * AST.signature
30
31  | St_seq of statement * statement
32  | St_ifthenelse of expression * statement * statement
33  | St_loop of statement
34  | St_block of statement
35  | St_exit of int
36
37  (* Switch. Parameters are the expression whose value is switch, a
38     table of cases and their corresponding number of blocks to exit,
39     and the number of block to exit in the default case. *)
40  | St_switch of expression * (int*int) list * int
41
42  | St_return of expression option
43  | St_label of AST.ident * statement
44  | St_goto of string
45  | St_cost of CostLabel.t * statement
46
47
48type internal_function =
49    { f_sig       : AST.signature ;
50      f_params    : AST.ident list ;
51      f_vars      : AST.ident list ;
52      f_ptrs      : AST.ident list ;
53      f_stacksize : int ;
54      f_body      : statement }
55
56type function_def =
57  | F_int of internal_function
58  | F_ext of AST.external_function
59
60(* A program is a list of global variables and their initialization
61   datas, a list of function names and their definition, and the name
62   of the main function. *)
63
64type program =
65    { vars   : (AST.ident * (AST.data list)) list ;
66      functs : (AST.ident * function_def) list ;
67      main   : AST.ident option }
Note: See TracBrowser for help on using the repository browser.