Minor fixes of minor tools

Signed-off-by: Kakadu <Kakadu@pm.me>
This commit is contained in:
Kakadu 2024-09-05 17:32:45 +03:00
parent f6277da16e
commit d3d2535f97
12 changed files with 67 additions and 27 deletions

View file

@ -1,12 +0,0 @@
all: gc_runtime.o runtime.o
ar rc runtime.a gc_runtime.o runtime.o
gc_runtime.o: gc_runtime.s
$(CC) -g -fstack-protector-all -m32 -c gc_runtime.s
runtime.o: runtime.c
$(CC) -g -fstack-protector-all -m32 -c runtime.c
clean:
$(RM) *.a *.o *~

1
byterun/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/byterun.exe

9
byterun/dune Normal file
View file

@ -0,0 +1,9 @@
(rule
(target byterun.exe)
(deps
(:main byterun.c)
(:runtime ../runtime/runtime.a))
(mode
(promote (until-clean)))
(action
(run gcc -g %{main} %{runtime} -o %{target})))

1
performance/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/*.exe

21
performance/dune Normal file
View file

@ -0,0 +1,21 @@
(rule
(targets Sort.x64.exe)
(deps
(:lama Sort.lama)
../runtime/runtime.a)
(mode
(promote (until-clean)))
(action
(setenv
LAMA
"../runtime"
(run
%{project_root}/src/Driver.exe
-march=x86_64
%{lama}
-I
../stdlib/x64
-I
../runtime
-o
%{targets}))))

View file

@ -21,7 +21,9 @@ let[@ocaml.warning "-32"] main =
let rec read acc =
try
let r = read_int () in
Printf.printf "> ";
Printf.printf " > ";
(* NOTE(Kakadu): This kind of ouput (leading >) will be in a conflict with dune's
integration tests machinery *)
read (r :: acc)
with End_of_file -> List.rev acc
in

View file

@ -1,7 +1,7 @@
(rule
(deps
../Makefile
../../runtime/Std.i
../../runtime32/Std.i
../List.lama
../Array.lama
../Buffer.lama

9
tools/dune Normal file
View file

@ -0,0 +1,9 @@
(executable
(name tool)
(modules tool)
(flags
(:standard -rectypes))
(libraries liba))
(cram
(deps ../runtime/runtime.a ../runtime/Std.i ./tool.exe demo1.lama))

4
tools/run.t Normal file
View file

@ -0,0 +1,4 @@
$ LAMA=../runtime ./tool.exe demo1.lama -pos 5,22 -use
found definition for `f` at (1,19)
Total 2 usages found
(5,24) (5,22)

View file

@ -14,9 +14,10 @@ type config =
; mutable line : int
; mutable col: int
; mutable mode: mode
; mutable includes : string list
}
let config = { filename= "file.ml"; pos="0,0"; line=0; col=0; mode = GoToDef }
let config = { filename= "file.ml"; pos="0,0"; line=0; col=0; mode = GoToDef; includes = ["."; "./runtime"] }
let _ = if false then config.pos <- "" else ignore config.pos
let parse_loc loc =
Scanf.sscanf loc "%d,%d" (fun l c -> config.line <- l; config.col <- c)
@ -26,6 +27,7 @@ let () =
[ "-pos", String parse_loc, "L,C when L is line and C is column"
; "-def", Unit (fun () -> config.mode <- GoToDef), "go to definition"
; "-use", Unit (fun () -> config.mode <- Usages), "find usages"
; "-I", String (fun s -> config.includes <- s :: config.includes), " Add include path"
]
(fun name -> config.filename <- name)
"Help"
@ -118,7 +120,10 @@ let find_usages root (def_name,(_,_)) =
let () =
let cfg = object
method get_include_paths = ["."; "./runtime"] method get_infile = config.filename method is_workaround=false end
method get_include_paths = ["."; "./runtime"; "../runtime"]
method get_infile = config.filename
method is_workaround = false
end
in
match Language.run_parser cfg with
| `Fail s -> failwith s

View file

@ -1,7 +1,7 @@
(rule
(targets Expressions.x32.exe)
(deps (:lama Expressions.lama) ../runtime32/runtime.a)
(deps (:lama Expressions.lama) ../runtime32/runtime.a ../stdlib/x32/Fun.i)
(mode
(promote (until-clean)))
(action
@ -21,7 +21,7 @@
(rule
(targets Expressions.x64.exe)
(deps (:lama Expressions.lama) ../runtime/runtime.a)
(deps (:lama Expressions.lama) ../runtime/runtime.a ../stdlib/x64/Fun.i)
(mode
(promote (until-clean)))
(action
@ -41,7 +41,7 @@
(rule
(targets Functions.x32.exe)
(deps (:lama Functions.lama) ../runtime32/runtime.a)
(deps (:lama Functions.lama) ../runtime32/runtime.a ../stdlib/x32/Fun.i)
(mode
(promote (until-clean)))
(action
@ -61,7 +61,7 @@
(rule
(targets Functions.x64.exe)
(deps (:lama Functions.lama) ../runtime/runtime.a)
(deps (:lama Functions.lama) ../runtime/runtime.a ../stdlib/x64/Fun.i)
(mode
(promote (until-clean)))
(action
@ -81,7 +81,7 @@
(rule
(targets Hello.x32.exe)
(deps (:lama Hello.lama) ../runtime32/runtime.a)
(deps (:lama Hello.lama) ../runtime32/runtime.a ../stdlib/x32/Fun.i)
(mode
(promote (until-clean)))
(action
@ -101,7 +101,7 @@
(rule
(targets Hello.x64.exe)
(deps (:lama Hello.lama) ../runtime/runtime.a)
(deps (:lama Hello.lama) ../runtime/runtime.a ../stdlib/x64/Fun.i)
(mode
(promote (until-clean)))
(action
@ -121,7 +121,7 @@
(rule
(targets PatternMatching.x32.exe)
(deps (:lama PatternMatching.lama) ../runtime32/runtime.a)
(deps (:lama PatternMatching.lama) ../runtime32/runtime.a ../stdlib/x32/Fun.i)
(mode
(promote (until-clean)))
(action
@ -141,7 +141,7 @@
(rule
(targets PatternMatching.x64.exe)
(deps (:lama PatternMatching.lama) ../runtime/runtime.a)
(deps (:lama PatternMatching.lama) ../runtime/runtime.a ../stdlib/x64/Fun.i)
(mode
(promote (until-clean)))
(action
@ -161,7 +161,7 @@
(rule
(targets Values.x32.exe)
(deps (:lama Values.lama) ../runtime32/runtime.a)
(deps (:lama Values.lama) ../runtime32/runtime.a ../stdlib/x32/Fun.i)
(mode
(promote (until-clean)))
(action
@ -181,7 +181,7 @@
(rule
(targets Values.x64.exe)
(deps (:lama Values.lama) ../runtime/runtime.a)
(deps (:lama Values.lama) ../runtime/runtime.a ../stdlib/x64/Fun.i)
(mode
(promote (until-clean)))
(action

View file

@ -5,7 +5,7 @@ let demos = ["Expressions"; "Functions"; "Hello"; "PatternMatching"; "Values"]
let template = {|
(rule
(targets %DEMO%.exe)
(deps (:lama %DEMOSRC%.lama) %RUNTIME%/runtime.a)
(deps (:lama %DEMOSRC%.lama) %RUNTIME%/runtime.a %STDLIB%/Fun.i)
(mode
(promote (until-clean)))
(action