mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Minor polishing
Signed-off-by: Kakadu <Kakadu@pm.me>
This commit is contained in:
parent
39fa6c2be9
commit
0ccc1c6e7d
9 changed files with 42 additions and 50 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
# This file is generated by dune, edit dune-project instead
|
# This file is generated by dune, edit dune-project instead
|
||||||
opam-version: "2.0"
|
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: [
|
depends: [
|
||||||
"dune" {>= "3.3"}
|
"dune" {>= "3.3"}
|
||||||
"posix-uname"
|
"posix-uname"
|
||||||
|
|
|
||||||
52
Makefile
52
Makefile
|
|
@ -1,48 +1,42 @@
|
||||||
EXECUTABLE = src/lamac
|
.PHONY: all regression
|
||||||
|
.PHONY: clean test regression regression-expressions regression-all uninstall install build
|
||||||
|
|
||||||
INSTALL ?= install -v
|
INSTALL ?= install -v
|
||||||
MKDIR ?= mkdir
|
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
|
build: dune b regression
|
||||||
mkdir -p $(BUILDDIR)
|
|
||||||
cp -r runtime/Std.i runtime/runtime.a stdlib/* src/lamac $(BUILDDIR)
|
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
$(INSTALL) $(EXECUTABLE) `opam var bin`
|
dune b @install --profile=release
|
||||||
$(MKDIR) -p `opam var share`/Lama
|
dune install --profile=release
|
||||||
$(INSTALL) $(STD_FILES) `opam var share`/Lama/
|
$(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:
|
uninstall:
|
||||||
$(RM) -r `opam var share`/Lama
|
$(RM) -r `opam var share`/Lama
|
||||||
$(RM) `opam var bin`/$(EXECUTABLE)
|
dune uninstall
|
||||||
|
|
||||||
|
|
||||||
regression-all: regression regression-expressions
|
regression-all: regression regression-expressions
|
||||||
|
|
||||||
|
test: regression
|
||||||
regression:
|
regression:
|
||||||
$(MAKE) clean check -j8 -C regression
|
dune test regression
|
||||||
$(MAKE) clean check -j8 -C stdlib/regression
|
|
||||||
|
|
||||||
regression-expressions:
|
regression-expressions:
|
||||||
$(MAKE) clean check -j8 -C regression/expressions
|
dune test regression_long
|
||||||
$(MAKE) clean check -j8 -C regression/deep-expressions
|
|
||||||
|
|
||||||
negative_scenarios_tests:
|
|
||||||
$(MAKE) -C runtime negative_tests
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) clean -C src
|
@dune clean
|
||||||
$(MAKE) clean -C runtime
|
|
||||||
$(MAKE) clean -C stdlib
|
|
||||||
$(MAKE) clean -C regression
|
|
||||||
$(MAKE) clean -C byterun
|
|
||||||
$(MAKE) clean -C bench
|
|
||||||
rm -rf $(BUILDDIR)
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
# Lama
|
# Lama
|
||||||
|
|
||||||
 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.
|
 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:
|
Its general characteristics are:
|
||||||
|
|
||||||
* procedural with first-class functions - functions can be passed as arguments, placed in data structures,
|
* procedural with first-class functions - functions can be passed as arguments, placed in data structures,
|
||||||
|
|
@ -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
|
1. Install the right [switch](https://opam.ocaml.org/doc/Manual.html#Switches) for the OCaml compiler
|
||||||
|
|
||||||
```bash
|
```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:
|
* In the above command:
|
||||||
|
|
||||||
- `opam switch create` is a subcommand to create a new switch
|
- `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
|
- `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`)
|
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`)
|
||||||
|
|
@ -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
|
* 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
|
Standard library directory: /home/user/.opam/lama/lib/ocaml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
(package
|
(package
|
||||||
(name Lama)
|
(name Lama)
|
||||||
(allow_empty)
|
(synopsis
|
||||||
(synopsis "TODO")
|
"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
|
(depends
|
||||||
posix-uname
|
posix-uname
|
||||||
GT
|
GT
|
||||||
|
|
|
||||||
1
src/.ocamlformat-ignore
Normal file
1
src/.ocamlformat-ignore
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
X86_32.ml
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
open GT
|
open GT
|
||||||
open Language
|
open Language
|
||||||
open SM
|
|
||||||
|
|
||||||
(* X86 codegeneration interface *)
|
(* X86 codegeneration interface *)
|
||||||
|
|
||||||
|
|
@ -241,7 +240,7 @@ let compile cmd env imports code =
|
||||||
match instr with
|
match instr with
|
||||||
| PUBLIC name -> env#register_public name, []
|
| PUBLIC name -> env#register_public name, []
|
||||||
| EXTERN name -> env#register_extern name, []
|
| EXTERN name -> env#register_extern name, []
|
||||||
| IMPORT name -> env, []
|
| IMPORT _name -> env, []
|
||||||
|
|
||||||
| CLOSURE (name, closure) ->
|
| CLOSURE (name, closure) ->
|
||||||
let pushr, popr =
|
let pushr, popr =
|
||||||
|
|
@ -691,7 +690,7 @@ class env prg =
|
||||||
|
|
||||||
(* tag hash: gets a hash for a string tag *)
|
(* tag hash: gets a hash for a string tag *)
|
||||||
method hash 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
|
for i = 0 to min (String.length tag - 1) 4 do
|
||||||
h := (!h lsl 6) lor (String.index chars tag.[i])
|
h := (!h lsl 6) lor (String.index chars tag.[i])
|
||||||
done;
|
done;
|
||||||
|
|
|
||||||
6
src/dune
6
src/dune
|
|
@ -76,11 +76,9 @@
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
(name Driver)
|
(name Driver)
|
||||||
|
(public_name lamac)
|
||||||
(flags
|
(flags
|
||||||
(:standard
|
(:standard -rectypes))
|
||||||
-rectypes
|
|
||||||
;-dsource
|
|
||||||
))
|
|
||||||
(modules Driver)
|
(modules Driver)
|
||||||
(libraries liba unix))
|
(libraries liba unix))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
../Timer.lama
|
../Timer.lama
|
||||||
%{project_root}/src/Driver.exe)
|
%{project_root}/src/Driver.exe)
|
||||||
(targets
|
(targets
|
||||||
List.i
|
Array.i
|
||||||
List.o
|
Array.o
|
||||||
Buffer.i
|
Buffer.i
|
||||||
Buffer.o
|
Buffer.o
|
||||||
Collection.i
|
Collection.i
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
(deps
|
(deps
|
||||||
../Makefile
|
../Makefile
|
||||||
../../runtime/Std.i
|
../../runtime/Std.i
|
||||||
../List.lama
|
|
||||||
../Array.lama
|
../Array.lama
|
||||||
../Buffer.lama
|
../Buffer.lama
|
||||||
../Collection.lama
|
../Collection.lama
|
||||||
|
|
@ -18,8 +17,8 @@
|
||||||
../Timer.lama
|
../Timer.lama
|
||||||
%{project_root}/src/Driver.exe)
|
%{project_root}/src/Driver.exe)
|
||||||
(targets
|
(targets
|
||||||
List.i
|
Array.i
|
||||||
List.o
|
Array.o
|
||||||
Buffer.i
|
Buffer.i
|
||||||
Buffer.o
|
Buffer.o
|
||||||
Collection.i
|
Collection.i
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue