1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-18 01:07:40 +00:00

Modularize compiler.

This commit is contained in:
Calvin Rose
2018-07-01 11:52:15 -04:00
parent fde9751eab
commit f4fc4a0bcc
13 changed files with 1055 additions and 679 deletions

View File

@@ -7,7 +7,7 @@
(loop [k :range [0 len]]
(put tab (get s k) k))
(loop [i :range [0 len], j :range [0 len]]
(def k (get tab (- 0 (get s i) (get s j))))
(when (and k (not= k i) (not= k j) (not= i j))
(put solutions {i true j true k true} true)))
(def k (get tab (- 0 (get s i) (get s j))))
(when (and k (not= k i) (not= k j) (not= i j))
(put solutions {i true j true k true} true)))
(map keys (keys solution)))

View File

@@ -1,11 +1,10 @@
# Example of dst bytecode assembly
# Fibonacci sequence, implemented with naive recursion.
(def fibasm (asm.asm '{
(def fibasm (asm '{
arity 1
bytecode [
(ldi 1 0x2) # $1 = 2
(lt 1 0 1) # $1 = $0 < $1
(ltim 1 0 0x2) # $1 = $0 < 2
(jmpif 1 :done) # if ($1) goto :done
(lds 1) # $1 = self
(addim 0 0 -0x1) # $0 = $0 - 1