Skip to content

Commit

Permalink
Merge remote-tracking branch 'chia/base' into list_to_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
prozacchiwawa committed Oct 25, 2023
2 parents bfce61a + 15206a4 commit 34937b5
Show file tree
Hide file tree
Showing 40 changed files with 2,695 additions and 435 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/build-riscv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: QEMU Build and test riscv64 crate

on:
push:
branches:
- main
- dev
tags:
- '**'
pull_request:
branches:
- '**'

jobs:
build_crate:
name: Build riscv64 crate and run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Set up QEMU on x86_64
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: riscv64

- name: Build and Test
run: |
docker run --rm --platform linux/riscv64 \
-v ${{ github.workspace }}:/ws --workdir=/ws \
chianetwork/ubuntu-22.04-risc-builder:latest \
bash -exc '\
cargo test --release
'
build_wheels:
name: QEMU riscv64 wheel
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Set up QEMU on x86_64
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: riscv64

- name: Build
run: |
docker run --rm --platform linux/riscv64 \
-v ${{ github.workspace }}:/ws --workdir=/ws \
chianetwork/ubuntu-22.04-risc-builder:latest \
bash -exc '\
pyenv global 3.10
python -m venv venv && \
source ./venv/bin/activate && \
pip install --upgrade pip && \
pip install --extra-index-url https://pypi.chia.net/simple/ maturin==1.2.3 && \
maturin build -i python --release --strip \
'
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packages
path: ./target/wheels/

28 changes: 28 additions & 0 deletions resources/tests/cse-complex-21.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(mod (X)
(include *standard-cl-21*)

(defun mess (X) ;; 11 41
(assign
Y (+ X 1) ;; 12 42
Z (+ Y 2) ;; 14 44

(if (= X 11)
(assign
Y (* X 2) ;; 22 82
Z (+ Y 1) ;; 23 83

(* Y Z) ;; 22 * 23 = 506
)

(assign
Y (* X 3) ;; 33 123
Z (+ Y 2) ;; 35 125

(* Y Z) ;; 123 * 125 = 15375
)
)
)
)

(mess X)
)
11 changes: 11 additions & 0 deletions resources/tests/strict/assert.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(mod (A)
(include *strict-cl-21*)

(include defmac_assert.clib)

(assert
1
A
13
)
)
10 changes: 10 additions & 0 deletions resources/tests/strict/defmac_assert.clib
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(
(defun assert_ (items)
(if (r items)
(qq (if (unquote (f items)) (unquote (assert_ (r items))) (x)))
(f items)
)
)

(defmac assert items (assert_ items))
)
8 changes: 8 additions & 0 deletions resources/tests/strict/defmac_if_smoke.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(mod ()
(include *strict-cl-21*)

(include defmac_simple_if.clib)

(if_ t1 t2 t3)
)

