module Ast:sig
..end
This is the output of the parser and the input of the type checker.
typelocation =
Stdlib.Lexing.position * Stdlib.Lexing.position
type
ident = {
|
loc : |
|
id : |
}
type
unop =
| |
Uneg |
(* | -e | *) |
| |
Unot |
(* | !e | *) |
| |
Ustring_of_int |
(* | integer to string conversion, introduced during type checking | *) |
type
binop =
| |
Badd |
|||
| |
Bsub |
|||
| |
Bmul |
|||
| |
Bdiv |
|||
| |
Bmod |
(* | + - * / % | *) |
| |
Beq |
|||
| |
Bneq |
|||
| |
Blt |
|||
| |
Ble |
|||
| |
Bgt |
|||
| |
Bge |
(* | == != < <= > >= | *) |
| |
Band |
|||
| |
Bor |
(* | && || | *) |
| |
Badd_s |
(* | string concatenation, introduced during type checking | *) |
type
constant =
| |
Cbool of |
| |
Cint of |
| |
Cstring of |
type
pexpr_typ =
| |
PTboolean |
| |
PTint |
| |
PTident of |
type
pexpr = {
|
pexpr_desc : |
|
pexpr_loc : |
}
type
pexpr_desc =
| |
PEconstant of |
| |
PEbinop of |
| |
PEunop of |
| |
PEthis |
| |
PEnull |
| |
PEident of |
| |
PEdot of |
| |
PEassign_ident of |
| |
PEassign_dot of |
| |
PEnew of |
| |
PEcall of |
| |
PEcast of |
| |
PEinstanceof of |
type
pstmt = {
|
pstmt_desc : |
|
pstmt_loc : |
}
type
pstmt_desc =
| |
PSexpr of |
| |
PSvar of |
| |
PSif of |
| |
PSreturn of |
| |
PSblock of |
| |
PSfor of |
typepparam =
pexpr_typ * ident
type
pdecl =
| |
PDattribute of |
| |
PDconstructor of |
| |
PDmethod of |
typepclass =
ident * ident option * pdecl list
typepfile =
pclass list
This is the output of the type checker and the input of the code generation.
type
typ =
| |
Tvoid |
| |
Tnull |
| |
Tboolean |
| |
Tint |
| |
Tclass of |
type
class_ = {
|
class_name : |
|
mutable class_extends : |
|
class_methods : |
|
class_attributes : |
}
type
attribute = {
|
attr_name : |
|||
|
attr_type : |
|||
|
mutable attr_ofs : |
(* | position within the object | *) |
}
All the occurrences of the same attribute point to a single record of the following type.
type
method_ = {
|
meth_name : |
(* | unique name | *) |
|
meth_type : |
|||
|
meth_params : |
|||
|
mutable meth_ofs : |
(* | position within the method table | *) |
}
type
var = {
|
var_name : |
|||
|
var_type : |
|||
|
mutable var_ofs : |
(* | position wrt %rbp | *) |
}
All the occurrences of the same variable point to a single record of the following type.
type
expr = {
|
expr_desc : |
|
expr_type : |
}
type
expr_desc =
| |
Econstant of |
| |
Ebinop of |
| |
Eunop of |
| |
Ethis |
| |
Enull |
| |
Evar of |
| |
Eassign_var of |
| |
Eattr of |
| |
Eassign_attr of |
| |
Enew of |
| |
Ecall of |
| |
Ecast of |
| |
Einstanceof of |
| |
Eprint of |
type
stmt =
| |
Sexpr of |
| |
Svar of |
| |
Sif of |
| |
Sreturn of |
| |
Sblock of |
| |
Sfor of |
type
decl =
| |
Dconstructor of |
| |
Dmethod of |
typetclass =
class_ * decl list
typetfile =
tclass list