Skip to content

Commit 4db93ab

Browse files
committed
Add wasip1/wasm support and filter generic types from exports
- Add wasip1/wasm build target and generated imports - Filter generic types and functions in isEligibleForExport to prevent invalid code generation for types with type parameters - Regenerate all platform-specific import files
1 parent 04434d0 commit 4db93ab

File tree

11 files changed

+10348
-15
lines changed

11 files changed

+10348
-15
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
SHELL := bash
55

6-
GO-VERSION ?= 1.19.3
6+
GO-VERSION ?= 1.24.0
77
CLOJURE-VERSION ?= 1.12.1
88

99
CLOJURE-STDLIB-VERSION := clojure-$(CLOJURE-VERSION)
@@ -60,6 +60,7 @@ GO-PLATFORMS := \
6060
windows_arm \
6161
windows_amd64 \
6262
js_wasm \
63+
wasip1_wasm \
6364
$(EXTRA-GO-PLATFORMS)
6465

6566
GLJ-IMPORTS=$(foreach platform,$(GO-PLATFORMS) \

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/glojurelang/glojure
22

3-
go 1.19
3+
go 1.24
44

55
require (
66
bitbucket.org/pcastools/hash v1.0.5

internal/genpkg/genpkg.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,23 @@ func isEligibleForExport(object types.Object, packageName string) bool {
8989
return false
9090
}
9191

92+
// Reject generic types (types with type parameters)
93+
if typeName, ok := object.(*types.TypeName); ok {
94+
if named, ok := typeName.Type().(*types.Named); ok {
95+
if named.TypeParams() != nil && named.TypeParams().Len() > 0 {
96+
return false
97+
}
98+
}
99+
}
100+
101+
// Reject generic functions (functions with type parameters)
102+
if fn, ok := object.(*types.Func); ok {
103+
sig := fn.Type().(*types.Signature)
104+
if sig.TypeParams() != nil && sig.TypeParams().Len() > 0 {
105+
return false
106+
}
107+
}
108+
92109
return true
93110
}
94111

@@ -237,12 +254,6 @@ func getVarDeclaration(object *types.Var, globalName string, aliasName string) s
237254
}
238255

239256
func getTypeNameDeclaration(object *types.TypeName, globalName string, aliasName string) string {
240-
isGeneric := strings.HasSuffix(object.Type().String(), "]")
241-
242-
if isGeneric {
243-
return ""
244-
}
245-
246257
ret := fmt.Sprintf("_register(%q, reflect.TypeOf((*%s)(nil)).Elem())", globalName, aliasName)
247258
if _, ok := object.Type().Underlying().(*types.Struct); ok {
248259
// register with a * prepended to the name _within_ the package

pkg/gen/gljimports/gljimports_darwin_amd64.go

Lines changed: 331 additions & 1 deletion
Large diffs are not rendered by default.

pkg/gen/gljimports/gljimports_darwin_arm64.go

Lines changed: 331 additions & 1 deletion
Large diffs are not rendered by default.

pkg/gen/gljimports/gljimports_js_wasm.go

Lines changed: 332 additions & 1 deletion
Large diffs are not rendered by default.

pkg/gen/gljimports/gljimports_linux_amd64.go

Lines changed: 336 additions & 1 deletion
Large diffs are not rendered by default.

pkg/gen/gljimports/gljimports_linux_arm64.go

Lines changed: 336 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)