Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leo ard/features with values #66

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ jobs:
with:
name: minify-exe
path: src/scripts/minify

rvm_generation_tests:
runs-on: ubuntu-latest
needs: compile_RSC
steps:
- name: Checkout the ribbit repository
uses: actions/checkout@v2
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}
- name: Download rsc.exe artifact into rsc-exe
uses: actions/download-artifact@v4
with:
name: rsc-exe
path: src
- name: Set up permissions on rsc.exe
run: |
chmod +x src/rsc.exe
- name: Run test
run: |
cd src && make check-features

py_rvm:
runs-on: ubuntu-latest
needs: compile_RSC
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ src/.vscode/launch.json
src/.vscode/tasks.json
src/rvm-sizes.log
**/tmp*
src/scripts/minify
src/.tests
8 changes: 4 additions & 4 deletions src/examples/rib_eater.scm
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
(define-feature
rib_eater
(use scm2host)
(decl "collected_ribs = [];
function eat_rib(r) { collected_ribs.push(scm2host(r)); }")
(start "console.log('Rib eater is activated');")
(end "console.log('Here are my lovely eaten ribs (miam) : ', collected_ribs)"))
((decl "collected_ribs = [];"
"function eat_rib(r) { collected_ribs.push(scm2host(r)); }")
(start "console.log('Rib eater is activated');")
(end "console.log('Here are my lovely eaten ribs (miam) : ', collected_ribs)")))

(define-primitive
(eat rib)
Expand Down
5 changes: 2 additions & 3 deletions src/host/asm/tests/60-primitives.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"\tdd prim_square\n")

(define-feature square
(prims "
((prims "
prim_square:
%if FIX_TAG != 0
\tdec LAST_ARG
Expand All @@ -14,8 +14,7 @@ prim_square:
\tinc LAST_ARG
%endif
\tNBARGS(1)
\tret"))

\tret")))

(##putchar (square 6))
(##putchar 10)
Expand Down
4 changes: 3 additions & 1 deletion src/host/hs/lib/prim-io.scm
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(define-feature hs/io-handle (hs/foreign-type " | RibHandle !Handle"))
(define-feature
hs/io-handle
((hs/foreign-type " | RibHandle !Handle")))

(define-primitive
(##stdin-fd)
Expand Down
2 changes: 1 addition & 1 deletion src/host/lua/rvm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ local primitives = {
prim2(quotient), -- @@(primitive (##quotient x y))@@
getchar, -- @@(primitive (##getchar))@@
prim1(putchar), -- @@(primitive (##putchar c))@@
prim1(os.exit) -- @@(primitive (##exit n))@@
prim1(os.exit), -- @@(primitive (##exit n))@@
-- )@@
}

Expand Down
2 changes: 1 addition & 1 deletion src/host/ml/rvm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ module Primitives : PRIMITIVES = struct
(* )@@ *)
prim0 (function () -> Integer (getchar ())); (* @@(primitive (##getchar))@@ *)
prim1 (function Integer ch -> Integer (putchar ch) | _ -> invalid_arg "putchar argument must be Integer"); (* @@(primitive (##putchar x))@@ *)
prim1 (function Integer status -> exit status | _ -> invalid_arg "exit argument must be Integer") (* @@(primitive (##exit x))@@ *)
prim1 (function Integer status -> exit status | _ -> invalid_arg "exit argument must be Integer"); (* @@(primitive (##exit x))@@ *)
(* )@@ *)
|]
end
Expand Down
4 changes: 2 additions & 2 deletions src/lib/r4rs/control.scm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
((host py)
(define-feature
##apply
(decl
((decl
"def prim_apply():
_arg = pop()
f = pop()
Expand All @@ -35,7 +35,7 @@
push(num_args) # @@(feature arity-check)@@
return f

"))
")))
(define-primitive
(##apply f args)
"prim_apply,"))
Expand Down
4 changes: 2 additions & 2 deletions src/lib/r4rs/sys.scm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(cond-expand
((host js)

;; (define-feature js/node/child-process (use) (decl "const child_p = require('child_process');\n"))
;; (define-feature js/node/child-process (use) ((decl "const child_p = require('child_process');\n")))

(define-primitive
(##cmd-line)
Expand All @@ -28,7 +28,7 @@

((host py)

(define-feature py/sys (use) (import "import os,sys"))
(define-feature py/sys (use) ((import "import os,sys")))

(define-primitive
(##cmd-line)
Expand Down
19 changes: 12 additions & 7 deletions src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,21 @@ check-repl: rsc.exe
check-pipeline: check
check-all: check-pipeline check-fancy check-features check-bootstrap

check-features:
check-features: rsc.exe
@host="$${HOST:-js}"; \
for host_path in ./tests/hosts/*; do \
error=0; \
for host_path in ./tests/hosts/*.test; do \
options=`sed -n -e '/;;;options:/p' $$host_path | sed -e 's/^;;;options://'`; \
nb_visible_original=`grep -c visible $$host_path`; \
nb_hidden_original=`grep -c hidden $$host_path`; \
echo "====================== TESTING FEATURE $$host_path (v:$$nb_visible_original, h:$$nb_hidden_original, options: '$$options')"; \
cmd="$${GSI} rsc.scm -t $$host $$options lib/empty.scm --rvm $$host_path -o .test-feature.REMOVE"; \
cmd="${RSC_COMPILER} -t $$host $$options lib/empty.scm --rvm $$host_path -o .test-feature.REMOVE"; \
$$cmd; \
nb_visible_after=`grep -c visible .test-feature.REMOVE;` \
nb_hidden_after=`grep -c hidden .test-feature.REMOVE`; \
if ! [[ "$$nb_visible_after" -eq "$$nb_visible_original" && "$$nb_hidden_after" -eq "0" ]] ; then \
echo "Mismatch on visible/hidden."; \
if [ "$$nb_visible_after" != "$$nb_visible_original" ] || [ "$$nb_hidden_after" != "0" ] ; then \
error=1; \
echo "Mismatch on visible/hidden."; \
echo " Visible expected : $$nb_visible_original "; \
echo " Visible got : $$nb_visible_after "; \
echo " Hidden expected : 0 (found $$nb_hidden_original in original file)"; \
Expand All @@ -92,9 +94,12 @@ check-features:
echo ""; \
echo "--- Generated file ($$cmd) :"; \
echo ""; \
cat .test-feature.REMOVE; \
cat .test-feature.REMOVE; \
fi; \
done
done; \
if [ $$error -eq 1 ]; then \
exit 1; \
fi;

check-bootstrap: rsc.exe
@UP_CASE="(##vector-set! ##main-readtable 1 'upcase)"; \
Expand Down
Loading
Loading