3 changes: 3 additions & 0 deletions resources/tests/strict/defmac_simple_if.clib
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(
(defmac if_ (C T E) (qq (if (unquote C) (unquote T) (unquote E))))
)
24 changes: 24 additions & 0 deletions resources/tests/strict/double-constant-fail.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(mod (X)
(include *strict-cl-21*)

;; A macro-level function to pass through only real integers.
(defun pass-through-integers (X)
(if (not (number? X))
(x "not a number given to only-integers" X)
X
)
)

;; A macro which at preprocessing time throws if the given argument
;; wasn't a lexical integer.
(defmac only-integers (X) (pass-through-integers X))

;; Note: when macro expanding, N is the N argument to the body of
;; the double macro, not the integer literal, so we use the function
;; version of pass-through-integers in the macro body.
(defmac double (N) (* 2 (pass-through-integers N)))

;; Here the macro form of only-integers can determine whether the
;; double macro produced an integer or some other expression.
(only-integers (double "hithere"))
)
26 changes: 26 additions & 0 deletions resources/tests/strict/double-constant-pass-in-function.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(mod (X)
(include *strict-cl-21*)

;; A macro-level function to pass through only real integers.
(defun pass-through-integers (X)
(if (not (number? X))
(x "not a number given to only-integers" X)
X
)
)

;; A macro which at preprocessing time throws if the given argument
;; wasn't a lexical integer.
(defmac only-integers (X) (pass-through-integers X))

;; Note: when macro expanding, N is the N argument to the body of
;; the double macro, not the integer literal, so we use the function
;; version of pass-through-integers in the macro body.
(defmac double (N) (* 2 (pass-through-integers N)))

;; Here the macro form of only-integers can determine whether the
;; double macro produced an integer or some other expression.
(defun F (N) (+ N (only-integers (double 99))))

(F X)
)
24 changes: 24 additions & 0 deletions resources/tests/strict/double-constant-pass.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(mod (X)
(include *strict-cl-21*)

;; A macro-level function to pass through only real integers.
(defun pass-through-integers (X)
(if (not (number? X))
(x "not a number given to only-integers" X)
X
)
)

;; A macro which at preprocessing time throws if the given argument
;; wasn't a lexical integer.
(defmac only-integers (X) (pass-through-integers X))

;; Note: when macro expanding, N is the N argument to the body of
;; the double macro, not the integer literal, so we use the function
;; version of pass-through-integers in the macro body.
(defmac double (N) (* 2 (pass-through-integers N)))

;; Here the macro form of only-integers can determine whether the
;; double macro produced an integer or some other expression.
(only-integers (double 99))
)
24 changes: 24 additions & 0 deletions resources/tests/strict/strict-classify-expr-if.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(mod (X)
(include *strict-cl-21*)
;; Ensure macros can expand inside other macros when using advanced primitives.
(defmac classify-expr (G)
(if (number? G)
1
(if (symbol? G)
2
(if (string? G)
3
(if (l G)
4
0
)
)
)
)
)

(if X
(classify-expr X)
(list (classify-expr ()) (classify-expr 33) (classify-expr test) (classify-expr "foo") (classify-expr (* 3 2)) (classify-expr (list 1 2 3)))
)
)
6 changes: 6 additions & 0 deletions resources/tests/strict/strict-in-place-factorial.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(mod (X)
(include *strict-cl-21*)
(defmac factorial (N)
(if (> 2 N) 1 (qq (* (unquote N) (factorial (- N 1))))))
(factorial 5)
)
4 changes: 4 additions & 0 deletions resources/tests/strict/strict-list-fail.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(mod (X)
(include *strict-cl-21*)
(list X (+ X 1) (+ X2))
)
4 changes: 4 additions & 0 deletions resources/tests/strict/strict-list-pass.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(mod (X)
(include *strict-cl-21*)
(list X (+ X 1) (+ X 2))
)
4 changes: 4 additions & 0 deletions resources/tests/strict/strict-nested-list.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(mod (X)
(include *strict-cl-21*)
(list X (list X) (list (list X)))
)
9 changes: 9 additions & 0 deletions resources/tests/strict/strict-test-fail.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(mod (X)
(include *strict-cl-21*)
;; This wouldn't be able to be rejected because X1 is coming from a macro
;; expansion. This should fail in strict but succeed wrong non-strict.
(if X
(+ X1 2)
5
)
)
7 changes: 7 additions & 0 deletions resources/tests/strict/strict-test-pass.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(mod (X)
(include *strict-cl-21*)
(if X
(+ X 2)
5
)
)
3 changes: 3 additions & 0 deletions resources/tests/strict/test-inner-include.clinc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(
(include defmac_simple_if.clib)
)
7 changes: 7 additions & 0 deletions resources/tests/strict/test-inner-include.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(mod (X)
(include *strict-cl-21*)

(include test-inner-include.clinc)

(if_ X (* X 2) (+ X 1))
)
Loading

0 comments on commit 34937b5

Please sign in to comment.