Skip to content

Commit

Permalink
Finalisation of the C backend PR
Browse files Browse the repository at this point in the history
  • Loading branch information
AltGr committed Sep 25, 2024
1 parent 270d33f commit aa8bc35
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ testsuite: unit-tests
reset-tests: .FORCE $(CLERK_BIN)
$(CLERK_TEST) tests doc --reset

# tests/%: .FORCE
# $(CLERK_TEST) test $@

%.c.exe: %.catala_en $(CLERK_BIN) .FORCE
$(CLERK_BIN) build _build/$@
_build/$@
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ However, if you wish to get the latest developments of the compiler, you probabl
want to compile it from the sources of this repository or use nix. For that, see
[the dedicated readme](INSTALL.md).

Note: the `--locked` flag can be added to the above commands to more closely
mimic known working dev setups. Conversely, `opam lock` should be called to
regenerate the `catala.opam.locked` file upon modifications of the main opam
file.

## Usage

### Catala
Expand Down
1 change: 1 addition & 0 deletions catala.opam
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ depexts: [
]
pin-depends: [
[
# FIXME: this is temporary, while we wait for the branch to be merged (and package released)
"dates_calc.0.0.6"
"git+https://github.com/CatalaLang/dates-calc#add-c-implem"
]
Expand Down
2 changes: 2 additions & 0 deletions compiler/scalc/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type stmt =
| SLocalInit of { name : VarName.t Mark.pos; typ : typ; expr : expr }
| SLocalDef of { name : VarName.t Mark.pos; typ : typ; expr : expr }
| SFatalError of { pos_expr : expr; error : Runtime.error }
(** [pos_expr] here is the position reified into an expression *)
| SIfThenElse of { if_expr : expr; then_block : block; else_block : block }
| SSwitch of {
switch_var : VarName.t;
Expand All @@ -76,6 +77,7 @@ type stmt =
}
| SReturn of expr
| SAssert of { pos_expr : expr; expr : expr }
(** [pos_expr] here is the position reified into an expression *)
| SSpecialOp of special_operator

and special_operator = |
Expand Down
3 changes: 3 additions & 0 deletions runtimes/c/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,8 @@ const CATALA_OPTION() handle_exceptions
/* --- Runtime initialisation --- */

void catala_init();
/* This must be called once and before any use of the functions above: it
performs necessary initialisations of GMP, as well as the setup for our error
handling mechanism. */

#endif /* __CATALA_RUNTIME_H__ */
7 changes: 7 additions & 0 deletions tests/func/good/closure_conversion_reduce.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ $ catala Typecheck --check-invariants
└─
```

Note: in the following test, a closure is passed as argument to the `reduce`
operator. This is temporary, and because `--keep-special-ops` is disabled: the
non-monomorphised C backend in its current state comes with a runtime featuring
functional operators that directly take closures as arguments. It's closer to
lambda-calculus and a first step to make it work, clearly we'll turn that flag
back on and translate to loops at some point.

```catala-test-inline
$ catala Lcalc -s S -O --closure-conversion
let scope S (s_in: S_in {x_in: list of integer}): S {y: integer} =
Expand Down

0 comments on commit aa8bc35

Please sign in to comment.