New package: joker-0.12.1

This commit is contained in:
Dominic Monroe 2019-03-23 07:02:21 +00:00 committed by maxice8
parent 255c3f7479
commit 5d9f031596
2 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,61 @@
diff --git core/array_map.go core/array_map.go
index 3d9b95d..6e03cfa 100644
--- core/array_map.go
+++ core/array_map.go
@@ -21,7 +21,7 @@ type (
)
var (
- HASHMAP_THRESHOLD int = 16
+ HASHMAP_THRESHOLD int64 = 16
)
func EmptyArrayMap() *ArrayMap {
@@ -169,7 +169,7 @@ func (m *ArrayMap) Assoc(key Object, value Object) Associative {
res.arr[i+1] = value
return res
}
- if len(m.arr) >= HASHMAP_THRESHOLD {
+ if int64(len(m.arr)) >= HASHMAP_THRESHOLD {
return NewHashMap(m.arr...).Assoc(key, value)
}
res := m.Clone()
diff --git core/eval.go core/eval.go
index 42b7ff2..49ade93 100644
--- core/eval.go
+++ core/eval.go
@@ -204,7 +204,7 @@ func (expr *VectorExpr) Eval(env *LocalEnv) Object {
}
func (expr *MapExpr) Eval(env *LocalEnv) Object {
- if len(expr.keys) > HASHMAP_THRESHOLD/2 {
+ if int64(len(expr.keys)) > HASHMAP_THRESHOLD/2 {
res := EmptyHashMap
for i := range expr.keys {
key := Eval(expr.keys[i], env)
diff --git core/read.go core/read.go
index 199fd72..1a03ca8 100644
--- core/read.go
+++ core/read.go
@@ -604,7 +604,7 @@ func readMapWithNamespace(reader *Reader, nsname string) Object {
if len(objs)%2 != 0 {
panic(MakeReadError(reader, "Map literal must contain an even number of forms"))
}
- if len(objs) > HASHMAP_THRESHOLD {
+ if int64(len(objs)) >= HASHMAP_THRESHOLD {
hashMap := NewHashMap()
for i := 0; i < len(objs); i += 2 {
key := resolveKey(objs[i], nsname)
diff --git main.go main.go
index 126f221..bfd1b84 100644
--- main.go
+++ main.go
@@ -437,7 +437,7 @@ func parseArgs(args []string) {
if thresh < 0 {
HASHMAP_THRESHOLD = math.MaxInt64
} else {
- HASHMAP_THRESHOLD = thresh
+ HASHMAP_THRESHOLD = int64(thresh)
}
} else {
missing = true

29
srcpkgs/joker/template Normal file
View file

@ -0,0 +1,29 @@
# Template file for 'joker'
pkgname=joker
version=0.12.1
revision=1
build_style=go
go_import_path="github.com/candid82/joker"
hostmakedepends="git"
short_desc="Interpreted dialect of Clojure written in Go and Clojure(Script) linter"
maintainer="Dominic Monroe <monroef4@googlemail.com>"
license="EPL-1.0"
homepage="https://joker-lang.org/"
distfiles="https://github.com/candid82/joker/archive/v${version}.tar.gz"
checksum=b019b96f9a36cb88749701c8e93a3d811ee26f6c453595320a3ab3adca404c09
if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" joker"
fi
pre_build() {
JOKER="joker"
if [ -z "$CROSS_BUILD" ]; then
JOKER="../joker"
go generate ./...
go build
fi
(cd std; "$JOKER" --hashmap-threshold 8192 generate-std.joke)
}