Module Ctt_abstree


module Ctt_abstree: sig  end


type identifier = string

type location = string * int

type properties = {
   ctt_loc : location;
}

type global_storage_class =
| Extern
| ModuleStatic
| Inline


type local_storage_class =
| Auto
| Register
| LocalStatic
| FuncArgs


type union_flag = C_abstree.union_flag =
| Struct
| Union


type program = global_declaration list

type global_declaration = global_declaration_desc

type ctt_initializer =
| CTTinitExp of expr
| CTTinitList of ctt_initializer list


type global_declaration_desc =
| CTTdeclFunction of global_storage_class * c_type
* identifier * identifier list
* statement
| CTTdeclVariable of global_storage_class * c_type
* identifier * ctt_initializer option


type variable_declaration = local_storage_class * c_type *
identifier * ctt_initializer option


type builtin_type = C_types.builtin_type =
| Tchar
| Tschar
| Tuchar
| Tshort
| Tushort
| Tint
| Tuint
| Tlong
| Tulong
| Tlonglong
| Tulonglong
| Tfloat
| Tdouble
| Tlongdouble


type c_type_desc =
| Tvoid
| Tbuiltin of builtin_type
| Tpointer of c_type
| Tfunction of c_type list * bool * c_type
| Tarray of c_type * Big_int.big_int option
| Tstruct of struct_id


type c_type = {
   ct_const_p : bool;
   ct_volatile_p : bool;
   ct_ty : c_type_desc;
}

type struct_id = int

type statement_desc =
| CTTstmtNull
| CTTstmtExpr of expr
| CTTstmtLabeled of identifier * statement
| CTTstmtCase_Labeled of Big_int.big_int * statement
| CTTstmtDefault_Labeled of statement
| CTTstmtCompound of variable_declaration list * statement list
| CTTstmtIf of expr * statement * statement option
| CTTstmtSwitch of expr * statement
| CTTstmtWhile of expr * statement
| CTTstmtDoWhile of statement * expr
| CTTstmtFor of expr option * expr option * expr option
* statement
| CTTstmtGoto of identifier
| CTTstmtContinue
| CTTstmtBreak
| CTTstmtReturn of expr option


type statement = {
   stmt_t : statement_desc;
   stmt_pr : properties;
}

type expr = {
   expr_type : c_type;
   expr_t : expr_desc;
   expr_pr : properties;
}

type binop =
| CTTbinTimes
| CTTbinDiv
| CTTbinPlusVV
| CTTbinMinusVV
| CTTbinPostPlusVV
| CTTbinPostMinusVV
| CTTbinPlusPV
| CTTbinMinusPP
| CTTbinMinusPV
| CTTbinPostPlusPV
| CTTbinPostMinusPV
| CTTbinModulo
| CTTbinLshift
| CTTbinRshift
| CTTbinLogAnd
| CTTbinLogOr
| CTTbinIntAnd
| CTTbinIntOr
| CTTbinIntXor
| CTTbinLessThan
| CTTbinLessEqual
| CTTbinGtrThan
| CTTbinGtrEqual
| CTTbinEqual
| CTTbinNotEqual


type unaryop = C_abstree.unaryop =
| UnaryPlus
| UnaryMinus
| LogNot
| IntNot


type expr_desc =
| CTTexpComma of expr * expr
| CTTexpAssign of expr * expr
| CTTexpBinAssign of binop * expr * c_type option
* expr
| CTTexpConditional of expr * expr * expr
| CTTexpBinExpr of binop * expr * expr
| CTTexpCoerce of c_type * expr
| CTTexpUnaryExpr of unaryop * expr
| CTTexpAddress of expr
| CTTexpPtrDeref of expr
| CTTexpInvoke of expr * expr list
| CTTexpField of expr * identifier
| CTTexpConstant of c_constants
| CTTexpVar of identifier


type c_constants =
| CTTconstNull
| CTTconstInteger of Big_int.big_int
| CTTconstFloat of float
| CTTconstString of string

val make_c_type : ?const:bool ->
?volatile:bool -> c_type_desc -> c_type
val make_c_type_ql : C_types.type_qualifier list -> c_type_desc -> c_type
val type_char : c_type
val type_signed_char : c_type
val type_unsigned_char : c_type
val type_short : c_type
val type_unsigned_short : c_type
val type_int : c_type
val type_unsigned_int : c_type
val type_long : c_type
val type_unsigned_long : c_type
val type_long_long : c_type
val type_unsigned_long_long : c_type
val type_float : c_type
val type_double : c_type
val type_long_double : c_type
val type_void : c_type
val type_boolean : c_type
val type_ptrdiff_t : c_type
val type_size_t : c_type
val type_char_array : int -> c_type
val make_expr : expr_desc ->
c_type -> loc:location -> expr

type struct_field_normal = {
   sf_id : identifier;
   sf_type : c_type;
   sf_size : Big_int.big_int;
}

type struct_field_bitfields = {
   s_bf_size : Big_int.big_int;
   s_bf_fields : (identifier option * c_type * int * (int * int)) list;
}

type struct_field =
| NormalField of struct_field_normal
| BitField of struct_field_bitfields


type struct_desc = {
   str_union_p : union_flag;
   str_size : Big_int.big_int option;
   str_align : Big_int.big_int option;
   str_fields : (Big_int.big_int * struct_field) list;
}
val size_of_builtin_type : builtin_type -> int
val align_of_builtin_type : builtin_type -> int
val get_max_value_of_type : c_type -> Big_int.big_int

type variableType =
| EnumVal of Big_int.big_int
| Var of c_type
| TypeDefName of c_type


type local_binding = {
   lbind_new_name : identifier;
   lbind_storage_class : local_storage_class;
   lbind_type : variableType;
}

type local_bind_frame = (identifier * local_binding) list

type global_binding = {
   gbind_storage_class : global_storage_class;
   gbind_is_tentative : bool;
   gbind_type : variableType;
}

type struct_name_entry =
| EnumName
| StructName of struct_id


type environment = {
   mutable global_binding : (identifier * global_binding) list;
   mutable struct_table : (struct_id * struct_desc Pervasives.ref) list;
   mutable struct_name_table : (identifier * struct_name_entry) list;
   mutable local_binding : local_bind_frame list;
}