Project

General

Profile

Revision a28d1ba7 src/modules.ml

View differences:

src/modules.ml
116 116
let name_dependency (local, dep) =
117 117
  ((if local then !Options.dest_dir else Version.include_path) ^ "/") ^ dep
118 118

  
119
let import_dependency loc (local, dep) =
119
let import_dependency_aux loc (local, dep) =
120
  let basename = name_dependency (local, dep) in
121
  let extension = ".lusic" in 
120 122
  try
121
    let basename = name_dependency (local, dep) in
122
    let extension = ".lusic" in 
123
    try
124
      let lusic = Lusic.read_lusic basename extension in
125
      Lusic.check_obsolete lusic basename;
126
      lusic
127
    with Sys_error msg ->
128
      begin
123
    let lusic = Lusic.read_lusic basename extension in
124
    Lusic.check_obsolete lusic basename;
125
    lusic
126
  with
127
  | Sys_error msg ->
128
    begin
129 129
      (*Format.eprintf "Error: %s@." msg;*)
130
	raise (Error (loc, Unknown_library basename))
131
      end
130
      raise (Error (loc, Unknown_library basename))
131
    end
132
  | Corelang.Error (_, msg) as exc -> raise (Corelang.Error (loc, msg))
133

  
134
let import_dependency loc (local, dep) =
135
  try
136
    import_dependency_aux loc (local, dep)
137
  with
138
  | Corelang.Error (_, err) as exc -> (
139
    Format.eprintf "Import error: %a%a@."
140
      Corelang.pp_error err
141
      Location.pp_loc loc;
142
    raise exc
143
  )
144

  
145
let check_dependency lusic basename =
146
  try
147
    Lusic.check_obsolete lusic basename
132 148
  with
133 149
  | Corelang.Error (loc, err) as exc -> (
134
    Format.eprintf "Library error: %a%a@."
150
    Format.eprintf "Import error: %a%a@."
135 151
      Corelang.pp_error err
136 152
      Location.pp_loc loc;
137 153
    raise exc
......
147 163
    | Open (local, dep) ->
148 164
       let basename = name_dependency (local, dep) in
149 165
       if ISet.mem basename imported then imp else
150
	 let lusic = import_dependency decl.top_decl_loc (local, dep)
166
	 let lusic = import_dependency_aux decl.top_decl_loc (local, dep)
151 167
	 in load_header_rec (ISet.add basename imported) lusic.Lusic.contents
152 168
		 ) imported header
153 169

  
......
172 188
    | Open (local, dep) ->
173 189
       let basename = name_dependency (local, dep) in
174 190
       if ISet.mem basename imported then imp else
175
	 let lusic = import_dependency decl.top_decl_loc (local, dep)
191
	 let lusic = import_dependency_aux decl.top_decl_loc (local, dep)
176 192
	 in load_header_rec (ISet.add basename imported) lusic.Lusic.contents
177 193
		 ) imported program
178 194

  

Also available in: Unified diff