Skip to content

Commit

Permalink
Minor polishing
Browse files Browse the repository at this point in the history
Signed-off-by: Kakadu <[email protected]>
  • Loading branch information
Kakadu committed Sep 5, 2024
1 parent 953c29e commit ff5f2bf
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 50 deletions.
3 changes: 2 additions & 1 deletion Lama.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "TODO"
synopsis:
"A programming language (initualy developed by JetBrains Research) for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools."
depends: [
"dune" {>= "3.3"}
"posix-uname"
Expand Down
52 changes: 23 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,48 +1,42 @@
EXECUTABLE = src/lamac
.PHONY: all regression
.PHONY: clean test regression regression-expressions regression-all uninstall install build

INSTALL ?= install -v
MKDIR ?= mkdir
BUILDDIR = build
BUILDDIR = _build

.PHONY: all regression

all:
$(MAKE) -C src
$(MAKE) -C runtime
$(MAKE) -C stdlib

STD_FILES=$(shell ls stdlib/*.[oi] stdlib/*.lama runtime/runtime.a runtime/Std.i)
all: dune test regression

build: all
mkdir -p $(BUILDDIR)
cp -r runtime/Std.i runtime/runtime.a stdlib/* src/lamac $(BUILDDIR)
build: dune b regression

install: all
$(INSTALL) $(EXECUTABLE) `opam var bin`
$(MKDIR) -p `opam var share`/Lama
$(INSTALL) $(STD_FILES) `opam var share`/Lama/
dune b @install --profile=release
dune install --profile=release
$(MKDIR) -p `opam var share`/Lama/x64
$(INSTALL) $(shell ls _build/default/stdlib/x64/*.[oi] _build/default/stdlib/x64/stdlib/*.lama \
runtime/runtime.a runtime/Std.i) \
`opam var share`/Lama/x64
$(MKDIR) -p `opam var share`/Lama/x32
$(INSTALL) $(shell ls _build/default/stdlib/x32/*.[oi] _build/default/stdlib/x32/stdlib/*.lama \
runtime32/runtime.a runtime32/Std.i) \
`opam var share`/Lama/x32

uninstall:
$(RM) -r `opam var share`/Lama
$(RM) `opam var bin`/$(EXECUTABLE)
dune uninstall


regression-all: regression regression-expressions

test: regression
regression:
$(MAKE) clean check -j8 -C regression
$(MAKE) clean check -j8 -C stdlib/regression
dune test regression

regression-expressions:
$(MAKE) clean check -j8 -C regression/expressions
$(MAKE) clean check -j8 -C regression/deep-expressions

negative_scenarios_tests:
$(MAKE) -C runtime negative_tests
dune test regression_long

clean:
$(MAKE) clean -C src
$(MAKE) clean -C runtime
$(MAKE) clean -C stdlib
$(MAKE) clean -C regression
$(MAKE) clean -C byterun
$(MAKE) clean -C bench
rm -rf $(BUILDDIR)
@dune clean

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Lama

![lama](lama.svg) is a programming language developed by JetBrains Research for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools.
![lama](lama.svg) is a programming language (initualy developed by JetBrains Research) for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools.
Its general characteristics are:

* procedural with first-class functions - functions can be passed as arguments, placed in data structures,
Expand Down Expand Up @@ -52,8 +52,8 @@ Ubuntu-based variant of WSL is recommended.
sudo apt install gcc
```

- MacOS: `clang`
- MacOS: `clang`

Should be automatically installed with developer tools.

- [opam](http://opam.ocaml.org) (>= 2.0.4)
Expand All @@ -67,13 +67,13 @@ Ubuntu-based variant of WSL is recommended.
1. Install the right [switch](https://opam.ocaml.org/doc/Manual.html#Switches) for the OCaml compiler

```bash
opam switch create lama --packages=ocaml-variants.4.14.0+options,ocaml-option-flambda
opam switch create lama --packages=ocaml-variants.4.14.2+options,ocaml-option-flambda
```

* In the above command:

- `opam switch create` is a subcommand to create a new switch
- `ocaml-variants.4.14.0+options` is the name of a standard template for the switch
- `ocaml-variants.4.14.2+options` is the name of a standard template for the switch
- `lama` is an alias for the switch being created; on success a directory `$(HOME)/.opam/lama` should be created

2. Update PATH variable for the fresh switch. (You can add these commands to your `~/.bashrc` for convenience but they should be added by `opam`)
Expand All @@ -83,7 +83,7 @@ Ubuntu-based variant of WSL is recommended.

* Check that the OCaml compiler is now available in PATH by running `which ocamlc`; it should answer with `/home/user/.opam/lama/bin/ocamlc` (or similar) and `ocamlc -v` should answer with
```
The OCaml compiler, version 4.10.1
The OCaml compiler, version 4.14.2
Standard library directory: /home/user/.opam/lama/lib/ocaml
```

Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

(package
(name Lama)
(allow_empty)
(synopsis "TODO")
(synopsis
"A programming language (initualy developed by JetBrains Research) for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools.")
(depends
posix-uname
GT
Expand Down
1 change: 1 addition & 0 deletions src/.ocamlformat-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
X86_32.ml
5 changes: 2 additions & 3 deletions src/X86_32.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
open GT
open Language
open SM

(* X86 codegeneration interface *)

Expand Down Expand Up @@ -241,7 +240,7 @@ let compile cmd env imports code =
match instr with
| PUBLIC name -> env#register_public name, []
| EXTERN name -> env#register_extern name, []
| IMPORT name -> env, []
| IMPORT _name -> env, []

| CLOSURE (name, closure) ->
let pushr, popr =
Expand Down Expand Up @@ -691,7 +690,7 @@ class env prg =

(* tag hash: gets a hash for a string tag *)
method hash tag =
let h = Pervasives.ref 0 in
let h = Stdlib.ref 0 in
for i = 0 to min (String.length tag - 1) 4 do
h := (!h lsl 6) lor (String.index chars tag.[i])
done;
Expand Down
6 changes: 2 additions & 4 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@

(executable
(name Driver)
(public_name lamac)
(flags
(:standard
-rectypes
;-dsource
))
(:standard -rectypes))
(modules Driver)
(libraries liba unix))

Expand Down
4 changes: 2 additions & 2 deletions stdlib/x32/dune
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
../Timer.lama
%{project_root}/src/Driver.exe)
(targets
List.i
List.o
Array.i
Array.o
Buffer.i
Buffer.o
Collection.i
Expand Down
5 changes: 2 additions & 3 deletions stdlib/x64/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(deps
../Makefile
../../runtime/Std.i
../List.lama
../Array.lama
../Buffer.lama
../Collection.lama
Expand All @@ -18,8 +17,8 @@
../Timer.lama
%{project_root}/src/Driver.exe)
(targets
List.i
List.o
Array.i
Array.o
Buffer.i
Buffer.o
Collection.i
Expand Down

0 comments on commit ff5f2bf

Please sign in to comment.