goscript 0.0.36 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/analysis.go +129 -8
- package/compiler/compiler.go +4 -1
- package/compiler/composite-lit.go +2 -4
- package/compiler/expr-call.go +26 -0
- package/compiler/lit.go +83 -0
- package/compiler/protobuf.go +2 -2
- package/compiler/spec-value.go +3 -3
- package/compiler/spec.go +7 -4
- package/compiler/stmt-assign.go +1 -1
- package/compiler/stmt.go +26 -8
- package/dist/gs/builtin/slice.js +2 -1
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/errors.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/errors.js +182 -23
- package/dist/gs/github.com/pkg/errors/errors.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/go113.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/index.d.ts +3 -3
- package/dist/gs/github.com/pkg/errors/index.js +3 -3
- package/dist/gs/github.com/pkg/errors/index.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/stack.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/stack.js +8 -5
- package/dist/gs/github.com/pkg/errors/stack.js.map +1 -1
- package/dist/gs/internal/abi/index.d.ts +20 -0
- package/dist/gs/internal/abi/index.js +20 -0
- package/dist/gs/internal/abi/index.js.map +1 -0
- package/dist/gs/internal/bytealg/index.d.ts +2 -0
- package/dist/gs/internal/bytealg/index.js +33 -0
- package/dist/gs/internal/bytealg/index.js.map +1 -0
- package/dist/gs/internal/byteorder/index.d.ts +8 -0
- package/dist/gs/internal/byteorder/index.js +34 -0
- package/dist/gs/internal/byteorder/index.js.map +1 -0
- package/dist/gs/internal/testlog/index.d.ts +1 -0
- package/dist/gs/internal/testlog/index.js +5 -0
- package/dist/gs/internal/testlog/index.js.map +1 -0
- package/dist/gs/math/index.d.ts +44 -44
- package/dist/gs/math/index.js +44 -44
- package/dist/gs/math/index.js.map +1 -1
- package/dist/gs/os/dir.gs.d.ts +6 -0
- package/dist/gs/os/dir.gs.js +35 -0
- package/dist/gs/os/dir.gs.js.map +1 -0
- package/dist/gs/os/dir_unix.gs.d.ts +7 -0
- package/dist/gs/os/dir_unix.gs.js +113 -0
- package/dist/gs/os/dir_unix.gs.js.map +1 -0
- package/dist/gs/os/dirent_js.gs.d.ts +5 -0
- package/dist/gs/os/dirent_js.gs.js +20 -0
- package/dist/gs/os/dirent_js.gs.js.map +1 -0
- package/dist/gs/os/env.gs.d.ts +12 -0
- package/dist/gs/os/env.gs.js +157 -0
- package/dist/gs/os/env.gs.js.map +1 -0
- package/dist/gs/os/error.gs.d.ts +40 -0
- package/dist/gs/os/error.gs.js +158 -0
- package/dist/gs/os/error.gs.js.map +1 -0
- package/dist/gs/os/error_errno.gs.d.ts +1 -0
- package/dist/gs/os/error_errno.gs.js +5 -0
- package/dist/gs/os/error_errno.gs.js.map +1 -0
- package/dist/gs/os/exec.gs.d.ts +60 -0
- package/dist/gs/os/exec.gs.js +136 -0
- package/dist/gs/os/exec.gs.js.map +1 -0
- package/dist/gs/os/exec_nohandle.gs.d.ts +1 -0
- package/dist/gs/os/exec_nohandle.gs.js +2 -0
- package/dist/gs/os/exec_nohandle.gs.js.map +1 -0
- package/dist/gs/os/exec_posix.gs.d.ts +25 -0
- package/dist/gs/os/exec_posix.gs.js +67 -0
- package/dist/gs/os/exec_posix.gs.js.map +1 -0
- package/dist/gs/os/exec_unix.gs.d.ts +4 -0
- package/dist/gs/os/exec_unix.gs.js +46 -0
- package/dist/gs/os/exec_unix.gs.js.map +1 -0
- package/dist/gs/os/executable.gs.d.ts +2 -0
- package/dist/gs/os/executable.gs.js +16 -0
- package/dist/gs/os/executable.gs.js.map +1 -0
- package/dist/gs/os/executable_js.gs.d.ts +2 -0
- package/dist/gs/os/executable_js.gs.js +5 -0
- package/dist/gs/os/executable_js.gs.js.map +1 -0
- package/dist/gs/os/executable_wasm.gs.d.ts +2 -0
- package/dist/gs/os/executable_wasm.gs.js +6 -0
- package/dist/gs/os/executable_wasm.gs.js.map +1 -0
- package/dist/gs/os/file_constants_js.gs.d.ts +41 -0
- package/dist/gs/os/file_constants_js.gs.js +78 -0
- package/dist/gs/os/file_constants_js.gs.js.map +1 -0
- package/dist/gs/os/file_js.gs.d.ts +22 -0
- package/dist/gs/os/file_js.gs.js +73 -0
- package/dist/gs/os/file_js.gs.js.map +1 -0
- package/dist/gs/os/file_open_unix.gs.d.ts +6 -0
- package/dist/gs/os/file_open_unix.gs.js +10 -0
- package/dist/gs/os/file_open_unix.gs.js.map +1 -0
- package/dist/gs/os/file_posix_js.gs.d.ts +8 -0
- package/dist/gs/os/file_posix_js.gs.js +32 -0
- package/dist/gs/os/file_posix_js.gs.js.map +1 -0
- package/dist/gs/os/file_unix_js.gs.d.ts +27 -0
- package/dist/gs/os/file_unix_js.gs.js +64 -0
- package/dist/gs/os/file_unix_js.gs.js.map +1 -0
- package/dist/gs/os/getwd_js.gs.d.ts +6 -0
- package/dist/gs/os/getwd_js.gs.js +21 -0
- package/dist/gs/os/getwd_js.gs.js.map +1 -0
- package/dist/gs/os/index.d.ts +19 -0
- package/dist/gs/os/index.js +20 -0
- package/dist/gs/os/index.js.map +1 -0
- package/dist/gs/os/path.gs.d.ts +4 -0
- package/dist/gs/os/path.gs.js +32 -0
- package/dist/gs/os/path.gs.js.map +1 -0
- package/dist/gs/os/path_unix.gs.d.ts +4 -0
- package/dist/gs/os/path_unix.gs.js +40 -0
- package/dist/gs/os/path_unix.gs.js.map +1 -0
- package/dist/gs/os/pidfd_js.gs.d.ts +6 -0
- package/dist/gs/os/pidfd_js.gs.js +14 -0
- package/dist/gs/os/pidfd_js.gs.js.map +1 -0
- package/dist/gs/os/pipe_wasm.gs.d.ts +2 -0
- package/dist/gs/os/pipe_wasm.gs.js +14 -0
- package/dist/gs/os/pipe_wasm.gs.js.map +1 -0
- package/dist/gs/os/proc.gs.d.ts +11 -0
- package/dist/gs/os/proc.gs.js +68 -0
- package/dist/gs/os/proc.gs.js.map +1 -0
- package/dist/gs/os/proc_js.gs.d.ts +3 -0
- package/dist/gs/os/proc_js.gs.js +12 -0
- package/dist/gs/os/proc_js.gs.js.map +1 -0
- package/dist/gs/os/rawconn_js.gs.d.ts +10 -0
- package/dist/gs/os/rawconn_js.gs.js +26 -0
- package/dist/gs/os/rawconn_js.gs.js.map +1 -0
- package/dist/gs/os/removeall_js.gs.d.ts +2 -0
- package/dist/gs/os/removeall_js.gs.js +7 -0
- package/dist/gs/os/removeall_js.gs.js.map +1 -0
- package/dist/gs/os/root_js.gs.d.ts +23 -0
- package/dist/gs/os/root_js.gs.js +80 -0
- package/dist/gs/os/root_js.gs.js.map +1 -0
- package/dist/gs/os/root_nonwindows.gs.d.ts +2 -0
- package/dist/gs/os/root_nonwindows.gs.js +4 -0
- package/dist/gs/os/root_nonwindows.gs.js.map +1 -0
- package/dist/gs/os/root_noopenat.gs.d.ts +11 -0
- package/dist/gs/os/root_noopenat.gs.js +31 -0
- package/dist/gs/os/root_noopenat.gs.js.map +1 -0
- package/dist/gs/os/stat.gs.d.ts +24 -0
- package/dist/gs/os/stat.gs.js +20 -0
- package/dist/gs/os/stat.gs.js.map +1 -0
- package/dist/gs/os/stat_js.gs.d.ts +6 -0
- package/dist/gs/os/stat_js.gs.js +23 -0
- package/dist/gs/os/stat_js.gs.js.map +1 -0
- package/dist/gs/os/stat_unix_js.gs.d.ts +8 -0
- package/dist/gs/os/stat_unix_js.gs.js +16 -0
- package/dist/gs/os/stat_unix_js.gs.js.map +1 -0
- package/dist/gs/os/sticky_bsd.gs.d.ts +1 -0
- package/dist/gs/os/sticky_bsd.gs.js +3 -0
- package/dist/gs/os/sticky_bsd.gs.js.map +1 -0
- package/dist/gs/os/sys.gs.d.ts +2 -0
- package/dist/gs/os/sys.gs.js +10 -0
- package/dist/gs/os/sys.gs.js.map +1 -0
- package/dist/gs/os/sys_bsd.gs.d.ts +2 -0
- package/dist/gs/os/sys_bsd.gs.js +15 -0
- package/dist/gs/os/sys_bsd.gs.js.map +1 -0
- package/dist/gs/os/sys_js.gs.d.ts +2 -0
- package/dist/gs/os/sys_js.gs.js +6 -0
- package/dist/gs/os/sys_js.gs.js.map +1 -0
- package/dist/gs/os/tempfile.gs.d.ts +5 -0
- package/dist/gs/os/tempfile.gs.js +30 -0
- package/dist/gs/os/tempfile.gs.js.map +1 -0
- package/dist/gs/os/types.gs.d.ts +59 -0
- package/dist/gs/os/types.gs.js +123 -0
- package/dist/gs/os/types.gs.js.map +1 -0
- package/dist/gs/os/types_js.gs.d.ts +74 -0
- package/dist/gs/os/types_js.gs.js +147 -0
- package/dist/gs/os/types_js.gs.js.map +1 -0
- package/dist/gs/os/types_unix.gs.d.ts +40 -0
- package/dist/gs/os/types_unix.gs.js +87 -0
- package/dist/gs/os/types_unix.gs.js.map +1 -0
- package/dist/gs/os/wait_unimp.gs.d.ts +1 -0
- package/dist/gs/os/wait_unimp.gs.js +2 -0
- package/dist/gs/os/wait_unimp.gs.js.map +1 -0
- package/dist/gs/os/zero_copy_posix.gs.d.ts +4 -0
- package/dist/gs/os/zero_copy_posix.gs.js +27 -0
- package/dist/gs/os/zero_copy_posix.gs.js.map +1 -0
- package/dist/gs/os/zero_copy_stub.gs.d.ts +1 -0
- package/dist/gs/os/zero_copy_stub.gs.js +2 -0
- package/dist/gs/os/zero_copy_stub.gs.js.map +1 -0
- package/dist/gs/reflect/abi.d.ts +59 -0
- package/dist/gs/reflect/abi.gs.d.ts +59 -0
- package/dist/gs/reflect/abi.gs.js +79 -0
- package/dist/gs/reflect/abi.gs.js.map +1 -0
- package/dist/gs/reflect/abi.js +79 -0
- package/dist/gs/reflect/abi.js.map +1 -0
- package/dist/gs/reflect/badlinkname.d.ts +52 -0
- package/dist/gs/reflect/badlinkname.gs.d.ts +52 -0
- package/dist/gs/reflect/badlinkname.gs.js +72 -0
- package/dist/gs/reflect/badlinkname.gs.js.map +1 -0
- package/dist/gs/reflect/badlinkname.js +72 -0
- package/dist/gs/reflect/badlinkname.js.map +1 -0
- package/dist/gs/reflect/deepequal.d.ts +1 -0
- package/dist/gs/reflect/deepequal.gs.d.ts +25 -0
- package/dist/gs/reflect/deepequal.gs.js +308 -0
- package/dist/gs/reflect/deepequal.gs.js.map +1 -0
- package/dist/gs/reflect/deepequal.js +139 -0
- package/dist/gs/reflect/deepequal.js.map +1 -0
- package/dist/gs/reflect/float32reg_generic.gs.d.ts +2 -0
- package/dist/gs/reflect/float32reg_generic.gs.js +10 -0
- package/dist/gs/reflect/float32reg_generic.gs.js.map +1 -0
- package/dist/gs/reflect/index.d.ts +8 -0
- package/dist/gs/reflect/index.gs.d.ts +1 -0
- package/dist/gs/reflect/index.gs.js +3 -0
- package/dist/gs/reflect/index.gs.js.map +1 -0
- package/dist/gs/reflect/index.js +10 -0
- package/dist/gs/reflect/index.js.map +1 -0
- package/dist/gs/reflect/iter.d.ts +4 -0
- package/dist/gs/reflect/iter.gs.d.ts +3 -0
- package/dist/gs/reflect/iter.gs.js +24 -0
- package/dist/gs/reflect/iter.gs.js.map +1 -0
- package/dist/gs/reflect/iter.js +24 -0
- package/dist/gs/reflect/iter.js.map +1 -0
- package/dist/gs/reflect/makefunc.gs.d.ts +34 -0
- package/dist/gs/reflect/makefunc.gs.js +288 -0
- package/dist/gs/reflect/makefunc.gs.js.map +1 -0
- package/dist/gs/reflect/map.d.ts +14 -0
- package/dist/gs/reflect/map.js +70 -0
- package/dist/gs/reflect/map.js.map +1 -0
- package/dist/gs/reflect/map_swiss.gs.d.ts +14 -0
- package/dist/gs/reflect/map_swiss.gs.js +70 -0
- package/dist/gs/reflect/map_swiss.gs.js.map +1 -0
- package/dist/gs/reflect/reflect.gs.d.ts +132 -0
- package/dist/gs/reflect/reflect.gs.js +437 -0
- package/dist/gs/reflect/reflect.gs.js.map +1 -0
- package/dist/gs/reflect/swapper.d.ts +2 -0
- package/dist/gs/reflect/swapper.gs.d.ts +1 -0
- package/dist/gs/reflect/swapper.gs.js +32 -0
- package/dist/gs/reflect/swapper.gs.js.map +1 -0
- package/dist/gs/reflect/swapper.js +46 -0
- package/dist/gs/reflect/swapper.js.map +1 -0
- package/dist/gs/reflect/type.d.ts +126 -0
- package/dist/gs/reflect/type.gs.d.ts +4 -0
- package/dist/gs/reflect/type.gs.js +21 -0
- package/dist/gs/reflect/type.gs.js.map +1 -0
- package/dist/gs/reflect/type.js +825 -0
- package/dist/gs/reflect/type.js.map +1 -0
- package/dist/gs/reflect/types.d.ts +90 -0
- package/dist/gs/reflect/types.js +119 -0
- package/dist/gs/reflect/types.js.map +1 -0
- package/dist/gs/reflect/value.d.ts +13 -0
- package/dist/gs/reflect/value.gs.d.ts +4 -0
- package/dist/gs/reflect/value.gs.js +12 -0
- package/dist/gs/reflect/value.gs.js.map +1 -0
- package/dist/gs/reflect/value.js +201 -0
- package/dist/gs/reflect/value.js.map +1 -0
- package/dist/gs/reflect/visiblefields.d.ts +4 -0
- package/dist/gs/reflect/visiblefields.gs.d.ts +3 -0
- package/dist/gs/reflect/visiblefields.gs.js +123 -0
- package/dist/gs/reflect/visiblefields.gs.js.map +1 -0
- package/dist/gs/reflect/visiblefields.js +143 -0
- package/dist/gs/reflect/visiblefields.js.map +1 -0
- package/dist/gs/strconv/index.d.ts +6 -6
- package/dist/gs/strconv/index.js +6 -6
- package/dist/gs/strconv/index.js.map +1 -1
- package/dist/gs/strings/index.d.ts +1 -1
- package/dist/gs/strings/index.js +1 -1
- package/dist/gs/strings/index.js.map +1 -1
- package/dist/gs/strings/replace.js.map +1 -1
- package/dist/gs/sync/atomic/index.d.ts +4 -4
- package/dist/gs/sync/atomic/index.js +4 -4
- package/dist/gs/sync/atomic/index.js.map +1 -1
- package/dist/gs/syscall/index.d.ts +80 -0
- package/dist/gs/syscall/index.js +169 -0
- package/dist/gs/syscall/index.js.map +1 -0
- package/dist/gs/unsafe/unsafe.js.map +1 -1
- package/gs/builtin/slice.ts +2 -1
- package/gs/github.com/pkg/errors/errors.ts +408 -238
- package/gs/github.com/pkg/errors/go113.ts +5 -6
- package/gs/github.com/pkg/errors/index.ts +12 -3
- package/gs/github.com/pkg/errors/stack.ts +107 -105
- package/gs/internal/abi/index.ts +37 -0
- package/gs/internal/bytealg/index.ts +34 -0
- package/gs/internal/byteorder/index.ts +40 -0
- package/gs/math/abs.gs.test.ts +1 -1
- package/gs/math/acosh.gs.test.ts +4 -2
- package/gs/math/asin.gs.test.ts +1 -1
- package/gs/math/asinh.gs.test.ts +7 -3
- package/gs/math/atan.gs.test.ts +1 -1
- package/gs/math/atan2.gs.test.ts +17 -9
- package/gs/math/atanh.gs.test.ts +1 -1
- package/gs/math/bits.gs.test.ts +1 -1
- package/gs/math/cbrt.gs.test.ts +1 -1
- package/gs/math/const.gs.test.ts +34 -8
- package/gs/math/copysign.gs.test.ts +7 -3
- package/gs/math/dim.gs.test.ts +19 -7
- package/gs/math/erf.gs.test.ts +1 -1
- package/gs/math/erfinv.gs.test.ts +4 -2
- package/gs/math/exp.gs.test.ts +1 -1
- package/gs/math/expm1.gs.test.ts +6 -4
- package/gs/math/floor.gs.test.ts +17 -4
- package/gs/math/fma.gs.test.ts +53 -53
- package/gs/math/frexp.gs.test.ts +112 -117
- package/gs/math/gamma.gs.test.ts +1 -1
- package/gs/math/hypot.gs.test.ts +53 -53
- package/gs/math/index.ts +80 -44
- package/gs/math/j0.gs.test.ts +6 -2
- package/gs/math/j1.gs.test.ts +6 -2
- package/gs/math/jn.gs.test.ts +9 -5
- package/gs/math/ldexp.gs.test.ts +103 -86
- package/gs/math/lgamma.gs.test.ts +10 -10
- package/gs/math/log.gs.test.ts +1 -1
- package/gs/math/log10.gs.test.ts +1 -1
- package/gs/math/log1p.gs.test.ts +2 -2
- package/gs/math/logb.gs.test.ts +1 -1
- package/gs/math/mod.gs.test.ts +2 -2
- package/gs/math/modf.gs.test.ts +7 -7
- package/gs/math/nextafter.gs.test.ts +9 -7
- package/gs/math/pow.gs.test.ts +6 -4
- package/gs/math/pow10.gs.test.ts +1 -1
- package/gs/math/remainder.gs.test.ts +1 -1
- package/gs/math/signbit.gs.test.ts +1 -1
- package/gs/math/sin.gs.test.ts +1 -1
- package/gs/math/sincos.gs.test.ts +33 -14
- package/gs/math/sinh.gs.test.ts +1 -1
- package/gs/math/sqrt.gs.test.ts +1 -1
- package/gs/math/tan.gs.test.ts +3 -3
- package/gs/math/tanh.gs.test.ts +1 -1
- package/gs/os/dir.gs.ts +42 -0
- package/gs/os/dir_unix.gs.ts +155 -0
- package/gs/os/dirent_js.gs.ts +27 -0
- package/gs/os/env.gs.ts +179 -0
- package/gs/os/error.gs.ts +205 -0
- package/gs/os/error_errno.gs.ts +12 -0
- package/gs/os/exec.gs.ts +198 -0
- package/gs/os/exec_nohandle.gs.ts +2 -0
- package/gs/os/exec_posix.gs.ts +95 -0
- package/gs/os/exec_unix.gs.ts +64 -0
- package/gs/os/executable.gs.ts +18 -0
- package/gs/os/executable_js.gs.ts +6 -0
- package/gs/os/executable_wasm.gs.ts +10 -0
- package/gs/os/file_constants_js.gs.ts +98 -0
- package/gs/os/file_js.gs.ts +99 -0
- package/gs/os/file_open_unix.gs.ts +15 -0
- package/gs/os/file_posix_js.gs.ts +40 -0
- package/gs/os/file_unix_js.gs.ts +94 -0
- package/gs/os/getwd_js.gs.ts +28 -0
- package/gs/os/index.ts +128 -0
- package/gs/os/path.gs.ts +35 -0
- package/gs/os/path_unix.gs.ts +49 -0
- package/gs/os/pidfd_js.gs.ts +25 -0
- package/gs/os/pipe_wasm.gs.ts +17 -0
- package/gs/os/proc.gs.ts +84 -0
- package/gs/os/proc_js.gs.ts +15 -0
- package/gs/os/rawconn_js.gs.ts +30 -0
- package/gs/os/removeall_js.gs.ts +9 -0
- package/gs/os/root_js.gs.ts +111 -0
- package/gs/os/root_nonwindows.gs.ts +6 -0
- package/gs/os/root_noopenat.gs.ts +45 -0
- package/gs/os/stat.gs.ts +38 -0
- package/gs/os/stat_js.gs.ts +30 -0
- package/gs/os/stat_unix_js.gs.ts +27 -0
- package/gs/os/sticky_bsd.gs.ts +4 -0
- package/gs/os/sys.gs.ts +12 -0
- package/gs/os/sys_bsd.gs.ts +17 -0
- package/gs/os/sys_js.gs.ts +9 -0
- package/gs/os/tempfile.gs.ts +34 -0
- package/gs/os/types.gs.ts +170 -0
- package/gs/os/types_js.gs.ts +205 -0
- package/gs/os/types_unix.gs.ts +118 -0
- package/gs/os/wait_unimp.gs.ts +2 -0
- package/gs/os/zero_copy_posix.gs.ts +35 -0
- package/gs/os/zero_copy_stub.gs.ts +4 -0
- package/gs/reflect/ANALYSIS.md +278 -0
- package/gs/reflect/deepequal.ts +154 -0
- package/gs/reflect/function-types.test.ts +146 -0
- package/gs/reflect/godoc.txt +67 -0
- package/gs/reflect/index.ts +83 -0
- package/gs/reflect/iter.ts +44 -0
- package/gs/reflect/map.ts +81 -0
- package/gs/reflect/swapper.ts +52 -0
- package/gs/reflect/type.ts +1012 -0
- package/gs/reflect/types.ts +214 -0
- package/gs/reflect/value.ts +264 -0
- package/gs/reflect/visiblefields.ts +173 -0
- package/gs/strconv/index.ts +39 -6
- package/gs/strings/index.ts +7 -1
- package/gs/strings/replace.ts +1 -9
- package/gs/sync/atomic/index.ts +53 -4
- package/gs/syscall/index.ts +212 -0
- package/gs/unsafe/unsafe.ts +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
5
|
+
import * as io from "@goscript/io/index.js"
|
|
6
|
+
import * as time from "@goscript/time/index.js"
|
|
7
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
8
|
+
|
|
9
|
+
// Re-export essential types
|
|
10
|
+
export type Time = time.Time;
|
|
11
|
+
export type FileInfo = fs.FileInfo;
|
|
12
|
+
export type FileMode = fs.FileMode;
|
|
13
|
+
export type DirEntry = fs.DirEntry;
|
|
14
|
+
|
|
15
|
+
// Export runtime values for ES module compatibility
|
|
16
|
+
export const Time = null as any;
|
|
17
|
+
export const FileInfo = null as any;
|
|
18
|
+
export const FileMode = null as any;
|
|
19
|
+
export const DirEntry = null as any;
|
|
20
|
+
|
|
21
|
+
// Getpagesize returns the underlying system's memory page size.
|
|
22
|
+
export function Getpagesize(): number {
|
|
23
|
+
// Return a standard page size for JavaScript environment
|
|
24
|
+
// Most systems use 4096 bytes as the default page size
|
|
25
|
+
return 4096
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Stub implementation of File for JavaScript environment
|
|
29
|
+
export class File {
|
|
30
|
+
public get file(): file | null {
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
public set file(value: file | null) {
|
|
34
|
+
// No-op
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public _fields: {
|
|
38
|
+
file: $.VarRef<file | null>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
constructor(init?: Partial<{file?: file | null}>) {
|
|
42
|
+
this._fields = {
|
|
43
|
+
file: $.varRef(null)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public clone(): File {
|
|
48
|
+
return new File()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// All File methods return ErrUnimplemented in JavaScript environment
|
|
52
|
+
public Readdir(n: number): [$.Slice<fs.FileInfo>, $.GoError] {
|
|
53
|
+
return [null, ErrUnimplemented]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public Readdirnames(n: number): [$.Slice<string>, $.GoError] {
|
|
57
|
+
return [null, ErrUnimplemented]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public ReadDir(n: number): [$.Slice<fs.DirEntry>, $.GoError] {
|
|
61
|
+
return [null, ErrUnimplemented]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public readdir(n: number, mode: readdirMode): [$.Slice<string>, $.Slice<fs.DirEntry>, $.Slice<fs.FileInfo>, $.GoError] {
|
|
65
|
+
return [null, null, null, ErrUnimplemented]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public Name(): string {
|
|
69
|
+
return ""
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public Read(b: $.Bytes): [number, $.GoError] {
|
|
73
|
+
return [0, ErrUnimplemented]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public ReadAt(b: $.Bytes, off: number): [number, $.GoError] {
|
|
77
|
+
return [0, ErrUnimplemented]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public ReadFrom(r: io.Reader): [number, $.GoError] {
|
|
81
|
+
return [0, ErrUnimplemented]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public Write(b: $.Bytes): [number, $.GoError] {
|
|
85
|
+
return [0, ErrUnimplemented]
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public WriteAt(b: $.Bytes, off: number): [number, $.GoError] {
|
|
89
|
+
return [0, ErrUnimplemented]
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public WriteTo(w: io.Writer): [number, $.GoError] {
|
|
93
|
+
return [0, ErrUnimplemented]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public Seek(offset: number, whence: number): [number, $.GoError] {
|
|
97
|
+
return [0, ErrUnimplemented]
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public WriteString(s: string): [number, $.GoError] {
|
|
101
|
+
return [0, ErrUnimplemented]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public Chmod(mode: number): $.GoError {
|
|
105
|
+
return ErrUnimplemented
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public SetDeadline(t: time.Time): $.GoError {
|
|
109
|
+
return ErrUnimplemented
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public SetReadDeadline(t: time.Time): $.GoError {
|
|
113
|
+
return ErrUnimplemented
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public SetWriteDeadline(t: time.Time): $.GoError {
|
|
117
|
+
return ErrUnimplemented
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public SyscallConn(): [any, $.GoError] {
|
|
121
|
+
return [null, ErrUnimplemented]
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public Close(): $.GoError {
|
|
125
|
+
return ErrUnimplemented
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public Chown(uid: number, gid: number): $.GoError {
|
|
129
|
+
return ErrUnimplemented
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public Truncate(size: number): $.GoError {
|
|
133
|
+
return ErrUnimplemented
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public Sync(): $.GoError {
|
|
137
|
+
return ErrUnimplemented
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public Chdir(): $.GoError {
|
|
141
|
+
return ErrUnimplemented
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public Fd(): syscall.uintptr {
|
|
145
|
+
return 0
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public Stat(): [fs.FileInfo, $.GoError] {
|
|
149
|
+
return [null, ErrUnimplemented]
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Internal methods
|
|
153
|
+
public checkValid(op: string): $.GoError {
|
|
154
|
+
return ErrUnimplemented
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public wrapErr(op: string, err: $.GoError): $.GoError {
|
|
158
|
+
return err
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Register this type with the runtime type system
|
|
162
|
+
static __typeInfo = $.registerStructType(
|
|
163
|
+
'File',
|
|
164
|
+
new File(),
|
|
165
|
+
[
|
|
166
|
+
{ name: "Readdir", args: [{ name: "n", type: { kind: $.TypeKind.Basic, name: "number" } }], returns: [{ type: { kind: $.TypeKind.Slice, elemType: "FileInfo" } }, { type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
|
|
167
|
+
{ name: "Read", args: [{ name: "b", type: { kind: $.TypeKind.Slice, elemType: { kind: $.TypeKind.Basic, name: "number" } } }], returns: [{ type: { kind: $.TypeKind.Basic, name: "number" } }, { type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
|
|
168
|
+
{ name: "Close", args: [], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] }
|
|
169
|
+
],
|
|
170
|
+
File,
|
|
171
|
+
{ "file": { kind: $.TypeKind.Pointer, elemType: "file" } }
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Stub file type for internal use
|
|
176
|
+
class file {
|
|
177
|
+
constructor() {}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Stub readdirMode type
|
|
181
|
+
type readdirMode = number
|
|
182
|
+
|
|
183
|
+
// File mode constants
|
|
184
|
+
export let ModeDir: fs.FileMode = fs.ModeDir
|
|
185
|
+
export let ModeAppend: fs.FileMode = fs.ModeAppend
|
|
186
|
+
export let ModeExclusive: fs.FileMode = fs.ModeExclusive
|
|
187
|
+
export let ModeTemporary: fs.FileMode = fs.ModeTemporary
|
|
188
|
+
export let ModeSymlink: fs.FileMode = fs.ModeSymlink
|
|
189
|
+
export let ModeDevice: fs.FileMode = fs.ModeDevice
|
|
190
|
+
export let ModeNamedPipe: fs.FileMode = fs.ModeNamedPipe
|
|
191
|
+
export let ModeSocket: fs.FileMode = fs.ModeSocket
|
|
192
|
+
export let ModeSetuid: fs.FileMode = fs.ModeSetuid
|
|
193
|
+
export let ModeSetgid: fs.FileMode = fs.ModeSetgid
|
|
194
|
+
export let ModeCharDevice: fs.FileMode = fs.ModeCharDevice
|
|
195
|
+
export let ModeSticky: fs.FileMode = fs.ModeSticky
|
|
196
|
+
export let ModeIrregular: fs.FileMode = fs.ModeIrregular
|
|
197
|
+
|
|
198
|
+
export let ModeType: fs.FileMode = fs.ModeType
|
|
199
|
+
export let ModePerm: fs.FileMode = fs.ModePerm
|
|
200
|
+
|
|
201
|
+
// SameFile reports whether fi1 and fi2 describe the same file.
|
|
202
|
+
export function SameFile(fi1: fs.FileInfo, fi2: fs.FileInfo): boolean {
|
|
203
|
+
// In JavaScript environment, always return false as we can't compare files
|
|
204
|
+
return false
|
|
205
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
|
|
3
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
4
|
+
|
|
5
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
6
|
+
|
|
7
|
+
import * as time from "@goscript/time/index.js"
|
|
8
|
+
|
|
9
|
+
class fileStat {
|
|
10
|
+
public get name(): string {
|
|
11
|
+
return this._fields.name.value
|
|
12
|
+
}
|
|
13
|
+
public set name(value: string) {
|
|
14
|
+
this._fields.name.value = value
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public get size(): number {
|
|
18
|
+
return this._fields.size.value
|
|
19
|
+
}
|
|
20
|
+
public set size(value: number) {
|
|
21
|
+
this._fields.size.value = value
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public get mode(): fs.FileMode {
|
|
25
|
+
return this._fields.mode.value
|
|
26
|
+
}
|
|
27
|
+
public set mode(value: fs.FileMode) {
|
|
28
|
+
this._fields.mode.value = value
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public get modTime(): time.Time {
|
|
32
|
+
return this._fields.modTime.value
|
|
33
|
+
}
|
|
34
|
+
public set modTime(value: time.Time) {
|
|
35
|
+
this._fields.modTime.value = value
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public get sys(): syscall.Stat_t {
|
|
39
|
+
return this._fields.sys.value
|
|
40
|
+
}
|
|
41
|
+
public set sys(value: syscall.Stat_t) {
|
|
42
|
+
this._fields.sys.value = value
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public _fields: {
|
|
46
|
+
name: $.VarRef<string>;
|
|
47
|
+
size: $.VarRef<number>;
|
|
48
|
+
mode: $.VarRef<fs.FileMode>;
|
|
49
|
+
modTime: $.VarRef<time.Time>;
|
|
50
|
+
sys: $.VarRef<syscall.Stat_t>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
constructor(init?: Partial<{modTime?: time.Time, mode?: fs.FileMode, name?: string, size?: number, sys?: syscall.Stat_t}>) {
|
|
54
|
+
this._fields = {
|
|
55
|
+
name: $.varRef(init?.name ?? ""),
|
|
56
|
+
size: $.varRef(init?.size ?? 0),
|
|
57
|
+
mode: $.varRef(init?.mode ?? 0),
|
|
58
|
+
modTime: $.varRef(init?.modTime?.clone() ?? time.Now()),
|
|
59
|
+
sys: $.varRef(init?.sys?.clone() ?? new syscall.Stat_t())
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public clone(): fileStat {
|
|
64
|
+
const cloned = new fileStat()
|
|
65
|
+
cloned._fields = {
|
|
66
|
+
name: $.varRef(this._fields.name.value),
|
|
67
|
+
size: $.varRef(this._fields.size.value),
|
|
68
|
+
mode: $.varRef(this._fields.mode.value),
|
|
69
|
+
modTime: $.varRef(this._fields.modTime.value?.clone() ?? null),
|
|
70
|
+
sys: $.varRef(this._fields.sys.value?.clone() ?? null)
|
|
71
|
+
}
|
|
72
|
+
return cloned
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public Name(): string {
|
|
76
|
+
const fs = this
|
|
77
|
+
return fs!.name
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public IsDir(): boolean {
|
|
81
|
+
const fileStat = this
|
|
82
|
+
return (fileStat!.Mode() & fs.ModeDir) !== 0
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public Size(): number {
|
|
86
|
+
const fs = this
|
|
87
|
+
return fs!.size
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public Mode(): fs.FileMode {
|
|
91
|
+
const fileStat = this
|
|
92
|
+
return fileStat!.mode
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public ModTime(): time.Time {
|
|
96
|
+
const fs = this
|
|
97
|
+
return fs!.modTime
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public Sys(): null | any {
|
|
101
|
+
const fs = this
|
|
102
|
+
return fs!.sys
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Register this type with the runtime type system
|
|
106
|
+
static __typeInfo = $.registerStructType(
|
|
107
|
+
'fileStat',
|
|
108
|
+
new fileStat(),
|
|
109
|
+
[{ name: "Name", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "string" } }] }, { name: "IsDir", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "boolean" } }] }, { name: "Size", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "number" } }] }, { name: "Mode", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "number" } }] }, { name: "ModTime", args: [], returns: [{ type: "Time" }] }, { name: "Sys", args: [], returns: [{ type: { kind: $.TypeKind.Interface, methods: [] } }] }],
|
|
110
|
+
fileStat,
|
|
111
|
+
{"name": { kind: $.TypeKind.Basic, name: "string" }, "size": { kind: $.TypeKind.Basic, name: "number" }, "mode": { kind: $.TypeKind.Basic, name: "number" }, "modTime": "Time", "sys": "Stat_t"}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function sameFile(fs1: fileStat | null, fs2: fileStat | null): boolean {
|
|
116
|
+
return fs1!.sys.Dev == fs2!.sys.Dev && fs1!.sys.Ino == fs2!.sys.Ino
|
|
117
|
+
}
|
|
118
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { NewSyscallError } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as io from "@goscript/io/index.js"
|
|
5
|
+
|
|
6
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
7
|
+
|
|
8
|
+
// wrapSyscallError takes an error and a syscall name. If the error is
|
|
9
|
+
// a syscall.Errno, it wraps it in an os.SyscallError using the syscall name.
|
|
10
|
+
export function wrapSyscallError(name: string, err: $.GoError): $.GoError {
|
|
11
|
+
{
|
|
12
|
+
let { ok: ok } = $.typeAssert<syscall.Errno>(err, 'syscall.Errno')
|
|
13
|
+
if (ok) {
|
|
14
|
+
err = NewSyscallError(name, err)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return err
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// tryLimitedReader tries to assert the io.Reader to io.LimitedReader, it returns the io.LimitedReader,
|
|
21
|
+
// the underlying io.Reader and the remaining amount of bytes if the assertion succeeds,
|
|
22
|
+
// otherwise it just returns the original io.Reader and the theoretical unlimited remaining amount of bytes.
|
|
23
|
+
export function tryLimitedReader(r: io.Reader): [io.LimitedReader | null, io.Reader, number] {
|
|
24
|
+
// by default, copy until EOF
|
|
25
|
+
let remain: number = Number.MAX_SAFE_INTEGER - 1
|
|
26
|
+
|
|
27
|
+
let { value: lr, ok: ok } = $.typeAssert<io.LimitedReader | null>(r, {kind: $.TypeKind.Pointer, elemType: 'io.LimitedReader'})
|
|
28
|
+
if (!ok) {
|
|
29
|
+
return [null, r, remain]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
remain = lr!.N
|
|
33
|
+
return [lr, lr!.R, remain]
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# GoScript Reflect Package Implementation Analysis
|
|
2
|
+
|
|
3
|
+
This document analyzes the implementation status of the `gs/reflect/` package compared to the Go standard library `reflect` package as specified in `godoc.txt`.
|
|
4
|
+
|
|
5
|
+
## Constants
|
|
6
|
+
|
|
7
|
+
### `const Ptr = Pointer`
|
|
8
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
9
|
+
- **Location**: `type.ts`
|
|
10
|
+
- **Notes**: Exported in `index.ts` as alias
|
|
11
|
+
|
|
12
|
+
## Functions
|
|
13
|
+
|
|
14
|
+
### `func Copy(dst, src Value) int`
|
|
15
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
16
|
+
- **Location**: `value.ts:63-78`
|
|
17
|
+
- **Notes**: Correctly implemented with proper array extraction and copying logic
|
|
18
|
+
|
|
19
|
+
### `func DeepEqual(x, y any) bool`
|
|
20
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
21
|
+
- **Location**: `deepequal.ts:333-345`
|
|
22
|
+
- **Notes**: Full implementation with cycle detection, supports all Go types. Helper function `deepValueEqual` handles the recursive comparison logic.
|
|
23
|
+
|
|
24
|
+
### `func Select(cases []SelectCase) (chosen int, recv Value, recvOK bool)`
|
|
25
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
26
|
+
- **Location**: `value.ts:184-227`
|
|
27
|
+
- **Notes**: Full implementation with support for channel receive operations, default cases, and proper value extraction from channels with queued values
|
|
28
|
+
|
|
29
|
+
### `func Swapper(slice any) func(i, j int)`
|
|
30
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
31
|
+
- **Location**: `swapper.ts:5-46`
|
|
32
|
+
- **Notes**: Correctly implemented with support for regular arrays and GoScript slice objects
|
|
33
|
+
|
|
34
|
+
## Types
|
|
35
|
+
|
|
36
|
+
### `type ChanDir int`
|
|
37
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
38
|
+
- **Location**: `types.ts:35-50`
|
|
39
|
+
- **Notes**: Class implementation with proper constants
|
|
40
|
+
|
|
41
|
+
#### Constants: `const RecvDir ChanDir = 1 << iota ...`
|
|
42
|
+
- **RecvDir, SendDir, BothDir**: ✅ **IMPLEMENTED** in `types.ts:51-53`
|
|
43
|
+
|
|
44
|
+
### `type Kind uint`
|
|
45
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
46
|
+
- **Location**: `type.ts:69-100`
|
|
47
|
+
- **Notes**: Class implementation with `String()` method
|
|
48
|
+
|
|
49
|
+
#### Kind Constants: `const Invalid Kind = iota ...`
|
|
50
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
51
|
+
- **Location**: `type.ts:103-127`
|
|
52
|
+
- **Notes**: All 27 kind constants properly defined (Invalid through UnsafePointer)
|
|
53
|
+
|
|
54
|
+
### `type MapIter struct{ ... }`
|
|
55
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
56
|
+
- **Location**: `types.ts:139-148` and `map.ts:35-64`
|
|
57
|
+
- **Notes**: Interface defined in types.ts, concrete implementation in map.ts
|
|
58
|
+
|
|
59
|
+
### `type Method struct{ ... }`
|
|
60
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
61
|
+
- **Location**: `types.ts:95-100`
|
|
62
|
+
- **Notes**: Interface definition only, methods not implemented
|
|
63
|
+
|
|
64
|
+
### `type SelectCase struct{ ... }`
|
|
65
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
66
|
+
- **Location**: `types.ts:116-120`
|
|
67
|
+
- **Notes**: Type defined and used by Select function implementation
|
|
68
|
+
|
|
69
|
+
### `type SelectDir int`
|
|
70
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
71
|
+
- **Location**: `types.ts:122-131`
|
|
72
|
+
- **Notes**: Class with constants SelectSend, SelectRecv, SelectDefault
|
|
73
|
+
|
|
74
|
+
### `type SliceHeader struct{ ... }`
|
|
75
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
76
|
+
- **Location**: `types.ts:133-137`
|
|
77
|
+
- **Notes**: Interface definition
|
|
78
|
+
|
|
79
|
+
### `type StringHeader struct{ ... }`
|
|
80
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
81
|
+
- **Location**: `types.ts:139-142`
|
|
82
|
+
- **Notes**: Interface definition
|
|
83
|
+
|
|
84
|
+
### `type StructField struct{ ... }`
|
|
85
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
86
|
+
- **Location**: `types.ts:57-84`
|
|
87
|
+
- **Notes**: Full class implementation with clone method
|
|
88
|
+
|
|
89
|
+
#### `func VisibleFields(t Type) []StructField`
|
|
90
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
91
|
+
- **Location**: `visiblefields.ts:14-42`
|
|
92
|
+
- **Notes**: Complete implementation with proper field walking logic
|
|
93
|
+
|
|
94
|
+
### `type StructTag string`
|
|
95
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
96
|
+
- **Location**: `types.ts:86-104`
|
|
97
|
+
- **Notes**: Class with `Get(key string) string` method for tag parsing
|
|
98
|
+
|
|
99
|
+
### `type Type interface{ ... }`
|
|
100
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
101
|
+
- **Location**: `type.ts:128-151`
|
|
102
|
+
- **Notes**: Interface definition with all required methods
|
|
103
|
+
|
|
104
|
+
#### Type Constructor Functions:
|
|
105
|
+
|
|
106
|
+
##### `func ArrayOf(length int, elem Type) Type`
|
|
107
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
108
|
+
- **Location**: `type.ts:764`
|
|
109
|
+
- **Notes**: Uses internal `ArrayType` class
|
|
110
|
+
|
|
111
|
+
##### `func ChanOf(dir ChanDir, t Type) Type`
|
|
112
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
113
|
+
- **Location**: `type.ts:838-842` and `type.ts:593-644`
|
|
114
|
+
- **Notes**: Uses internal `ChannelType` class with proper direction formatting (chan T, <-chan T, chan<- T)
|
|
115
|
+
|
|
116
|
+
##### `func FuncOf(in, out []Type, variadic bool) Type`
|
|
117
|
+
- **Status**: ❌ **NOT IMPLEMENTED**
|
|
118
|
+
- **Notes**: No function type constructor found
|
|
119
|
+
|
|
120
|
+
##### `func MapOf(key, elem Type) Type`
|
|
121
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
122
|
+
- **Location**: `type.ts:774` and `map.ts:7-32`
|
|
123
|
+
- **Notes**: Multiple implementations, uses internal `MapType` class
|
|
124
|
+
|
|
125
|
+
##### `func PointerTo(t Type) Type`
|
|
126
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
127
|
+
- **Location**: `type.ts:768`
|
|
128
|
+
- **Notes**: Uses internal `PointerType` class
|
|
129
|
+
|
|
130
|
+
##### `func PtrTo(t Type) Type`
|
|
131
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
132
|
+
- **Location**: `type.ts:772`
|
|
133
|
+
- **Notes**: Alias for PointerTo
|
|
134
|
+
|
|
135
|
+
##### `func SliceOf(t Type) Type`
|
|
136
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
137
|
+
- **Location**: `type.ts:766`
|
|
138
|
+
- **Notes**: Uses internal `SliceType` class
|
|
139
|
+
|
|
140
|
+
##### `func StructOf(fields []StructField) Type`
|
|
141
|
+
- **Status**: ❌ **NOT IMPLEMENTED**
|
|
142
|
+
- **Notes**: No struct type constructor found
|
|
143
|
+
|
|
144
|
+
##### `func TypeFor[T any]() Type`
|
|
145
|
+
- **Status**: ❌ **NOT IMPLEMENTED**
|
|
146
|
+
- **Notes**: Generic type function not implemented (TypeScript limitation)
|
|
147
|
+
|
|
148
|
+
##### `func TypeOf(i any) Type`
|
|
149
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
150
|
+
- **Location**: `type.ts:758`
|
|
151
|
+
- **Notes**: Comprehensive implementation with support for all JavaScript and GoScript types
|
|
152
|
+
|
|
153
|
+
### `type Value struct{ ... }`
|
|
154
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
155
|
+
- **Location**: `type.ts:153-351`
|
|
156
|
+
- **Notes**: Comprehensive class implementation with most methods including Send for channel operations
|
|
157
|
+
|
|
158
|
+
#### Value Constructor Functions:
|
|
159
|
+
|
|
160
|
+
##### `func Append(s Value, x ...Value) Value`
|
|
161
|
+
- **Status**: ⚠️ **PARTIALLY IMPLEMENTED**
|
|
162
|
+
- **Location**: `value.ts:145-162`
|
|
163
|
+
- **Notes**: Only handles single value append, not variadic
|
|
164
|
+
|
|
165
|
+
##### `func AppendSlice(s, t Value) Value`
|
|
166
|
+
- **Status**: ❌ **NOT IMPLEMENTED**
|
|
167
|
+
- **Notes**: No implementation found
|
|
168
|
+
|
|
169
|
+
##### `func Indirect(v Value) Value`
|
|
170
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
171
|
+
- **Location**: `value.ts:96-108`
|
|
172
|
+
- **Notes**: Correctly handles pointer dereferencing
|
|
173
|
+
|
|
174
|
+
##### `func MakeChan(typ Type, buffer int) Value`
|
|
175
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
176
|
+
- **Location**: `value.ts:164-182`
|
|
177
|
+
- **Notes**: Creates channels using builtin.makeChannel with proper element type zero values
|
|
178
|
+
|
|
179
|
+
##### `func MakeFunc(typ Type, fn func(args []Value) (results []Value)) Value`
|
|
180
|
+
- **Status**: ⚠️ **STUBBED**
|
|
181
|
+
- **Location**: `makefunc.ts:83-107`
|
|
182
|
+
- **Notes**: Function exists but returns empty Value, complex stub implementation
|
|
183
|
+
|
|
184
|
+
##### `func MakeMap(typ Type) Value`
|
|
185
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
186
|
+
- **Location**: `value.ts:125-133` and `map.ts:67-71`
|
|
187
|
+
- **Notes**: Multiple implementations, creates JavaScript Map
|
|
188
|
+
|
|
189
|
+
##### `func MakeMapWithSize(typ Type, n int) Value`
|
|
190
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
191
|
+
- **Location**: `map.ts:73-76`
|
|
192
|
+
- **Notes**: Ignores size parameter (JavaScript Map limitation)
|
|
193
|
+
|
|
194
|
+
##### `func MakeSlice(typ Type, len, cap int) Value`
|
|
195
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
196
|
+
- **Location**: `value.ts:111-124`
|
|
197
|
+
- **Notes**: Creates array with proper length and zero values
|
|
198
|
+
|
|
199
|
+
##### `func New(typ Type) Value`
|
|
200
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
201
|
+
- **Location**: `value.ts:110-118`
|
|
202
|
+
- **Notes**: Returns pointer to zero value
|
|
203
|
+
|
|
204
|
+
##### `func NewAt(typ Type, p unsafe.Pointer) Value`
|
|
205
|
+
- **Status**: ❌ **NOT IMPLEMENTED**
|
|
206
|
+
- **Notes**: No unsafe pointer implementation
|
|
207
|
+
|
|
208
|
+
##### `func SliceAt(typ Type, p unsafe.Pointer, n int) Value`
|
|
209
|
+
- **Status**: ❌ **NOT IMPLEMENTED**
|
|
210
|
+
- **Notes**: No unsafe pointer implementation
|
|
211
|
+
|
|
212
|
+
##### `func ValueOf(i any) Value`
|
|
213
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
214
|
+
- **Location**: `type.ts:760`
|
|
215
|
+
- **Notes**: Creates Value from any JavaScript/GoScript value
|
|
216
|
+
|
|
217
|
+
##### `func Zero(typ Type) Value`
|
|
218
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
219
|
+
- **Location**: `value.ts:20-50`
|
|
220
|
+
- **Notes**: Returns appropriate zero values for all basic types
|
|
221
|
+
|
|
222
|
+
### `type ValueError struct{ ... }`
|
|
223
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
224
|
+
- **Location**: `types.ts:178-208`
|
|
225
|
+
- **Notes**: Extends Error class with Kind and Method fields
|
|
226
|
+
|
|
227
|
+
## Channel Operations
|
|
228
|
+
|
|
229
|
+
### Channel Type System
|
|
230
|
+
- **Status**: ✅ **IMPLEMENTED**
|
|
231
|
+
- **Location**: `type.ts:593-644`
|
|
232
|
+
- **Notes**: `ChannelType` class supports all channel directions (BothDir, SendDir, RecvDir) with proper string formatting
|
|
233
|
+
|
|
234
|
+
### Channel Creation and Operations
|
|
235
|
+
- **`MakeChan`**: ✅ **IMPLEMENTED** - Creates channels with proper buffering support
|
|
236
|
+
- **`ChanOf`**: ✅ **IMPLEMENTED** - Creates channel types with direction support
|
|
237
|
+
- **`Value.Send`**: ✅ **IMPLEMENTED** - Sends values to channels using internal queue mechanism
|
|
238
|
+
- **`Select`**: ✅ **IMPLEMENTED** - Handles channel selection with receive operations and default cases
|
|
239
|
+
|
|
240
|
+
### Channel Integration
|
|
241
|
+
- **Status**: ✅ **FULLY INTEGRATED**
|
|
242
|
+
- **Location**: `index.ts` exports all channel-related functions
|
|
243
|
+
- **Notes**: Channel operations are fully integrated into the reflect package and pass compliance tests
|
|
244
|
+
|
|
245
|
+
## Missing/Stubbed Implementations
|
|
246
|
+
|
|
247
|
+
### Major Missing Features:
|
|
248
|
+
1. **Unsafe pointer operations**: `NewAt`, `SliceAt`
|
|
249
|
+
2. **Function type construction**: `FuncOf`
|
|
250
|
+
3. **Struct type construction**: `StructOf`
|
|
251
|
+
4. **Generic type support**: `TypeFor[T any]()`
|
|
252
|
+
5. **Variadic append**: `AppendSlice`, variadic `Append`
|
|
253
|
+
|
|
254
|
+
### Stubbed Files:
|
|
255
|
+
1. **`badlinkname.ts`**: Contains stub implementations for Go runtime linkname functions
|
|
256
|
+
2. **`abi.ts`**: Contains stub implementations for ABI-related functionality
|
|
257
|
+
3. **`makefunc.ts`**: Partially implemented but returns empty values
|
|
258
|
+
|
|
259
|
+
### Internal Implementation Files:
|
|
260
|
+
1. **`iter.ts`**: Contains range iteration support for numeric types
|
|
261
|
+
2. **Test file**: `function-types.test.ts` shows good test coverage for function type detection
|
|
262
|
+
|
|
263
|
+
## Known Issues
|
|
264
|
+
|
|
265
|
+
### Go Reflect Package Bug (from godoc.txt)
|
|
266
|
+
The official Go reflect package has a known bug where `FieldByName` and related functions consider struct field names equal if the names are equal, even if they are unexported names from different packages. This affects the behavior when a struct contains multiple fields with the same name from different embedded packages. This issue is documented in https://golang.org/issue/4876.
|
|
267
|
+
|
|
268
|
+
**GoScript Implementation**: Since the current implementation has limited struct field operations, this bug may not be present, but should be considered if implementing more comprehensive struct field access methods.
|
|
269
|
+
|
|
270
|
+
## Overall Assessment
|
|
271
|
+
|
|
272
|
+
The GoScript reflect package has a **comprehensive foundation** with most core functionality implemented:
|
|
273
|
+
|
|
274
|
+
- ✅ **Strong**: Type system, Value operations, basic constructors, deep equality, **channel operations**
|
|
275
|
+
- ⚠️ **Partial**: Function reflection, method operations
|
|
276
|
+
- ❌ **Missing**: Unsafe operations, some type constructors
|
|
277
|
+
|
|
278
|
+
The implementation appears designed for JavaScript/TypeScript interoperability rather than full Go runtime compatibility, which explains the absence of unsafe operations and some low-level features. **Channel operations are now fully implemented and tested**, making this a robust reflect package for GoScript's use cases.
|