Project

General

Profile

Revision 19a1e66b src/modules.ml

View differences:

src/modules.ml
114 114
    | _       -> assert false
115 115
  with Not_found -> Hashtbl.add consts_table name value
116 116

  
117
let import_dependency_aux loc (local, dep) =
118
  let basename = Options_management.name_dependency (local, dep) in
119
  let extension = ".lusic" in 
120
  try
121
    let lusic = Lusic.read_lusic basename extension in
122
    Lusic.check_obsolete lusic basename;
123
    lusic
124
  with
125
  | Sys_error msg ->
126
      raise (Error (loc, Error.Unknown_library basename))
127
    
128
let import_dependency loc (local, dep) =
129
  try
130
    import_dependency_aux loc (local, dep)
131
  with
132
  | Corelang.Error (_, err) as exc -> (
133
    Format.eprintf "Import error: %a%a@."
134
      Error.pp_error_msg err
135
      Location.pp_loc loc;
136
    raise exc
137
  )
117
(* let import_dependency_aux loc (local, dep) =
118
 *   let basename = Options_management.name_dependency (local, dep) in
119
 *   let extension = ".lusic" in 
120
 *   try
121
 *     let lusic = Lusic.read_lusic basename extension in
122
 *     Lusic.check_obsolete lusic basename;
123
 *     lusic
124
 *   with
125
 *   | Sys_error msg ->
126
 *       raise (Error (loc, Error.Unknown_library basename))
127
 *     
128
 * let import_dependency loc (local, dep) =
129
 *   try
130
 *     import_dependency_aux loc (local, dep)
131
 *   with
132
 *   | Corelang.Error (_, err) as exc -> (
133
 *     Format.eprintf "Import error: %a%a@."
134
 *       Error.pp_error_msg err
135
 *       Location.pp_loc loc;
136
 *     raise exc
137
 *   ) *)
138 138

  
139 139
let get_lusic decl =
140 140
  match decl.top_decl_desc with
141 141
  | Open (local, dep) -> (
142 142
    let loc = decl.top_decl_loc in
143
    let basename = Options_management.name_dependency (local, dep) in
144 143
    let extension = ".lusic" in 
144
    let basename = Options_management.name_dependency (local, dep) extension in
145 145
    try
146 146
      let lusic = Lusic.read_lusic basename extension in
147 147
      Lusic.check_obsolete lusic basename;
......
168 168
			 Env.add_value ck_env ind.nodei_id ind.nodei_clock)
169 169
  | Const c          -> get_envs_from_const c (ty_env, ck_env)
170 170
  | TypeDef _        -> List.fold_left get_envs_from_top_decl (ty_env, ck_env) (consts_of_enum_type top_decl)
171
  | Open _           -> (ty_env, ck_env)
171
  | Include _ | Open _           -> (ty_env, ck_env)
172 172

  
173 173
(* get type and clock environments from a header *)
174 174
let get_envs_from_top_decls header =
......
187 187
      match decl.top_decl_desc with
188 188
      | Open (local, dep) ->
189 189
         (* loading the dep *)
190
         let basename = Options_management.name_dependency (local, dep) in
190
         let basename = Options_management.name_dependency (local, dep) ".lusic" in
191 191
         if List.exists
192
              (fun dep -> basename = Options_management.name_dependency (dep.local, dep.name))
192
              (fun dep -> basename = Options_management.name_dependency (dep.local, dep.name) ".lusic")
193 193
              accu_dep
194 194
         then
195 195
           (* Library already imported. Just skip *)
196 196
           accu
197 197
         else (
198
           Log.report ~level:1 (fun fmt -> Format.fprintf fmt "@ Library %s@ " basename);
198
           Log.report ~level:1 (fun fmt -> Format.fprintf fmt "@ .. Library %s@ " basename);
199 199
           let lusic = get_lusic decl in
200 200
           (* Recursive call with accumulator on lusic *)
201 201
           let (accu_prog, accu_dep, typ_env, clk_env) =
......
211 211
            one and the updated envs *)
212 212
           accu_prog, (new_dep::accu_dep), typ_env, clk_env
213 213
         )
214
      (*    | Include xxx -> TODO
215
                     load the lus file
216
                     call load_rec ~is_header:false accu on the luscontent
217
       *)                     
214
      | Include name ->
215
         let basename = Options_management.name_dependency (true, name) "" in
216
         let include_src = Compiler_common.parse_source basename in
217
         load_rec ~is_header:false accu include_src
218
                         
218 219

  
219 220
      | Node nd ->
220 221
         if is_header then

Also available in: Unified diff