Project

General

Profile

Revision 04a188ec src/modules.ml

View differences:

src/modules.ml
18 18
    Options_management.name_dependency (local, dep) ext 
19 19
  with Not_found ->
20 20
    (* Error.pp_error loc (fun fmt -> Format.fprintf fmt "Unknown library %s" dep); *)
21
    raise (Error (loc, Error.Unknown_library dep))
21
    raise (Error.Error (loc, Error.Unknown_library dep))
22 22

  
23 23
  
24 24
let add_symbol loc msg hashtbl name value =
25 25
 if Hashtbl.mem hashtbl name
26
 then raise (Error (loc, Error.Already_bound_symbol msg))
26
 then raise (Error.Error (loc, Error.Already_bound_symbol msg))
27 27
 else Hashtbl.add hashtbl name value
28 28

  
29 29
let check_symbol loc msg hashtbl name =
30 30
 if not (Hashtbl.mem hashtbl name)
31
 then raise (Error (loc, Error.Unbound_symbol msg))
31
 then raise (Error.Error (loc, Error.Unbound_symbol msg))
32 32
 else ()
33 33

  
34 34

  
......
42 42
    let itf = value.top_decl_itf in
43 43
    match value'.top_decl_desc, value.top_decl_desc with
44 44
    | Node _        , ImportedNode _  when owner = owner' && itf' && (not itf) -> update_node name value
45
    | ImportedNode _, ImportedNode _            -> raise (Error (value.top_decl_loc, Error.Already_bound_symbol ("node " ^ name)))
45
    | ImportedNode _, ImportedNode _            -> raise (Error.Error (value.top_decl_loc, Error.Already_bound_symbol ("node " ^ name)))
46 46
    | _                                         -> assert false
47 47
  with
48 48
    Not_found                                   -> update_node name value
......
57 57
    let itf = value.top_decl_itf in
58 58
    match value'.top_decl_desc, value.top_decl_desc with
59 59
    | ImportedNode _, Node _          when owner = owner' && itf' && (not itf) -> ()
60
    | Node _        , Node _                    -> raise (Error (value.top_decl_loc, Error.Already_bound_symbol ("node " ^ name)))
60
    | Node _        , Node _                    -> raise (Error.Error (value.top_decl_loc, Error.Already_bound_symbol ("node " ^ name)))
61 61
    | _                                         -> assert false
62 62
  with
63 63
    Not_found                                   -> update_node name value
......
65 65

  
66 66
let add_tag loc name typ =
67 67
  if Hashtbl.mem tag_table name then
68
    raise (Error (loc, Error.Already_bound_symbol ("enum tag " ^ name)))
68
    raise (Error.Error (loc, Error.Already_bound_symbol ("enum tag " ^ name)))
69 69
  else Hashtbl.add tag_table name typ
70 70

  
71 71
let add_field loc name typ =
72 72
  if Hashtbl.mem field_table name then
73
    raise (Error (loc, Error.Already_bound_symbol ("struct field " ^ name)))
73
    raise (Error.Error (loc, Error.Already_bound_symbol ("struct field " ^ name)))
74 74
  else Hashtbl.add field_table name typ
75 75

  
76 76
let import_typedef name tydef =
......
84 84
    | Tydec_clock ty      -> import ty
85 85
    | Tydec_const c       ->
86 86
       if not (Hashtbl.mem type_table (Tydec_const c))
87
       then raise (Error (loc, Error.Unbound_symbol ("type " ^ c)))
87
       then raise (Error.Error (loc, Error.Unbound_symbol ("type " ^ c)))
88 88
       else ()
89 89
    | Tydec_array (c, ty) -> import ty
90 90
    | _                   -> ()
......
100 100
    let itf = value.top_decl_itf in
101 101
    match value'.top_decl_desc, value.top_decl_desc with
102 102
    | TypeDef ty', TypeDef ty when coretype_equal ty'.tydef_desc ty.tydef_desc && owner' = owner && itf' && (not itf) -> ()
103
    | TypeDef ty', TypeDef ty -> raise (Error (value.top_decl_loc, Error.Already_bound_symbol ("type " ^ name)))
103
    | TypeDef ty', TypeDef ty -> raise (Error.Error (value.top_decl_loc, Error.Already_bound_symbol ("type " ^ name)))
104 104
    | _       -> assert false
105 105
  with Not_found -> (import_typedef name value; Hashtbl.add type_table (Tydec_const name) value)
106 106

  
107 107
let check_type loc name =
108 108
 if not (Hashtbl.mem type_table (Tydec_const name))
109
 then raise (Error (loc, Error.Unbound_symbol ("type " ^ name)))
109
 then raise (Error.Error (loc, Error.Unbound_symbol ("type " ^ name)))
110 110
 else ()
111 111

  
112 112
let add_const itf name value =
......
118 118
    let itf = value.top_decl_itf in
119 119
    match value'.top_decl_desc, value.top_decl_desc with
120 120
    | Const c', Const c when c.const_value = c'.const_value && owner' = owner && itf' && (not itf) -> ()
121
    | Const c', Const c -> raise (Error (value.top_decl_loc, Error.Already_bound_symbol ("const " ^ name)))
121
    | Const c', Const c -> raise (Error.Error (value.top_decl_loc, Error.Already_bound_symbol ("const " ^ name)))
122 122
    | _       -> assert false
123 123
  with Not_found -> Hashtbl.add consts_table name value
124 124

  
......
156 156
      lusic
157 157
    with
158 158
    | Sys_error _  ->
159
       raise (Error (loc, Error.Unknown_library basename))
159
       raise (Error.Error (loc, Error.Unknown_library basename))
160 160
  )
161 161
  | _ -> assert false (* should not happen *)
162 162

  
......
224 224
          | Not_found ->
225 225
             let loc = decl.top_decl_loc in
226 226
             Error.pp_error loc (fun fmt -> Format.fprintf fmt "Unknown library %s" dep);
227
             raise (Error (loc, Error.Unknown_library dep (*basename*)))
227
             raise (Error.Error (loc, Error.Unknown_library dep (*basename*)))
228 228
        )
229 229
        | Include name ->
230 230
           let basename = name_dependency decl.top_decl_loc (true, name) "" in
......
235 235
             in
236 236
             decl::accu_prog, accu_dep, typ_env, clk_env
237 237
           else
238
             raise (Error (decl.top_decl_loc, LoadError("include requires a lustre file")))
238
             raise (Error.Error (decl.top_decl_loc, LoadError("include requires a lustre file")))
239 239
           
240 240
        | Node nd ->
241 241
           if is_header then
242
             raise (Error(decl.top_decl_loc,
242
             raise (Error.Error(decl.top_decl_loc,
243 243
                          LoadError ("node " ^ nd.node_id ^ " declared in a header file")))  
244 244
           else (
245 245
             (* Registering node *)
......
254 254
             decl::accu_prog, accu_dep, typ_env', clk_env'                   
255 255
           )
256 256
           else
257
             raise (Error(decl.top_decl_loc,
257
             raise (Error.Error(decl.top_decl_loc,
258 258
                          LoadError ("imported node " ^ ind.nodei_id ^
259 259
                                       " declared in a regular Lustre file")))  
260 260
        | Const c -> (
......
281 281
    in
282 282
    List.rev prog, List.rev deps, (typ_env, clk_env)
283 283
  with
284
    Corelang.Error (loc, err) as exc -> (
284
    Error.Error (loc, err) as exc -> (
285 285
    (* Format.eprintf "Import error: %a%a@."
286 286
     *   Error.pp_error_msg err
287 287
     *   Location.pp_loc loc; *)

Also available in: Unified diff