mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
3649f92975
This changes the `decl_ctx` to be toplevel only, with flattened references to uids for most elements. The module hierarchy, which is still useful in a few places, is kept separately. Module names are also changed to UIDs early on, and support for module aliases has been added (needs testing). This resolves some issues with lookup, and should be much more robust, as well as more convenient for most lookups. The `decl_ctx` was also extended for string ident lookups, which avoids having to keep the desugared resolution structure available throughout the compilation chain.
33 lines
1.1 KiB
OCaml
33 lines
1.1 KiB
OCaml
open Catala_utils
|
|
open Driver
|
|
open Js_of_ocaml
|
|
|
|
let () =
|
|
Js.export_all
|
|
(object%js
|
|
method interpret
|
|
(contents : Js.js_string Js.t)
|
|
(scope : Js.js_string Js.t)
|
|
(language : Js.js_string Js.t)
|
|
(trace : bool) =
|
|
let contents = Js.to_string contents in
|
|
let scope = Js.to_string scope in
|
|
let language = Js.to_string language in
|
|
let language =
|
|
try List.assoc (String.lowercase_ascii language) Cli.languages
|
|
with Not_found ->
|
|
Message.raise_error "Unrecognised input locale %S" language
|
|
in
|
|
let options =
|
|
Cli.enforce_globals
|
|
~input_src:(Contents (contents, "-inline-"))
|
|
~language:(Some language) ~debug:false ~color:Never ~trace ()
|
|
in
|
|
let prg, _type_order =
|
|
Passes.dcalc options ~includes:[] ~optimize:false
|
|
~check_invariants:false ~typed:Shared_ast.Expr.typed
|
|
in
|
|
Shared_ast.Interpreter.interpret_program_dcalc prg
|
|
(Commands.get_scope_uid prg.decl_ctx scope)
|
|
end)
|