source: Deliverables/D2.2/8051/src/common/primitive.ml @ 486

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

Deliverable D2.2

File size: 870 bytes
Line 
1
2(** These are the functions provided by the runtime system. *)
3
4let print_int = "print_int"
5let print_intln = "print_intln"
6let scan_int = "scan_int"
7let alloc = "alloc"
8let modulo = "mod"
9
10let primitives_list =
11  [print_int ; print_intln ; scan_int ; alloc ; modulo]
12
13let primitives =
14  List.fold_left (fun res f -> StringTools.Set.add f res) StringTools.Set.empty
15    primitives_list
16
17let is_primitive f = StringTools.Set.mem f primitives
18
19
20let print_type = function
21  | AST.Sig_int -> "int"
22  | AST.Sig_float -> "float"
23  | AST.Sig_ptr -> "ptr"
24
25let print_type_return = function
26  | AST.Type_ret t -> print_type t
27  | AST.Type_void -> "void"
28
29let rec print_arg_types = function
30  | [] -> ""
31  | t :: ts -> (print_type t) ^ " -> " ^ (print_arg_types ts)
32
33let print_sig sg =
34  Printf.sprintf "%s%s"
35    (print_arg_types sg.AST.args)
36    (print_type_return sg.AST.res)
Note: See TracBrowser for help on using the repository browser.