├── .gitignore ├── LICENSE ├── README.md ├── TrickyGo.md ├── _example ├── arith.gomacro ├── bag.go.easyjson ├── bag.go.save ├── channel.gomacro ├── collatz.gomacro ├── collatz.igo ├── collatz.py ├── earljwagner1 │ └── earljwagner1.go ├── earljwagner2 │ ├── cube.go │ └── earljwagner2.go ├── embedded_field.go ├── embedded_field.gomacro ├── fibonacci.gomacro ├── fibonacci.igo ├── fibonacci.py ├── for_nested.go ├── for_range.gomacro ├── glycerine1 │ └── main.go ├── interface.go ├── interrupt │ └── interrupt_interpreter.go ├── main.go ├── make_fibonacci.gomacro └── make_fibonacci.gomacro_output ├── _experiments ├── bench_test.go ├── bytecode_interfaces │ └── bytecode_interfaces.go ├── bytecode_values │ └── bytecode_values.go ├── closure_interfaces │ └── closure_interfaces.go ├── closure_ints │ └── closure_ints.go ├── closure_maps │ └── closure_maps.go ├── closure_values │ └── closure_values.go ├── dummy.go ├── issue122.gomacro ├── stmt_0-3_test.go ├── stmt_4-5_test.go ├── stmt_6_test.go ├── stmt_7_test.go ├── stmt_test.go └── zero │ ├── function_zero.go │ └── z_test.go ├── all_test.go ├── ast2 ├── ast.go ├── ast_node.go ├── ast_slice.go ├── error.go ├── test │ ├── empty.go │ ├── z_test.go │ └── z_test_data_2.txt ├── tonodes.go ├── unwrap.go ├── wrap.go └── x_package.go ├── atomic └── spinlock.go ├── base ├── constant.go ├── dep │ ├── api.go │ ├── api_internal.go │ ├── decl.go │ ├── graph.go │ ├── scope.go │ ├── sorter.go │ ├── util.go │ ├── x_package.go │ ├── z_test.go │ ├── z_test_data_1.txt │ ├── z_test_data_2.txt │ └── z_test_data_3.txt ├── genimport │ ├── analize_wrappers.go │ ├── genimport.go │ ├── gogenerate.go │ ├── importer.go │ ├── importer_load.go │ ├── plugin.go │ ├── proxy.go │ ├── scanner.go │ ├── types.go │ └── x_package.go ├── global.go ├── inspect │ ├── inspect.go │ └── x_package.go ├── output │ ├── output.go │ ├── write_decl.go │ └── x_package.go ├── paths │ ├── paths.go │ └── x_package.go ├── quasiquote.go ├── read.go ├── readline.go ├── reflect │ ├── reflect.go │ └── x_package.go ├── signal.go ├── strings │ ├── string.go │ └── x_package.go ├── type.go ├── untyped │ ├── global.go │ ├── lit.go │ ├── val.go │ └── x_package.go └── x_package.go ├── bench_sort_test.go ├── bench_test.go ├── classic ├── README.md ├── assignment.go ├── binaryexpr.go ├── builtin.go ├── call.go ├── cmd.go ├── declaration.go ├── env.go ├── env_multithread.go ├── env_singlethread.go ├── eval.go ├── expr.go ├── file.go ├── for.go ├── function.go ├── global.go ├── identifier.go ├── import.go ├── inspect.go ├── interface.go ├── interpreter.go ├── literal.go ├── macroexpand.go ├── method.go ├── number.go ├── output.go ├── quasiquote.go ├── select.go ├── statement.go ├── switch.go ├── switch_type.go ├── type.go ├── unaryexpr.go └── x_package.go ├── cmd ├── cmd.go └── x_package.go ├── cmd_classic └── main.go ├── doc ├── code_generation.pdf ├── features-and-limitations.md ├── generics-c++.md ├── generics-cti.md └── quasiquote.md ├── fast ├── README.md ├── address.go ├── address.gomacro ├── assignment.go ├── attic │ ├── call0ret1_compact.go │ ├── call1ret1_compact.go │ ├── call2ret1.gomacro │ └── callnret0_compact.go ├── binary.go ├── binary_eqlneq.go ├── binary_eqlneq.gomacro ├── binary_ops.go ├── binary_ops.gomacro ├── binary_relops.go ├── binary_relops.gomacro ├── binary_shifts.go ├── binary_shifts.gomacro ├── builtin.go ├── call.go ├── call0ret1.go ├── call0ret1.gomacro ├── call1ret1.go ├── call1ret1.gomacro ├── call2ret1.go ├── call_ellipsis.go ├── call_multivalue.go ├── call_variadic.go ├── callnret0.go ├── callnret0.gomacro ├── callnret1.go ├── callnret1.gomacro ├── channel.go ├── channel.gomacro ├── cmd.go ├── code.go ├── compile.go ├── compositelit.go ├── convert.go ├── debug.go ├── debug │ ├── api.go │ ├── backtrace.go │ ├── bind.go │ ├── cmd.go │ └── debugger.go ├── declaration.go ├── expr.go ├── expr1.go ├── func0ret0.go ├── func0ret1.go ├── func0ret1.gomacro ├── func1ret0.go ├── func1ret0.gomacro ├── func1ret1.go ├── func1ret1.gomacro ├── func2ret0.go ├── func2ret0.gomacro ├── function.go ├── generic_func.go ├── generic_infer.go ├── generic_maker.go ├── generic_type.go ├── global.go ├── identifier.go ├── import.go ├── index.go ├── index.gomacro ├── inspect.go ├── interface.go ├── interpreter.go ├── literal.go ├── macroexpand.go ├── output.go ├── place_get.go ├── place_ops.go ├── place_ops.gomacro ├── place_set.go ├── place_set.gomacro ├── place_set_value.go ├── place_shifts.go ├── place_shifts.gomacro ├── quasiquote.go ├── range.go ├── range_map.go ├── repl.go ├── select.go ├── selector.go ├── slice.go ├── statement.go ├── switch.go ├── switch2.go ├── switch2.gomacro ├── switch_type.go ├── type.go ├── unary.go ├── unary_ops.go ├── util.go ├── var_ops.go ├── var_ops.gomacro ├── var_set.go ├── var_set.gomacro ├── var_set_value.go ├── var_shifts.go ├── var_shifts.gomacro └── x_package.go ├── gls ├── LICENSE ├── README.md ├── api_gc.go ├── api_gccgo.go ├── id_386.s ├── id_amd64.s ├── id_arm.s ├── id_arm64.s ├── id_mips.s ├── id_mips64.s ├── id_mips64le.s ├── id_mipsle.s ├── id_ppc64.s ├── id_ppc64le.s ├── id_riscv64.s ├── id_s390x.s ├── id_wasm.s └── z_test.go ├── go.mod ├── go.sum ├── go ├── etoken │ ├── LICENSE │ ├── fileset.go │ ├── generics.go │ ├── token.go │ └── x_package.go ├── parser │ ├── LICENSE │ ├── generics.go │ ├── global.go │ ├── parser.diffs │ ├── parser.go │ ├── quote.go │ └── x_package.go ├── printer │ ├── LICENSE │ ├── example_test.go │ ├── nodes.go │ ├── performance_test.go │ ├── printer.go │ ├── printer_test.go │ ├── testdata │ │ ├── comments.golden │ │ ├── comments.input │ │ ├── comments.x │ │ ├── comments2.golden │ │ ├── comments2.input │ │ ├── declarations.golden │ │ ├── declarations.input │ │ ├── empty.golden │ │ ├── empty.input │ │ ├── expressions.golden │ │ ├── expressions.input │ │ ├── expressions.raw │ │ ├── linebreaks.golden │ │ ├── linebreaks.input │ │ ├── parser.go │ │ ├── slow.golden │ │ ├── slow.input │ │ ├── statements.golden │ │ └── statements.input │ └── x_package.go ├── scanner │ ├── LICENSE │ ├── errors.go │ ├── scanner.go │ ├── scanner_1.10_gomacro.diff │ ├── scanner_1.13_gomacro.diff │ ├── scanner_test.go │ └── x_package.go ├── types │ ├── LICENSE │ ├── api.go │ ├── api_test.go.off │ ├── assignments.go │ ├── builtins.go │ ├── builtins_test.go.off │ ├── call.go │ ├── check.go │ ├── check_test.go.off │ ├── conversions.go │ ├── converter.go │ ├── converter_test.go │ ├── cti_method.go │ ├── cti_method_test.go │ ├── decl.go │ ├── errors.go │ ├── eval.go │ ├── eval_test.go.off │ ├── example_test.go │ ├── expr.go │ ├── exprstring.go │ ├── exprstring_test.go.off │ ├── gotype.go │ ├── hilbert_test.go.off │ ├── initorder.go │ ├── interfaces.go │ ├── issues_test.go.off │ ├── labels.go │ ├── lookup.go │ ├── methodset.go │ ├── object.go │ ├── object_test.go │ ├── objset.go │ ├── operand.go │ ├── package.go │ ├── predicates.go │ ├── resolver.go │ ├── resolver_test.go │ ├── return.go │ ├── scope.go │ ├── selection.go │ ├── self_test.go.off │ ├── sizes.go │ ├── sizes_test.go │ ├── stdlib_test.go.off │ ├── stmt.go │ ├── testdata │ │ ├── blank.src │ │ ├── builtins.src │ │ ├── const0.src │ │ ├── const1.src │ │ ├── constdecl.src │ │ ├── conversions.src │ │ ├── conversions2.src │ │ ├── cycles.src │ │ ├── cycles1.src │ │ ├── cycles2.src │ │ ├── cycles3.src │ │ ├── cycles4.src │ │ ├── cycles5.src │ │ ├── decls0.src │ │ ├── decls1.src │ │ ├── decls2a.src │ │ ├── decls2b.src │ │ ├── decls3.src │ │ ├── decls4.src │ │ ├── decls5.src │ │ ├── errors.src │ │ ├── expr0.src │ │ ├── expr1.src │ │ ├── expr2.src │ │ ├── expr3.src │ │ ├── gotos.src │ │ ├── importC.src │ │ ├── importdecl0a.src │ │ ├── importdecl0b.src │ │ ├── importdecl1a.src │ │ ├── importdecl1b.src │ │ ├── init0.src │ │ ├── init1.src │ │ ├── init2.src │ │ ├── issue23203a.src │ │ ├── issue23203b.src │ │ ├── issue25008a.src │ │ ├── issue25008b.src │ │ ├── issue26390.src │ │ ├── issue28251.src │ │ ├── issues.src │ │ ├── labels.src │ │ ├── methodsets.src │ │ ├── shifts.src │ │ ├── stmt0.src │ │ ├── stmt1.src │ │ └── vardecl.src │ ├── token_test.go │ ├── type.go │ ├── typestring.go │ ├── typestring_test.go.off │ ├── typexpr.go │ ├── universe.go │ └── x_package.go └── typeutil │ ├── LICENSE │ ├── README.md │ ├── map.go │ ├── predicates.go │ ├── string.go │ ├── x_package.go │ └── z_test.go ├── imports ├── a_package.go ├── archive_tar.go ├── archive_zip.go ├── bufio.go ├── bytes.go ├── compress_bzip2.go ├── compress_flate.go ├── compress_gzip.go ├── compress_lzw.go ├── compress_zlib.go ├── container_heap.go ├── container_list.go ├── container_ring.go ├── context.go ├── crypto.go ├── crypto_aes.go ├── crypto_cipher.go ├── crypto_des.go ├── crypto_dsa.go ├── crypto_ecdsa.go ├── crypto_ed25519.go ├── crypto_elliptic.go ├── crypto_hmac.go ├── crypto_md5.go ├── crypto_rand.go ├── crypto_rc4.go ├── crypto_rsa.go ├── crypto_sha1.go ├── crypto_sha256.go ├── crypto_sha512.go ├── crypto_subtle.go ├── crypto_tls.go ├── crypto_x509.go ├── crypto_x509_pkix.go ├── database_sql.go ├── database_sql_driver.go ├── debug_buildinfo.go ├── debug_dwarf.go ├── debug_elf.go ├── debug_gosym.go ├── debug_macho.go ├── debug_pe.go ├── debug_plan9obj.go ├── embed.go ├── encoding.go ├── encoding_ascii85.go ├── encoding_asn1.go ├── encoding_base32.go ├── encoding_base64.go ├── encoding_binary.go ├── encoding_csv.go ├── encoding_gob.go ├── encoding_hex.go ├── encoding_json.go ├── encoding_pem.go ├── encoding_xml.go ├── errors.go ├── expvar.go ├── flag.go ├── fmt.go ├── genimports.gomacro ├── genimports.sh ├── go_ast.go ├── go_build.go ├── go_build_constraint.go ├── go_constant.go ├── go_doc.go ├── go_format.go ├── go_importer.go ├── go_parser.go ├── go_printer.go ├── go_scanner.go ├── go_token.go ├── go_types.go ├── hash.go ├── hash_adler32.go ├── hash_crc32.go ├── hash_crc64.go ├── hash_fnv.go ├── hash_maphash.go ├── html.go ├── html_template.go ├── image.go ├── image_color.go ├── image_color_palette.go ├── image_draw.go ├── image_gif.go ├── image_jpeg.go ├── image_png.go ├── index_suffixarray.go ├── io.go ├── io_fs.go ├── io_ioutil.go ├── log.go ├── log_syslog.go ├── math.go ├── math_big.go ├── math_bits.go ├── math_cmplx.go ├── math_rand.go ├── mime.go ├── mime_multipart.go ├── mime_quotedprintable.go ├── net.go ├── net_http.go ├── net_http_cgi.go ├── net_http_cookiejar.go ├── net_http_fcgi.go ├── net_http_httptest.go ├── net_http_httptrace.go ├── net_http_httputil.go ├── net_http_pprof.go ├── net_mail.go ├── net_netip.go ├── net_rpc.go ├── net_rpc_jsonrpc.go ├── net_smtp.go ├── net_textproto.go ├── net_url.go ├── os.go ├── os_exec.go ├── os_signal.go ├── os_user.go ├── path.go ├── path_filepath.go ├── plugin.go ├── reflect.go ├── regexp.go ├── regexp_syntax.go ├── runtime.go ├── runtime_debug.go ├── runtime_metrics.go ├── runtime_pprof.go ├── runtime_trace.go ├── sort.go ├── strconv.go ├── strings.go ├── sync.go ├── sync_atomic.go ├── syscall │ ├── a_package.go │ ├── gccgo_syscall_linux_386.go │ ├── gccgo_syscall_linux_amd64.go │ ├── gccgo_syscall_linux_arm64.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_windows_386.go │ └── syscall_windows_amd64.go ├── testing.go ├── testing_fstest.go ├── testing_iotest.go ├── testing_quick.go ├── text_scanner.go ├── text_tabwriter.go ├── text_template.go ├── text_template_parse.go ├── thirdparty │ ├── README.md │ ├── a_package.go │ ├── github_com_mattn_go_runewidth_.go │ ├── github_com_peterh_liner_.go │ ├── golang_org_x_tools_go_gcexportdata_.go │ └── golang_org_x_tools_go_packages_.go ├── time.go ├── unicode.go ├── unicode_utf16.go ├── unicode_utf8.go ├── unsafe.go └── util │ └── util.go ├── issue122_test.go ├── main.go └── xreflect ├── README.md ├── api.go ├── composite.go ├── cti_basic_method.go ├── cti_basic_method.gomacro ├── cti_method.go ├── debug.go ├── fromreflect.go ├── function.go ├── gensym.go ├── global.go ├── importer.go ├── init.go ├── interface.go ├── lookup.go ├── method.go ├── named.go ├── package.go ├── struct.go ├── type.go ├── universe.go ├── util.go ├── value.go ├── wrap.go ├── x_package.go └── z_test.go /.gitignore: -------------------------------------------------------------------------------- 1 | /gomacro 2 | /gomacro.debug 3 | a.out 4 | *~ 5 | *.o 6 | *.exe 7 | *.test 8 | *.dump 9 | _gen_*.s 10 | /_example/example 11 | /_example/interrupt/interrupt 12 | /jit/**/test 13 | /jit/**/_template/_template 14 | /jit/arm64/_template/_bitwise_immediate/_bitwise_immediate 15 | /jit/arm64/_template/_go/_go 16 | -------------------------------------------------------------------------------- /TrickyGo.md: -------------------------------------------------------------------------------- 1 | A collection of tricky go code 2 | 3 | ``` 4 | // change the meaning of true 5 | const true = false 6 | println(true) 7 | ``` 8 | 9 | ``` 10 | // change the meaning of uint 11 | type uint int 12 | println(uint(1)) 13 | ``` 14 | 15 | ``` 16 | // change the meaning of uint (again) 17 | func uint(x int) int { return x + 7 } 18 | println(uint(1)) 19 | ``` 20 | 21 | ``` 22 | // nil interface values don't implement interfaces 23 | var x error 24 | y := x.(error) // panic! 25 | ``` 26 | 27 | ``` 28 | // except that nil interface{} implements interface{} 29 | var x interface{} 30 | y := x.(interface{}) // works 31 | ``` 32 | 33 | ``` 34 | import "os" 35 | func getGoPath() string { 36 | dir := os.Getenv("GOPATH") 37 | if len(dir) == 0 { 38 | dir := os.Getenv("HOME") // shadows outer "dir", does NOT modify it 39 | if len(dir) == 0 { 40 | panic("cannot determine go source directory: both $GOPATH and $HOME are unset or empty") 41 | } 42 | dir += "/go" 43 | } 44 | return dir // inner "dir" is not seen -> always returns os.Getenv("GOPATH") 45 | } 46 | ``` 47 | -------------------------------------------------------------------------------- /_example/arith.gomacro: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gomacro 2 | 3 | func BenchmarkArith(n int) int { 4 | total := 0 5 | for i := 0; i < n; i++ { 6 | total += ((n*2+3)&4 | 5 ^ 6) / (n | 1) 7 | } 8 | return total 9 | } 10 | 11 | println(BenchmarkArith(1000000)) 12 | -------------------------------------------------------------------------------- /_example/bag.go.save: -------------------------------------------------------------------------------- 1 | // empty file. stops "go build" from complaining that 2 | // no buildable files are in the directory "examples" 3 | 4 | package main 5 | 6 | type Bag struct { 7 | B bool 8 | I int 9 | I8 int8 10 | I16 int16 11 | I32 int32 12 | I64 int64 13 | U uint 14 | U8 uint8 15 | U16 uint16 16 | U32 uint32 17 | U64 uint64 18 | // Uptr uintptr 19 | S string 20 | // E error 21 | Any interface{} 22 | Box *Box 23 | } 24 | 25 | type Box struct { 26 | B []bool 27 | I []int 28 | I8 []int8 29 | I16 []int16 30 | I32 []int32 31 | I64 []int64 32 | U []uint 33 | U8 []uint8 34 | U16 []uint16 35 | U32 []uint32 36 | U64 []uint64 37 | // Uptr []uintptr 38 | S []string 39 | // E []error 40 | Any []interface{} 41 | Bag []*Bag 42 | } 43 | 44 | func main() { 45 | } 46 | -------------------------------------------------------------------------------- /_example/channel.gomacro: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func channelTest() { 4 | j := 0; cx := make(chan int, 2) 5 | cs := (chan<- int)(cx); cr := (<-chan int)(cx) 6 | 7 | for i := 0; i < 1000000; i++ { cs <- i; j = <-cr } 8 | } 9 | -------------------------------------------------------------------------------- /_example/collatz.gomacro: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gomacro 2 | 3 | func collatz(n int) { 4 | for n > 1 { 5 | if n&1 != 0 { 6 | n = ((n * 3) + 1) / 2 7 | } else { 8 | n = n / 2 9 | } 10 | } 11 | } 12 | 13 | 14 | for i := 0; i < 100000; i++ { 15 | collatz(837799) 16 | } 17 | -------------------------------------------------------------------------------- /_example/collatz.igo: -------------------------------------------------------------------------------- 1 | 2 | collatz := func(n int) { for n > 1 { if n&1 != 0 { n = ((n * 3) + 1) / 2 } else { n = n / 2 } } } 3 | 4 | 5 | collatz_loop := func() { for i := 0; i < 100000; i++ { collatz(837799) } } 6 | 7 | collatz_loop() 8 | -------------------------------------------------------------------------------- /_example/collatz.py: -------------------------------------------------------------------------------- 1 | # collatz conjecture 2 | def collatz(n): 3 | while n > 1: 4 | if n&1 != 0: 5 | n = ((n * 3) + 1) / 2 6 | else: 7 | n = n / 2 8 | 9 | i = 0 10 | while i < 100000: 11 | collatz(837799) 12 | i+=1 13 | -------------------------------------------------------------------------------- /_example/earljwagner2/cube.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func Cube(x float64) float64 { 4 | return x*x*x - 1 // intentionally bugged 5 | } 6 | -------------------------------------------------------------------------------- /_example/embedded_field.gomacro: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gomacro 2 | 3 | type Pair struct{ a, b int } 4 | type Triple struct {Pair; c int} 5 | 6 | var t Triple 7 | 8 | println(t) 9 | -------------------------------------------------------------------------------- /_example/fibonacci.gomacro: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gomacro 2 | 3 | func fibonacci(n uint) uint { 4 | if n <= 2 { 5 | return 1 6 | } 7 | return fibonacci(n-1) + fibonacci(n-2) 8 | } 9 | 10 | println(fibonacci(40)) 11 | 12 | -------------------------------------------------------------------------------- /_example/fibonacci.igo: -------------------------------------------------------------------------------- 1 | fibonacci:=func(n int) int { return n }; 2 | 3 | fibonacci=func(n int) int { if n <= 2 { return 1 }; return fibonacci(n-1) + fibonacci(n-2) }; 4 | 5 | println(fibonacci(30)); 6 | 7 | -------------------------------------------------------------------------------- /_example/fibonacci.py: -------------------------------------------------------------------------------- 1 | def fib(n): 2 | if n <= 2: 3 | return 1 4 | return fib(n-1) + fib(n-2) 5 | 6 | print(fib(30)) 7 | -------------------------------------------------------------------------------- /_example/for_nested.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func for_nested(n1, n2, n3 int) int { 4 | x := 0 5 | for i := 0; i < n1; i++ { 6 | for k := 0; k < n2; k++ { 7 | for j := 0; j < n3; j++ { 8 | x++ 9 | } 10 | } 11 | } 12 | return x 13 | } 14 | 15 | func run_for_nested() { 16 | for_nested(2, 3, 4) 17 | } 18 | 19 | /* 20 | (func (n1, n2, n3 int) int { 21 | x := 0 22 | for i := 0; i < n1; i++ { 23 | for k := 0; k < n2; k++ { 24 | for j := 0; j < n3; j++ { 25 | x++ 26 | } 27 | } 28 | } 29 | return x 30 | })(2,3,5) 31 | */ 32 | -------------------------------------------------------------------------------- /_example/for_range.gomacro: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gomacro 2 | 3 | import "fmt" 4 | 5 | type Entry struct { 6 | Key int 7 | Value string 8 | } 9 | 10 | func mapEntries(m map[int]string) []Entry { 11 | entries := make([]Entry, len(m)) 12 | i := 0 13 | for k, v := range m { 14 | entries[i] = Entry{k, v} 15 | i++ 16 | } 17 | return entries 18 | } 19 | 20 | func printEntries(entries []Entry) { 21 | for i, e := range entries { 22 | fmt.Println(i, ":", e) 23 | } 24 | } 25 | 26 | m := map[int]string{1: "foo", 2: "bar", 3: "baz"} 27 | entries := mapEntries(m) 28 | printEntries(entries) 29 | 30 | -------------------------------------------------------------------------------- /_example/interface.go: -------------------------------------------------------------------------------- 1 | // #!/usr/bin/env gomacro 2 | 3 | package main 4 | 5 | import "fmt" 6 | 7 | type Person struct { 8 | Name, Surname string 9 | } 10 | 11 | type Driver struct { 12 | CanDrive []string 13 | Person 14 | } 15 | 16 | func (p Person) String() string { 17 | return fmt.Sprintf("%s %s", p.Name, p.Surname) 18 | } 19 | 20 | var p = Person{"John", "Smith"} 21 | var d = Driver{nil, p} 22 | 23 | func pd() (Person, Driver) { return p, d } 24 | 25 | type FmtPair struct{ a, b fmt.Stringer } 26 | 27 | func fmtpair(a, b fmt.Stringer) FmtPair { return FmtPair{a, b} } 28 | 29 | func conv() { 30 | fmt.Printf("%v\n", p) 31 | fmt.Printf("%v\n", d) 32 | 33 | fmtpair(pd()) 34 | 35 | var s fmt.Stringer 36 | var ch = make(chan fmt.Stringer, 2) 37 | 38 | s = p 39 | ch <- s 40 | fmt.Printf("%v\n", <-ch) 41 | 42 | s = d 43 | ch <- s 44 | fmt.Printf("%v\n", <-ch) 45 | 46 | ch <- p 47 | fmt.Printf("%v\n", <-ch) 48 | 49 | ch <- d 50 | fmt.Printf("%v\n", <-ch) 51 | 52 | fp := func() fmt.Stringer { return p } 53 | fmt.Printf("%v\n", fp()) 54 | 55 | fd := func() fmt.Stringer { return d } 56 | fmt.Printf("%v\n", fd()) 57 | } 58 | -------------------------------------------------------------------------------- /_example/interrupt/interrupt_interpreter.go: -------------------------------------------------------------------------------- 1 | // interrupt_interpreter.go 2 | package main 3 | 4 | import ( 5 | "fmt" 6 | "time" 7 | 8 | "github.com/cosmos72/gomacro/fast" 9 | ) 10 | 11 | func main() { 12 | interp := fast.New() 13 | 14 | go stop(interp) 15 | 16 | // you should use interp in the same goroutine where it was created, 17 | // otherwise interp.Interrupt() may not work 18 | run(interp) 19 | } 20 | 21 | func stop(interp *fast.Interp) { 22 | fmt.Println("sleeping 3 seconds") 23 | time.Sleep(3 * time.Second) 24 | 25 | fmt.Println("slept. stopping interpreter..") 26 | // tell interpreter to exit the infinite loop 27 | interp.Interrupt(nil) 28 | } 29 | 30 | func run(interp *fast.Interp) { 31 | defer func() { 32 | p := recover() 33 | fmt.Printf("interpreter: infinite loop exited with panic = %T(%#v) %v\n", p, p, p) 34 | }() 35 | fmt.Println("interpreter: entering infinite loop") 36 | 37 | // this is an infinite loop 38 | interp.Eval(` 39 | func main() { 40 | for {} 41 | } 42 | main() 43 | `) 44 | } 45 | -------------------------------------------------------------------------------- /_example/main.go: -------------------------------------------------------------------------------- 1 | // empty file. stops "go build" from complaining that 2 | // no buildable files are in the directory "examples" 3 | 4 | package main 5 | 6 | import ( 7 | "fmt" 8 | "io" 9 | "os" 10 | r "reflect" 11 | ) 12 | 13 | func main() { 14 | // run_for_nested() 15 | run_interface_method_to_closure() 16 | run_struct_method_to_closure() 17 | } 18 | 19 | type stringer interface{ String() string } 20 | type Box struct{ value int } 21 | 22 | func (b *Box) Value() int { 23 | return b.value 24 | } 25 | 26 | func run_struct_method_to_closure() { 27 | var b *Box 28 | fmt.Printf("%v %T\n", b, b) 29 | function := (*Box).Value 30 | fmt.Printf("%v %T\n", function, function) 31 | closure := b.Value 32 | fmt.Printf("%v %T\n", closure, closure) 33 | } 34 | 35 | func run_interface_method_to_closure() { 36 | var s stringer 37 | fmt.Printf("%v %T\n", s, s) 38 | function := stringer.String 39 | fmt.Printf("%v %T\n", function, function) 40 | closure := s.String 41 | fmt.Printf("%v %T\n", closure, closure) 42 | } 43 | 44 | func main2() { 45 | var TypeOfInterface = r.TypeOf((*interface{})(nil)).Elem() 46 | p := r.ValueOf(new(interface{})) 47 | i := p.Elem() 48 | c := i.Convert(TypeOfInterface) 49 | fmt.Printf("%v %v\n", p, p.Type()) 50 | fmt.Printf("%v %v\n", i, i.Type()) 51 | fmt.Printf("%v %v\n", c, c.Type()) 52 | /* 53 | defer func() { 54 | fmt.Println(recover()) 55 | }() 56 | defer func() { 57 | fmt.Println("foo") 58 | }() 59 | panic("test panic") 60 | */ 61 | // m := [...]int{0x7ffffff: 3} 62 | // fmt.Println(m) 63 | // p := Pair{A: 1, B: true} 64 | // Pair{1, 2} = Pair{} 65 | // var f os.file 66 | // _ = bytes.Buffer{nil, 0} 67 | } 68 | 69 | func main1() { 70 | var x io.ReadWriteCloser = os.Stdin 71 | f := io.ReadWriteCloser.Close 72 | f(x) 73 | fmt.Printf("%T\n", f) 74 | } 75 | -------------------------------------------------------------------------------- /_example/make_fibonacci.gomacro: -------------------------------------------------------------------------------- 1 | 2 | // run "gomacro -m -w make_fibonacci.gomacro" 3 | // to preprocess this file and generate make_fibonacci.go 4 | 5 | package main 6 | 7 | :import ( 8 | "go/ast" 9 | "reflect" 10 | ) 11 | 12 | :macro makefib(name, typ ast.Node) ast.Node { 13 | // go/ast.FuncDecl can only represent function declarations 14 | // where the function name is an *ast.Ident, not a generic ast.Node 15 | // 16 | // Work around this limitation by using the name FOO and replacing it below 17 | ret := ~"{ 18 | ~func FOO(n ~,typ) ~,typ { 19 | if n <= 2 { 20 | return 1 21 | } 22 | return ~,name(n-1) + ~,name(n-2) 23 | } 24 | } 25 | ret.Name = name.(*ast.Ident) 26 | return ret 27 | } 28 | 29 | makefib; fibonacci_int; int 30 | makefib; fibonacci_int32; int32 31 | makefib; fibonacci_int64; int64 32 | 33 | makefib; fibonacci_uint; uint 34 | makefib; fibonacci_uint32; uint32 35 | makefib; fibonacci_uint64; uint64 36 | -------------------------------------------------------------------------------- /_example/make_fibonacci.gomacro_output: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------- 2 | // DO NOT EDIT! this file was generated automatically by gomacro 3 | // Any change will be lost when the file is re-generated 4 | // ------------------------------------------------------------- 5 | 6 | 7 | // run "gomacro -m -w make_fibonacci.gomacro" 8 | // to preprocess this file and generate make_fibonacci.go 9 | 10 | package main 11 | 12 | func fibonacci_int(n int, 13 | 14 | ) int { 15 | if n <= 2 { 16 | return 1 17 | } 18 | return fibonacci_int(n-1) + 19 | fibonacci_int(n-2) 20 | } 21 | func fibonacci_int32(n int32, 22 | 23 | ) int32 { 24 | if n <= 2 { 25 | return 1 26 | } 27 | return fibonacci_int32(n-1) + 28 | fibonacci_int32(n-2) 29 | } 30 | func fibonacci_int64(n int64, 31 | 32 | ) int64 { 33 | if n <= 2 { 34 | return 1 35 | } 36 | return fibonacci_int64(n-1) + 37 | fibonacci_int64(n-2) 38 | } 39 | func fibonacci_uint(n uint, 40 | 41 | ) uint { 42 | if n <= 2 { 43 | return 1 44 | } 45 | return fibonacci_uint(n-1) + 46 | fibonacci_uint(n-2) 47 | } 48 | func fibonacci_uint32(n uint32, 49 | 50 | ) uint32 { 51 | if n <= 2 { 52 | return 1 53 | } 54 | return fibonacci_uint32(n-1) + 55 | fibonacci_uint32(n-2) 56 | } 57 | func fibonacci_uint64(n uint64, 58 | 59 | ) uint64 { 60 | if n <= 2 { 61 | return 1 62 | } 63 | return fibonacci_uint64(n-1) + 64 | fibonacci_uint64(n-2) 65 | } 66 | -------------------------------------------------------------------------------- /_experiments/dummy.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * dummy.go 12 | * 13 | * Created on Apr 01, 2017 14 | * Author Massimiliano Ghilardi 15 | */ 16 | 17 | // empty file. stops "go build" from complaining that 18 | // no buildable files are in the directory "experiments" 19 | 20 | package experiments 21 | -------------------------------------------------------------------------------- /_experiments/issue122.gomacro: -------------------------------------------------------------------------------- 1 | import ( 2 | "fmt" 3 | "github.com/imroc/req/v3" 4 | ) 5 | 6 | func getData() *req.Response { 7 | client := req.C() 8 | res, err := client.R().Get("https://api.github.com/users/cosmos72") 9 | if err != nil { 10 | return nil 11 | } 12 | fmt.Println("Response length:", len(res.Bytes())) 13 | return res 14 | } 15 | 16 | res := getData() 17 | 18 | fmt.Println("Cookies:", res.Cookies()) 19 | fmt.Println("Content-Type:", res.GetHeader("Content-Type")) 20 | -------------------------------------------------------------------------------- /ast2/error.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * error.go 12 | * 13 | * Created on: Mar 18, 2017 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package ast2 18 | 19 | import ( 20 | "fmt" 21 | ) 22 | 23 | func badIndex(index int, size int) AstWithNode { 24 | if size > 0 { 25 | errorf("index out of range: %d not in 0...%d", index, size-1) 26 | } else { 27 | errorf("index out of range: %d, slice is empty", index) 28 | } 29 | return nil 30 | } 31 | 32 | func errorf(format string, args ...interface{}) { 33 | panic(fmt.Errorf(format, args...)) 34 | } 35 | -------------------------------------------------------------------------------- /ast2/test/empty.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * empty.go 12 | * 13 | * Created on: May 05, 2018 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package test 18 | -------------------------------------------------------------------------------- /ast2/test/z_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * z_test.go 12 | * 13 | * Created on: May 05, 2018 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package test 18 | 19 | import ( 20 | "io/ioutil" 21 | "os" 22 | "testing" 23 | 24 | . "github.com/cosmos72/gomacro/ast2" 25 | "github.com/cosmos72/gomacro/base/output" 26 | "github.com/cosmos72/gomacro/go/etoken" 27 | "github.com/cosmos72/gomacro/go/parser" 28 | ) 29 | 30 | func TestToNodes(t *testing.T) { 31 | tests := []struct { 32 | Name string 33 | Path string 34 | }{ 35 | {"z_test_data_2", "z_test_data_2.txt"}, 36 | {"fast_global", "../../fast/global.go"}, 37 | } 38 | for _, test := range tests { 39 | t.Run(test.Name, func(t *testing.T) { 40 | _testToNodes(t, test.Path) 41 | }) 42 | } 43 | } 44 | 45 | func _testToNodes(t *testing.T, filename string) { 46 | bytes, err := ioutil.ReadFile(filename) 47 | if err != nil { 48 | t.Errorf("read file %q failed: %v", filename, err) 49 | return 50 | } 51 | 52 | fset := etoken.NewFileSet() 53 | st := output.Stringer{Fileset: fset} 54 | 55 | var p parser.Parser 56 | p.Init(fset, filename, 0, bytes) 57 | 58 | nodes, err := p.Parse() 59 | if err != nil { 60 | t.Errorf("parse file %q failed: %v", filename, err) 61 | return 62 | } 63 | nodes = ToNodes(NodeSlice{nodes}) 64 | 65 | for _, node := range nodes { 66 | st.Fprintf(os.Stdout, "%v\n", node) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ast2/test/z_test_data_2.txt: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | var c = []int{0:a, 1:b} 4 | 5 | var a, b = pair(2, 3) 6 | 7 | func pair(a, b int) (int, int) { 8 | return a, b 9 | } 10 | 11 | -------------------------------------------------------------------------------- /atomic/spinlock.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * spinlock.go 12 | * 13 | * Created on: Apr 30 2018 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package atomic 18 | 19 | import ( 20 | "runtime" 21 | "sync/atomic" 22 | ) 23 | 24 | type SpinLock int32 25 | 26 | func (s *SpinLock) Lock() { 27 | for i := 0; i < 10; i++ { 28 | if atomic.CompareAndSwapInt32((*int32)(s), 0, 1) { 29 | return 30 | } 31 | } 32 | for !atomic.CompareAndSwapInt32((*int32)(s), 0, 1) { 33 | runtime.Gosched() 34 | } 35 | } 36 | 37 | func (s *SpinLock) Unlock() { 38 | atomic.StoreInt32((*int32)(s), 0) 39 | } 40 | -------------------------------------------------------------------------------- /base/dep/api_internal.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * api_internal.go 12 | * 13 | * Created on: May 05, 2018 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package dep 18 | 19 | type void struct{} 20 | 21 | type set map[string]void 22 | 23 | type depMap map[string]set 24 | 25 | type fwdDeclList struct { 26 | List DeclList 27 | Set set 28 | } 29 | 30 | type graph struct { 31 | Nodes DeclMap 32 | Edges depMap 33 | } 34 | 35 | type visitCtx struct { 36 | visiting map[string]int 37 | visited map[string]int 38 | beforeFunc func(node *Decl, ctx *visitCtx) // invoked once for each node, in visit pre-order 39 | afterFunc func(node *Decl, ctx *visitCtx) // invoked once for each node, in visit post-order 40 | cycleFunc func(node *Decl, ctx *visitCtx) // invoked when ctx.visiting[node.Name] exists already, i.e. for cycles 41 | } 42 | -------------------------------------------------------------------------------- /base/dep/util.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * util.go 12 | * 13 | * Created on: May 03, 2018 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package dep 18 | 19 | import ( 20 | "sort" 21 | ) 22 | 23 | // keep only items satisfying pred(item). 24 | // destructively modifies list. 25 | func filter_if_inplace(list []string, pred func(string) bool) []string { 26 | out := 0 27 | for _, e := range list { 28 | if pred(e) { 29 | list[out] = e 30 | out++ 31 | } 32 | } 33 | return list[:out] 34 | } 35 | 36 | // remove all strings equal to 'str' from list 37 | // destructively modifies list. 38 | func remove_item_inplace(str string, list []string) []string { 39 | out := 0 40 | for _, e := range list { 41 | if e != str { 42 | list[out] = e 43 | out++ 44 | } 45 | } 46 | return list[:out] 47 | } 48 | 49 | // make a copy of list 50 | func dup(list []string) []string { 51 | if len(list) == 0 { 52 | return nil 53 | } 54 | ret := make([]string, len(list)) 55 | copy(ret, list) 56 | return ret 57 | } 58 | 59 | // sort and remove duplicates from lists 60 | func sort_unique_inplace(list []string) []string { 61 | if len(list) <= 1 { 62 | return list 63 | } 64 | sort.Strings(list) 65 | 66 | prev := list[0] 67 | out := 1 68 | 69 | // remove duplicates 70 | for _, e := range list[1:] { 71 | if e == prev { 72 | continue 73 | } 74 | prev = e 75 | list[out] = e 76 | out++ 77 | } 78 | return list[:out] 79 | } 80 | -------------------------------------------------------------------------------- /base/dep/z_test_data_2.txt: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import "fmt" 4 | 5 | fmt.Println("Hello, World!") 6 | 7 | var c = []int{0:a, 1:b} 8 | 9 | var a, b = pair(2, 3) 10 | 11 | func pair(a, b int) (int, int) { 12 | return a, b 13 | } 14 | 15 | println(pair(a,b)) 16 | 17 | if a < b { 18 | fmt.Println("a < b") 19 | } 20 | -------------------------------------------------------------------------------- /base/dep/z_test_data_3.txt: -------------------------------------------------------------------------------- 1 | var i, j, k int; for i=1; i<=2; i=i+1 { if i<2 {j=i} else {k=i} }; i 2 | 3 | var a, b = b, 5 4 | -------------------------------------------------------------------------------- /base/genimport/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/base/genimport" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package genimport 5 | 6 | import ( 7 | r "reflect" 8 | 9 | "github.com/cosmos72/gomacro/imports" 10 | ) 11 | 12 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/base/genimport" 13 | func init() { 14 | imports.Packages["github.com/cosmos72/gomacro/base/genimport"] = imports.Package{ 15 | Binds: map[string]r.Value{ 16 | "DefaultImporter": r.ValueOf(DefaultImporter), 17 | "GoModuleSupported": r.ValueOf(GoModuleSupported), 18 | "ImBuiltin": r.ValueOf(ImBuiltin), 19 | "ImInception": r.ValueOf(ImInception), 20 | "ImPlugin": r.ValueOf(ImPlugin), 21 | "ImThirdParty": r.ValueOf(ImThirdParty), 22 | "LookupPackage": r.ValueOf(LookupPackage), 23 | }, Types: map[string]r.Type{ 24 | "ImportMode": r.TypeOf((*ImportMode)(nil)).Elem(), 25 | "Importer": r.TypeOf((*Importer)(nil)).Elem(), 26 | "Output": r.TypeOf((*Output)(nil)).Elem(), 27 | "PackageRef": r.TypeOf((*PackageRef)(nil)).Elem(), 28 | "TypeVisitor": r.TypeOf((*TypeVisitor)(nil)).Elem(), 29 | }, Wrappers: map[string][]string{ 30 | "Output": []string{"Copy", "ErrorAt", "Errorf", "Fprintf", "IncLine", "IncLineBytes", "MakeRuntimeError", "Position", "Sprintf", "ToString"}, 31 | "PackageRef": []string{"LazyInit", "Merge"}, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /base/inspect/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/base/inspect" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package inspect 5 | 6 | import ( 7 | r "reflect" 8 | "github.com/cosmos72/gomacro/imports" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/base/inspect" 12 | func init() { 13 | imports.Packages["github.com/cosmos72/gomacro/base/inspect"] = imports.Package{ 14 | Types: map[string]r.Type{ 15 | "Inspector": r.TypeOf((*Inspector)(nil)).Elem(), 16 | }, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /base/output/write_decl.go: -------------------------------------------------------------------------------- 1 | package output 2 | 3 | import ( 4 | "fmt" 5 | "go/ast" 6 | "io" 7 | ) 8 | 9 | func (o *Output) WriteDeclsToStream(out io.Writer, packagePath string, 10 | imports []*ast.GenDecl, declarations []ast.Decl, statements []ast.Stmt) { 11 | 12 | fmt.Fprintf(out, "package %s\n\n", packagePath) 13 | 14 | for _, imp := range imports { 15 | fmt.Fprintln(out, o.toPrintable("%v", imp)) 16 | } 17 | if len(imports) != 0 { 18 | fmt.Fprintln(out) 19 | } 20 | for _, decl := range declarations { 21 | fmt.Fprintln(out, o.toPrintable("%v", decl)) 22 | } 23 | if len(statements) != 0 { 24 | fmt.Fprint(out, "\nfunc init() {\n") 25 | config.Indent = 1 26 | defer func() { 27 | config.Indent = 0 28 | }() 29 | for _, stmt := range statements { 30 | fmt.Fprintln(out, o.toPrintable("%v", stmt)) 31 | } 32 | fmt.Fprint(out, "}\n") 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /base/output/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/base/output" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package output 5 | 6 | import ( 7 | r "reflect" 8 | "github.com/cosmos72/gomacro/imports" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/base/output" 12 | func init() { 13 | imports.Packages["github.com/cosmos72/gomacro/base/output"] = imports.Package{ 14 | Binds: map[string]r.Value{ 15 | "Debugf": r.ValueOf(Debugf), 16 | "Error": r.ValueOf(Error), 17 | "Errorf": r.ValueOf(Errorf), 18 | "MakeRuntimeError": r.ValueOf(MakeRuntimeError), 19 | "ShowPackageHeader": r.ValueOf(ShowPackageHeader), 20 | "Warnf": r.ValueOf(Warnf), 21 | }, Types: map[string]r.Type{ 22 | "Output": r.TypeOf((*Output)(nil)).Elem(), 23 | "RuntimeError": r.TypeOf((*RuntimeError)(nil)).Elem(), 24 | "Stringer": r.TypeOf((*Stringer)(nil)).Elem(), 25 | }, Wrappers: map[string][]string{ 26 | "Output": []string{"Copy","ErrorAt","Errorf","Fprintf","IncLine","IncLineBytes","MakeRuntimeError","Position","Sprintf","ToString",}, 27 | }, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /base/paths/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/base/paths" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package paths 5 | 6 | import ( 7 | r "reflect" 8 | 9 | "github.com/cosmos72/gomacro/imports" 10 | ) 11 | 12 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/base/paths" 13 | func init() { 14 | imports.Packages["github.com/cosmos72/gomacro/base/paths"] = imports.Package{ 15 | Binds: map[string]r.Value{ 16 | "DirName": r.ValueOf(DirName), 17 | "FileName": r.ValueOf(FileName), 18 | "GetImportsSrcDir": r.ValueOf(GetImportsSrcDir), 19 | "GoSrcDir": r.ValueOf(&GoSrcDir).Elem(), 20 | "RemoveFinalSlash": r.ValueOf(RemoveFinalSlash), 21 | "Subdir": r.ValueOf(Subdir), 22 | "SymbolFromImportsPackage": r.ValueOf(&SymbolFromImportsPackage).Elem(), 23 | "UserHomeDir": r.ValueOf(UserHomeDir), 24 | }, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /base/strings/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/base/strings" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package strings 5 | 6 | import ( 7 | r "reflect" 8 | "github.com/cosmos72/gomacro/imports" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/base/strings" 12 | func init() { 13 | imports.Packages["github.com/cosmos72/gomacro/base/strings"] = imports.Package{ 14 | Binds: map[string]r.Value{ 15 | "FindFirstToken": r.ValueOf(FindFirstToken), 16 | "MaybeUnescapeString": r.ValueOf(MaybeUnescapeString), 17 | "Split2": r.ValueOf(Split2), 18 | "UnescapeChar": r.ValueOf(UnescapeChar), 19 | "UnescapeString": r.ValueOf(UnescapeString), 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /base/untyped/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/base/untyped" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package untyped 5 | 6 | import ( 7 | r "reflect" 8 | "github.com/cosmos72/gomacro/imports" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/base/untyped" 12 | func init() { 13 | imports.Packages["github.com/cosmos72/gomacro/base/untyped"] = imports.Package{ 14 | Binds: map[string]r.Value{ 15 | "Bool": r.ValueOf(Bool), 16 | "Complex": r.ValueOf(Complex), 17 | "ConvertLiteralCheckOverflow": r.ValueOf(ConvertLiteralCheckOverflow), 18 | "Float": r.ValueOf(Float), 19 | "GoUntypedToKind": r.ValueOf(GoUntypedToKind), 20 | "Int": r.ValueOf(Int), 21 | "MakeKind": r.ValueOf(MakeKind), 22 | "MakeLit": r.ValueOf(MakeLit), 23 | "Marshal": r.ValueOf(Marshal), 24 | "None": r.ValueOf(None), 25 | "Rune": r.ValueOf(Rune), 26 | "String": r.ValueOf(String), 27 | "Unmarshal": r.ValueOf(Unmarshal), 28 | "UnmarshalVal": r.ValueOf(UnmarshalVal), 29 | }, Types: map[string]r.Type{ 30 | "Kind": r.TypeOf((*Kind)(nil)).Elem(), 31 | "Lit": r.TypeOf((*Lit)(nil)).Elem(), 32 | "Val": r.TypeOf((*Val)(nil)).Elem(), 33 | }, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /classic/README.md: -------------------------------------------------------------------------------- 1 | ## gomacro - A Go interpreter with Lisp-like macros 2 | 3 | The package `classic` contains the original old, small (and slow) implementation of gomacro interpreter. 4 | 5 | For the current `fast` interpreter, see [../fast/README.md](../fast/README.md). 6 | 7 | To learn about gomacro, download, compile and use it, please refer to the main [README.md](../README.md) 8 | 9 | ## Current Status 10 | 11 | STABLE. 12 | 13 | ## Features and limitations 14 | 15 | The classic interpreter has some additional limitations with respect to the fast one. Most notably: 16 | 17 | * untyped constants and arithmetic on them, as `1<<100`, are evaluated as typed constants. 18 | * types are not accurate when mixing untyped constants with typed values, 19 | i.e. `uint8(10) + 1` gives `uint64(11)` instead of `uint8(11)`. 20 | * interpreted interfaces are not functional (they can only be declared). 21 | * interpreted types cannot implement compiled interfaces. 22 | * struct tags are ignored. 23 | * support for embedded fields in structs is very limited - they mostly 24 | work as non-embedded fields. 25 | 26 | -------------------------------------------------------------------------------- /classic/file.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * file.go 12 | * 13 | * Created on: Feb 15, 2017 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package classic 18 | 19 | import ( 20 | "bufio" 21 | "go/ast" 22 | "os" 23 | 24 | . "github.com/cosmos72/gomacro/base" 25 | ) 26 | 27 | func (ir *Interp) EvalFile(filePath string) { 28 | file, err := os.Open(filePath) 29 | if err != nil { 30 | ir.Errorf("error opening file '%s': %v", filePath, err) 31 | return 32 | } 33 | defer file.Close() 34 | 35 | saveOpts := ir.Env.Options 36 | ir.Env.Options &^= OptShowEval 37 | 38 | defer func() { 39 | ir.Env.Options = saveOpts 40 | }() 41 | 42 | in := bufio.NewReader(file) 43 | ir.Repl(in) 44 | } 45 | 46 | func (env *Env) evalFile(node *ast.File) { 47 | env.Name = node.Name.Name 48 | env.Path = env.Name 49 | env.PackagePath = env.Name 50 | 51 | for _, imp := range node.Imports { 52 | env.evalImport(imp) 53 | } 54 | 55 | for _, decl := range node.Decls { 56 | env.evalDecl(decl) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /classic/global.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * global.go 12 | * 13 | * Created on: Feb 19, 2017 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package classic 18 | 19 | import ( 20 | "go/ast" 21 | r "reflect" 22 | ) 23 | 24 | type CallStack struct { 25 | Frames []CallFrame 26 | } 27 | 28 | type CallFrame struct { 29 | FuncEnv *Env 30 | InnerEnv *Env // innermost Env 31 | CurrentCall *ast.CallExpr // call currently in progress 32 | defers []func() 33 | panick interface{} // current panic 34 | panicking bool 35 | runningDefers bool 36 | } 37 | 38 | type Constructor struct { 39 | exec func(env *Env, arg0 r.Type, args []r.Value) (r.Value, []r.Value) 40 | argNum int // if negative, do not check 41 | } 42 | 43 | type Function struct { 44 | exec func(env *Env, args []r.Value) (r.Value, []r.Value) 45 | argNum int // if negative, do not check 46 | } 47 | 48 | type Macro struct { 49 | closure func(args []r.Value) (results []r.Value) 50 | argNum int 51 | } 52 | 53 | type TypedValue struct { 54 | typ r.Type 55 | val r.Value 56 | } 57 | 58 | /** 59 | * inside Methods, each string is the method name 60 | * and each TypedValue is { 61 | * Type: the method signature, i.e. the type of a func() *without* the receiver (to allow comparison with Interface methods) 62 | * Value: the method implementation, i.e. a func() whose first argument is the receiver, 63 | * } 64 | */ 65 | type Methods map[string]TypedValue 66 | -------------------------------------------------------------------------------- /classic/identifier.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * identifier.go 12 | * 13 | * Created on: Feb 13, 2017 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package classic 18 | 19 | import ( 20 | "go/ast" 21 | r "reflect" 22 | 23 | . "github.com/cosmos72/gomacro/base" 24 | ) 25 | 26 | func (env *Env) evalIdentifier(ident *ast.Ident) r.Value { 27 | value, found := env.resolveIdentifier(ident) 28 | if !found { 29 | env.Errorf("undefined identifier: %s", ident.Name) 30 | } 31 | return value 32 | } 33 | 34 | func (env *Env) resolveIdentifier(ident *ast.Ident) (r.Value, bool) { 35 | name := ident.Name 36 | value := NilR 37 | found := false 38 | for e := env; e != nil; e = e.Outer { 39 | // Debugf("evalIdentifier() looking up %#v in %#v", name, env.Binds) 40 | if value, found = e.Binds.Get(name); found { 41 | break 42 | } 43 | } 44 | return value, found 45 | } 46 | -------------------------------------------------------------------------------- /classic/inspect.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * inspect.go 12 | * 13 | * Created on: Feb 11, 2017 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package classic 18 | 19 | import ( 20 | r "reflect" 21 | 22 | . "github.com/cosmos72/gomacro/base" 23 | ) 24 | 25 | func (env *Env) Inspect(str string) { 26 | inspector := env.Globals.Inspector 27 | if inspector == nil { 28 | env.Errorf("no inspector set: call Interp.SetInspector() first") 29 | return 30 | } 31 | 32 | form := env.Parse(str) 33 | v := env.EvalAst1(form) 34 | var t r.Type 35 | if v.IsValid() && v != NoneR { 36 | if v.Kind() == r.Interface { 37 | v = v.Elem() // extract concrete type 38 | } 39 | t = v.Type() 40 | } 41 | inspector.Inspect(str, v, t, nil, env.Globals) 42 | } 43 | -------------------------------------------------------------------------------- /classic/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * interface.go 12 | * 13 | * Created on: Mar 29, 2017 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package classic 18 | 19 | import ( 20 | "go/ast" 21 | r "reflect" 22 | 23 | . "github.com/cosmos72/gomacro/base" 24 | ) 25 | 26 | func (env *Env) evalTypeInterface(node *ast.InterfaceType) r.Type { 27 | if node.Methods == nil || len(node.Methods.List) == 0 { 28 | return TypeOfInterface 29 | } 30 | types, names := env.evalTypeFields(node.Methods) 31 | 32 | types = append([]r.Type{TypeOfInterface}, types...) 33 | names = append([]string{StrGensymInterface}, names...) 34 | 35 | fields := makeStructFields(env.FileEnv().Path, names, types) 36 | return r.StructOf(fields) 37 | } 38 | 39 | func isInterfaceType(t r.Type) bool { 40 | if t.Kind() == r.Struct && t.NumField() > 0 { 41 | field := t.Field(0) 42 | return field.Name == StrGensymInterface && field.Type == TypeOfInterface 43 | } 44 | return false 45 | } 46 | -------------------------------------------------------------------------------- /classic/number.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * number.go 12 | * 13 | * Created on: Feb 13, 2017 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package classic 18 | 19 | import ( 20 | r "reflect" 21 | ) 22 | 23 | func (env *Env) toInt(xv r.Value) (int64, bool) { 24 | switch xv.Kind() { 25 | case r.Uint, r.Uint8, r.Uint16, r.Uint32, r.Uint64, r.Uintptr: 26 | u := xv.Uint() 27 | i := int64(u) 28 | if uint64(i) != u { 29 | env.Warnf("value %d overflows int64, truncated to %d", u, i) 30 | } 31 | return i, true 32 | case r.Int, r.Int8, r.Int16, r.Int32, r.Int64: 33 | return xv.Int(), true 34 | default: 35 | return 0, false 36 | } 37 | } 38 | 39 | func (env *Env) toFloat(xv r.Value) (float64, bool) { 40 | switch xv.Kind() { 41 | case r.Uint, r.Uint8, r.Uint16, r.Uint32, r.Uint64, r.Uintptr: 42 | return float64(xv.Uint()), true 43 | case r.Int, r.Int8, r.Int16, r.Int32, r.Int64: 44 | return float64(xv.Int()), true 45 | case r.Float32, r.Float64: 46 | return xv.Float(), true 47 | default: 48 | return 0.0, false 49 | } 50 | } 51 | 52 | func (env *Env) toComplex(xv r.Value) (complex128, bool) { 53 | switch xv.Kind() { 54 | case r.Complex64, r.Complex128: 55 | return xv.Complex(), true 56 | default: 57 | f, ok := env.toFloat(xv) 58 | return complex(f, 0.0), ok 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /cmd/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/cmd" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package cmd 5 | 6 | import ( 7 | r "reflect" 8 | "github.com/cosmos72/gomacro/imports" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/cmd" 12 | func init() { 13 | imports.Packages["github.com/cosmos72/gomacro/cmd"] = imports.Package{ 14 | Binds: map[string]r.Value{ 15 | "New": r.ValueOf(New), 16 | }, Types: map[string]r.Type{ 17 | "Cmd": r.TypeOf((*Cmd)(nil)).Elem(), 18 | }, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cmd_classic/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * main.go 12 | * 13 | * Created on: Nov 23, 2019 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | . "github.com/cosmos72/gomacro/base" 21 | "github.com/cosmos72/gomacro/classic" 22 | ) 23 | 24 | func main() { 25 | ir := classic.New() 26 | g := ir.Globals 27 | g.Options |= OptTrapPanic | OptShowPrompt | OptShowEval | OptShowEvalType 28 | ir.ReplStdin() 29 | } 30 | -------------------------------------------------------------------------------- /doc/code_generation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmos72/gomacro/2ff796e3da1057c005cb33c58e4fd1231cc315a6/doc/code_generation.pdf -------------------------------------------------------------------------------- /fast/README.md: -------------------------------------------------------------------------------- 1 | ## gomacro - A Go interpreter with Lisp-like macros 2 | 3 | The package `fast` contains a faster reimplementation of gomacro interpreter. 4 | 5 | To learn about gomacro, download, compile and use it, please refer to the main [README.md](../README.md) 6 | 7 | ## Current Status 8 | 9 | STABLE. 10 | 11 | ## Features and limitations 12 | 13 | See [../doc/features-and-limitations.md](../doc/features-and-limitations.md) 14 | 15 | 16 | ## Misc TODO notes 17 | 18 | * contact github.com/neugram/ng author? 19 | * when importing a package, reuse compiled .so if exists already? 20 | * gomacro FILE: execute all the init() functions, then execute main() if (re)defined and package == "main" 21 | * try to run Go compiler tests 22 | -------------------------------------------------------------------------------- /fast/attic/callnret0_compact.go: -------------------------------------------------------------------------------- 1 | //go:build gomacro_fast_compact 2 | 3 | /* 4 | * gomacro - A Go interpreter with Lisp-like macros 5 | * 6 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 7 | * 8 | * This Source Code Form is subject to the terms of the Mozilla Public 9 | * License, v. 2.0. If a copy of the MPL was not distributed with this 10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | * 12 | * 13 | * callnret0_compact.go 14 | * 15 | * Created on Jun 14, 2017 16 | * Author Massimiliano Ghilardi 17 | */ 18 | 19 | package fast 20 | 21 | import ( 22 | r "reflect" 23 | ) 24 | 25 | func (c *Comp) call0ret0(call *Call, maxdepth int) func(env *Env) { 26 | expr := call.Fun 27 | exprfun := expr.AsX1() 28 | return func(env *Env) { 29 | fun := exprfun(env).Interface().(func()) 30 | fun() 31 | } 32 | } 33 | 34 | func (c *Comp) call1ret0(call *Call, maxdepth int) func(env *Env) { 35 | expr := call.Fun 36 | exprfun := expr.AsX1() 37 | 38 | argfun := call.MakeArgfunsX1()[0] 39 | 40 | return func(env *Env) { 41 | funv := exprfun(env) 42 | argv := []r.Value{argfun(env)} 43 | 44 | funv.Call(argv) 45 | } 46 | } 47 | 48 | func (c *Comp) call2ret0(call *Call, maxdepth int) func(env *Env) { 49 | expr := call.Fun 50 | exprfun := expr.AsX1() 51 | 52 | argfunsX1 := call.MakeArgfunsX1() 53 | argfuns := [2]func(*Env) r.Value{ 54 | argfunsX1[0], 55 | argfunsX1[1], 56 | } 57 | 58 | return func(env *Env) { 59 | funv := exprfun(env) 60 | 61 | argv := []r.Value{ 62 | argfuns[0](env), 63 | argfuns[1](env), 64 | } 65 | funv.Call(argv) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /fast/debug/api.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * api.go 12 | * 13 | * Created on Apr 21, 2018 14 | * Author Massimiliano Ghilardi 15 | */ 16 | 17 | package debug 18 | 19 | import ( 20 | "github.com/cosmos72/gomacro/base" 21 | "github.com/cosmos72/gomacro/fast" 22 | ) 23 | 24 | type DebugOp = fast.DebugOp 25 | 26 | var ( 27 | DebugOpContinue = fast.DebugOpContinue 28 | DebugOpStep = fast.DebugOpStep 29 | DebugOpRepl = DebugOp{-1, nil} 30 | ) 31 | 32 | type Debugger struct { 33 | interp *fast.Interp 34 | env *fast.Env 35 | globals *base.Globals 36 | lastcmd string 37 | } 38 | 39 | func (d *Debugger) Breakpoint(interp *fast.Interp, env *fast.Env) DebugOp { 40 | return d.main(interp, env, true) 41 | } 42 | 43 | func (d *Debugger) At(interp *fast.Interp, env *fast.Env) DebugOp { 44 | return d.main(interp, env, false) 45 | } 46 | 47 | func (d *Debugger) main(interp *fast.Interp, env *fast.Env, breakpoint bool) DebugOp { 48 | // create an inner Interp to preserve existing Binds, compiled Code and IP 49 | // 50 | // this is needed to allow compiling and evaluating code at a breakpoint or single step 51 | // without disturbing the code being debugged 52 | d.interp = fast.NewInnerInterp(interp, "debug", "debug") 53 | d.env = env 54 | d.globals = &interp.Comp.Globals 55 | if !d.Show(breakpoint) { 56 | // skip synthetic statements 57 | return DebugOp{Depth: env.Run.DebugDepth} 58 | } 59 | return d.Repl() 60 | } 61 | -------------------------------------------------------------------------------- /fast/debug/backtrace.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * backtrace.go 12 | * 13 | * Created on Apr 27, 2018 14 | * Author Massimiliano Ghilardi 15 | */ 16 | 17 | package debug 18 | 19 | import ( 20 | "github.com/cosmos72/gomacro/fast" 21 | ) 22 | 23 | func (d *Debugger) Backtrace(arg string) DebugOp { 24 | env := d.env 25 | var calls []*fast.Env 26 | for env != nil { 27 | if env.Caller != nil { 28 | // function body 29 | calls = append(calls, env) 30 | env = env.Caller 31 | } else { 32 | // nested env 33 | env = env.Outer 34 | } 35 | } 36 | d.showFunctionCalls(calls) 37 | return DebugOpRepl 38 | } 39 | 40 | func (d *Debugger) showFunctionCalls(calls []*fast.Env) { 41 | // show outermost stack frame first 42 | for i := len(calls) - 1; i >= 0; i-- { 43 | d.showFunctionCall(calls[i]) 44 | } 45 | } 46 | 47 | func (d *Debugger) showFunctionCall(env *fast.Env) { 48 | g := d.globals 49 | c := env.DebugComp 50 | if c == nil || c.FuncMaker == nil { 51 | g.Fprintf(g.Stdout, "%p\tfunc (???) ???\n", env) 52 | return 53 | } 54 | m := c.FuncMaker 55 | 56 | g.Fprintf(g.Stdout, "%p\tfunc %s(", env, m.Name) 57 | d.showBinds(env, m.Param) 58 | g.Fprintf(g.Stdout, ") ") 59 | if len(m.Result) > 1 { 60 | g.Fprintf(g.Stdout, "(") 61 | } 62 | d.showBinds(env, m.Result) 63 | if len(m.Result) > 1 { 64 | g.Fprintf(g.Stdout, ")\n") 65 | } else { 66 | g.Fprintf(g.Stdout, "\n") 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /fast/func0ret0.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * func0ret0.go 12 | * 13 | * Created on Apr 16, 2017 14 | * Author Massimiliano Ghilardi 15 | */ 16 | 17 | package fast 18 | 19 | import ( 20 | "github.com/cosmos72/gomacro/base" 21 | xr "github.com/cosmos72/gomacro/xreflect" 22 | ) 23 | 24 | func (c *Comp) func0ret0(t xr.Type, m *funcMaker) func(env *Env) xr.Value { 25 | funcbody := m.funcbody 26 | if funcbody == nil { 27 | return func(env *Env) xr.Value { 28 | return valueOfNopFunc 29 | } 30 | } 31 | var debugC *Comp 32 | if c.Globals.Options&base.OptDebugger != 0 { 33 | debugC = c 34 | } 35 | 36 | nbind := m.nbind 37 | nintbind := m.nintbind 38 | return func(env *Env) xr.Value { 39 | // function is closed over the env used to DECLARE it 40 | env.MarkUsedByClosure() 41 | return xr.ValueOf(func() { 42 | env := newEnv4Func(env, nbind, nintbind, debugC) 43 | // execute the body 44 | funcbody(env) 45 | 46 | env.freeEnv4Func() 47 | }) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /fast/inspect.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * inspect.go 12 | * 13 | * Created on: Apr 20, 2017 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package fast 18 | 19 | import ( 20 | r "reflect" 21 | 22 | "github.com/cosmos72/gomacro/ast2" 23 | "github.com/cosmos72/gomacro/base/reflect" 24 | xr "github.com/cosmos72/gomacro/xreflect" 25 | ) 26 | 27 | func (ir *Interp) Inspect(src string) { 28 | c := ir.Comp 29 | g := &c.Globals 30 | inspector := g.Inspector 31 | if inspector == nil { 32 | c.Errorf("no inspector set: call Interp.SetInspector() first") 33 | return 34 | } 35 | form := c.Parse(src) 36 | if _, ok := form.(ast2.AstWithSlice); ok && form.Size() == 1 { 37 | form = form.Get(0) 38 | } 39 | expr, xtyp := c.Expr1OrType(ast2.ToExpr(form)) 40 | var val xr.Value 41 | if expr != nil { 42 | val, xtyp = ir.RunExpr1(expr) 43 | } else { 44 | // attempt to inspect a type: inspect the zero value of the type 45 | val = xr.Zero(xtyp) 46 | } 47 | typ := xtyp.ReflectType() 48 | if val.IsValid() && val.Kind() == r.Interface { 49 | // extract concrete type 50 | val = val.Elem() 51 | typ = reflect.ValueType(val) 52 | } 53 | inspector.Inspect(src, val.ReflectValue(), typ, xtyp, &ir.Comp.Globals) 54 | } 55 | -------------------------------------------------------------------------------- /gls/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, Massimiliano Ghilardi 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /gls/api_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | 7 | package gls 8 | 9 | // return the current goroutine ID. 10 | // 11 | // note that the returned value is DIFFERENT from most other goroutine libraries: 12 | // this GoID() returns the address of the runtime.g struct, converted to uintptr. 13 | // NOT the runtime.g.goid field returned by most other libraries. 14 | func GoID() uintptr 15 | -------------------------------------------------------------------------------- /gls/api_gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gccgo 6 | 7 | package gls 8 | 9 | // return the current goroutine ID. 10 | // 11 | // note that the returned value is DIFFERENT from most other goroutine libraries: 12 | // this GoID() returns the address of the runtime.g struct, converted to uintptr. 13 | // NOT the runtime.g.goid field returned by most other libraries. 14 | //go:nosplit 15 | func GoID() uintptr { 16 | return goid() 17 | } 18 | 19 | // cannot export this function directly: when compiling other packages, 20 | // gccgo forgets that its name is actually "runtime.getg" 21 | // 22 | //extern runtime.getg 23 | func goid() uintptr 24 | -------------------------------------------------------------------------------- /gls/id_386.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT,$0-4 11 | get_tls(CX) 12 | MOVL g(CX), AX 13 | MOVL AX, goid+0(FP) 14 | RET 15 | -------------------------------------------------------------------------------- /gls/id_amd64.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT,$0-8 11 | get_tls(CX) 12 | MOVQ g(CX), AX 13 | MOVQ AX, goid+0(FP) 14 | RET 15 | -------------------------------------------------------------------------------- /gls/id_arm.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT,$0-4 11 | MOVW g, goid+0(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /gls/id_arm64.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT,$0-8 11 | MOVD g, goid+0(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /gls/id_mips.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT|NOFRAME,$-4-4 11 | MOVW g, goid+0(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /gls/id_mips64.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT|NOFRAME,$-8-8 11 | MOVV g, goid+0(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /gls/id_mips64le.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT|NOFRAME,$-8-8 11 | MOVV g, goid+0(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /gls/id_mipsle.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT|NOFRAME,$-4-4 11 | MOVW g, goid+0(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /gls/id_ppc64.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT,$0-8 11 | MOVD g, goid+0(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /gls/id_ppc64le.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT,$0-8 11 | MOVD g, goid+0(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /gls/id_riscv64.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "go_asm.h" 8 | #include "textflag.h" // for NOSPLIT 9 | #include "../../src/runtime/go_tls.h" 10 | 11 | TEXT ·GoID(SB),NOSPLIT,$0-8 12 | MOV g, goid+0(FP) 13 | RET 14 | -------------------------------------------------------------------------------- /gls/id_s390x.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "textflag.h" // for NOSPLIT 8 | #include "../../src/runtime/go_tls.h" 9 | 10 | TEXT ·GoID(SB),NOSPLIT|NOFRAME,$0-8 11 | MOVD g, goid+0(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /gls/id_wasm.s: -------------------------------------------------------------------------------- 1 | //go:build gc 2 | 3 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | #include "go_asm.h" 8 | #include "textflag.h" // for NOSPLIT 9 | #include "../../src/runtime/go_tls.h" 10 | 11 | TEXT ·GoID(SB),NOSPLIT,$0-8 12 | MOVD g, goid+0(FP) 13 | RET 14 | -------------------------------------------------------------------------------- /gls/z_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Massimiliano Ghilardi. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gls 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | var verbose bool = false 12 | 13 | func AsyncGoID() <-chan uintptr { 14 | ch := make(chan uintptr) 15 | go func() { 16 | ch <- GoID() 17 | }() 18 | return ch 19 | } 20 | 21 | func TestGoID(t *testing.T) { 22 | id1 := GoID() 23 | id2 := GoID() 24 | if id1 == id2 { 25 | if verbose { 26 | t.Logf("TestGoID: 0x%x == 0x%x", id1, id2) 27 | } 28 | } else { 29 | t.Errorf("TestGoID: 0x%x != 0x%x", id1, id2) 30 | } 31 | } 32 | 33 | func TestAsyncGoID1(t *testing.T) { 34 | id1 := GoID() 35 | id2 := <-AsyncGoID() 36 | if id1 != id2 { 37 | if verbose { 38 | t.Logf("TestAsyncGoID1: 0x%x != 0x%x", id1, id2) 39 | } 40 | } else { 41 | t.Errorf("TestAsyncGoID1: 0x%x == 0x%x", id1, id2) 42 | } 43 | } 44 | 45 | func TestAsyncGoID2(t *testing.T) { 46 | ch1 := AsyncGoID() 47 | ch2 := AsyncGoID() 48 | id1 := <-ch1 49 | id2 := <-ch2 50 | if id1 != id2 { 51 | if verbose { 52 | t.Logf("TestAsyncGoID2: 0x%x != 0x%x", id1, id2) 53 | } 54 | } else { 55 | t.Errorf("TestAsyncGoID2: 0x%x == 0x%x", id1, id2) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/cosmos72/gomacro 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/mattn/go-runewidth v0.0.15 7 | github.com/peterh/liner v1.2.2 8 | golang.org/x/tools v0.14.0 9 | ) 10 | 11 | require ( 12 | github.com/rivo/uniseg v0.2.0 // indirect 13 | golang.org/x/mod v0.13.0 // indirect 14 | golang.org/x/sys v0.13.0 // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= 2 | github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= 3 | github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= 4 | github.com/peterh/liner v1.2.2 h1:aJ4AOodmL+JxOZZEL2u9iJf8omNRpqHc/EbrK+3mAXw= 5 | github.com/peterh/liner v1.2.2/go.mod h1:xFwJyiKIXJZUKItq5dGHZSTBRAuG/CpeNpWLyiNRNwI= 6 | github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= 7 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 8 | golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= 9 | golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= 10 | golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= 11 | golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 12 | golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= 13 | golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 14 | golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= 15 | golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= 16 | -------------------------------------------------------------------------------- /go/etoken/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /go/etoken/generics.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package etoken 6 | 7 | type Generics int 8 | 9 | const ( 10 | GENERICS_NONE Generics = iota 11 | // enables C++ style generics 12 | GENERICS_V1_CXX 13 | // enables generics "contracts are interfaces" 14 | GENERICS_V2_CTI 15 | ) 16 | 17 | // can be changed at runtime. useful to enable them by in gomacro, 18 | // without affecting packages that depend on gomacro, as Gophernotes 19 | var GENERICS = GENERICS_NONE 20 | 21 | func (g Generics) V1_CXX() bool { 22 | return g == GENERICS_V1_CXX 23 | } 24 | 25 | func (g Generics) V2_CTI() bool { 26 | return g == GENERICS_V2_CTI 27 | } 28 | -------------------------------------------------------------------------------- /go/etoken/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/go/etoken" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package etoken 5 | 6 | import ( 7 | r "reflect" 8 | 9 | "github.com/cosmos72/gomacro/imports" 10 | ) 11 | 12 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/go/etoken" 13 | func init() { 14 | imports.Packages["github.com/cosmos72/gomacro/go/etoken"] = imports.Package{ 15 | Binds: map[string]r.Value{ 16 | "FUNCTION": r.ValueOf(FUNCTION), 17 | "IsKeyword": r.ValueOf(IsKeyword), 18 | "IsLiteral": r.ValueOf(IsLiteral), 19 | "IsMacroKeyword": r.ValueOf(IsMacroKeyword), 20 | "IsOperator": r.ValueOf(IsOperator), 21 | "LAMBDA": r.ValueOf(LAMBDA), 22 | "Lookup": r.ValueOf(Lookup), 23 | "LookupSpecial": r.ValueOf(LookupSpecial), 24 | "MACRO": r.ValueOf(MACRO), 25 | "NewFileSet": r.ValueOf(NewFileSet), 26 | "QUASIQUOTE": r.ValueOf(QUASIQUOTE), 27 | "QUOTE": r.ValueOf(QUOTE), 28 | "String": r.ValueOf(String), 29 | "TYPECASE": r.ValueOf(TYPECASE), 30 | "UNQUOTE": r.ValueOf(UNQUOTE), 31 | "UNQUOTE_SPLICE": r.ValueOf(UNQUOTE_SPLICE), 32 | }, 33 | Types: map[string]r.Type{ 34 | "File": r.TypeOf((*File)(nil)).Elem(), 35 | "FileSet": r.TypeOf((*FileSet)(nil)).Elem(), 36 | "Token": r.TypeOf((*Token)(nil)).Elem(), 37 | }, 38 | Proxies: map[string]r.Type{}} 39 | } 40 | -------------------------------------------------------------------------------- /go/parser/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /go/parser/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/go/parser" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package parser 5 | 6 | import ( 7 | r "reflect" 8 | 9 | "github.com/cosmos72/gomacro/imports" 10 | ) 11 | 12 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/go/parser" 13 | func init() { 14 | imports.Packages["github.com/cosmos72/gomacro/go/parser"] = imports.Package{ 15 | Binds: map[string]r.Value{ 16 | "AllErrors": r.ValueOf(AllErrors), 17 | "DeclarationErrors": r.ValueOf(DeclarationErrors), 18 | "ImportsOnly": r.ValueOf(ImportsOnly), 19 | "MakeQuote": r.ValueOf(MakeQuote), 20 | "PackageClauseOnly": r.ValueOf(PackageClauseOnly), 21 | "ParseComments": r.ValueOf(ParseComments), 22 | "SpuriousErrors": r.ValueOf(SpuriousErrors), 23 | "Trace": r.ValueOf(Trace), 24 | }, Types: map[string]r.Type{ 25 | "Mode": r.TypeOf((*Mode)(nil)).Elem(), 26 | "Parser": r.TypeOf((*Parser)(nil)).Elem(), 27 | }, Wrappers: map[string][]string{ 28 | "Parser": []string{"Configure", "Init", "Parse"}, 29 | }, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /go/printer/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /go/printer/performance_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file implements a simple printer performance benchmark: 6 | // go test -bench=BenchmarkPrint 7 | 8 | package printer 9 | 10 | import ( 11 | "bytes" 12 | "go/ast" 13 | "go/parser" 14 | "io" 15 | "io/ioutil" 16 | "log" 17 | "testing" 18 | ) 19 | 20 | var testfile *ast.File 21 | 22 | func testprint(out io.Writer, file *ast.File) { 23 | if err := (&Config{TabIndent | UseSpaces, 8, 0}).Fprint(out, fset, file); err != nil { 24 | log.Fatalf("print error: %s", err) 25 | } 26 | } 27 | 28 | // cannot initialize in init because (printer) Fprint launches goroutines. 29 | func initialize() { 30 | const filename = "testdata/parser.go" 31 | 32 | src, err := ioutil.ReadFile(filename) 33 | if err != nil { 34 | log.Fatalf("%s", err) 35 | } 36 | 37 | file, err := parser.ParseFile(fset, filename, src, parser.ParseComments) 38 | if err != nil { 39 | log.Fatalf("%s", err) 40 | } 41 | 42 | var buf bytes.Buffer 43 | testprint(&buf, file) 44 | if !bytes.Equal(buf.Bytes(), src) { 45 | log.Fatalf("print error: %s not idempotent", filename) 46 | } 47 | 48 | testfile = file 49 | } 50 | 51 | func BenchmarkPrint(b *testing.B) { 52 | if testfile == nil { 53 | initialize() 54 | } 55 | for i := 0; i < b.N; i++ { 56 | testprint(ioutil.Discard, testfile) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /go/printer/testdata/comments.x: -------------------------------------------------------------------------------- 1 | // This is a package for testing comment placement by go/printer. 2 | // 3 | package main 4 | 5 | // The SZ struct; it is empty. 6 | type SZ struct{} 7 | 8 | // The S0 struct; no field is exported. 9 | type S0 struct { 10 | // contains filtered or unexported fields 11 | } 12 | 13 | // The S1 struct; some fields are not exported. 14 | type S1 struct { 15 | S0 16 | A, B, C float // 3 exported fields 17 | D int // 2 unexported fields 18 | // contains filtered or unexported fields 19 | } 20 | 21 | // The S2 struct; all fields are exported. 22 | type S2 struct { 23 | S1 24 | A, B, C float // 3 exported fields 25 | } 26 | 27 | // The IZ interface; it is empty. 28 | type SZ interface{} 29 | 30 | // The I0 interface; no method is exported. 31 | type I0 interface { 32 | // contains filtered or unexported methods 33 | } 34 | 35 | // The I1 interface; some methods are not exported. 36 | type I1 interface { 37 | I0 38 | F(x float) float // exported methods 39 | // contains filtered or unexported methods 40 | } 41 | 42 | // The I2 interface; all methods are exported. 43 | type I2 interface { 44 | I0 45 | F(x float) float // exported method 46 | G(x float) float // exported method 47 | } 48 | 49 | // The S3 struct; all comments except for the last one must appear in the export. 50 | type S3 struct { 51 | // lead comment for F1 52 | F1 int // line comment for F1 53 | // lead comment for F2 54 | F2 int // line comment for F2 55 | // contains filtered or unexported fields 56 | } 57 | -------------------------------------------------------------------------------- /go/printer/testdata/empty.golden: -------------------------------------------------------------------------------- 1 | // a comment at the beginning of the file 2 | 3 | package empty 4 | 5 | // a comment at the end of the file 6 | -------------------------------------------------------------------------------- /go/printer/testdata/empty.input: -------------------------------------------------------------------------------- 1 | // a comment at the beginning of the file 2 | 3 | package empty 4 | 5 | // a comment at the end of the file 6 | -------------------------------------------------------------------------------- /go/printer/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/go/printer" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package printer 5 | 6 | import ( 7 | r "reflect" 8 | 9 | "github.com/cosmos72/gomacro/imports" 10 | ) 11 | 12 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/go/printer" 13 | func init() { 14 | imports.Packages["github.com/cosmos72/gomacro/go/printer"] = imports.Package{ 15 | Binds: map[string]r.Value{ 16 | "Fprint": r.ValueOf(Fprint), 17 | "RawFormat": r.ValueOf(RawFormat), 18 | "SourcePos": r.ValueOf(SourcePos), 19 | "TabIndent": r.ValueOf(TabIndent), 20 | "UseSpaces": r.ValueOf(UseSpaces), 21 | }, Types: map[string]r.Type{ 22 | "CommentedNode": r.TypeOf((*CommentedNode)(nil)).Elem(), 23 | "Config": r.TypeOf((*Config)(nil)).Elem(), 24 | "Mode": r.TypeOf((*Mode)(nil)).Elem(), 25 | }, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /go/scanner/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /go/scanner/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/go/scanner" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package scanner 5 | 6 | import ( 7 | r "reflect" 8 | 9 | "github.com/cosmos72/gomacro/imports" 10 | ) 11 | 12 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/go/scanner" 13 | func init() { 14 | imports.Packages["github.com/cosmos72/gomacro/go/scanner"] = imports.Package{ 15 | Binds: map[string]r.Value{ 16 | "PrintError": r.ValueOf(PrintError), 17 | "ScanComments": r.ValueOf(ScanComments), 18 | }, 19 | Types: map[string]r.Type{ 20 | "Error": r.TypeOf((*Error)(nil)).Elem(), 21 | "ErrorHandler": r.TypeOf((*ErrorHandler)(nil)).Elem(), 22 | "ErrorList": r.TypeOf((*ErrorList)(nil)).Elem(), 23 | "Mode": r.TypeOf((*Mode)(nil)).Elem(), 24 | "Scanner": r.TypeOf((*Scanner)(nil)).Elem(), 25 | }, 26 | Proxies: map[string]r.Type{}} 27 | } 28 | -------------------------------------------------------------------------------- /go/types/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /go/types/objset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file implements objsets. 6 | // 7 | // An objset is similar to a Scope but objset elements 8 | // are identified by their unique id, instead of their 9 | // object name. 10 | 11 | package types 12 | 13 | // An objset is a set of objects identified by their unique id. 14 | // The zero value for objset is a ready-to-use empty objset. 15 | type objset map[string]Object // initialized lazily 16 | 17 | // insert attempts to insert an object obj into objset s. 18 | // If s already contains an alternative object alt with 19 | // the same name, insert leaves s unchanged and returns alt. 20 | // Otherwise it inserts obj and returns nil. 21 | func (s *objset) insert(obj Object) Object { 22 | id := obj.Id() 23 | if alt := (*s)[id]; alt != nil { 24 | return alt 25 | } 26 | if *s == nil { 27 | *s = make(map[string]Object) 28 | } 29 | (*s)[id] = obj 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /go/types/testdata/blank.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package _ /* ERROR invalid package name */ 6 | -------------------------------------------------------------------------------- /go/types/testdata/cycles1.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | type ( 8 | A interface { 9 | a() interface { 10 | ABC1 11 | } 12 | } 13 | B interface { 14 | b() interface { 15 | ABC2 16 | } 17 | } 18 | C interface { 19 | c() interface { 20 | ABC3 21 | } 22 | } 23 | 24 | AB interface { 25 | A 26 | B 27 | } 28 | BC interface { 29 | B 30 | C 31 | } 32 | 33 | ABC1 interface { 34 | A 35 | B 36 | C 37 | } 38 | ABC2 interface { 39 | AB 40 | C 41 | } 42 | ABC3 interface { 43 | A 44 | BC 45 | } 46 | ) 47 | 48 | var ( 49 | x1 ABC1 50 | x2 ABC2 51 | x3 ABC3 52 | ) 53 | 54 | func _() { 55 | // all types have the same method set 56 | x1 = x2 57 | x2 = x1 58 | 59 | x1 = x3 60 | x3 = x1 61 | 62 | x2 = x3 63 | x3 = x2 64 | 65 | // all methods return the same type again 66 | x1 = x1.a() 67 | x1 = x1.b() 68 | x1 = x1.c() 69 | 70 | x2 = x2.a() 71 | x2 = x2.b() 72 | x2 = x2.c() 73 | 74 | x3 = x3.a() 75 | x3 = x3.b() 76 | x3 = x3.c() 77 | } 78 | -------------------------------------------------------------------------------- /go/types/testdata/cycles2.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | import "unsafe" 8 | 9 | // Test case for issue 5090 10 | 11 | type t interface { 12 | f(u) 13 | } 14 | 15 | type u interface { 16 | t 17 | } 18 | 19 | func _() { 20 | var t t 21 | var u u 22 | 23 | t.f(t) 24 | t.f(u) 25 | 26 | u.f(t) 27 | u.f(u) 28 | } 29 | 30 | 31 | // Test case for issue 6589. 32 | 33 | type A interface { 34 | a() interface { 35 | AB 36 | } 37 | } 38 | 39 | type B interface { 40 | a() interface { 41 | AB 42 | } 43 | } 44 | 45 | type AB interface { 46 | a() interface { 47 | A 48 | B /* ERROR a redeclared */ 49 | } 50 | b() interface { 51 | A 52 | B /* ERROR a redeclared */ 53 | } 54 | } 55 | 56 | var x AB 57 | var y interface { 58 | A 59 | B /* ERROR a redeclared */ 60 | } 61 | var _ = x /* ERROR cannot compare */ == y 62 | 63 | 64 | // Test case for issue 6638. 65 | 66 | type T interface { 67 | m() [T /* ERROR no value */ (nil).m()[0]]int 68 | } 69 | 70 | // Variations of this test case. 71 | 72 | type T1 /* ERROR cycle */ interface { 73 | m() [x1.m()[0]]int 74 | } 75 | 76 | var x1 T1 77 | 78 | type T2 /* ERROR cycle */ interface { 79 | m() [len(x2.m())]int 80 | } 81 | 82 | var x2 T2 83 | 84 | type T3 /* ERROR cycle */ interface { 85 | m() [unsafe.Sizeof(x3.m)]int 86 | } 87 | 88 | var x3 T3 89 | 90 | type T4 /* ERROR cycle */ interface { 91 | m() [unsafe.Sizeof(cast4(x4.m))]int // cast is invalid but we have a cycle, so all bets are off 92 | } 93 | 94 | var x4 T4 95 | var _ = cast4(x4.m) 96 | 97 | type cast4 func() 98 | -------------------------------------------------------------------------------- /go/types/testdata/cycles3.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | import "unsafe" 8 | 9 | var ( 10 | _ A = A(nil).a().b().c().d().e().f() 11 | _ A = A(nil).b().c().d().e().f() 12 | _ A = A(nil).c().d().e().f() 13 | _ A = A(nil).d().e().f() 14 | _ A = A(nil).e().f() 15 | _ A = A(nil).f() 16 | _ A = A(nil) 17 | ) 18 | 19 | type ( 20 | A interface { 21 | a() B 22 | B 23 | } 24 | 25 | B interface { 26 | b() C 27 | C 28 | } 29 | 30 | C interface { 31 | c() D 32 | D 33 | } 34 | 35 | D interface { 36 | d() E 37 | E 38 | } 39 | 40 | E interface { 41 | e() F 42 | F 43 | } 44 | 45 | F interface { 46 | f() A 47 | } 48 | ) 49 | 50 | type ( 51 | U /* ERROR cycle */ interface { 52 | V 53 | } 54 | 55 | V interface { 56 | v() [unsafe.Sizeof(u)]int 57 | } 58 | ) 59 | 60 | var u U 61 | -------------------------------------------------------------------------------- /go/types/testdata/decls5.src: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | // declarations of main 8 | const _, main /* ERROR "cannot declare main" */ , _ = 0, 1, 2 9 | type main /* ERROR "cannot declare main" */ struct{} 10 | var _, main /* ERROR "cannot declare main" */ int 11 | -------------------------------------------------------------------------------- /go/types/testdata/importC.src: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package importC 6 | 7 | import "C" 8 | import _ /* ERROR cannot rename import "C" */ "C" 9 | import foo /* ERROR cannot rename import "C" */ "C" 10 | import . /* ERROR cannot rename import "C" */ "C" 11 | 12 | // Test cases extracted from issue #22090. 13 | 14 | import "unsafe" 15 | 16 | const _ C.int = 0xff // no error due to invalid constant type 17 | 18 | type T struct { 19 | Name string 20 | Ordinal int 21 | } 22 | 23 | func _(args []T) { 24 | var s string 25 | for i, v := range args { 26 | cname := C.CString(v.Name) 27 | args[i].Ordinal = int(C.sqlite3_bind_parameter_index(s, cname)) // no error due to i not being "used" 28 | C.free(unsafe.Pointer(cname)) 29 | } 30 | } 31 | 32 | type CType C.Type 33 | 34 | const _ CType = C.X // no error due to invalid constant type 35 | const _ = C.X 36 | 37 | // Test cases extracted from issue #23712. 38 | 39 | func _() { 40 | var a [C.ArrayLength]byte 41 | _ = a[0] // no index out of bounds error here 42 | } 43 | 44 | // Additional tests to verify fix for #23712. 45 | 46 | func _() { 47 | var a [C.ArrayLength1]byte 48 | _ = 1 / len(a) // no division by zero error here and below 49 | _ = 1 / cap(a) 50 | _ = uint(unsafe.Sizeof(a)) // must not be negative 51 | 52 | var b [C.ArrayLength2]byte 53 | a = b // should be valid 54 | } 55 | -------------------------------------------------------------------------------- /go/types/testdata/importdecl0a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package importdecl0 6 | 7 | import () 8 | 9 | import ( 10 | // we can have multiple blank imports (was bug) 11 | _ "math" 12 | _ "net/rpc" 13 | init /* ERROR "cannot declare init" */ "fmt" 14 | // reflect defines a type "flag" which shows up in the gc export data 15 | "reflect" 16 | . /* ERROR "imported but not used" */ "reflect" 17 | ) 18 | 19 | import "math" /* ERROR "imported but not used" */ 20 | import m /* ERROR "imported but not used as m" */ "math" 21 | import _ "math" 22 | 23 | import ( 24 | "math/big" /* ERROR "imported but not used" */ 25 | b /* ERROR "imported but not used" */ "math/big" 26 | _ "math/big" 27 | ) 28 | 29 | import "fmt" 30 | import f1 "fmt" 31 | import f2 "fmt" 32 | 33 | // reflect.flag must not be visible in this package 34 | type flag int 35 | type _ reflect.flag /* ERROR "not exported" */ 36 | 37 | // imported package name may conflict with local objects 38 | type reflect /* ERROR "reflect already declared" */ int 39 | 40 | // dot-imported exported objects may conflict with local objects 41 | type Value /* ERROR "Value already declared through dot-import of package reflect" */ struct{} 42 | 43 | var _ = fmt.Println // use "fmt" 44 | 45 | func _() { 46 | f1.Println() // use "fmt" 47 | } 48 | 49 | func _() { 50 | _ = func() { 51 | f2.Println() // use "fmt" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /go/types/testdata/importdecl0b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package importdecl0 6 | 7 | import "math" 8 | import m "math" 9 | 10 | import . "testing" // declares T in file scope 11 | import . /* ERROR "imported but not used" */ "unsafe" 12 | import . "fmt" // declares Println in file scope 13 | 14 | import ( 15 | // TODO(gri) At the moment, 2 errors are reported because both go/parser 16 | // and the type checker report it. Eventually, this test should not be 17 | // done by the parser anymore. 18 | "" /* ERROR invalid import path */ /* ERROR invalid import path */ 19 | "a!b" /* ERROR invalid import path */ /* ERROR invalid import path */ 20 | "abc\xffdef" /* ERROR invalid import path */ /* ERROR invalid import path */ 21 | ) 22 | 23 | // using "math" in this file doesn't affect its use in other files 24 | const Pi0 = math.Pi 25 | const Pi1 = m.Pi 26 | 27 | type _ T // use "testing" 28 | 29 | func _() func() interface{} { 30 | return func() interface{} { 31 | return Println // use "fmt" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /go/types/testdata/importdecl1a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Test case for issue 8969. 6 | 7 | package importdecl1 8 | 9 | import "go/ast" 10 | import . "unsafe" 11 | 12 | var _ Pointer // use dot-imported package unsafe 13 | 14 | // Test cases for issue 23914. 15 | 16 | type A interface { 17 | // Methods m1, m2 must be type-checked in this file scope 18 | // even when embedded in an interface in a different 19 | // file of the same package. 20 | m1() ast.Node 21 | m2() Pointer 22 | } 23 | -------------------------------------------------------------------------------- /go/types/testdata/importdecl1b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package importdecl1 6 | 7 | import . /* ERROR "imported but not used" */ "unsafe" 8 | 9 | type B interface { 10 | A 11 | } 12 | -------------------------------------------------------------------------------- /go/types/testdata/issue23203a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import "unsafe" 8 | 9 | type T struct{} 10 | 11 | func (T) m1() {} 12 | func (T) m2([unsafe.Sizeof(T.m1)]int) {} 13 | 14 | func main() {} 15 | -------------------------------------------------------------------------------- /go/types/testdata/issue23203b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import "unsafe" 8 | 9 | type T struct{} 10 | 11 | func (T) m2([unsafe.Sizeof(T.m1)]int) {} 12 | func (T) m1() {} 13 | 14 | func main() {} 15 | -------------------------------------------------------------------------------- /go/types/testdata/issue25008a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | import "io" 8 | 9 | type A interface { 10 | io.Reader 11 | } 12 | 13 | func f(a A) { 14 | a.Read(nil) 15 | } 16 | -------------------------------------------------------------------------------- /go/types/testdata/issue25008b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | type B interface { 8 | A 9 | } 10 | -------------------------------------------------------------------------------- /go/types/testdata/issue26390.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue26390 6 | 7 | type A = T 8 | 9 | func (t *T) m() *A { return t } 10 | 11 | type T struct{} 12 | -------------------------------------------------------------------------------- /go/types/testdata/issue28251.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file contains test cases for various forms of 6 | // method receiver declarations, per the spec clarification 7 | // https://golang.org/cl/142757. 8 | 9 | package issue28251 10 | 11 | // test case from issue28251 12 | type T struct{} 13 | 14 | type T0 = *T 15 | 16 | func (T0) m() {} 17 | 18 | func _() { (&T{}).m() } 19 | 20 | // various alternative forms 21 | type ( 22 | T1 = (((T))) 23 | ) 24 | 25 | func ((*(T1))) m1() {} 26 | func _() { (T{}).m2() } 27 | func _() { (&T{}).m2() } 28 | 29 | type ( 30 | T2 = (((T3))) 31 | T3 = T 32 | ) 33 | 34 | func (T2) m2() {} 35 | func _() { (T{}).m2() } 36 | func _() { (&T{}).m2() } 37 | 38 | type ( 39 | T4 = ((*(T5))) 40 | T5 = T 41 | ) 42 | 43 | func (T4) m4() {} 44 | func _() { (T{}).m4 /* ERROR m4 is not in method set of T */ () } 45 | func _() { (&T{}).m4() } 46 | 47 | type ( 48 | T6 = (((T7))) 49 | T7 = (*(T8)) 50 | T8 = T 51 | ) 52 | 53 | func (T6) m6() {} 54 | func _() { (T{}).m6 /* ERROR m6 is not in method set of T */ () } 55 | func _() { (&T{}).m6() } 56 | 57 | type ( 58 | T9 = *T10 59 | T10 = *T11 60 | T11 = T 61 | ) 62 | 63 | func (T9 /* ERROR invalid receiver \*\*T */ ) m9() {} 64 | func _() { (T{}).m9 /* ERROR has no field or method m9 */ () } 65 | func _() { (&T{}).m9 /* ERROR has no field or method m9 */ () } 66 | -------------------------------------------------------------------------------- /go/types/token_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file checks invariants of token.Token ordering that we rely on 6 | // since package go/token doesn't provide any guarantees at the moment. 7 | 8 | package types 9 | 10 | import ( 11 | "go/token" 12 | "testing" 13 | ) 14 | 15 | var assignOps = map[token.Token]token.Token{ 16 | token.ADD_ASSIGN: token.ADD, 17 | token.SUB_ASSIGN: token.SUB, 18 | token.MUL_ASSIGN: token.MUL, 19 | token.QUO_ASSIGN: token.QUO, 20 | token.REM_ASSIGN: token.REM, 21 | token.AND_ASSIGN: token.AND, 22 | token.OR_ASSIGN: token.OR, 23 | token.XOR_ASSIGN: token.XOR, 24 | token.SHL_ASSIGN: token.SHL, 25 | token.SHR_ASSIGN: token.SHR, 26 | token.AND_NOT_ASSIGN: token.AND_NOT, 27 | } 28 | 29 | func TestZeroTok(t *testing.T) { 30 | // zero value for token.Token must be token.ILLEGAL 31 | var zero token.Token 32 | if token.ILLEGAL != zero { 33 | t.Errorf("%s == %d; want 0", token.ILLEGAL, zero) 34 | } 35 | } 36 | 37 | func TestAssignOp(t *testing.T) { 38 | // there are fewer than 256 tokens 39 | for i := 0; i < 256; i++ { 40 | tok := token.Token(i) 41 | got := assignOp(tok) 42 | want := assignOps[tok] 43 | if got != want { 44 | t.Errorf("for assignOp(%s): got %s; want %s", tok, got, want) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /go/typeutil/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /go/typeutil/README.md: -------------------------------------------------------------------------------- 1 | ## typeutil - patched versions of `go/types.Identical` and `golang.org/x/tools/go/type/typeutil.Map` 2 | 3 | typeutil contains patched version of some Go utilities to handle `github.com/cosmos72/gomacro/go/types.Type` 4 | 5 | 1. an Identical() function with a stricter definition of type identity: 6 | 7 | * interfaces are considered identical only if they **print** equally, 8 | so embedding an interface is **different** from copying its methods 9 | (standard `go/types.Identical` intentionally does not distinguish 10 | these two cases). Also, the order of methods and embedded interfaces 11 | is relevant. 12 | 13 | * methods are considered identical only if their receiver, parameters 14 | and results types are identical (standard `go/types.Identical` 15 | intentionally ignores the receiver type) 16 | 17 | 2. Map: a mapping from `go/types.Type` to `interface{}` values, 18 | using the stricter definition of type identity defined above. 19 | 20 | Since `github.com/cosmos72/gomacro/go/types.Type` are not canonical, 21 | i.e. not unique, comparing them with == does not give the expected results, 22 | as explained in https://github.com/golang/example/tree/master/gotypes#types 23 | 24 | So a specialized map is needed to use them as keys - either 25 | `golang.org/x/tools/go/type/typeutil.Map`, or this patched version 26 | `github.com/cosmos72/gomacro/go/typeutil/Map`, or something analogous 27 | 28 | They are useful as type canonicalizing tools for the Go interpreter gomacro, 29 | and not necessarily suitable for other purpouses. 30 | 31 | ## License 32 | 33 | BSD-3-Clause as the original, unpatched utilities. 34 | 35 | -------------------------------------------------------------------------------- /go/typeutil/x_package.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _i "github.com/cosmos72/gomacro/typeutil" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package typeutil 5 | 6 | import ( 7 | r "reflect" 8 | 9 | "github.com/cosmos72/gomacro/imports" 10 | ) 11 | 12 | // reflection: allow interpreted code to import "github.com/cosmos72/gomacro/typeutil" 13 | func init() { 14 | imports.Packages["github.com/cosmos72/gomacro/typeutil"] = imports.Package{ 15 | Binds: map[string]r.Value{ 16 | "Identical": r.ValueOf(Identical), 17 | "IdenticalIgnoreTags": r.ValueOf(IdenticalIgnoreTags), 18 | "MakeHasher": r.ValueOf(MakeHasher), 19 | }, 20 | Types: map[string]r.Type{ 21 | "Hasher": r.TypeOf((*Hasher)(nil)).Elem(), 22 | "Map": r.TypeOf((*Map)(nil)).Elem(), 23 | }, 24 | Proxies: map[string]r.Type{}} 25 | } 26 | -------------------------------------------------------------------------------- /imports/archive_zip.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "archive/zip" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | zip "archive/zip" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "archive/zip" 12 | func init() { 13 | Packages["archive/zip"] = Package{ 14 | Name: "zip", 15 | Binds: map[string]Value{ 16 | "Deflate": ValueOf(zip.Deflate), 17 | "ErrAlgorithm": ValueOf(&zip.ErrAlgorithm).Elem(), 18 | "ErrChecksum": ValueOf(&zip.ErrChecksum).Elem(), 19 | "ErrFormat": ValueOf(&zip.ErrFormat).Elem(), 20 | "FileInfoHeader": ValueOf(zip.FileInfoHeader), 21 | "NewReader": ValueOf(zip.NewReader), 22 | "NewWriter": ValueOf(zip.NewWriter), 23 | "OpenReader": ValueOf(zip.OpenReader), 24 | "RegisterCompressor": ValueOf(zip.RegisterCompressor), 25 | "RegisterDecompressor": ValueOf(zip.RegisterDecompressor), 26 | "Store": ValueOf(zip.Store), 27 | }, Types: map[string]Type{ 28 | "Compressor": TypeOf((*zip.Compressor)(nil)).Elem(), 29 | "Decompressor": TypeOf((*zip.Decompressor)(nil)).Elem(), 30 | "File": TypeOf((*zip.File)(nil)).Elem(), 31 | "FileHeader": TypeOf((*zip.FileHeader)(nil)).Elem(), 32 | "ReadCloser": TypeOf((*zip.ReadCloser)(nil)).Elem(), 33 | "Reader": TypeOf((*zip.Reader)(nil)).Elem(), 34 | "Writer": TypeOf((*zip.Writer)(nil)).Elem(), 35 | }, Wrappers: map[string][]string{ 36 | "File": []string{"FileInfo","ModTime","Mode","SetModTime","SetMode",}, 37 | "ReadCloser": []string{"Open","RegisterDecompressor",}, 38 | }, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /imports/compress_bzip2.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "compress/bzip2" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | bzip2 "compress/bzip2" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "compress/bzip2" 12 | func init() { 13 | Packages["compress/bzip2"] = Package{ 14 | Name: "bzip2", 15 | Binds: map[string]Value{ 16 | "NewReader": ValueOf(bzip2.NewReader), 17 | }, Types: map[string]Type{ 18 | "StructuralError": TypeOf((*bzip2.StructuralError)(nil)).Elem(), 19 | }, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /imports/compress_gzip.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "compress/gzip" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | gzip "compress/gzip" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "compress/gzip" 12 | func init() { 13 | Packages["compress/gzip"] = Package{ 14 | Name: "gzip", 15 | Binds: map[string]Value{ 16 | "BestCompression": ValueOf(gzip.BestCompression), 17 | "BestSpeed": ValueOf(gzip.BestSpeed), 18 | "DefaultCompression": ValueOf(gzip.DefaultCompression), 19 | "ErrChecksum": ValueOf(&gzip.ErrChecksum).Elem(), 20 | "ErrHeader": ValueOf(&gzip.ErrHeader).Elem(), 21 | "HuffmanOnly": ValueOf(gzip.HuffmanOnly), 22 | "NewReader": ValueOf(gzip.NewReader), 23 | "NewWriter": ValueOf(gzip.NewWriter), 24 | "NewWriterLevel": ValueOf(gzip.NewWriterLevel), 25 | "NoCompression": ValueOf(gzip.NoCompression), 26 | }, Types: map[string]Type{ 27 | "Header": TypeOf((*gzip.Header)(nil)).Elem(), 28 | "Reader": TypeOf((*gzip.Reader)(nil)).Elem(), 29 | "Writer": TypeOf((*gzip.Writer)(nil)).Elem(), 30 | }, Untypeds: map[string]string{ 31 | "BestCompression": "int:9", 32 | "BestSpeed": "int:1", 33 | "DefaultCompression": "int:-1", 34 | "HuffmanOnly": "int:-2", 35 | "NoCompression": "int:0", 36 | }, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /imports/compress_lzw.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "compress/lzw" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | lzw "compress/lzw" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "compress/lzw" 12 | func init() { 13 | Packages["compress/lzw"] = Package{ 14 | Name: "lzw", 15 | Binds: map[string]Value{ 16 | "LSB": ValueOf(lzw.LSB), 17 | "MSB": ValueOf(lzw.MSB), 18 | "NewReader": ValueOf(lzw.NewReader), 19 | "NewWriter": ValueOf(lzw.NewWriter), 20 | }, Types: map[string]Type{ 21 | "Order": TypeOf((*lzw.Order)(nil)).Elem(), 22 | "Reader": TypeOf((*lzw.Reader)(nil)).Elem(), 23 | "Writer": TypeOf((*lzw.Writer)(nil)).Elem(), 24 | }, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /imports/container_heap.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "container/heap" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | heap "container/heap" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "container/heap" 12 | func init() { 13 | Packages["container/heap"] = Package{ 14 | Name: "heap", 15 | Binds: map[string]Value{ 16 | "Fix": ValueOf(heap.Fix), 17 | "Init": ValueOf(heap.Init), 18 | "Pop": ValueOf(heap.Pop), 19 | "Push": ValueOf(heap.Push), 20 | "Remove": ValueOf(heap.Remove), 21 | }, Types: map[string]Type{ 22 | "Interface": TypeOf((*heap.Interface)(nil)).Elem(), 23 | }, Proxies: map[string]Type{ 24 | "Interface": TypeOf((*P_container_heap_Interface)(nil)).Elem(), 25 | }, 26 | } 27 | } 28 | 29 | // --------------- proxy for container/heap.Interface --------------- 30 | type P_container_heap_Interface struct { 31 | Object interface{} 32 | Len_ func(interface{}) int 33 | Less_ func(_proxy_obj_ interface{}, i int, j int) bool 34 | Pop_ func(interface{}) any 35 | Push_ func(_proxy_obj_ interface{}, x any) 36 | Swap_ func(_proxy_obj_ interface{}, i int, j int) 37 | } 38 | func (P *P_container_heap_Interface) Len() int { 39 | return P.Len_(P.Object) 40 | } 41 | func (P *P_container_heap_Interface) Less(i int, j int) bool { 42 | return P.Less_(P.Object, i, j) 43 | } 44 | func (P *P_container_heap_Interface) Pop() any { 45 | return P.Pop_(P.Object) 46 | } 47 | func (P *P_container_heap_Interface) Push(x any) { 48 | P.Push_(P.Object, x) 49 | } 50 | func (P *P_container_heap_Interface) Swap(i int, j int) { 51 | P.Swap_(P.Object, i, j) 52 | } 53 | -------------------------------------------------------------------------------- /imports/container_list.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "container/list" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | list "container/list" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "container/list" 12 | func init() { 13 | Packages["container/list"] = Package{ 14 | Name: "list", 15 | Binds: map[string]Value{ 16 | "New": ValueOf(list.New), 17 | }, Types: map[string]Type{ 18 | "Element": TypeOf((*list.Element)(nil)).Elem(), 19 | "List": TypeOf((*list.List)(nil)).Elem(), 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /imports/container_ring.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "container/ring" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | ring "container/ring" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "container/ring" 12 | func init() { 13 | Packages["container/ring"] = Package{ 14 | Name: "ring", 15 | Binds: map[string]Value{ 16 | "New": ValueOf(ring.New), 17 | }, Types: map[string]Type{ 18 | "Ring": TypeOf((*ring.Ring)(nil)).Elem(), 19 | }, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /imports/crypto_aes.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/aes" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | aes "crypto/aes" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/aes" 12 | func init() { 13 | Packages["crypto/aes"] = Package{ 14 | Name: "aes", 15 | Binds: map[string]Value{ 16 | "BlockSize": ValueOf(aes.BlockSize), 17 | "NewCipher": ValueOf(aes.NewCipher), 18 | }, Types: map[string]Type{ 19 | "KeySizeError": TypeOf((*aes.KeySizeError)(nil)).Elem(), 20 | }, Untypeds: map[string]string{ 21 | "BlockSize": "int:16", 22 | }, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /imports/crypto_des.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/des" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | des "crypto/des" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/des" 12 | func init() { 13 | Packages["crypto/des"] = Package{ 14 | Name: "des", 15 | Binds: map[string]Value{ 16 | "BlockSize": ValueOf(des.BlockSize), 17 | "NewCipher": ValueOf(des.NewCipher), 18 | "NewTripleDESCipher": ValueOf(des.NewTripleDESCipher), 19 | }, Types: map[string]Type{ 20 | "KeySizeError": TypeOf((*des.KeySizeError)(nil)).Elem(), 21 | }, Untypeds: map[string]string{ 22 | "BlockSize": "int:8", 23 | }, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /imports/crypto_dsa.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/dsa" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | dsa "crypto/dsa" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/dsa" 12 | func init() { 13 | Packages["crypto/dsa"] = Package{ 14 | Name: "dsa", 15 | Binds: map[string]Value{ 16 | "ErrInvalidPublicKey": ValueOf(&dsa.ErrInvalidPublicKey).Elem(), 17 | "GenerateKey": ValueOf(dsa.GenerateKey), 18 | "GenerateParameters": ValueOf(dsa.GenerateParameters), 19 | "L1024N160": ValueOf(dsa.L1024N160), 20 | "L2048N224": ValueOf(dsa.L2048N224), 21 | "L2048N256": ValueOf(dsa.L2048N256), 22 | "L3072N256": ValueOf(dsa.L3072N256), 23 | "Sign": ValueOf(dsa.Sign), 24 | "Verify": ValueOf(dsa.Verify), 25 | }, Types: map[string]Type{ 26 | "ParameterSizes": TypeOf((*dsa.ParameterSizes)(nil)).Elem(), 27 | "Parameters": TypeOf((*dsa.Parameters)(nil)).Elem(), 28 | "PrivateKey": TypeOf((*dsa.PrivateKey)(nil)).Elem(), 29 | "PublicKey": TypeOf((*dsa.PublicKey)(nil)).Elem(), 30 | }, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /imports/crypto_ecdsa.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/ecdsa" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | ecdsa "crypto/ecdsa" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/ecdsa" 12 | func init() { 13 | Packages["crypto/ecdsa"] = Package{ 14 | Name: "ecdsa", 15 | Binds: map[string]Value{ 16 | "GenerateKey": ValueOf(ecdsa.GenerateKey), 17 | "Sign": ValueOf(ecdsa.Sign), 18 | "SignASN1": ValueOf(ecdsa.SignASN1), 19 | "Verify": ValueOf(ecdsa.Verify), 20 | "VerifyASN1": ValueOf(ecdsa.VerifyASN1), 21 | }, Types: map[string]Type{ 22 | "PrivateKey": TypeOf((*ecdsa.PrivateKey)(nil)).Elem(), 23 | "PublicKey": TypeOf((*ecdsa.PublicKey)(nil)).Elem(), 24 | }, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /imports/crypto_ed25519.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/ed25519" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | ed25519 "crypto/ed25519" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/ed25519" 12 | func init() { 13 | Packages["crypto/ed25519"] = Package{ 14 | Name: "ed25519", 15 | Binds: map[string]Value{ 16 | "GenerateKey": ValueOf(ed25519.GenerateKey), 17 | "NewKeyFromSeed": ValueOf(ed25519.NewKeyFromSeed), 18 | "PrivateKeySize": ValueOf(ed25519.PrivateKeySize), 19 | "PublicKeySize": ValueOf(ed25519.PublicKeySize), 20 | "SeedSize": ValueOf(ed25519.SeedSize), 21 | "Sign": ValueOf(ed25519.Sign), 22 | "SignatureSize": ValueOf(ed25519.SignatureSize), 23 | "Verify": ValueOf(ed25519.Verify), 24 | }, Types: map[string]Type{ 25 | "PrivateKey": TypeOf((*ed25519.PrivateKey)(nil)).Elem(), 26 | "PublicKey": TypeOf((*ed25519.PublicKey)(nil)).Elem(), 27 | }, Untypeds: map[string]string{ 28 | "PrivateKeySize": "int:64", 29 | "PublicKeySize": "int:32", 30 | "SeedSize": "int:32", 31 | "SignatureSize": "int:64", 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /imports/crypto_hmac.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/hmac" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | hmac "crypto/hmac" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/hmac" 12 | func init() { 13 | Packages["crypto/hmac"] = Package{ 14 | Name: "hmac", 15 | Binds: map[string]Value{ 16 | "Equal": ValueOf(hmac.Equal), 17 | "New": ValueOf(hmac.New), 18 | }, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /imports/crypto_md5.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/md5" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | md5 "crypto/md5" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/md5" 12 | func init() { 13 | Packages["crypto/md5"] = Package{ 14 | Name: "md5", 15 | Binds: map[string]Value{ 16 | "BlockSize": ValueOf(md5.BlockSize), 17 | "New": ValueOf(md5.New), 18 | "Size": ValueOf(md5.Size), 19 | "Sum": ValueOf(md5.Sum), 20 | }, Untypeds: map[string]string{ 21 | "BlockSize": "int:64", 22 | "Size": "int:16", 23 | }, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /imports/crypto_rand.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/rand" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | rand "crypto/rand" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/rand" 12 | func init() { 13 | Packages["crypto/rand"] = Package{ 14 | Name: "rand", 15 | Binds: map[string]Value{ 16 | "Int": ValueOf(rand.Int), 17 | "Prime": ValueOf(rand.Prime), 18 | "Read": ValueOf(rand.Read), 19 | "Reader": ValueOf(&rand.Reader).Elem(), 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /imports/crypto_rc4.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/rc4" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | rc4 "crypto/rc4" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/rc4" 12 | func init() { 13 | Packages["crypto/rc4"] = Package{ 14 | Name: "rc4", 15 | Binds: map[string]Value{ 16 | "NewCipher": ValueOf(rc4.NewCipher), 17 | }, Types: map[string]Type{ 18 | "Cipher": TypeOf((*rc4.Cipher)(nil)).Elem(), 19 | "KeySizeError": TypeOf((*rc4.KeySizeError)(nil)).Elem(), 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /imports/crypto_sha1.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/sha1" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | sha1 "crypto/sha1" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/sha1" 12 | func init() { 13 | Packages["crypto/sha1"] = Package{ 14 | Name: "sha1", 15 | Binds: map[string]Value{ 16 | "BlockSize": ValueOf(sha1.BlockSize), 17 | "New": ValueOf(sha1.New), 18 | "Size": ValueOf(sha1.Size), 19 | "Sum": ValueOf(sha1.Sum), 20 | }, Untypeds: map[string]string{ 21 | "BlockSize": "int:64", 22 | "Size": "int:20", 23 | }, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /imports/crypto_sha256.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/sha256" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | sha256 "crypto/sha256" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/sha256" 12 | func init() { 13 | Packages["crypto/sha256"] = Package{ 14 | Name: "sha256", 15 | Binds: map[string]Value{ 16 | "BlockSize": ValueOf(sha256.BlockSize), 17 | "New": ValueOf(sha256.New), 18 | "New224": ValueOf(sha256.New224), 19 | "Size": ValueOf(sha256.Size), 20 | "Size224": ValueOf(sha256.Size224), 21 | "Sum224": ValueOf(sha256.Sum224), 22 | "Sum256": ValueOf(sha256.Sum256), 23 | }, Untypeds: map[string]string{ 24 | "BlockSize": "int:64", 25 | "Size": "int:32", 26 | "Size224": "int:28", 27 | }, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /imports/crypto_sha512.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/sha512" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | sha512 "crypto/sha512" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/sha512" 12 | func init() { 13 | Packages["crypto/sha512"] = Package{ 14 | Name: "sha512", 15 | Binds: map[string]Value{ 16 | "BlockSize": ValueOf(sha512.BlockSize), 17 | "New": ValueOf(sha512.New), 18 | "New384": ValueOf(sha512.New384), 19 | "New512_224": ValueOf(sha512.New512_224), 20 | "New512_256": ValueOf(sha512.New512_256), 21 | "Size": ValueOf(sha512.Size), 22 | "Size224": ValueOf(sha512.Size224), 23 | "Size256": ValueOf(sha512.Size256), 24 | "Size384": ValueOf(sha512.Size384), 25 | "Sum384": ValueOf(sha512.Sum384), 26 | "Sum512": ValueOf(sha512.Sum512), 27 | "Sum512_224": ValueOf(sha512.Sum512_224), 28 | "Sum512_256": ValueOf(sha512.Sum512_256), 29 | }, Untypeds: map[string]string{ 30 | "BlockSize": "int:128", 31 | "Size": "int:64", 32 | "Size224": "int:28", 33 | "Size256": "int:32", 34 | "Size384": "int:48", 35 | }, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /imports/crypto_subtle.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/subtle" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | subtle "crypto/subtle" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/subtle" 12 | func init() { 13 | Packages["crypto/subtle"] = Package{ 14 | Name: "subtle", 15 | Binds: map[string]Value{ 16 | "ConstantTimeByteEq": ValueOf(subtle.ConstantTimeByteEq), 17 | "ConstantTimeCompare": ValueOf(subtle.ConstantTimeCompare), 18 | "ConstantTimeCopy": ValueOf(subtle.ConstantTimeCopy), 19 | "ConstantTimeEq": ValueOf(subtle.ConstantTimeEq), 20 | "ConstantTimeLessOrEq": ValueOf(subtle.ConstantTimeLessOrEq), 21 | "ConstantTimeSelect": ValueOf(subtle.ConstantTimeSelect), 22 | }, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /imports/crypto_x509_pkix.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "crypto/x509/pkix" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | pkix "crypto/x509/pkix" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "crypto/x509/pkix" 12 | func init() { 13 | Packages["crypto/x509/pkix"] = Package{ 14 | Name: "pkix", 15 | Types: map[string]Type{ 16 | "AlgorithmIdentifier": TypeOf((*pkix.AlgorithmIdentifier)(nil)).Elem(), 17 | "AttributeTypeAndValue": TypeOf((*pkix.AttributeTypeAndValue)(nil)).Elem(), 18 | "AttributeTypeAndValueSET": TypeOf((*pkix.AttributeTypeAndValueSET)(nil)).Elem(), 19 | "CertificateList": TypeOf((*pkix.CertificateList)(nil)).Elem(), 20 | "Extension": TypeOf((*pkix.Extension)(nil)).Elem(), 21 | "Name": TypeOf((*pkix.Name)(nil)).Elem(), 22 | "RDNSequence": TypeOf((*pkix.RDNSequence)(nil)).Elem(), 23 | "RelativeDistinguishedNameSET": TypeOf((*pkix.RelativeDistinguishedNameSET)(nil)).Elem(), 24 | "RevokedCertificate": TypeOf((*pkix.RevokedCertificate)(nil)).Elem(), 25 | "TBSCertificateList": TypeOf((*pkix.TBSCertificateList)(nil)).Elem(), 26 | }, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /imports/debug_buildinfo.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "debug/buildinfo" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | buildinfo "debug/buildinfo" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "debug/buildinfo" 12 | func init() { 13 | Packages["debug/buildinfo"] = Package{ 14 | Name: "buildinfo", 15 | Binds: map[string]Value{ 16 | "Read": ValueOf(buildinfo.Read), 17 | "ReadFile": ValueOf(buildinfo.ReadFile), 18 | }, Types: map[string]Type{ 19 | "BuildInfo": TypeOf((*buildinfo.BuildInfo)(nil)).Elem(), 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /imports/debug_gosym.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "debug/gosym" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | gosym "debug/gosym" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "debug/gosym" 12 | func init() { 13 | Packages["debug/gosym"] = Package{ 14 | Name: "gosym", 15 | Binds: map[string]Value{ 16 | "NewLineTable": ValueOf(gosym.NewLineTable), 17 | "NewTable": ValueOf(gosym.NewTable), 18 | }, Types: map[string]Type{ 19 | "DecodingError": TypeOf((*gosym.DecodingError)(nil)).Elem(), 20 | "Func": TypeOf((*gosym.Func)(nil)).Elem(), 21 | "LineTable": TypeOf((*gosym.LineTable)(nil)).Elem(), 22 | "Obj": TypeOf((*gosym.Obj)(nil)).Elem(), 23 | "Sym": TypeOf((*gosym.Sym)(nil)).Elem(), 24 | "Table": TypeOf((*gosym.Table)(nil)).Elem(), 25 | "UnknownFileError": TypeOf((*gosym.UnknownFileError)(nil)).Elem(), 26 | "UnknownLineError": TypeOf((*gosym.UnknownLineError)(nil)).Elem(), 27 | }, Wrappers: map[string][]string{ 28 | "Func": []string{"BaseName","PackageName","ReceiverName","Static",}, 29 | }, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /imports/debug_plan9obj.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "debug/plan9obj" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | plan9obj "debug/plan9obj" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "debug/plan9obj" 12 | func init() { 13 | Packages["debug/plan9obj"] = Package{ 14 | Name: "plan9obj", 15 | Binds: map[string]Value{ 16 | "ErrNoSymbols": ValueOf(&plan9obj.ErrNoSymbols).Elem(), 17 | "Magic386": ValueOf(plan9obj.Magic386), 18 | "Magic64": ValueOf(plan9obj.Magic64), 19 | "MagicAMD64": ValueOf(plan9obj.MagicAMD64), 20 | "MagicARM": ValueOf(plan9obj.MagicARM), 21 | "NewFile": ValueOf(plan9obj.NewFile), 22 | "Open": ValueOf(plan9obj.Open), 23 | }, Types: map[string]Type{ 24 | "File": TypeOf((*plan9obj.File)(nil)).Elem(), 25 | "FileHeader": TypeOf((*plan9obj.FileHeader)(nil)).Elem(), 26 | "Section": TypeOf((*plan9obj.Section)(nil)).Elem(), 27 | "SectionHeader": TypeOf((*plan9obj.SectionHeader)(nil)).Elem(), 28 | "Sym": TypeOf((*plan9obj.Sym)(nil)).Elem(), 29 | }, Untypeds: map[string]string{ 30 | "Magic386": "int:491", 31 | "Magic64": "int:32768", 32 | "MagicAMD64": "int:35479", 33 | "MagicARM": "int:1607", 34 | }, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /imports/embed.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "embed" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | embed "embed" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "embed" 12 | func init() { 13 | Packages["embed"] = Package{ 14 | Name: "embed", 15 | Types: map[string]Type{ 16 | "FS": TypeOf((*embed.FS)(nil)).Elem(), 17 | }, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /imports/encoding_ascii85.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "encoding/ascii85" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | ascii85 "encoding/ascii85" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "encoding/ascii85" 12 | func init() { 13 | Packages["encoding/ascii85"] = Package{ 14 | Name: "ascii85", 15 | Binds: map[string]Value{ 16 | "Decode": ValueOf(ascii85.Decode), 17 | "Encode": ValueOf(ascii85.Encode), 18 | "MaxEncodedLen": ValueOf(ascii85.MaxEncodedLen), 19 | "NewDecoder": ValueOf(ascii85.NewDecoder), 20 | "NewEncoder": ValueOf(ascii85.NewEncoder), 21 | }, Types: map[string]Type{ 22 | "CorruptInputError": TypeOf((*ascii85.CorruptInputError)(nil)).Elem(), 23 | }, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /imports/encoding_base32.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "encoding/base32" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | base32 "encoding/base32" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "encoding/base32" 12 | func init() { 13 | Packages["encoding/base32"] = Package{ 14 | Name: "base32", 15 | Binds: map[string]Value{ 16 | "HexEncoding": ValueOf(&base32.HexEncoding).Elem(), 17 | "NewDecoder": ValueOf(base32.NewDecoder), 18 | "NewEncoder": ValueOf(base32.NewEncoder), 19 | "NewEncoding": ValueOf(base32.NewEncoding), 20 | "NoPadding": ValueOf(base32.NoPadding), 21 | "StdEncoding": ValueOf(&base32.StdEncoding).Elem(), 22 | "StdPadding": ValueOf(base32.StdPadding), 23 | }, Types: map[string]Type{ 24 | "CorruptInputError": TypeOf((*base32.CorruptInputError)(nil)).Elem(), 25 | "Encoding": TypeOf((*base32.Encoding)(nil)).Elem(), 26 | }, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /imports/encoding_base64.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "encoding/base64" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | base64 "encoding/base64" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "encoding/base64" 12 | func init() { 13 | Packages["encoding/base64"] = Package{ 14 | Name: "base64", 15 | Binds: map[string]Value{ 16 | "NewDecoder": ValueOf(base64.NewDecoder), 17 | "NewEncoder": ValueOf(base64.NewEncoder), 18 | "NewEncoding": ValueOf(base64.NewEncoding), 19 | "NoPadding": ValueOf(base64.NoPadding), 20 | "RawStdEncoding": ValueOf(&base64.RawStdEncoding).Elem(), 21 | "RawURLEncoding": ValueOf(&base64.RawURLEncoding).Elem(), 22 | "StdEncoding": ValueOf(&base64.StdEncoding).Elem(), 23 | "StdPadding": ValueOf(base64.StdPadding), 24 | "URLEncoding": ValueOf(&base64.URLEncoding).Elem(), 25 | }, Types: map[string]Type{ 26 | "CorruptInputError": TypeOf((*base64.CorruptInputError)(nil)).Elem(), 27 | "Encoding": TypeOf((*base64.Encoding)(nil)).Elem(), 28 | }, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /imports/encoding_csv.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "encoding/csv" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | csv "encoding/csv" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "encoding/csv" 12 | func init() { 13 | Packages["encoding/csv"] = Package{ 14 | Name: "csv", 15 | Binds: map[string]Value{ 16 | "ErrBareQuote": ValueOf(&csv.ErrBareQuote).Elem(), 17 | "ErrFieldCount": ValueOf(&csv.ErrFieldCount).Elem(), 18 | "ErrQuote": ValueOf(&csv.ErrQuote).Elem(), 19 | "ErrTrailingComma": ValueOf(&csv.ErrTrailingComma).Elem(), 20 | "NewReader": ValueOf(csv.NewReader), 21 | "NewWriter": ValueOf(csv.NewWriter), 22 | }, Types: map[string]Type{ 23 | "ParseError": TypeOf((*csv.ParseError)(nil)).Elem(), 24 | "Reader": TypeOf((*csv.Reader)(nil)).Elem(), 25 | "Writer": TypeOf((*csv.Writer)(nil)).Elem(), 26 | }, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /imports/encoding_gob.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "encoding/gob" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | gob "encoding/gob" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "encoding/gob" 12 | func init() { 13 | Packages["encoding/gob"] = Package{ 14 | Name: "gob", 15 | Binds: map[string]Value{ 16 | "NewDecoder": ValueOf(gob.NewDecoder), 17 | "NewEncoder": ValueOf(gob.NewEncoder), 18 | "Register": ValueOf(gob.Register), 19 | "RegisterName": ValueOf(gob.RegisterName), 20 | }, Types: map[string]Type{ 21 | "CommonType": TypeOf((*gob.CommonType)(nil)).Elem(), 22 | "Decoder": TypeOf((*gob.Decoder)(nil)).Elem(), 23 | "Encoder": TypeOf((*gob.Encoder)(nil)).Elem(), 24 | "GobDecoder": TypeOf((*gob.GobDecoder)(nil)).Elem(), 25 | "GobEncoder": TypeOf((*gob.GobEncoder)(nil)).Elem(), 26 | }, Proxies: map[string]Type{ 27 | "GobDecoder": TypeOf((*P_encoding_gob_GobDecoder)(nil)).Elem(), 28 | "GobEncoder": TypeOf((*P_encoding_gob_GobEncoder)(nil)).Elem(), 29 | }, 30 | } 31 | } 32 | 33 | // --------------- proxy for encoding/gob.GobDecoder --------------- 34 | type P_encoding_gob_GobDecoder struct { 35 | Object interface{} 36 | GobDecode_ func(interface{}, []byte) error 37 | } 38 | func (P *P_encoding_gob_GobDecoder) GobDecode(unnamed0 []byte) error { 39 | return P.GobDecode_(P.Object, unnamed0) 40 | } 41 | 42 | // --------------- proxy for encoding/gob.GobEncoder --------------- 43 | type P_encoding_gob_GobEncoder struct { 44 | Object interface{} 45 | GobEncode_ func(interface{}) ([]byte, error) 46 | } 47 | func (P *P_encoding_gob_GobEncoder) GobEncode() ([]byte, error) { 48 | return P.GobEncode_(P.Object) 49 | } 50 | -------------------------------------------------------------------------------- /imports/encoding_hex.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "encoding/hex" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | hex "encoding/hex" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "encoding/hex" 12 | func init() { 13 | Packages["encoding/hex"] = Package{ 14 | Name: "hex", 15 | Binds: map[string]Value{ 16 | "Decode": ValueOf(hex.Decode), 17 | "DecodeString": ValueOf(hex.DecodeString), 18 | "DecodedLen": ValueOf(hex.DecodedLen), 19 | "Dump": ValueOf(hex.Dump), 20 | "Dumper": ValueOf(hex.Dumper), 21 | "Encode": ValueOf(hex.Encode), 22 | "EncodeToString": ValueOf(hex.EncodeToString), 23 | "EncodedLen": ValueOf(hex.EncodedLen), 24 | "ErrLength": ValueOf(&hex.ErrLength).Elem(), 25 | "NewDecoder": ValueOf(hex.NewDecoder), 26 | "NewEncoder": ValueOf(hex.NewEncoder), 27 | }, Types: map[string]Type{ 28 | "InvalidByteError": TypeOf((*hex.InvalidByteError)(nil)).Elem(), 29 | }, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /imports/encoding_pem.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "encoding/pem" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | pem "encoding/pem" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "encoding/pem" 12 | func init() { 13 | Packages["encoding/pem"] = Package{ 14 | Name: "pem", 15 | Binds: map[string]Value{ 16 | "Decode": ValueOf(pem.Decode), 17 | "Encode": ValueOf(pem.Encode), 18 | "EncodeToMemory": ValueOf(pem.EncodeToMemory), 19 | }, Types: map[string]Type{ 20 | "Block": TypeOf((*pem.Block)(nil)).Elem(), 21 | }, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /imports/errors.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "errors" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | errors "errors" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "errors" 12 | func init() { 13 | Packages["errors"] = Package{ 14 | Name: "errors", 15 | Binds: map[string]Value{ 16 | "As": ValueOf(errors.As), 17 | "Is": ValueOf(errors.Is), 18 | "New": ValueOf(errors.New), 19 | "Unwrap": ValueOf(errors.Unwrap), 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /imports/expvar.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "expvar" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | expvar "expvar" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "expvar" 12 | func init() { 13 | Packages["expvar"] = Package{ 14 | Name: "expvar", 15 | Binds: map[string]Value{ 16 | "Do": ValueOf(expvar.Do), 17 | "Get": ValueOf(expvar.Get), 18 | "Handler": ValueOf(expvar.Handler), 19 | "NewFloat": ValueOf(expvar.NewFloat), 20 | "NewInt": ValueOf(expvar.NewInt), 21 | "NewMap": ValueOf(expvar.NewMap), 22 | "NewString": ValueOf(expvar.NewString), 23 | "Publish": ValueOf(expvar.Publish), 24 | }, Types: map[string]Type{ 25 | "Float": TypeOf((*expvar.Float)(nil)).Elem(), 26 | "Func": TypeOf((*expvar.Func)(nil)).Elem(), 27 | "Int": TypeOf((*expvar.Int)(nil)).Elem(), 28 | "KeyValue": TypeOf((*expvar.KeyValue)(nil)).Elem(), 29 | "Map": TypeOf((*expvar.Map)(nil)).Elem(), 30 | "String": TypeOf((*expvar.String)(nil)).Elem(), 31 | "Var": TypeOf((*expvar.Var)(nil)).Elem(), 32 | }, Proxies: map[string]Type{ 33 | "Var": TypeOf((*P_expvar_Var)(nil)).Elem(), 34 | }, 35 | } 36 | } 37 | 38 | // --------------- proxy for expvar.Var --------------- 39 | type P_expvar_Var struct { 40 | Object interface{} 41 | String_ func(interface{}) string 42 | } 43 | func (P *P_expvar_Var) String() string { 44 | return P.String_(P.Object) 45 | } 46 | -------------------------------------------------------------------------------- /imports/genimports.sh: -------------------------------------------------------------------------------- 1 | exec > genimports.gomacro 2 | 3 | if [ x"$GOROOT" = "x" ]; then 4 | GOROOT="/usr/lib/go" 5 | fi 6 | 7 | echo "#!/usr/bin/env gomacro" 8 | echo 9 | 10 | 11 | find "$GOROOT/src/" -type d | \ 12 | sed -e "s,$GOROOT/src/,," -e "s,$GOROOT/src,," | \ 13 | grep "[a-z]" | grep -v 'builtin\|cmd\|internal\|syscall\|testdata\|vendor' | \ 14 | sort | 15 | while read i; do 16 | echo ":unload \"$i\"" 17 | echo "import _b \"$i\"" 18 | done 19 | 20 | -------------------------------------------------------------------------------- /imports/go_build.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "go/build" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | build "go/build" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "go/build" 12 | func init() { 13 | Packages["go/build"] = Package{ 14 | Name: "build", 15 | Binds: map[string]Value{ 16 | "AllowBinary": ValueOf(build.AllowBinary), 17 | "ArchChar": ValueOf(build.ArchChar), 18 | "Default": ValueOf(&build.Default).Elem(), 19 | "FindOnly": ValueOf(build.FindOnly), 20 | "IgnoreVendor": ValueOf(build.IgnoreVendor), 21 | "Import": ValueOf(build.Import), 22 | "ImportComment": ValueOf(build.ImportComment), 23 | "ImportDir": ValueOf(build.ImportDir), 24 | "IsLocalImport": ValueOf(build.IsLocalImport), 25 | "ToolDir": ValueOf(&build.ToolDir).Elem(), 26 | }, Types: map[string]Type{ 27 | "Context": TypeOf((*build.Context)(nil)).Elem(), 28 | "ImportMode": TypeOf((*build.ImportMode)(nil)).Elem(), 29 | "MultiplePackageError": TypeOf((*build.MultiplePackageError)(nil)).Elem(), 30 | "NoGoError": TypeOf((*build.NoGoError)(nil)).Elem(), 31 | "Package": TypeOf((*build.Package)(nil)).Elem(), 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /imports/go_build_constraint.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "go/build/constraint" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | constraint "go/build/constraint" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "go/build/constraint" 12 | func init() { 13 | Packages["go/build/constraint"] = Package{ 14 | Name: "constraint", 15 | Binds: map[string]Value{ 16 | "IsGoBuild": ValueOf(constraint.IsGoBuild), 17 | "IsPlusBuild": ValueOf(constraint.IsPlusBuild), 18 | "Parse": ValueOf(constraint.Parse), 19 | "PlusBuildLines": ValueOf(constraint.PlusBuildLines), 20 | }, Types: map[string]Type{ 21 | "AndExpr": TypeOf((*constraint.AndExpr)(nil)).Elem(), 22 | "Expr": TypeOf((*constraint.Expr)(nil)).Elem(), 23 | "NotExpr": TypeOf((*constraint.NotExpr)(nil)).Elem(), 24 | "OrExpr": TypeOf((*constraint.OrExpr)(nil)).Elem(), 25 | "SyntaxError": TypeOf((*constraint.SyntaxError)(nil)).Elem(), 26 | "TagExpr": TypeOf((*constraint.TagExpr)(nil)).Elem(), 27 | }, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /imports/go_doc.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "go/doc" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | doc "go/doc" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "go/doc" 12 | func init() { 13 | Packages["go/doc"] = Package{ 14 | Name: "doc", 15 | Binds: map[string]Value{ 16 | "AllDecls": ValueOf(doc.AllDecls), 17 | "AllMethods": ValueOf(doc.AllMethods), 18 | "Examples": ValueOf(doc.Examples), 19 | "IllegalPrefixes": ValueOf(&doc.IllegalPrefixes).Elem(), 20 | "IsPredeclared": ValueOf(doc.IsPredeclared), 21 | "New": ValueOf(doc.New), 22 | "NewFromFiles": ValueOf(doc.NewFromFiles), 23 | "PreserveAST": ValueOf(doc.PreserveAST), 24 | "Synopsis": ValueOf(doc.Synopsis), 25 | "ToHTML": ValueOf(doc.ToHTML), 26 | "ToText": ValueOf(doc.ToText), 27 | }, Types: map[string]Type{ 28 | "Example": TypeOf((*doc.Example)(nil)).Elem(), 29 | "Filter": TypeOf((*doc.Filter)(nil)).Elem(), 30 | "Func": TypeOf((*doc.Func)(nil)).Elem(), 31 | "Mode": TypeOf((*doc.Mode)(nil)).Elem(), 32 | "Note": TypeOf((*doc.Note)(nil)).Elem(), 33 | "Package": TypeOf((*doc.Package)(nil)).Elem(), 34 | "Type": TypeOf((*doc.Type)(nil)).Elem(), 35 | "Value": TypeOf((*doc.Value)(nil)).Elem(), 36 | }, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /imports/go_format.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "go/format" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | format "go/format" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "go/format" 12 | func init() { 13 | Packages["go/format"] = Package{ 14 | Name: "format", 15 | Binds: map[string]Value{ 16 | "Node": ValueOf(format.Node), 17 | "Source": ValueOf(format.Source), 18 | }, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /imports/go_importer.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "go/importer" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | importer "go/importer" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "go/importer" 12 | func init() { 13 | Packages["go/importer"] = Package{ 14 | Name: "importer", 15 | Binds: map[string]Value{ 16 | "Default": ValueOf(importer.Default), 17 | "For": ValueOf(importer.For), 18 | "ForCompiler": ValueOf(importer.ForCompiler), 19 | }, Types: map[string]Type{ 20 | "Lookup": TypeOf((*importer.Lookup)(nil)).Elem(), 21 | }, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /imports/go_parser.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "go/parser" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | parser "go/parser" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "go/parser" 12 | func init() { 13 | Packages["go/parser"] = Package{ 14 | Name: "parser", 15 | Binds: map[string]Value{ 16 | "AllErrors": ValueOf(parser.AllErrors), 17 | "DeclarationErrors": ValueOf(parser.DeclarationErrors), 18 | "ImportsOnly": ValueOf(parser.ImportsOnly), 19 | "PackageClauseOnly": ValueOf(parser.PackageClauseOnly), 20 | "ParseComments": ValueOf(parser.ParseComments), 21 | "ParseDir": ValueOf(parser.ParseDir), 22 | "ParseExpr": ValueOf(parser.ParseExpr), 23 | "ParseExprFrom": ValueOf(parser.ParseExprFrom), 24 | "ParseFile": ValueOf(parser.ParseFile), 25 | "SkipObjectResolution": ValueOf(parser.SkipObjectResolution), 26 | "SpuriousErrors": ValueOf(parser.SpuriousErrors), 27 | "Trace": ValueOf(parser.Trace), 28 | }, Types: map[string]Type{ 29 | "Mode": TypeOf((*parser.Mode)(nil)).Elem(), 30 | }, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /imports/go_printer.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "go/printer" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | printer "go/printer" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "go/printer" 12 | func init() { 13 | Packages["go/printer"] = Package{ 14 | Name: "printer", 15 | Binds: map[string]Value{ 16 | "Fprint": ValueOf(printer.Fprint), 17 | "RawFormat": ValueOf(printer.RawFormat), 18 | "SourcePos": ValueOf(printer.SourcePos), 19 | "TabIndent": ValueOf(printer.TabIndent), 20 | "UseSpaces": ValueOf(printer.UseSpaces), 21 | }, Types: map[string]Type{ 22 | "CommentedNode": TypeOf((*printer.CommentedNode)(nil)).Elem(), 23 | "Config": TypeOf((*printer.Config)(nil)).Elem(), 24 | "Mode": TypeOf((*printer.Mode)(nil)).Elem(), 25 | }, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /imports/go_scanner.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "go/scanner" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | scanner "go/scanner" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "go/scanner" 12 | func init() { 13 | Packages["go/scanner"] = Package{ 14 | Name: "scanner", 15 | Binds: map[string]Value{ 16 | "PrintError": ValueOf(scanner.PrintError), 17 | "ScanComments": ValueOf(scanner.ScanComments), 18 | }, Types: map[string]Type{ 19 | "Error": TypeOf((*scanner.Error)(nil)).Elem(), 20 | "ErrorHandler": TypeOf((*scanner.ErrorHandler)(nil)).Elem(), 21 | "ErrorList": TypeOf((*scanner.ErrorList)(nil)).Elem(), 22 | "Mode": TypeOf((*scanner.Mode)(nil)).Elem(), 23 | "Scanner": TypeOf((*scanner.Scanner)(nil)).Elem(), 24 | }, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /imports/hash_adler32.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "hash/adler32" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | adler32 "hash/adler32" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "hash/adler32" 12 | func init() { 13 | Packages["hash/adler32"] = Package{ 14 | Name: "adler32", 15 | Binds: map[string]Value{ 16 | "Checksum": ValueOf(adler32.Checksum), 17 | "New": ValueOf(adler32.New), 18 | "Size": ValueOf(adler32.Size), 19 | }, Untypeds: map[string]string{ 20 | "Size": "int:4", 21 | }, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /imports/hash_crc32.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "hash/crc32" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | crc32 "hash/crc32" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "hash/crc32" 12 | func init() { 13 | Packages["hash/crc32"] = Package{ 14 | Name: "crc32", 15 | Binds: map[string]Value{ 16 | "Castagnoli": ValueOf(uint32(crc32.Castagnoli)), 17 | "Checksum": ValueOf(crc32.Checksum), 18 | "ChecksumIEEE": ValueOf(crc32.ChecksumIEEE), 19 | "IEEE": ValueOf(uint32(crc32.IEEE)), 20 | "IEEETable": ValueOf(&crc32.IEEETable).Elem(), 21 | "Koopman": ValueOf(uint32(crc32.Koopman)), 22 | "MakeTable": ValueOf(crc32.MakeTable), 23 | "New": ValueOf(crc32.New), 24 | "NewIEEE": ValueOf(crc32.NewIEEE), 25 | "Size": ValueOf(crc32.Size), 26 | "Update": ValueOf(crc32.Update), 27 | }, Types: map[string]Type{ 28 | "Table": TypeOf((*crc32.Table)(nil)).Elem(), 29 | }, Untypeds: map[string]string{ 30 | "Castagnoli": "int:2197175160", 31 | "IEEE": "int:3988292384", 32 | "Koopman": "int:3945912366", 33 | "Size": "int:4", 34 | }, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /imports/hash_crc64.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "hash/crc64" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | crc64 "hash/crc64" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "hash/crc64" 12 | func init() { 13 | Packages["hash/crc64"] = Package{ 14 | Name: "crc64", 15 | Binds: map[string]Value{ 16 | "Checksum": ValueOf(crc64.Checksum), 17 | "ECMA": ValueOf(uint64(crc64.ECMA)), 18 | "ISO": ValueOf(uint64(crc64.ISO)), 19 | "MakeTable": ValueOf(crc64.MakeTable), 20 | "New": ValueOf(crc64.New), 21 | "Size": ValueOf(crc64.Size), 22 | "Update": ValueOf(crc64.Update), 23 | }, Types: map[string]Type{ 24 | "Table": TypeOf((*crc64.Table)(nil)).Elem(), 25 | }, Untypeds: map[string]string{ 26 | "ECMA": "int:14514072000185962306", 27 | "ISO": "int:15564440312192434176", 28 | "Size": "int:8", 29 | }, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /imports/hash_fnv.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "hash/fnv" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | fnv "hash/fnv" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "hash/fnv" 12 | func init() { 13 | Packages["hash/fnv"] = Package{ 14 | Name: "fnv", 15 | Binds: map[string]Value{ 16 | "New128": ValueOf(fnv.New128), 17 | "New128a": ValueOf(fnv.New128a), 18 | "New32": ValueOf(fnv.New32), 19 | "New32a": ValueOf(fnv.New32a), 20 | "New64": ValueOf(fnv.New64), 21 | "New64a": ValueOf(fnv.New64a), 22 | }, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /imports/hash_maphash.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "hash/maphash" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | maphash "hash/maphash" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "hash/maphash" 12 | func init() { 13 | Packages["hash/maphash"] = Package{ 14 | Name: "maphash", 15 | Binds: map[string]Value{ 16 | "MakeSeed": ValueOf(maphash.MakeSeed), 17 | }, Types: map[string]Type{ 18 | "Hash": TypeOf((*maphash.Hash)(nil)).Elem(), 19 | "Seed": TypeOf((*maphash.Seed)(nil)).Elem(), 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /imports/html.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "html" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | html "html" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "html" 12 | func init() { 13 | Packages["html"] = Package{ 14 | Name: "html", 15 | Binds: map[string]Value{ 16 | "EscapeString": ValueOf(html.EscapeString), 17 | "UnescapeString": ValueOf(html.UnescapeString), 18 | }, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /imports/image_color_palette.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "image/color/palette" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | palette "image/color/palette" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "image/color/palette" 12 | func init() { 13 | Packages["image/color/palette"] = Package{ 14 | Name: "palette", 15 | Binds: map[string]Value{ 16 | "Plan9": ValueOf(&palette.Plan9).Elem(), 17 | "WebSafe": ValueOf(&palette.WebSafe).Elem(), 18 | }, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /imports/image_gif.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "image/gif" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | gif "image/gif" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "image/gif" 12 | func init() { 13 | Packages["image/gif"] = Package{ 14 | Name: "gif", 15 | Binds: map[string]Value{ 16 | "Decode": ValueOf(gif.Decode), 17 | "DecodeAll": ValueOf(gif.DecodeAll), 18 | "DecodeConfig": ValueOf(gif.DecodeConfig), 19 | "DisposalBackground": ValueOf(gif.DisposalBackground), 20 | "DisposalNone": ValueOf(gif.DisposalNone), 21 | "DisposalPrevious": ValueOf(gif.DisposalPrevious), 22 | "Encode": ValueOf(gif.Encode), 23 | "EncodeAll": ValueOf(gif.EncodeAll), 24 | }, Types: map[string]Type{ 25 | "GIF": TypeOf((*gif.GIF)(nil)).Elem(), 26 | "Options": TypeOf((*gif.Options)(nil)).Elem(), 27 | }, Untypeds: map[string]string{ 28 | "DisposalBackground": "int:2", 29 | "DisposalNone": "int:1", 30 | "DisposalPrevious": "int:3", 31 | }, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /imports/image_jpeg.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "image/jpeg" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | jpeg "image/jpeg" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "image/jpeg" 12 | func init() { 13 | Packages["image/jpeg"] = Package{ 14 | Name: "jpeg", 15 | Binds: map[string]Value{ 16 | "Decode": ValueOf(jpeg.Decode), 17 | "DecodeConfig": ValueOf(jpeg.DecodeConfig), 18 | "DefaultQuality": ValueOf(jpeg.DefaultQuality), 19 | "Encode": ValueOf(jpeg.Encode), 20 | }, Types: map[string]Type{ 21 | "FormatError": TypeOf((*jpeg.FormatError)(nil)).Elem(), 22 | "Options": TypeOf((*jpeg.Options)(nil)).Elem(), 23 | "Reader": TypeOf((*jpeg.Reader)(nil)).Elem(), 24 | "UnsupportedError": TypeOf((*jpeg.UnsupportedError)(nil)).Elem(), 25 | }, Proxies: map[string]Type{ 26 | "Reader": TypeOf((*P_image_jpeg_Reader)(nil)).Elem(), 27 | }, Untypeds: map[string]string{ 28 | "DefaultQuality": "int:75", 29 | }, 30 | } 31 | } 32 | 33 | // --------------- proxy for image/jpeg.Reader --------------- 34 | type P_image_jpeg_Reader struct { 35 | Object interface{} 36 | Read_ func(_proxy_obj_ interface{}, p []byte) (n int, err error) 37 | ReadByte_ func(interface{}) (byte, error) 38 | } 39 | func (P *P_image_jpeg_Reader) Read(p []byte) (n int, err error) { 40 | return P.Read_(P.Object, p) 41 | } 42 | func (P *P_image_jpeg_Reader) ReadByte() (byte, error) { 43 | return P.ReadByte_(P.Object) 44 | } 45 | -------------------------------------------------------------------------------- /imports/image_png.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "image/png" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | png "image/png" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "image/png" 12 | func init() { 13 | Packages["image/png"] = Package{ 14 | Name: "png", 15 | Binds: map[string]Value{ 16 | "BestCompression": ValueOf(png.BestCompression), 17 | "BestSpeed": ValueOf(png.BestSpeed), 18 | "Decode": ValueOf(png.Decode), 19 | "DecodeConfig": ValueOf(png.DecodeConfig), 20 | "DefaultCompression": ValueOf(png.DefaultCompression), 21 | "Encode": ValueOf(png.Encode), 22 | "NoCompression": ValueOf(png.NoCompression), 23 | }, Types: map[string]Type{ 24 | "CompressionLevel": TypeOf((*png.CompressionLevel)(nil)).Elem(), 25 | "Encoder": TypeOf((*png.Encoder)(nil)).Elem(), 26 | "EncoderBuffer": TypeOf((*png.EncoderBuffer)(nil)).Elem(), 27 | "EncoderBufferPool": TypeOf((*png.EncoderBufferPool)(nil)).Elem(), 28 | "FormatError": TypeOf((*png.FormatError)(nil)).Elem(), 29 | "UnsupportedError": TypeOf((*png.UnsupportedError)(nil)).Elem(), 30 | }, Proxies: map[string]Type{ 31 | "EncoderBufferPool": TypeOf((*P_image_png_EncoderBufferPool)(nil)).Elem(), 32 | }, 33 | } 34 | } 35 | 36 | // --------------- proxy for image/png.EncoderBufferPool --------------- 37 | type P_image_png_EncoderBufferPool struct { 38 | Object interface{} 39 | Get_ func(interface{}) *png.EncoderBuffer 40 | Put_ func(interface{}, *png.EncoderBuffer) 41 | } 42 | func (P *P_image_png_EncoderBufferPool) Get() *png.EncoderBuffer { 43 | return P.Get_(P.Object) 44 | } 45 | func (P *P_image_png_EncoderBufferPool) Put(unnamed0 *png.EncoderBuffer) { 46 | P.Put_(P.Object, unnamed0) 47 | } 48 | -------------------------------------------------------------------------------- /imports/index_suffixarray.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "index/suffixarray" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | suffixarray "index/suffixarray" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "index/suffixarray" 12 | func init() { 13 | Packages["index/suffixarray"] = Package{ 14 | Name: "suffixarray", 15 | Binds: map[string]Value{ 16 | "New": ValueOf(suffixarray.New), 17 | }, Types: map[string]Type{ 18 | "Index": TypeOf((*suffixarray.Index)(nil)).Elem(), 19 | }, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /imports/io_ioutil.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "io/ioutil" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | ioutil "io/ioutil" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "io/ioutil" 12 | func init() { 13 | Packages["io/ioutil"] = Package{ 14 | Name: "ioutil", 15 | Binds: map[string]Value{ 16 | "Discard": ValueOf(&ioutil.Discard).Elem(), 17 | "NopCloser": ValueOf(ioutil.NopCloser), 18 | "ReadAll": ValueOf(ioutil.ReadAll), 19 | "ReadDir": ValueOf(ioutil.ReadDir), 20 | "ReadFile": ValueOf(ioutil.ReadFile), 21 | "TempDir": ValueOf(ioutil.TempDir), 22 | "TempFile": ValueOf(ioutil.TempFile), 23 | "WriteFile": ValueOf(ioutil.WriteFile), 24 | }, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /imports/log.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "log" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | log "log" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "log" 12 | func init() { 13 | Packages["log"] = Package{ 14 | Name: "log", 15 | Binds: map[string]Value{ 16 | "Default": ValueOf(log.Default), 17 | "Fatal": ValueOf(log.Fatal), 18 | "Fatalf": ValueOf(log.Fatalf), 19 | "Fatalln": ValueOf(log.Fatalln), 20 | "Flags": ValueOf(log.Flags), 21 | "LUTC": ValueOf(log.LUTC), 22 | "Ldate": ValueOf(log.Ldate), 23 | "Llongfile": ValueOf(log.Llongfile), 24 | "Lmicroseconds": ValueOf(log.Lmicroseconds), 25 | "Lmsgprefix": ValueOf(log.Lmsgprefix), 26 | "Lshortfile": ValueOf(log.Lshortfile), 27 | "LstdFlags": ValueOf(log.LstdFlags), 28 | "Ltime": ValueOf(log.Ltime), 29 | "New": ValueOf(log.New), 30 | "Output": ValueOf(log.Output), 31 | "Panic": ValueOf(log.Panic), 32 | "Panicf": ValueOf(log.Panicf), 33 | "Panicln": ValueOf(log.Panicln), 34 | "Prefix": ValueOf(log.Prefix), 35 | "Print": ValueOf(log.Print), 36 | "Printf": ValueOf(log.Printf), 37 | "Println": ValueOf(log.Println), 38 | "SetFlags": ValueOf(log.SetFlags), 39 | "SetOutput": ValueOf(log.SetOutput), 40 | "SetPrefix": ValueOf(log.SetPrefix), 41 | "Writer": ValueOf(log.Writer), 42 | }, Types: map[string]Type{ 43 | "Logger": TypeOf((*log.Logger)(nil)).Elem(), 44 | }, Untypeds: map[string]string{ 45 | "LUTC": "int:32", 46 | "Ldate": "int:1", 47 | "Llongfile": "int:8", 48 | "Lmicroseconds": "int:4", 49 | "Lmsgprefix": "int:64", 50 | "Lshortfile": "int:16", 51 | "LstdFlags": "int:3", 52 | "Ltime": "int:2", 53 | }, 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /imports/math_big.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "math/big" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | big "math/big" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "math/big" 12 | func init() { 13 | Packages["math/big"] = Package{ 14 | Name: "big", 15 | Binds: map[string]Value{ 16 | "Above": ValueOf(big.Above), 17 | "AwayFromZero": ValueOf(big.AwayFromZero), 18 | "Below": ValueOf(big.Below), 19 | "Exact": ValueOf(big.Exact), 20 | "Jacobi": ValueOf(big.Jacobi), 21 | "MaxBase": ValueOf(big.MaxBase), 22 | "MaxExp": ValueOf(big.MaxExp), 23 | "MaxPrec": ValueOf(uint32(big.MaxPrec)), 24 | "MinExp": ValueOf(big.MinExp), 25 | "NewFloat": ValueOf(big.NewFloat), 26 | "NewInt": ValueOf(big.NewInt), 27 | "NewRat": ValueOf(big.NewRat), 28 | "ParseFloat": ValueOf(big.ParseFloat), 29 | "ToNearestAway": ValueOf(big.ToNearestAway), 30 | "ToNearestEven": ValueOf(big.ToNearestEven), 31 | "ToNegativeInf": ValueOf(big.ToNegativeInf), 32 | "ToPositiveInf": ValueOf(big.ToPositiveInf), 33 | "ToZero": ValueOf(big.ToZero), 34 | }, Types: map[string]Type{ 35 | "Accuracy": TypeOf((*big.Accuracy)(nil)).Elem(), 36 | "ErrNaN": TypeOf((*big.ErrNaN)(nil)).Elem(), 37 | "Float": TypeOf((*big.Float)(nil)).Elem(), 38 | "Int": TypeOf((*big.Int)(nil)).Elem(), 39 | "Rat": TypeOf((*big.Rat)(nil)).Elem(), 40 | "RoundingMode": TypeOf((*big.RoundingMode)(nil)).Elem(), 41 | "Word": TypeOf((*big.Word)(nil)).Elem(), 42 | }, Untypeds: map[string]string{ 43 | "MaxBase": "rune:62", 44 | "MaxExp": "int:2147483647", 45 | "MaxPrec": "int:4294967295", 46 | "MinExp": "int:-2147483648", 47 | }, 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /imports/math_cmplx.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "math/cmplx" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | cmplx "math/cmplx" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "math/cmplx" 12 | func init() { 13 | Packages["math/cmplx"] = Package{ 14 | Name: "cmplx", 15 | Binds: map[string]Value{ 16 | "Abs": ValueOf(cmplx.Abs), 17 | "Acos": ValueOf(cmplx.Acos), 18 | "Acosh": ValueOf(cmplx.Acosh), 19 | "Asin": ValueOf(cmplx.Asin), 20 | "Asinh": ValueOf(cmplx.Asinh), 21 | "Atan": ValueOf(cmplx.Atan), 22 | "Atanh": ValueOf(cmplx.Atanh), 23 | "Conj": ValueOf(cmplx.Conj), 24 | "Cos": ValueOf(cmplx.Cos), 25 | "Cosh": ValueOf(cmplx.Cosh), 26 | "Cot": ValueOf(cmplx.Cot), 27 | "Exp": ValueOf(cmplx.Exp), 28 | "Inf": ValueOf(cmplx.Inf), 29 | "IsInf": ValueOf(cmplx.IsInf), 30 | "IsNaN": ValueOf(cmplx.IsNaN), 31 | "Log": ValueOf(cmplx.Log), 32 | "Log10": ValueOf(cmplx.Log10), 33 | "NaN": ValueOf(cmplx.NaN), 34 | "Phase": ValueOf(cmplx.Phase), 35 | "Polar": ValueOf(cmplx.Polar), 36 | "Pow": ValueOf(cmplx.Pow), 37 | "Rect": ValueOf(cmplx.Rect), 38 | "Sin": ValueOf(cmplx.Sin), 39 | "Sinh": ValueOf(cmplx.Sinh), 40 | "Sqrt": ValueOf(cmplx.Sqrt), 41 | "Tan": ValueOf(cmplx.Tan), 42 | "Tanh": ValueOf(cmplx.Tanh), 43 | }, 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /imports/mime.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "mime" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | mime "mime" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "mime" 12 | func init() { 13 | Packages["mime"] = Package{ 14 | Name: "mime", 15 | Binds: map[string]Value{ 16 | "AddExtensionType": ValueOf(mime.AddExtensionType), 17 | "BEncoding": ValueOf(mime.BEncoding), 18 | "ErrInvalidMediaParameter": ValueOf(&mime.ErrInvalidMediaParameter).Elem(), 19 | "ExtensionsByType": ValueOf(mime.ExtensionsByType), 20 | "FormatMediaType": ValueOf(mime.FormatMediaType), 21 | "ParseMediaType": ValueOf(mime.ParseMediaType), 22 | "QEncoding": ValueOf(mime.QEncoding), 23 | "TypeByExtension": ValueOf(mime.TypeByExtension), 24 | }, Types: map[string]Type{ 25 | "WordDecoder": TypeOf((*mime.WordDecoder)(nil)).Elem(), 26 | "WordEncoder": TypeOf((*mime.WordEncoder)(nil)).Elem(), 27 | }, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /imports/mime_quotedprintable.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "mime/quotedprintable" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | quotedprintable "mime/quotedprintable" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "mime/quotedprintable" 12 | func init() { 13 | Packages["mime/quotedprintable"] = Package{ 14 | Name: "quotedprintable", 15 | Binds: map[string]Value{ 16 | "NewReader": ValueOf(quotedprintable.NewReader), 17 | "NewWriter": ValueOf(quotedprintable.NewWriter), 18 | }, Types: map[string]Type{ 19 | "Reader": TypeOf((*quotedprintable.Reader)(nil)).Elem(), 20 | "Writer": TypeOf((*quotedprintable.Writer)(nil)).Elem(), 21 | }, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /imports/net_http_cgi.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/http/cgi" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | cgi "net/http/cgi" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/http/cgi" 12 | func init() { 13 | Packages["net/http/cgi"] = Package{ 14 | Name: "cgi", 15 | Binds: map[string]Value{ 16 | "Request": ValueOf(cgi.Request), 17 | "RequestFromMap": ValueOf(cgi.RequestFromMap), 18 | "Serve": ValueOf(cgi.Serve), 19 | }, Types: map[string]Type{ 20 | "Handler": TypeOf((*cgi.Handler)(nil)).Elem(), 21 | }, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /imports/net_http_cookiejar.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/http/cookiejar" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | cookiejar "net/http/cookiejar" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/http/cookiejar" 12 | func init() { 13 | Packages["net/http/cookiejar"] = Package{ 14 | Name: "cookiejar", 15 | Binds: map[string]Value{ 16 | "New": ValueOf(cookiejar.New), 17 | }, Types: map[string]Type{ 18 | "Jar": TypeOf((*cookiejar.Jar)(nil)).Elem(), 19 | "Options": TypeOf((*cookiejar.Options)(nil)).Elem(), 20 | "PublicSuffixList": TypeOf((*cookiejar.PublicSuffixList)(nil)).Elem(), 21 | }, Proxies: map[string]Type{ 22 | "PublicSuffixList": TypeOf((*P_net_http_cookiejar_PublicSuffixList)(nil)).Elem(), 23 | }, 24 | } 25 | } 26 | 27 | // --------------- proxy for net/http/cookiejar.PublicSuffixList --------------- 28 | type P_net_http_cookiejar_PublicSuffixList struct { 29 | Object interface{} 30 | PublicSuffix_ func(_proxy_obj_ interface{}, domain string) string 31 | String_ func(interface{}) string 32 | } 33 | func (P *P_net_http_cookiejar_PublicSuffixList) PublicSuffix(domain string) string { 34 | return P.PublicSuffix_(P.Object, domain) 35 | } 36 | func (P *P_net_http_cookiejar_PublicSuffixList) String() string { 37 | return P.String_(P.Object) 38 | } 39 | -------------------------------------------------------------------------------- /imports/net_http_fcgi.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/http/fcgi" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | fcgi "net/http/fcgi" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/http/fcgi" 12 | func init() { 13 | Packages["net/http/fcgi"] = Package{ 14 | Name: "fcgi", 15 | Binds: map[string]Value{ 16 | "ErrConnClosed": ValueOf(&fcgi.ErrConnClosed).Elem(), 17 | "ErrRequestAborted": ValueOf(&fcgi.ErrRequestAborted).Elem(), 18 | "ProcessEnv": ValueOf(fcgi.ProcessEnv), 19 | "Serve": ValueOf(fcgi.Serve), 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /imports/net_http_httptest.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/http/httptest" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | httptest "net/http/httptest" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/http/httptest" 12 | func init() { 13 | Packages["net/http/httptest"] = Package{ 14 | Name: "httptest", 15 | Binds: map[string]Value{ 16 | "DefaultRemoteAddr": ValueOf(httptest.DefaultRemoteAddr), 17 | "NewRecorder": ValueOf(httptest.NewRecorder), 18 | "NewRequest": ValueOf(httptest.NewRequest), 19 | "NewServer": ValueOf(httptest.NewServer), 20 | "NewTLSServer": ValueOf(httptest.NewTLSServer), 21 | "NewUnstartedServer": ValueOf(httptest.NewUnstartedServer), 22 | }, Types: map[string]Type{ 23 | "ResponseRecorder": TypeOf((*httptest.ResponseRecorder)(nil)).Elem(), 24 | "Server": TypeOf((*httptest.Server)(nil)).Elem(), 25 | }, Untypeds: map[string]string{ 26 | "DefaultRemoteAddr": "string:1.2.3.4", 27 | }, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /imports/net_http_httptrace.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/http/httptrace" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | httptrace "net/http/httptrace" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/http/httptrace" 12 | func init() { 13 | Packages["net/http/httptrace"] = Package{ 14 | Name: "httptrace", 15 | Binds: map[string]Value{ 16 | "ContextClientTrace": ValueOf(httptrace.ContextClientTrace), 17 | "WithClientTrace": ValueOf(httptrace.WithClientTrace), 18 | }, Types: map[string]Type{ 19 | "ClientTrace": TypeOf((*httptrace.ClientTrace)(nil)).Elem(), 20 | "DNSDoneInfo": TypeOf((*httptrace.DNSDoneInfo)(nil)).Elem(), 21 | "DNSStartInfo": TypeOf((*httptrace.DNSStartInfo)(nil)).Elem(), 22 | "GotConnInfo": TypeOf((*httptrace.GotConnInfo)(nil)).Elem(), 23 | "WroteRequestInfo": TypeOf((*httptrace.WroteRequestInfo)(nil)).Elem(), 24 | }, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /imports/net_http_pprof.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/http/pprof" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | pprof "net/http/pprof" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/http/pprof" 12 | func init() { 13 | Packages["net/http/pprof"] = Package{ 14 | Name: "pprof", 15 | Binds: map[string]Value{ 16 | "Cmdline": ValueOf(pprof.Cmdline), 17 | "Handler": ValueOf(pprof.Handler), 18 | "Index": ValueOf(pprof.Index), 19 | "Profile": ValueOf(pprof.Profile), 20 | "Symbol": ValueOf(pprof.Symbol), 21 | "Trace": ValueOf(pprof.Trace), 22 | }, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /imports/net_mail.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/mail" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | mail "net/mail" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/mail" 12 | func init() { 13 | Packages["net/mail"] = Package{ 14 | Name: "mail", 15 | Binds: map[string]Value{ 16 | "ErrHeaderNotPresent": ValueOf(&mail.ErrHeaderNotPresent).Elem(), 17 | "ParseAddress": ValueOf(mail.ParseAddress), 18 | "ParseAddressList": ValueOf(mail.ParseAddressList), 19 | "ParseDate": ValueOf(mail.ParseDate), 20 | "ReadMessage": ValueOf(mail.ReadMessage), 21 | }, Types: map[string]Type{ 22 | "Address": TypeOf((*mail.Address)(nil)).Elem(), 23 | "AddressParser": TypeOf((*mail.AddressParser)(nil)).Elem(), 24 | "Header": TypeOf((*mail.Header)(nil)).Elem(), 25 | "Message": TypeOf((*mail.Message)(nil)).Elem(), 26 | }, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /imports/net_netip.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/netip" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | netip "net/netip" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/netip" 12 | func init() { 13 | Packages["net/netip"] = Package{ 14 | Name: "netip", 15 | Binds: map[string]Value{ 16 | "AddrFrom16": ValueOf(netip.AddrFrom16), 17 | "AddrFrom4": ValueOf(netip.AddrFrom4), 18 | "AddrFromSlice": ValueOf(netip.AddrFromSlice), 19 | "AddrPortFrom": ValueOf(netip.AddrPortFrom), 20 | "IPv4Unspecified": ValueOf(netip.IPv4Unspecified), 21 | "IPv6LinkLocalAllNodes": ValueOf(netip.IPv6LinkLocalAllNodes), 22 | "IPv6Unspecified": ValueOf(netip.IPv6Unspecified), 23 | "MustParseAddr": ValueOf(netip.MustParseAddr), 24 | "MustParseAddrPort": ValueOf(netip.MustParseAddrPort), 25 | "MustParsePrefix": ValueOf(netip.MustParsePrefix), 26 | "ParseAddr": ValueOf(netip.ParseAddr), 27 | "ParseAddrPort": ValueOf(netip.ParseAddrPort), 28 | "ParsePrefix": ValueOf(netip.ParsePrefix), 29 | "PrefixFrom": ValueOf(netip.PrefixFrom), 30 | }, Types: map[string]Type{ 31 | "Addr": TypeOf((*netip.Addr)(nil)).Elem(), 32 | "AddrPort": TypeOf((*netip.AddrPort)(nil)).Elem(), 33 | "Prefix": TypeOf((*netip.Prefix)(nil)).Elem(), 34 | }, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /imports/net_rpc_jsonrpc.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/rpc/jsonrpc" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | jsonrpc "net/rpc/jsonrpc" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/rpc/jsonrpc" 12 | func init() { 13 | Packages["net/rpc/jsonrpc"] = Package{ 14 | Name: "jsonrpc", 15 | Binds: map[string]Value{ 16 | "Dial": ValueOf(jsonrpc.Dial), 17 | "NewClient": ValueOf(jsonrpc.NewClient), 18 | "NewClientCodec": ValueOf(jsonrpc.NewClientCodec), 19 | "NewServerCodec": ValueOf(jsonrpc.NewServerCodec), 20 | "ServeConn": ValueOf(jsonrpc.ServeConn), 21 | }, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /imports/net_smtp.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/smtp" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | smtp "net/smtp" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/smtp" 12 | func init() { 13 | Packages["net/smtp"] = Package{ 14 | Name: "smtp", 15 | Binds: map[string]Value{ 16 | "CRAMMD5Auth": ValueOf(smtp.CRAMMD5Auth), 17 | "Dial": ValueOf(smtp.Dial), 18 | "NewClient": ValueOf(smtp.NewClient), 19 | "PlainAuth": ValueOf(smtp.PlainAuth), 20 | "SendMail": ValueOf(smtp.SendMail), 21 | }, Types: map[string]Type{ 22 | "Auth": TypeOf((*smtp.Auth)(nil)).Elem(), 23 | "Client": TypeOf((*smtp.Client)(nil)).Elem(), 24 | "ServerInfo": TypeOf((*smtp.ServerInfo)(nil)).Elem(), 25 | }, Proxies: map[string]Type{ 26 | "Auth": TypeOf((*P_net_smtp_Auth)(nil)).Elem(), 27 | }, 28 | } 29 | } 30 | 31 | // --------------- proxy for net/smtp.Auth --------------- 32 | type P_net_smtp_Auth struct { 33 | Object interface{} 34 | Next_ func(_proxy_obj_ interface{}, fromServer []byte, more bool) (toServer []byte, err error) 35 | Start_ func(_proxy_obj_ interface{}, server *smtp.ServerInfo) (proto string, toServer []byte, err error) 36 | } 37 | func (P *P_net_smtp_Auth) Next(fromServer []byte, more bool) (toServer []byte, err error) { 38 | return P.Next_(P.Object, fromServer, more) 39 | } 40 | func (P *P_net_smtp_Auth) Start(server *smtp.ServerInfo) (proto string, toServer []byte, err error) { 41 | return P.Start_(P.Object, server) 42 | } 43 | -------------------------------------------------------------------------------- /imports/net_textproto.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/textproto" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | textproto "net/textproto" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/textproto" 12 | func init() { 13 | Packages["net/textproto"] = Package{ 14 | Name: "textproto", 15 | Binds: map[string]Value{ 16 | "CanonicalMIMEHeaderKey": ValueOf(textproto.CanonicalMIMEHeaderKey), 17 | "Dial": ValueOf(textproto.Dial), 18 | "NewConn": ValueOf(textproto.NewConn), 19 | "NewReader": ValueOf(textproto.NewReader), 20 | "NewWriter": ValueOf(textproto.NewWriter), 21 | "TrimBytes": ValueOf(textproto.TrimBytes), 22 | "TrimString": ValueOf(textproto.TrimString), 23 | }, Types: map[string]Type{ 24 | "Conn": TypeOf((*textproto.Conn)(nil)).Elem(), 25 | "Error": TypeOf((*textproto.Error)(nil)).Elem(), 26 | "MIMEHeader": TypeOf((*textproto.MIMEHeader)(nil)).Elem(), 27 | "Pipeline": TypeOf((*textproto.Pipeline)(nil)).Elem(), 28 | "ProtocolError": TypeOf((*textproto.ProtocolError)(nil)).Elem(), 29 | "Reader": TypeOf((*textproto.Reader)(nil)).Elem(), 30 | "Writer": TypeOf((*textproto.Writer)(nil)).Elem(), 31 | }, Wrappers: map[string][]string{ 32 | "Conn": []string{"DotReader","DotWriter","EndRequest","EndResponse","Next","PrintfLine","ReadCodeLine","ReadContinuedLine","ReadContinuedLineBytes","ReadDotBytes","ReadDotLines","ReadLine","ReadLineBytes","ReadMIMEHeader","ReadResponse","StartRequest","StartResponse",}, 33 | }, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /imports/net_url.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "net/url" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | url "net/url" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "net/url" 12 | func init() { 13 | Packages["net/url"] = Package{ 14 | Name: "url", 15 | Binds: map[string]Value{ 16 | "Parse": ValueOf(url.Parse), 17 | "ParseQuery": ValueOf(url.ParseQuery), 18 | "ParseRequestURI": ValueOf(url.ParseRequestURI), 19 | "PathEscape": ValueOf(url.PathEscape), 20 | "PathUnescape": ValueOf(url.PathUnescape), 21 | "QueryEscape": ValueOf(url.QueryEscape), 22 | "QueryUnescape": ValueOf(url.QueryUnescape), 23 | "User": ValueOf(url.User), 24 | "UserPassword": ValueOf(url.UserPassword), 25 | }, Types: map[string]Type{ 26 | "Error": TypeOf((*url.Error)(nil)).Elem(), 27 | "EscapeError": TypeOf((*url.EscapeError)(nil)).Elem(), 28 | "InvalidHostError": TypeOf((*url.InvalidHostError)(nil)).Elem(), 29 | "URL": TypeOf((*url.URL)(nil)).Elem(), 30 | "Userinfo": TypeOf((*url.Userinfo)(nil)).Elem(), 31 | "Values": TypeOf((*url.Values)(nil)).Elem(), 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /imports/os_exec.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "os/exec" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | exec "os/exec" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "os/exec" 12 | func init() { 13 | Packages["os/exec"] = Package{ 14 | Name: "exec", 15 | Binds: map[string]Value{ 16 | "Command": ValueOf(exec.Command), 17 | "CommandContext": ValueOf(exec.CommandContext), 18 | "ErrNotFound": ValueOf(&exec.ErrNotFound).Elem(), 19 | "LookPath": ValueOf(exec.LookPath), 20 | }, Types: map[string]Type{ 21 | "Cmd": TypeOf((*exec.Cmd)(nil)).Elem(), 22 | "Error": TypeOf((*exec.Error)(nil)).Elem(), 23 | "ExitError": TypeOf((*exec.ExitError)(nil)).Elem(), 24 | }, Wrappers: map[string][]string{ 25 | "ExitError": []string{"ExitCode","Exited","Pid","String","Success","Sys","SysUsage","SystemTime","UserTime",}, 26 | }, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /imports/os_signal.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "os/signal" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | signal "os/signal" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "os/signal" 12 | func init() { 13 | Packages["os/signal"] = Package{ 14 | Name: "signal", 15 | Binds: map[string]Value{ 16 | "Ignore": ValueOf(signal.Ignore), 17 | "Ignored": ValueOf(signal.Ignored), 18 | "Notify": ValueOf(signal.Notify), 19 | "NotifyContext": ValueOf(signal.NotifyContext), 20 | "Reset": ValueOf(signal.Reset), 21 | "Stop": ValueOf(signal.Stop), 22 | }, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /imports/os_user.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "os/user" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | user "os/user" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "os/user" 12 | func init() { 13 | Packages["os/user"] = Package{ 14 | Name: "user", 15 | Binds: map[string]Value{ 16 | "Current": ValueOf(user.Current), 17 | "Lookup": ValueOf(user.Lookup), 18 | "LookupGroup": ValueOf(user.LookupGroup), 19 | "LookupGroupId": ValueOf(user.LookupGroupId), 20 | "LookupId": ValueOf(user.LookupId), 21 | }, Types: map[string]Type{ 22 | "Group": TypeOf((*user.Group)(nil)).Elem(), 23 | "UnknownGroupError": TypeOf((*user.UnknownGroupError)(nil)).Elem(), 24 | "UnknownGroupIdError": TypeOf((*user.UnknownGroupIdError)(nil)).Elem(), 25 | "UnknownUserError": TypeOf((*user.UnknownUserError)(nil)).Elem(), 26 | "UnknownUserIdError": TypeOf((*user.UnknownUserIdError)(nil)).Elem(), 27 | "User": TypeOf((*user.User)(nil)).Elem(), 28 | }, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /imports/path.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "path" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | path "path" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "path" 12 | func init() { 13 | Packages["path"] = Package{ 14 | Name: "path", 15 | Binds: map[string]Value{ 16 | "Base": ValueOf(path.Base), 17 | "Clean": ValueOf(path.Clean), 18 | "Dir": ValueOf(path.Dir), 19 | "ErrBadPattern": ValueOf(&path.ErrBadPattern).Elem(), 20 | "Ext": ValueOf(path.Ext), 21 | "IsAbs": ValueOf(path.IsAbs), 22 | "Join": ValueOf(path.Join), 23 | "Match": ValueOf(path.Match), 24 | "Split": ValueOf(path.Split), 25 | }, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /imports/path_filepath.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "path/filepath" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | filepath "path/filepath" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "path/filepath" 12 | func init() { 13 | Packages["path/filepath"] = Package{ 14 | Name: "filepath", 15 | Binds: map[string]Value{ 16 | "Abs": ValueOf(filepath.Abs), 17 | "Base": ValueOf(filepath.Base), 18 | "Clean": ValueOf(filepath.Clean), 19 | "Dir": ValueOf(filepath.Dir), 20 | "ErrBadPattern": ValueOf(&filepath.ErrBadPattern).Elem(), 21 | "EvalSymlinks": ValueOf(filepath.EvalSymlinks), 22 | "Ext": ValueOf(filepath.Ext), 23 | "FromSlash": ValueOf(filepath.FromSlash), 24 | "Glob": ValueOf(filepath.Glob), 25 | "HasPrefix": ValueOf(filepath.HasPrefix), 26 | "IsAbs": ValueOf(filepath.IsAbs), 27 | "Join": ValueOf(filepath.Join), 28 | "ListSeparator": ValueOf(filepath.ListSeparator), 29 | "Match": ValueOf(filepath.Match), 30 | "Rel": ValueOf(filepath.Rel), 31 | "Separator": ValueOf(filepath.Separator), 32 | "SkipDir": ValueOf(&filepath.SkipDir).Elem(), 33 | "Split": ValueOf(filepath.Split), 34 | "SplitList": ValueOf(filepath.SplitList), 35 | "ToSlash": ValueOf(filepath.ToSlash), 36 | "VolumeName": ValueOf(filepath.VolumeName), 37 | "Walk": ValueOf(filepath.Walk), 38 | "WalkDir": ValueOf(filepath.WalkDir), 39 | }, Types: map[string]Type{ 40 | "WalkFunc": TypeOf((*filepath.WalkFunc)(nil)).Elem(), 41 | }, Untypeds: map[string]string{ 42 | "ListSeparator": "rune:58", 43 | "Separator": "rune:47", 44 | }, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /imports/plugin.go: -------------------------------------------------------------------------------- 1 | //go:build gc && (linux || darwin || freebsd) && !android 2 | 3 | // this file was generated by gomacro command: import _b "plugin" 4 | // DO NOT EDIT! Any change will be lost when the file is re-generated 5 | 6 | package imports 7 | 8 | import ( 9 | . "reflect" 10 | plugin "plugin" 11 | ) 12 | 13 | // reflection: allow interpreted code to import "plugin" 14 | func init() { 15 | Packages["plugin"] = Package{ 16 | Name: "plugin", 17 | Binds: map[string]Value{ 18 | "Open": ValueOf(plugin.Open), 19 | }, Types: map[string]Type{ 20 | "Plugin": TypeOf((*plugin.Plugin)(nil)).Elem(), 21 | "Symbol": TypeOf((*plugin.Symbol)(nil)).Elem(), 22 | }, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /imports/regexp.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "regexp" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | regexp "regexp" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "regexp" 12 | func init() { 13 | Packages["regexp"] = Package{ 14 | Name: "regexp", 15 | Binds: map[string]Value{ 16 | "Compile": ValueOf(regexp.Compile), 17 | "CompilePOSIX": ValueOf(regexp.CompilePOSIX), 18 | "Match": ValueOf(regexp.Match), 19 | "MatchReader": ValueOf(regexp.MatchReader), 20 | "MatchString": ValueOf(regexp.MatchString), 21 | "MustCompile": ValueOf(regexp.MustCompile), 22 | "MustCompilePOSIX": ValueOf(regexp.MustCompilePOSIX), 23 | "QuoteMeta": ValueOf(regexp.QuoteMeta), 24 | }, Types: map[string]Type{ 25 | "Regexp": TypeOf((*regexp.Regexp)(nil)).Elem(), 26 | }, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /imports/runtime_debug.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "runtime/debug" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | debug "runtime/debug" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "runtime/debug" 12 | func init() { 13 | Packages["runtime/debug"] = Package{ 14 | Name: "debug", 15 | Binds: map[string]Value{ 16 | "FreeOSMemory": ValueOf(debug.FreeOSMemory), 17 | "ParseBuildInfo": ValueOf(debug.ParseBuildInfo), 18 | "PrintStack": ValueOf(debug.PrintStack), 19 | "ReadBuildInfo": ValueOf(debug.ReadBuildInfo), 20 | "ReadGCStats": ValueOf(debug.ReadGCStats), 21 | "SetGCPercent": ValueOf(debug.SetGCPercent), 22 | "SetMaxStack": ValueOf(debug.SetMaxStack), 23 | "SetMaxThreads": ValueOf(debug.SetMaxThreads), 24 | "SetPanicOnFault": ValueOf(debug.SetPanicOnFault), 25 | "SetTraceback": ValueOf(debug.SetTraceback), 26 | "Stack": ValueOf(debug.Stack), 27 | "WriteHeapDump": ValueOf(debug.WriteHeapDump), 28 | }, Types: map[string]Type{ 29 | "BuildInfo": TypeOf((*debug.BuildInfo)(nil)).Elem(), 30 | "BuildSetting": TypeOf((*debug.BuildSetting)(nil)).Elem(), 31 | "GCStats": TypeOf((*debug.GCStats)(nil)).Elem(), 32 | "Module": TypeOf((*debug.Module)(nil)).Elem(), 33 | }, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /imports/runtime_metrics.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "runtime/metrics" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | metrics "runtime/metrics" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "runtime/metrics" 12 | func init() { 13 | Packages["runtime/metrics"] = Package{ 14 | Name: "metrics", 15 | Binds: map[string]Value{ 16 | "All": ValueOf(metrics.All), 17 | "KindBad": ValueOf(metrics.KindBad), 18 | "KindFloat64": ValueOf(metrics.KindFloat64), 19 | "KindFloat64Histogram": ValueOf(metrics.KindFloat64Histogram), 20 | "KindUint64": ValueOf(metrics.KindUint64), 21 | "Read": ValueOf(metrics.Read), 22 | }, Types: map[string]Type{ 23 | "Description": TypeOf((*metrics.Description)(nil)).Elem(), 24 | "Float64Histogram": TypeOf((*metrics.Float64Histogram)(nil)).Elem(), 25 | "Sample": TypeOf((*metrics.Sample)(nil)).Elem(), 26 | "Value": TypeOf((*metrics.Value)(nil)).Elem(), 27 | "ValueKind": TypeOf((*metrics.ValueKind)(nil)).Elem(), 28 | }, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /imports/runtime_pprof.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "runtime/pprof" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | pprof "runtime/pprof" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "runtime/pprof" 12 | func init() { 13 | Packages["runtime/pprof"] = Package{ 14 | Name: "pprof", 15 | Binds: map[string]Value{ 16 | "Do": ValueOf(pprof.Do), 17 | "ForLabels": ValueOf(pprof.ForLabels), 18 | "Label": ValueOf(pprof.Label), 19 | "Labels": ValueOf(pprof.Labels), 20 | "Lookup": ValueOf(pprof.Lookup), 21 | "NewProfile": ValueOf(pprof.NewProfile), 22 | "Profiles": ValueOf(pprof.Profiles), 23 | "SetGoroutineLabels": ValueOf(pprof.SetGoroutineLabels), 24 | "StartCPUProfile": ValueOf(pprof.StartCPUProfile), 25 | "StopCPUProfile": ValueOf(pprof.StopCPUProfile), 26 | "WithLabels": ValueOf(pprof.WithLabels), 27 | "WriteHeapProfile": ValueOf(pprof.WriteHeapProfile), 28 | }, Types: map[string]Type{ 29 | "LabelSet": TypeOf((*pprof.LabelSet)(nil)).Elem(), 30 | "Profile": TypeOf((*pprof.Profile)(nil)).Elem(), 31 | }, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /imports/runtime_trace.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "runtime/trace" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | trace "runtime/trace" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "runtime/trace" 12 | func init() { 13 | Packages["runtime/trace"] = Package{ 14 | Name: "trace", 15 | Binds: map[string]Value{ 16 | "IsEnabled": ValueOf(trace.IsEnabled), 17 | "Log": ValueOf(trace.Log), 18 | "Logf": ValueOf(trace.Logf), 19 | "NewTask": ValueOf(trace.NewTask), 20 | "Start": ValueOf(trace.Start), 21 | "StartRegion": ValueOf(trace.StartRegion), 22 | "Stop": ValueOf(trace.Stop), 23 | "WithRegion": ValueOf(trace.WithRegion), 24 | }, Types: map[string]Type{ 25 | "Region": TypeOf((*trace.Region)(nil)).Elem(), 26 | "Task": TypeOf((*trace.Task)(nil)).Elem(), 27 | }, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /imports/sync.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "sync" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | sync "sync" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "sync" 12 | func init() { 13 | Packages["sync"] = Package{ 14 | Name: "sync", 15 | Binds: map[string]Value{ 16 | "NewCond": ValueOf(sync.NewCond), 17 | }, Types: map[string]Type{ 18 | "Cond": TypeOf((*sync.Cond)(nil)).Elem(), 19 | "Locker": TypeOf((*sync.Locker)(nil)).Elem(), 20 | "Map": TypeOf((*sync.Map)(nil)).Elem(), 21 | "Mutex": TypeOf((*sync.Mutex)(nil)).Elem(), 22 | "Once": TypeOf((*sync.Once)(nil)).Elem(), 23 | "Pool": TypeOf((*sync.Pool)(nil)).Elem(), 24 | "RWMutex": TypeOf((*sync.RWMutex)(nil)).Elem(), 25 | "WaitGroup": TypeOf((*sync.WaitGroup)(nil)).Elem(), 26 | }, Proxies: map[string]Type{ 27 | "Locker": TypeOf((*P_sync_Locker)(nil)).Elem(), 28 | }, 29 | } 30 | } 31 | 32 | // --------------- proxy for sync.Locker --------------- 33 | type P_sync_Locker struct { 34 | Object interface{} 35 | Lock_ func(interface{}) 36 | Unlock_ func(interface{}) 37 | } 38 | func (P *P_sync_Locker) Lock() { 39 | P.Lock_(P.Object) 40 | } 41 | func (P *P_sync_Locker) Unlock() { 42 | P.Unlock_(P.Object) 43 | } 44 | -------------------------------------------------------------------------------- /imports/syscall/a_package.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * a_package.go 12 | * 13 | * Created on: Apr 09, 2018 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package syscall 18 | 19 | import ( 20 | . "reflect" 21 | ) 22 | 23 | type Package = struct { // unnamed 24 | Name string 25 | Binds map[string]Value 26 | Types map[string]Type 27 | Proxies map[string]Type 28 | // Untypeds contains a string representation of untyped constants, 29 | // stored without loss of precision 30 | Untypeds map[string]string 31 | // Wrappers is the list of wrapper methods for named types. 32 | // Stored explicitly because reflect package cannot distinguish 33 | // between explicit methods and wrapper methods for embedded fields 34 | Wrappers map[string][]string 35 | } 36 | 37 | var Packages = make(map[string]Package) 38 | -------------------------------------------------------------------------------- /imports/testing_fstest.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "testing/fstest" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | fstest "testing/fstest" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "testing/fstest" 12 | func init() { 13 | Packages["testing/fstest"] = Package{ 14 | Name: "fstest", 15 | Binds: map[string]Value{ 16 | "TestFS": ValueOf(fstest.TestFS), 17 | }, Types: map[string]Type{ 18 | "MapFS": TypeOf((*fstest.MapFS)(nil)).Elem(), 19 | "MapFile": TypeOf((*fstest.MapFile)(nil)).Elem(), 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /imports/testing_iotest.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "testing/iotest" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | iotest "testing/iotest" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "testing/iotest" 12 | func init() { 13 | Packages["testing/iotest"] = Package{ 14 | Name: "iotest", 15 | Binds: map[string]Value{ 16 | "DataErrReader": ValueOf(iotest.DataErrReader), 17 | "ErrReader": ValueOf(iotest.ErrReader), 18 | "ErrTimeout": ValueOf(&iotest.ErrTimeout).Elem(), 19 | "HalfReader": ValueOf(iotest.HalfReader), 20 | "NewReadLogger": ValueOf(iotest.NewReadLogger), 21 | "NewWriteLogger": ValueOf(iotest.NewWriteLogger), 22 | "OneByteReader": ValueOf(iotest.OneByteReader), 23 | "TestReader": ValueOf(iotest.TestReader), 24 | "TimeoutReader": ValueOf(iotest.TimeoutReader), 25 | "TruncateWriter": ValueOf(iotest.TruncateWriter), 26 | }, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /imports/testing_quick.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "testing/quick" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | rand "math/rand" 9 | reflect "reflect" 10 | quick "testing/quick" 11 | ) 12 | 13 | // reflection: allow interpreted code to import "testing/quick" 14 | func init() { 15 | Packages["testing/quick"] = Package{ 16 | Name: "quick", 17 | Binds: map[string]Value{ 18 | "Check": ValueOf(quick.Check), 19 | "CheckEqual": ValueOf(quick.CheckEqual), 20 | "Value": ValueOf(quick.Value), 21 | }, Types: map[string]Type{ 22 | "CheckEqualError": TypeOf((*quick.CheckEqualError)(nil)).Elem(), 23 | "CheckError": TypeOf((*quick.CheckError)(nil)).Elem(), 24 | "Config": TypeOf((*quick.Config)(nil)).Elem(), 25 | "Generator": TypeOf((*quick.Generator)(nil)).Elem(), 26 | "SetupError": TypeOf((*quick.SetupError)(nil)).Elem(), 27 | }, Proxies: map[string]Type{ 28 | "Generator": TypeOf((*P_testing_quick_Generator)(nil)).Elem(), 29 | }, 30 | } 31 | } 32 | 33 | // --------------- proxy for testing/quick.Generator --------------- 34 | type P_testing_quick_Generator struct { 35 | Object interface{} 36 | Generate_ func(_proxy_obj_ interface{}, rand *rand.Rand, size int) reflect.Value 37 | } 38 | func (P *P_testing_quick_Generator) Generate(rand *rand.Rand, size int) reflect.Value { 39 | return P.Generate_(P.Object, rand, size) 40 | } 41 | -------------------------------------------------------------------------------- /imports/text_tabwriter.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "text/tabwriter" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | tabwriter "text/tabwriter" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "text/tabwriter" 12 | func init() { 13 | Packages["text/tabwriter"] = Package{ 14 | Name: "tabwriter", 15 | Binds: map[string]Value{ 16 | "AlignRight": ValueOf(tabwriter.AlignRight), 17 | "Debug": ValueOf(tabwriter.Debug), 18 | "DiscardEmptyColumns": ValueOf(tabwriter.DiscardEmptyColumns), 19 | "Escape": ValueOf(tabwriter.Escape), 20 | "FilterHTML": ValueOf(tabwriter.FilterHTML), 21 | "NewWriter": ValueOf(tabwriter.NewWriter), 22 | "StripEscape": ValueOf(tabwriter.StripEscape), 23 | "TabIndent": ValueOf(tabwriter.TabIndent), 24 | }, Types: map[string]Type{ 25 | "Writer": TypeOf((*tabwriter.Writer)(nil)).Elem(), 26 | }, Untypeds: map[string]string{ 27 | "Escape": "rune:255", 28 | }, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /imports/text_template.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "text/template" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | template "text/template" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "text/template" 12 | func init() { 13 | Packages["text/template"] = Package{ 14 | Name: "template", 15 | Binds: map[string]Value{ 16 | "HTMLEscape": ValueOf(template.HTMLEscape), 17 | "HTMLEscapeString": ValueOf(template.HTMLEscapeString), 18 | "HTMLEscaper": ValueOf(template.HTMLEscaper), 19 | "IsTrue": ValueOf(template.IsTrue), 20 | "JSEscape": ValueOf(template.JSEscape), 21 | "JSEscapeString": ValueOf(template.JSEscapeString), 22 | "JSEscaper": ValueOf(template.JSEscaper), 23 | "Must": ValueOf(template.Must), 24 | "New": ValueOf(template.New), 25 | "ParseFS": ValueOf(template.ParseFS), 26 | "ParseFiles": ValueOf(template.ParseFiles), 27 | "ParseGlob": ValueOf(template.ParseGlob), 28 | "URLQueryEscaper": ValueOf(template.URLQueryEscaper), 29 | }, Types: map[string]Type{ 30 | "ExecError": TypeOf((*template.ExecError)(nil)).Elem(), 31 | "FuncMap": TypeOf((*template.FuncMap)(nil)).Elem(), 32 | "Template": TypeOf((*template.Template)(nil)).Elem(), 33 | }, Wrappers: map[string][]string{ 34 | "Template": []string{"Copy","ErrorContext",}, 35 | }, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /imports/thirdparty/README.md: -------------------------------------------------------------------------------- 1 | The gomacro command `import` will write here import files for third-party 2 | libraries if they are to be imported and statically linked into gomacro. 3 | 4 | This is currently needed on non-Linux systems 5 | to allow importing third-party libraries at gomacro prompt. 6 | 7 | It is safe to remove files in this directory, 8 | as long as you **keep at least** README.md and a_package.go 9 | -------------------------------------------------------------------------------- /imports/thirdparty/a_package.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * a_package.go 12 | * 13 | * Created on: Apr 09, 2018 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package thirdparty 18 | 19 | import ( 20 | . "reflect" 21 | ) 22 | 23 | type Package = struct { // unnamed 24 | Name string 25 | Binds map[string]Value 26 | Types map[string]Type 27 | Proxies map[string]Type 28 | // Untypeds contains a string representation of untyped constants, 29 | // stored without loss of precision 30 | Untypeds map[string]string 31 | // Wrappers is the list of wrapper methods for named types. 32 | // Stored explicitly because reflect package cannot distinguish 33 | // between explicit methods and wrapper methods for embedded fields 34 | Wrappers map[string][]string 35 | } 36 | 37 | var Packages = make(map[string]Package) 38 | -------------------------------------------------------------------------------- /imports/thirdparty/github_com_mattn_go_runewidth_.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import "github.com/mattn/go-runewidth" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package thirdparty 5 | 6 | import ( 7 | . "reflect" 8 | 9 | go_runewidth_ "github.com/mattn/go-runewidth" 10 | ) 11 | 12 | // reflection: allow interpreted code to import "github.com/mattn/go-runewidth" 13 | func init() { 14 | Packages["github.com/mattn/go-runewidth"] = Package{ 15 | Name: "runewidth", 16 | Binds: map[string]Value{ 17 | "DefaultCondition": ValueOf(&go_runewidth_.DefaultCondition).Elem(), 18 | "EastAsianWidth": ValueOf(&go_runewidth_.EastAsianWidth).Elem(), 19 | "FillLeft": ValueOf(go_runewidth_.FillLeft), 20 | "FillRight": ValueOf(go_runewidth_.FillRight), 21 | "IsAmbiguousWidth": ValueOf(go_runewidth_.IsAmbiguousWidth), 22 | "IsEastAsian": ValueOf(go_runewidth_.IsEastAsian), 23 | "IsNeutralWidth": ValueOf(go_runewidth_.IsNeutralWidth), 24 | "NewCondition": ValueOf(go_runewidth_.NewCondition), 25 | "RuneWidth": ValueOf(go_runewidth_.RuneWidth), 26 | "StringWidth": ValueOf(go_runewidth_.StringWidth), 27 | "Truncate": ValueOf(go_runewidth_.Truncate), 28 | "Wrap": ValueOf(go_runewidth_.Wrap), 29 | }, Types: map[string]Type{ 30 | "Condition": TypeOf((*go_runewidth_.Condition)(nil)).Elem(), 31 | }, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /imports/thirdparty/golang_org_x_tools_go_gcexportdata_.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import "golang.org/x/tools/go/gcexportdata" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package thirdparty 5 | 6 | import ( 7 | . "reflect" 8 | 9 | gcexportdata_ "golang.org/x/tools/go/gcexportdata" 10 | ) 11 | 12 | // reflection: allow interpreted code to import "golang.org/x/tools/go/gcexportdata" 13 | func init() { 14 | Packages["golang.org/x/tools/go/gcexportdata"] = Package{ 15 | Name: "gcexportdata", 16 | Binds: map[string]Value{ 17 | "Find": ValueOf(gcexportdata_.Find), 18 | "NewImporter": ValueOf(gcexportdata_.NewImporter), 19 | "NewReader": ValueOf(gcexportdata_.NewReader), 20 | "Read": ValueOf(gcexportdata_.Read), 21 | "Write": ValueOf(gcexportdata_.Write), 22 | }, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /imports/unicode_utf16.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "unicode/utf16" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | utf16 "unicode/utf16" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "unicode/utf16" 12 | func init() { 13 | Packages["unicode/utf16"] = Package{ 14 | Name: "utf16", 15 | Binds: map[string]Value{ 16 | "Decode": ValueOf(utf16.Decode), 17 | "DecodeRune": ValueOf(utf16.DecodeRune), 18 | "Encode": ValueOf(utf16.Encode), 19 | "EncodeRune": ValueOf(utf16.EncodeRune), 20 | "IsSurrogate": ValueOf(utf16.IsSurrogate), 21 | }, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /imports/unicode_utf8.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "unicode/utf8" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | utf8 "unicode/utf8" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "unicode/utf8" 12 | func init() { 13 | Packages["unicode/utf8"] = Package{ 14 | Name: "utf8", 15 | Binds: map[string]Value{ 16 | "DecodeLastRune": ValueOf(utf8.DecodeLastRune), 17 | "DecodeLastRuneInString": ValueOf(utf8.DecodeLastRuneInString), 18 | "DecodeRune": ValueOf(utf8.DecodeRune), 19 | "DecodeRuneInString": ValueOf(utf8.DecodeRuneInString), 20 | "EncodeRune": ValueOf(utf8.EncodeRune), 21 | "FullRune": ValueOf(utf8.FullRune), 22 | "FullRuneInString": ValueOf(utf8.FullRuneInString), 23 | "MaxRune": ValueOf(utf8.MaxRune), 24 | "RuneCount": ValueOf(utf8.RuneCount), 25 | "RuneCountInString": ValueOf(utf8.RuneCountInString), 26 | "RuneError": ValueOf(utf8.RuneError), 27 | "RuneLen": ValueOf(utf8.RuneLen), 28 | "RuneSelf": ValueOf(utf8.RuneSelf), 29 | "RuneStart": ValueOf(utf8.RuneStart), 30 | "UTFMax": ValueOf(utf8.UTFMax), 31 | "Valid": ValueOf(utf8.Valid), 32 | "ValidRune": ValueOf(utf8.ValidRune), 33 | "ValidString": ValueOf(utf8.ValidString), 34 | }, Untypeds: map[string]string{ 35 | "MaxRune": "rune:1114111", 36 | "RuneError": "rune:65533", 37 | "RuneSelf": "int:128", 38 | "UTFMax": "int:4", 39 | }, 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /imports/unsafe.go: -------------------------------------------------------------------------------- 1 | // this file was generated by gomacro command: import _b "unsafe" 2 | // DO NOT EDIT! Any change will be lost when the file is re-generated 3 | 4 | package imports 5 | 6 | import ( 7 | . "reflect" 8 | unsafe "unsafe" 9 | ) 10 | 11 | // reflection: allow interpreted code to import "unsafe" 12 | func init() { 13 | Packages["unsafe"] = Package{ 14 | Name: "unsafe", 15 | Types: map[string]Type{ 16 | "Pointer": TypeOf((*unsafe.Pointer)(nil)).Elem(), 17 | }, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /imports/util/util.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * util.go 12 | * 13 | * Created on: Nov 23, 2019 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package util 18 | 19 | import ( 20 | "strings" 21 | "unicode" 22 | ) 23 | 24 | // return the string after last '/' in path 25 | func FileName(path string) string { 26 | return path[1+strings.LastIndexByte(path, '/'):] 27 | } 28 | 29 | func TailIdentifier(s string) string { 30 | if len(s) == 0 { 31 | return s 32 | } 33 | // work on unicode runes, not on bytes 34 | chars := []rune(s) 35 | var i, n = 0, len(chars) 36 | var digit bool 37 | for i = n - 1; i >= 0; i-- { 38 | ch := chars[i] 39 | if ch < 0x80 { 40 | if ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z' { 41 | digit = false 42 | } else if ch >= '0' && ch <= '9' { 43 | digit = true 44 | } else { 45 | break 46 | } 47 | } else if unicode.IsLetter(ch) { 48 | digit = false 49 | } else if unicode.IsDigit(ch) { 50 | digit = true 51 | } else { 52 | break 53 | } 54 | } 55 | if digit { 56 | i++ 57 | } 58 | return string(chars[i+1:]) 59 | } 60 | -------------------------------------------------------------------------------- /issue122_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * issue122_test.go 12 | * 13 | * Created on: Jun 25 2022 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "reflect" 21 | 22 | "github.com/cosmos72/gomacro/imports" 23 | ) 24 | 25 | type Base struct{} 26 | type Wrapper struct{ *Base } 27 | 28 | func (f *Base) IsBase(struct{}) bool { 29 | return true 30 | } 31 | 32 | func (b *Wrapper) IsWrapper() bool { 33 | return true 34 | } 35 | 36 | func init() { 37 | imports.Packages["test/issue122"] = imports.Package{ 38 | Types: map[string]reflect.Type{ 39 | "Base": reflect.TypeOf((*Base)(nil)).Elem(), 40 | "Wrapper": reflect.TypeOf((*Wrapper)(nil)).Elem(), 41 | }, 42 | Wrappers: map[string][]string{ 43 | "Wrapper": {"IsBase"}, 44 | }, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * main.go 12 | * 13 | * Created on: Feb 13, 2017 14 | * Author: Massimiliano Ghilardi 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "os" 21 | 22 | "github.com/cosmos72/gomacro/cmd" 23 | ) 24 | 25 | func main() { 26 | args := os.Args[1:] 27 | 28 | cmd := cmd.New() 29 | 30 | err := cmd.Main(args) 31 | if err != nil { 32 | o := &cmd.Interp.Comp.Output 33 | o.Fprintf(o.Stderr, "%s\n", err) 34 | os.Exit(1) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /xreflect/README.md: -------------------------------------------------------------------------------- 1 | ### xreflect 2 | 3 | The package `xreflect` is a wrapper aroung Go standard packages `reflect` and `go/types` 4 | that **emulates** the missing features of `reflect` package: 5 | 6 | * NamedOf: declare new named types at runtime 7 | * AddMethod: add method to a named type at runtime 8 | * InterfaceOf: declare new interfaces at runtime 9 | 10 | ## License 11 | 12 | MPL v2.0+ 13 | -------------------------------------------------------------------------------- /xreflect/debug.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2018-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * debug.go 12 | * 13 | * Created on Apr 04, 2018 14 | * Author Massimiliano Ghilardi 15 | */ 16 | 17 | package xreflect 18 | 19 | import "fmt" 20 | 21 | func debugf(format string, args ...interface{}) { 22 | str := fmt.Sprintf(format, args...) 23 | fmt.Printf("// debug: %s\n", str) 24 | } 25 | 26 | func (v *Universe) debugf(format string, args ...interface{}) { 27 | depth := v.DebugDepth 28 | if depth == 0 { 29 | return 30 | } 31 | depth = depth*2 - 2 32 | const dots = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " 33 | pad := make([]byte, depth) 34 | for i := 0; i < depth; i += depth { 35 | copy(pad[i:], dots) 36 | } 37 | format = "// debug: %s" + format + "\n" 38 | args = append([]interface{}{pad}, args...) 39 | fmt.Printf(format, args...) 40 | } 41 | 42 | func (v *Universe) debug() bool { 43 | return v.DebugDepth != 0 44 | } 45 | 46 | func de(v *Universe) { 47 | v.DebugDepth-- 48 | } 49 | 50 | func bug(v *Universe) *Universe { 51 | v.DebugDepth++ 52 | return v 53 | } 54 | -------------------------------------------------------------------------------- /xreflect/gensym.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * gensym.go 12 | * 13 | * Created on May 07, 2017 14 | * Author Massimiliano Ghilardi 15 | */ 16 | 17 | package xreflect 18 | 19 | import ( 20 | "fmt" 21 | ) 22 | 23 | // the following constants must match with github.com/cosmos72/gomacro/base/constants.go 24 | const ( 25 | StrGensymInterface = "\U0001202A" // name of extra struct field needed by the interpreter when creating interpreted interfaces 26 | StrGensymPrivate = "\U00012038" // prefix to generate names for unexported struct fields. 27 | StrGensymAnonymous = "\U00012039" // prefix to generate names for anonymous struct fields. 28 | ) 29 | 30 | var gensymn = 0 31 | 32 | func GensymAnonymous(name string) string { 33 | if len(name) != 0 { 34 | return StrGensymAnonymous + name 35 | } 36 | n := gensymn 37 | gensymn++ 38 | return fmt.Sprintf("%s%d", StrGensymAnonymous, n) 39 | } 40 | 41 | func GensymPrivate(name string) string { 42 | if len(name) != 0 { 43 | return StrGensymPrivate + name 44 | } 45 | n := gensymn 46 | gensymn++ 47 | return fmt.Sprintf("%s%d", StrGensymPrivate, n) 48 | } 49 | -------------------------------------------------------------------------------- /xreflect/importer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * importer.go 12 | * 13 | * Created on May 14, 2017 14 | * Author Massimiliano Ghilardi 15 | */ 16 | 17 | package xreflect 18 | 19 | import ( 20 | "fmt" 21 | "go/importer" 22 | gotypes "go/types" 23 | 24 | "github.com/cosmos72/gomacro/go/types" 25 | ) 26 | 27 | type Importer struct { 28 | // converts from go/types to github.com/cosmos72/gomacro/go/types 29 | Converter types.Converter 30 | from gotypes.ImporterFrom 31 | compat gotypes.Importer 32 | srcDir string 33 | mode gotypes.ImportMode 34 | } 35 | 36 | func DefaultImporter() *Importer { 37 | imp := Importer{} 38 | imp.Converter.Init(types.Universe) 39 | compat := importer.Default() 40 | if from, ok := compat.(gotypes.ImporterFrom); ok { 41 | imp.from = from 42 | } else { 43 | imp.compat = compat 44 | } 45 | return &imp 46 | } 47 | 48 | func (imp *Importer) Import(path string) (*types.Package, error) { 49 | return imp.ImportFrom(path, imp.srcDir, imp.mode) 50 | } 51 | 52 | func (imp *Importer) ImportFrom(path string, srcDir string, mode gotypes.ImportMode) (*types.Package, error) { 53 | var pkg *gotypes.Package 54 | var err error 55 | if imp.from != nil { 56 | pkg, err = imp.from.ImportFrom(path, srcDir, mode) 57 | } else if imp.compat != nil { 58 | pkg, err = imp.compat.Import(path) 59 | } else { 60 | return nil, fmt.Errorf("importer.Default() returned nil, cannot import %q", path) 61 | } 62 | return imp.Converter.Package(pkg), err 63 | } 64 | -------------------------------------------------------------------------------- /xreflect/package.go: -------------------------------------------------------------------------------- 1 | /* 2 | * gomacro - A Go interpreter with Lisp-like macros 3 | * 4 | * Copyright (C) 2017-2019 Massimiliano Ghilardi 5 | * 6 | * This Source Code Form is subject to the terms of the Mozilla Public 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | * 10 | * 11 | * package.go 12 | * 13 | * Created on May 07, 2017 14 | * Author Massimiliano Ghilardi 15 | */ 16 | 17 | package xreflect 18 | 19 | import ( 20 | "strings" 21 | 22 | "github.com/cosmos72/gomacro/go/types" 23 | ) 24 | 25 | func (v *Universe) loadPackage(path string) *Package { 26 | if len(path) == 0 { 27 | // do not create unnamed packages 28 | return nil 29 | } 30 | // try the importer and its cache 31 | if pkg := v.importPackage(path); pkg != nil { 32 | return pkg 33 | } 34 | // no luck. create and return an empty Package 35 | if v.Packages == nil { 36 | v.Packages = make(map[string]*Package) 37 | } 38 | name := path[1+strings.LastIndexByte(path, '/'):] 39 | pkg := (*Package)(types.NewPackage(path, name)) 40 | v.Packages[path] = pkg 41 | return pkg 42 | } 43 | 44 | func (v *Universe) LoadPackage(path string) *Package { 45 | if len(path) == 0 { 46 | // do not create unnamed packages 47 | return nil 48 | } 49 | if v.ThreadSafe { 50 | defer un(lock(v)) 51 | } 52 | return v.loadPackage(path) 53 | } 54 | 55 | func (pkg *Package) GoPackage() *types.Package { 56 | return (*types.Package)(pkg) 57 | } 58 | 59 | func (pkg *Package) Name() string { 60 | if pkg == nil { 61 | return "" 62 | } 63 | return (*types.Package)(pkg).Name() 64 | } 65 | 66 | func (pkg *Package) Path() string { 67 | if pkg == nil { 68 | return "" 69 | } 70 | return (*types.Package)(pkg).Path() 71 | } 72 | --------------------------------------------------------------------------------