open Ast
open Utils

let rec make_extern_func_list = 
    let extern_func_list = [] in
    let add_point = ("add_point", Int), [("pt", Struct("point"))] in 
        let extern_func_list = List.rev (add_point :: List.rev extern_func_list) in
    let add_shape = ("add_shape", Int), [("shp", Struct("shape"))] in 
        let extern_func_list = List.rev (add_shape :: List.rev extern_func_list) in
    let display_points = ("display_points", Int), [] in 
        let extern_func_list = List.rev (display_points :: List.rev extern_func_list) in
    let display_shapes = ("display_shapes", Int), [] in
        let extern_func_list = List.rev (display_shapes :: List.rev extern_func_list) in
    let display = ("display", Int), [] in 
        let extern_func_list = List.rev (display :: List.rev extern_func_list) in
    let setup = ("setup", Int), [] in 
        let extern_func_list = List.rev (setup :: List.rev extern_func_list) in
    let pop_point = ("pop_point", Int), [] in 
        let extern_func_list = List.rev (pop_point :: List.rev extern_func_list) in
    let pop_shape = ("pop_shape", Int), [] in 
        let extern_func_list = List.rev (pop_shape :: List.rev extern_func_list) in
    let wait = ("wait", Int), [("seconds", Double)] in 
        let extern_func_list = List.rev (wait :: List.rev extern_func_list) in
    let byebye = ("byebye", Int), [] in 
        let extern_func_list = List.rev (byebye :: List.rev extern_func_list) in
    let run =  ("run", Int), [] in 
        List.rev (run :: List.rev extern_func_list)

and load_extern_funcs (env : symbol_table) =
    env.functions <- (merge_list make_extern_func_list env.functions); env
