XML: LLVM + Typecheck (by Michael Gavrilenko, Danila Rudnev-Stepanyan and Daniel Vlasenko)#52
XML: LLVM + Typecheck (by Michael Gavrilenko, Danila Rudnev-Stepanyan and Daniel Vlasenko)#52spisladqo wants to merge 52 commits intoKakadu:masterfrom
Conversation
and don't call function with uninitialized parameters
fixed: add rt_init and collect, calls to 0-arg funs, alloca dereference, offset in tuple elem loading, rt_init in rt, refactor code
bugs are: order of inference in infer_vb, forgotten inst, let rec x = x, unary minus, alloc_block now in env unsound generalization is working, too
| [%expect{| 'a -> 's |}] | ||
|
|
||
|
|
||
| let%expect_test _= |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
| [%expect{| ('b -> 'c) -> 'b -> 'c |}] | ||
|
|
||
|
|
||
| let%expect_test _ = |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
| [%expect{| ('b -> 'c) -> 'b -> 'c |}] | ||
|
|
||
|
|
||
| let%expect_test _ = |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
|
|
||
| (************************** Let in **************************) | ||
|
|
||
| let%expect_test _ = |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
| [%expect{| int |}] | ||
|
|
||
|
|
||
| let%expect_test _ = |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
| vb_list | ||
| ;; | ||
|
|
||
| let rec get_pat_names acc pat = |
There was a problem hiding this comment.
Using function is recommended
|
Документация и тестовое покрытие (73.75%) должны скоро появиться. https://kakadu.github.io/comp25/docs/XML https://kakadu.github.io/comp25/cov/XML 2026-03-03 12:57
|
| [%expect{| 'a -> 's |}] | ||
|
|
||
|
|
||
| let%expect_test _= |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
| [%expect{| ('b -> 'c) -> 'b -> 'c |}] | ||
|
|
||
|
|
||
| let%expect_test _ = |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
| [%expect{| ('b -> 'c) -> 'b -> 'c |}] | ||
|
|
||
|
|
||
| let%expect_test _ = |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
|
|
||
| (************************** Let in **************************) | ||
|
|
||
| let%expect_test _ = |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
| [%expect{| int |}] | ||
|
|
||
|
|
||
| let%expect_test _ = |
There was a problem hiding this comment.
A test without description. Try `let%expect_test "name" = ...
| type env = (ident * TypeExpr.t) list | ||
|
|
||
| let gensym_counter = ref 0 | ||
| let reset_gensym : unit -> unit = fun () -> gensym_counter := 0 |
There was a problem hiding this comment.
Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable references and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
|
|
||
| let gensym : unit -> string = | ||
| fun () -> | ||
| let n = !gensym_counter in |
There was a problem hiding this comment.
Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable references and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
| if n < 26 then String.make 1 (Char.chr (Char.code 'a' + n)) else "t" ^ string_of_int n | ||
| ;; | ||
|
|
||
| let newvar () = Type_var (ref (Unbound (gensym (), !current_level))) |
There was a problem hiding this comment.
Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable references and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
| vb_list | ||
| ;; | ||
|
|
||
| let rec get_pat_names acc pat = |
There was a problem hiding this comment.
Using function is recommended
| @@ -0,0 +1,397 @@ | |||
| open Backend.Codegen_llvm | |||
There was a problem hiding this comment.
OCaml files should provide license information in second line (structure item)
|
Linter report from 2026-03-03 12:58, for mini language XML |
Функциональность:
lib/backend/codegen_llvm.mllib/middleend/infer.mlТесты:
many_tests/codegen_llvm.t,llvm_tweaks.t,gc_llvm.t)many_tests/unit/infer.ml) и добавил cram-тесты manytests (many_tests/infer.t)