Skip to content

Commit 7e1284c

Browse files
committed
some more plumbing
1 parent ad7f379 commit 7e1284c

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/lowering/desugar.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,8 +1272,10 @@ and transform_import (i : S.import) : Ir.dec list =
12721272
varE (var (id_of_full_path fp) t)
12731273
| S.PrimPath ->
12741274
varE (var (id_of_full_path "@prim") t)
1275-
| S.IDLPath (fp, canister_id) ->
1275+
| S.IDLPath (fp, Either.Right canister_id) ->
12761276
primE (I.ActorOfIdBlob t) [blobE canister_id]
1277+
| S.IDLPath (fp, Either.Left envvar) ->
1278+
failwith "IDLPath"
12771279
| S.ImportedValuePath path ->
12781280
if !Mo_config.Flags.blob_import_placeholders then
12791281
raise (Invalid_argument ("blob import placeholder"))

src/mo_def/syntax.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type lib_path = {package : string option; path : string}
1616
type resolved_import =
1717
| Unresolved
1818
| LibPath of lib_path
19-
| IDLPath of (string * string) (* filepath * bytes *)
19+
| IDLPath of (string * (string, string) Either.t) (* filepath * envvar/bytes *)
2020
| ImportedValuePath of string
2121
| PrimPath (* the built-in prim module *)
2222

src/pipeline/resolve_import.ml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ let add_lib_import msgs imported ri_ref at lib_path =
148148
| Error err ->
149149
Diag.add_msg msgs err
150150

151-
let add_idl_import msgs imported ri_ref at full_path bytes =
151+
let add_idl_import msgs imported ri_ref at full_path envvar_or_bytes =
152152
if Sys.file_exists full_path
153153
then begin
154-
ri_ref := IDLPath (full_path, bytes);
155-
imported := RIM.add (IDLPath (full_path, bytes)) at !imported
154+
ri_ref := IDLPath (full_path, envvar_or_bytes);
155+
imported := RIM.add !ri_ref at !imported
156156
end else
157157
err_file_does_not_exist msgs at full_path
158158

@@ -188,7 +188,13 @@ let resolve_import_string msgs base actor_idl_path aliases packages imported (f,
188188
| None -> err_actor_import_without_idl_path msgs at
189189
| Some actor_base ->
190190
let full_path = in_base actor_base (Url.idl_basename_of_blob bytes) in
191-
add_idl_import msgs imported ri_ref at full_path bytes
191+
add_idl_import msgs imported ri_ref at full_path (Either.Right bytes)
192+
in
193+
let resolve_env envvar = match actor_idl_path with
194+
| None -> err_actor_import_without_idl_path msgs at
195+
| Some actor_base ->
196+
let full_path = in_base actor_base envvar in
197+
add_idl_import msgs imported ri_ref at full_path (Either.Left envvar)
192198
in
193199
match Url.parse f with
194200
| Ok (Url.Relative path) ->
@@ -210,7 +216,7 @@ let resolve_import_string msgs base actor_idl_path aliases packages imported (f,
210216
| Ok (Url.IcAlias alias) ->
211217
begin match M.find_opt alias aliases with
212218
| Some (Either.Right bytes) -> resolve_ic bytes
213-
| Some (Either.Left envvar) -> failwith "envvar"
219+
| Some (Either.Left envvar) -> resolve_env envvar
214220
| None -> err_alias_not_defined msgs at alias
215221
end
216222
| Ok (Url.FileValue path) ->

0 commit comments

Comments
 (0)