Showing preview only (2,777K chars total). Download the full file or copy to clipboard to get everything.
Repository: goplus/xgo
Branch: main
Commit: 98c85f111d9b
Files: 844
Total size: 2.5 MB
Directory structure:
gitextract_31rdv4zt/
├── .gitattributes
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug-report.yml
│ │ ├── config.yml
│ │ └── enhancement.yml
│ ├── codecov.yml
│ ├── dependabot.yml
│ ├── workflows/
│ │ ├── check_goreleaser_config.py
│ │ ├── go.yml
│ │ └── release-build.yml
│ └── xgopilot.yml
├── .gitignore
├── .goreleaser.yaml
├── CLAUDE.md
├── CODE_OF_CONDUCT.md
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── all.bash
├── all.bat
├── ast/
│ ├── ast.go
│ ├── ast_xgo.go
│ ├── commentmap.go
│ ├── filter.go
│ ├── fromgo/
│ │ ├── gopast.go
│ │ ├── gopast_test.go
│ │ ├── typeparams/
│ │ │ ├── typeparams_go117.go
│ │ │ └── typeparams_go118.go
│ │ └── typeparams_test.go
│ ├── gopq/
│ │ ├── dom.go
│ │ ├── gopq.go
│ │ └── helper.go
│ ├── goptest/
│ │ └── gopq.go
│ ├── import.go
│ ├── mod/
│ │ └── deps.go
│ ├── print.go
│ ├── resolve.go
│ ├── scope.go
│ ├── togo/
│ │ ├── goast.go
│ │ └── goast_test.go
│ └── walk.go
├── builtin/
│ └── doc.xgo
├── cl/
│ ├── _testc/
│ │ └── hello/
│ │ ├── in.xgo
│ │ └── out.go
│ ├── _testgop/
│ │ ├── _matrix/
│ │ │ └── in.xgo
│ │ ├── append1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── append2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── autoref-2484/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── builtin/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-html/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-huh/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-json/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-md/
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-regexp/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-tpl/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintpl/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql3/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql4/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql5/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql6/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql7/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── enumlines-rdr/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── enumlines-stdin/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── errwrap1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── errwrap2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── errwrap3/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── fatal/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── for-in/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── for-range/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── implicit-cast-2439/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── kwargs1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── kwargs2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── kwargs3/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── kwargs4/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── list-compr1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── list-compr2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-compr-cond1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-compr-cond2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-compr1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-field-access1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-field-access2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── optparam/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── optparam2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── rangeexpr/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── repeatuntil/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── select-compr-twovalue1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── select-compr-twovalue2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── select-compr1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── structtag/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── tuplelit/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── tupletype1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── tupletype2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ └── unit/
│ │ ├── in.xgo
│ │ └── out.go
│ ├── _testpy/
│ │ ├── _matrix/
│ │ │ └── in.xgo
│ │ ├── hello/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ └── pycall/
│ │ ├── in.xgo
│ │ └── out.go
│ ├── _testspx/
│ │ ├── basic/
│ │ │ ├── Game.tgmx
│ │ │ ├── Kai.tspx
│ │ │ └── out.go
│ │ ├── clsinit1/
│ │ │ ├── Rect.gox
│ │ │ └── out.go
│ │ ├── clsinit2/
│ │ │ ├── Rect.gox
│ │ │ └── out.go
│ │ ├── execgsh/
│ │ │ ├── demo.gsh
│ │ │ └── out.go
│ │ ├── gshself/
│ │ │ ├── demo.gsh
│ │ │ └── out.go
│ │ ├── init/
│ │ │ ├── init.tspx
│ │ │ └── out.go
│ │ ├── multiworks/
│ │ │ ├── foo_prompt.gox
│ │ │ ├── hello_tool.gox
│ │ │ ├── main_mcp.gox
│ │ │ └── out.go
│ │ ├── newobj/
│ │ │ ├── Kai_spx.gox
│ │ │ ├── main_spx.gox
│ │ │ └── out.go
│ │ ├── nogame/
│ │ │ ├── bar.tspx
│ │ │ └── out.go
│ │ ├── singlework/
│ │ │ ├── Kai_spx.gox
│ │ │ ├── main_spx.gox
│ │ │ └── out.go
│ │ └── xgoinit_dup/
│ │ ├── Spr_spx.gox
│ │ ├── main_spx.gox
│ │ └── out.go
│ ├── builtin.go
│ ├── builtin_test.go
│ ├── c.go
│ ├── classfile.go
│ ├── cltest/
│ │ ├── cltest.go
│ │ ├── error_msg.go
│ │ ├── recorder.go
│ │ └── spx.go
│ ├── compile.go
│ ├── compile_spx_test.go
│ ├── compile_test.go
│ ├── compile_testdir_test.go
│ ├── compile_xgo_test.go
│ ├── error_msg_test.go
│ ├── expr.go
│ ├── func_type_and_var.go
│ ├── internal/
│ │ ├── .gitignore
│ │ ├── dql/
│ │ │ └── dql.go
│ │ ├── gop-in-go/
│ │ │ └── foo/
│ │ │ ├── foo.xgo
│ │ │ ├── foo_test.xgo
│ │ │ └── footest_test.xgo
│ │ ├── huh/
│ │ │ └── huh.go
│ │ ├── llgo-hello/
│ │ │ └── hello.go
│ │ ├── mcp/
│ │ │ └── classfile.go
│ │ ├── overload/
│ │ │ ├── bar/
│ │ │ │ └── bar.go
│ │ │ └── foo/
│ │ │ └── foo.go
│ │ ├── spx/
│ │ │ ├── game.go
│ │ │ ├── pkg/
│ │ │ │ └── pkg.go
│ │ │ └── sprite.go
│ │ ├── spx2/
│ │ │ └── spx2.go
│ │ ├── spx3/
│ │ │ ├── jwt/
│ │ │ │ └── jwt.go
│ │ │ └── spx3.go
│ │ ├── spx4/
│ │ │ ├── game.go
│ │ │ ├── pkg/
│ │ │ │ └── pkg.go
│ │ │ └── sprite.go
│ │ ├── test/
│ │ │ ├── case.go
│ │ │ └── match.go
│ │ ├── testutil/
│ │ │ └── testutil.go
│ │ ├── typesutil/
│ │ │ ├── api.go
│ │ │ ├── api_test.go
│ │ │ ├── mode.go
│ │ │ └── mode_go123.go
│ │ └── unit/
│ │ └── unit.go
│ ├── outline/
│ │ └── outline.go
│ ├── recorder.go
│ ├── run_test.go
│ ├── stmt.go
│ ├── typeparams.go
│ └── typeparams_test.go
├── cmd/
│ ├── chore/
│ │ ├── goptestgo/
│ │ │ └── goptestgo.go
│ │ ├── xgobuiltingen/
│ │ │ ├── builtin.gox
│ │ │ ├── builtingen.gox
│ │ │ ├── helper.xgo
│ │ │ └── reference.gox
│ │ ├── xgofullspec/
│ │ │ └── fullspec.xgo
│ │ └── xgominispec/
│ │ └── minispec.xgo
│ ├── hdq/
│ │ ├── fetch_cmd.gox
│ │ ├── list_cmd.gox
│ │ ├── main_app.gox
│ │ └── xgo_autogen.go
│ ├── internal/
│ │ ├── base/
│ │ │ ├── base.go
│ │ │ └── pass.go
│ │ ├── bug/
│ │ │ └── bug.go
│ │ ├── build/
│ │ │ └── build.go
│ │ ├── clean/
│ │ │ └── clean.go
│ │ ├── deps/
│ │ │ └── deps.go
│ │ ├── doc/
│ │ │ └── doc.go
│ │ ├── env/
│ │ │ └── env.go
│ │ ├── gengo/
│ │ │ └── go.go
│ │ ├── gopfmt/
│ │ │ └── fmt.go
│ │ ├── gopget/
│ │ │ └── get.go
│ │ ├── help/
│ │ │ └── help.go
│ │ ├── install/
│ │ │ └── install.go
│ │ ├── list/
│ │ │ └── list.go
│ │ ├── mod/
│ │ │ ├── download.go
│ │ │ ├── init.go
│ │ │ ├── mod.go
│ │ │ └── tidy.go
│ │ ├── run/
│ │ │ └── run.go
│ │ ├── serve/
│ │ │ └── serve.go
│ │ ├── test/
│ │ │ ├── test.go
│ │ │ └── testflag.go
│ │ ├── version/
│ │ │ └── ver.go
│ │ └── watch/
│ │ └── watch.go
│ ├── make.go
│ ├── make_test.go
│ └── xgo/
│ ├── bug_cmd.gox
│ ├── build_cmd.gox
│ ├── clean_cmd.gox
│ ├── doc_cmd.gox
│ ├── env_cmd.gox
│ ├── fmt_cmd.gox
│ ├── get_cmd.gox
│ ├── go_cmd.gox
│ ├── install_cmd.gox
│ ├── main_app.gox
│ ├── mod_cmd.gox
│ ├── mod_download_cmd.gox
│ ├── mod_init_cmd.gox
│ ├── mod_tidy_cmd.gox
│ ├── run_cmd.gox
│ ├── serve_cmd.gox
│ ├── test_cmd.gox
│ ├── version_cmd.gox
│ ├── watch_cmd.gox
│ └── xgo_autogen.go
├── demo/
│ ├── _llgo/
│ │ ├── callpy/
│ │ │ └── callpy.xgo
│ │ ├── chello/
│ │ │ └── hello.xgo
│ │ ├── cpphello/
│ │ │ └── cpphello.xgo
│ │ ├── defer/
│ │ │ └── defer.xgo
│ │ ├── errors/
│ │ │ └── errors.xgo
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── goroutine/
│ │ │ └── goroutine.xgo
│ │ ├── hello/
│ │ │ └── hello.xgo
│ │ ├── hellollgo/
│ │ │ ├── README.md
│ │ │ └── hello.xgo
│ │ ├── matrix/
│ │ │ └── matrix.xgo
│ │ ├── pyhello/
│ │ │ └── hello.xgo
│ │ ├── pymax/
│ │ │ └── pymax.xgo
│ │ ├── pyprint/
│ │ │ └── print.xgo
│ │ ├── pytensor/
│ │ │ └── tensor.xgo
│ │ ├── qsort/
│ │ │ └── qsort.xgo
│ │ ├── reflect/
│ │ │ └── reflect.xgo
│ │ ├── sqlitedemo/
│ │ │ └── sqlitedemo.xgo
│ │ ├── statistics/
│ │ │ └── statistics.xgo
│ │ └── tetris/
│ │ └── tetris.xgo
│ ├── _tinygo/
│ │ ├── blink/
│ │ │ └── blink.xgo
│ │ ├── go.mod
│ │ └── sortdemo/
│ │ └── sort.xgo
│ ├── clsinit/
│ │ └── Rect.gox
│ ├── domaintext/
│ │ └── domaintext.xgo
│ ├── dql-fs/
│ │ └── fsq.xgo
│ ├── dql-json/
│ │ └── jq.xgo
│ ├── dql-links/
│ │ └── links.xgo
│ ├── dql-xgo/
│ │ └── xgoq.xgo
│ ├── dql-yaml/
│ │ └── yq.xgo
│ ├── fullspec/
│ │ ├── mixgo-complex/
│ │ │ ├── bar.go
│ │ │ ├── foo.xgo
│ │ │ └── xgo_autogen.go
│ │ ├── overloadfunc1/
│ │ │ └── add.xgo
│ │ ├── overloadfunc2/
│ │ │ └── mul.xgo
│ │ ├── overloadmethod/
│ │ │ └── method.xgo
│ │ ├── overloadop1/
│ │ │ └── overloadop.xgo
│ │ ├── overloadop2/
│ │ │ └── overloadop.xgo
│ │ └── tpl-gen-ast/
│ │ └── gen_calc_ast.xgo
│ ├── gsh-exec/
│ │ ├── exec.gsh
│ │ └── foo/
│ │ └── foo.xgo
│ ├── kwargs/
│ │ └── run.xgo
│ ├── lambda1/
│ │ └── lambda.xgo
│ ├── mapliteral/
│ │ └── mapliteral.xgo
│ ├── mixgo/
│ │ ├── README.md
│ │ ├── a.go
│ │ ├── b.xgo
│ │ └── xgo_autogen.go
│ ├── sliceliteral/
│ │ └── sliceliteral.xgo
│ ├── stringtrans/
│ │ └── transform.xgo
│ ├── tpl-calc/
│ │ └── calc.xgo
│ ├── tpl-calc-dump/
│ │ └── calc_dump.xgo
│ ├── tpl-intlist/
│ │ └── ints.xgo
│ ├── tpl-natural-lang/
│ │ └── nlang.xgo
│ ├── tpl-parser-demo/
│ │ └── demo.xgo
│ ├── tpl-pseudo/
│ │ ├── gauss.pseudo
│ │ └── pseudo.gox
│ ├── tpl-vcalc/
│ │ └── variant_calc.xgo
│ ├── tupletype/
│ │ └── tuple.xgo
│ ├── typeasparamsfunc/
│ │ ├── col.go
│ │ └── typeAsParamsFunc.xgo
│ ├── typeasparamsmethod/
│ │ ├── col.go
│ │ └── typeAsParamsMethod.xgo
│ ├── typeparamscast/
│ │ ├── foo.go
│ │ └── typecast.xgo
│ ├── unit-test/
│ │ ├── foo.xgo
│ │ └── foo_test.gox
│ ├── unitliteral/
│ │ └── unitlit.xgo
│ ├── xgo-calc/
│ │ └── calc.xgo
│ ├── xgo-parser/
│ │ └── parser.xgo
│ ├── xgo-sample/
│ │ ├── a.xgo
│ │ ├── b.xgo
│ │ └── cpkag/
│ │ └── b/
│ │ └── ab.go
│ ├── xgo-scanner/
│ │ ├── rpncalc/
│ │ │ └── rpncalc.xgo
│ │ ├── scanner.xgo
│ │ └── simplecalc/
│ │ └── calc.xgo
│ └── xgo-typeof/
│ └── typeof.xgo
├── doc/
│ ├── _testdata/
│ │ ├── gopoFn/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ ├── gopoMethod/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ ├── overloadFn/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ ├── overloadMethod/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ ├── xgoOverloadFn/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ └── xgoOverloadMethod/
│ │ ├── in.go
│ │ └── out.expect
│ ├── builtin.md
│ ├── classfile.md
│ ├── code-coverage.md
│ ├── contributing.md
│ ├── docs.md
│ ├── domian-text-lit.md
│ ├── fncall.md
│ ├── func-closure.md
│ ├── goodbye-printf.md
│ ├── map.md
│ ├── overload.md
│ ├── slice.md
│ ├── spec/
│ │ └── mini/
│ │ └── mini.xgo
│ ├── spec-mini.md
│ ├── spec.md
│ ├── string.md
│ ├── struct-vs-tuple.md
│ ├── xgo-vs-go.md
│ ├── z_gop.go
│ ├── z_test.go
│ └── z_transform.go
├── dql/
│ ├── README.md
│ ├── dql.go
│ ├── fetcher/
│ │ ├── fetch.go
│ │ ├── github.com/
│ │ │ ├── issueTask/
│ │ │ │ ├── issueTask.xgo
│ │ │ │ └── xgo_autogen.go
│ │ │ └── repoList/
│ │ │ ├── repoList.xgo
│ │ │ └── xgo_autogen.go
│ │ ├── hrefs/
│ │ │ ├── hrefs.xgo
│ │ │ └── xgo_autogen.go
│ │ ├── pkg.go.dev/
│ │ │ └── importedBy/
│ │ │ ├── importedBy.xgo
│ │ │ └── xgo_autogen.go
│ │ └── pytorch.org/
│ │ └── fndoc/
│ │ ├── fndoc.xgo
│ │ └── xgo_autogen.go
│ ├── fs/
│ │ └── fs.go
│ ├── golang/
│ │ ├── golang.go
│ │ └── parse.go
│ ├── html/
│ │ ├── html.go
│ │ ├── html_test.go
│ │ ├── node.go
│ │ └── text.go
│ ├── json/
│ │ └── json.go
│ ├── maps/
│ │ ├── maps.go
│ │ └── node.go
│ ├── reflects/
│ │ ├── node.go
│ │ └── reflects.go
│ ├── xgo/
│ │ ├── parse.go
│ │ └── xgo.go
│ ├── xml/
│ │ ├── node.go
│ │ ├── text.go
│ │ └── xml.go
│ └── yaml/
│ └── yaml.go
├── encoding/
│ ├── csv/
│ │ └── csv.go
│ ├── fs/
│ │ └── fs.go
│ ├── golang/
│ │ └── golang.go
│ ├── html/
│ │ └── html.go
│ ├── json/
│ │ └── json.go
│ ├── regexp/
│ │ └── regexp.go
│ ├── regexposix/
│ │ └── regexp.go
│ ├── xgo/
│ │ └── xgo.go
│ ├── xml/
│ │ └── xml.go
│ └── yaml/
│ └── yaml.go
├── env/
│ ├── build.go
│ ├── goenv.go
│ ├── gop_nonwindows.go
│ ├── path.go
│ ├── path_test.go
│ ├── sys_others.go
│ ├── sys_plan9.go
│ ├── sys_windows.go
│ ├── version.go
│ └── version_test.go
├── format/
│ ├── format.go
│ ├── formatutil/
│ │ ├── _testdata/
│ │ │ ├── format/
│ │ │ │ ├── basic/
│ │ │ │ │ ├── in.data
│ │ │ │ │ └── out.expect
│ │ │ │ └── nondecl/
│ │ │ │ ├── in.data
│ │ │ │ └── out.expect
│ │ │ ├── rearrange/
│ │ │ │ ├── noeol/
│ │ │ │ │ ├── in.data
│ │ │ │ │ └── out.expect
│ │ │ │ └── nondecl/
│ │ │ │ ├── in.data
│ │ │ │ └── out.expect
│ │ │ └── splitstmts/
│ │ │ └── basic/
│ │ │ ├── in.data
│ │ │ └── out.expect
│ │ ├── format_gop.go
│ │ └── format_test.go
│ └── internal.go
├── go.mod
├── go.sum
├── make.bash
├── make.bat
├── parser/
│ ├── _instance/
│ │ ├── instance1/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── instance2/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── instance3/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── instance4/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ └── instance5/
│ │ ├── cmd.xgo
│ │ └── parser.expect
│ ├── _nofmt/
│ │ ├── cmdlinestyle1/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle2/
│ │ │ ├── cmd2.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle3/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── exists/
│ │ │ ├── exists.xgo
│ │ │ └── parser.expect
│ │ ├── forloop/
│ │ │ ├── forloop.xgo
│ │ │ └── parser.expect
│ │ ├── listcompr/
│ │ │ ├── listcompr.xgo
│ │ │ └── parser.expect
│ │ ├── matrix1/
│ │ │ ├── matrix.xgo
│ │ │ └── parser.expect
│ │ ├── printvariadic/
│ │ │ ├── parser.expect
│ │ │ └── printv.xgo
│ │ ├── rangeexpr1/
│ │ │ ├── parser.expect
│ │ │ └── rangeexpr.xgo
│ │ ├── selectdata/
│ │ │ ├── parser.expect
│ │ │ └── select.xgo
│ │ ├── structtag/
│ │ │ ├── parser.expect
│ │ │ └── tag.xgo
│ │ └── tupletype/
│ │ ├── parser.expect
│ │ └── tuple.xgo
│ ├── _testdata/
│ │ ├── append1/
│ │ │ ├── append.xgo
│ │ │ └── parser.expect
│ │ ├── append2/
│ │ │ ├── append.xgo
│ │ │ └── parser.expect
│ │ ├── arrowop/
│ │ │ ├── arrowop.xgo
│ │ │ └── parser.expect
│ │ ├── autoprop/
│ │ │ ├── goto.xgo
│ │ │ └── parser.expect
│ │ ├── build/
│ │ │ ├── build.xgo
│ │ │ └── parser.expect
│ │ ├── c2gohello/
│ │ │ ├── hello.xgo
│ │ │ └── parser.expect
│ │ ├── classfile_init1/
│ │ │ ├── Rect.gox
│ │ │ └── parser.expect
│ │ ├── classfile_init2/
│ │ │ ├── Rect.gox
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle1/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle2/
│ │ │ ├── cmd2.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle3/
│ │ │ ├── cmd3.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle4/
│ │ │ ├── cmd4.xgo
│ │ │ └── parser.expect
│ │ ├── collection/
│ │ │ ├── collection.xgo
│ │ │ └── parser.expect
│ │ ├── complit/
│ │ │ ├── complit.xgo
│ │ │ └── parser.expect
│ │ ├── domainhuh/
│ │ │ ├── huh.xgo
│ │ │ └── parser.expect
│ │ ├── domaintext/
│ │ │ ├── parser.expect
│ │ │ └── tpl.xgo
│ │ ├── domaintpl/
│ │ │ ├── parser.expect
│ │ │ └── tpl.xgo
│ │ ├── dql1/
│ │ │ ├── dql.xgo
│ │ │ └── parser.expect
│ │ ├── dql2/
│ │ │ ├── dql.xgo
│ │ │ └── parser.expect
│ │ ├── dql3/
│ │ │ ├── dql.xgo
│ │ │ └── parser.expect
│ │ ├── embedded1/
│ │ │ ├── embtype.xgo
│ │ │ └── parser.expect
│ │ ├── envop1/
│ │ │ ├── envop.xgo
│ │ │ └── parser.expect
│ │ ├── envop2/
│ │ │ ├── envop.xgo
│ │ │ └── parser.expect
│ │ ├── errwrap1/
│ │ │ ├── errwrap.xgo
│ │ │ └── parser.expect
│ │ ├── errwrap2/
│ │ │ ├── errwrap2.xgo
│ │ │ └── parser.expect
│ │ ├── errwrap3/
│ │ │ ├── errwrap3.xgo
│ │ │ └── parser.expect
│ │ ├── exists/
│ │ │ ├── exists.xgo
│ │ │ └── parser.expect
│ │ ├── fnbody/
│ │ │ ├── fnbody.xgo
│ │ │ └── parser.expect
│ │ ├── fncall/
│ │ │ ├── fncall.xgo
│ │ │ └── parser.expect
│ │ ├── forloop/
│ │ │ ├── forloop.xgo
│ │ │ └── parser.expect
│ │ ├── funcdecl1/
│ │ │ ├── fndecl.xgo
│ │ │ └── parser.expect
│ │ ├── funcdecl2/
│ │ │ ├── fndecl.xgo
│ │ │ └── parser.expect
│ │ ├── funcdecl3/
│ │ │ ├── fndecl.xgo
│ │ │ └── parser.expect
│ │ ├── funcdoc/
│ │ │ ├── funcdoc.xgo
│ │ │ └── parser.expect
│ │ ├── funclit/
│ │ │ ├── funclit.xgo
│ │ │ └── parser.expect
│ │ ├── functype/
│ │ │ ├── dummy/
│ │ │ │ └── dummy.md
│ │ │ ├── functype.go
│ │ │ └── parser.expect
│ │ ├── gmxtest/
│ │ │ ├── foo.gmx
│ │ │ └── parser.expect
│ │ ├── goto1/
│ │ │ ├── goto.xgo
│ │ │ └── parser.expect
│ │ ├── goto2/
│ │ │ ├── goto.xgo
│ │ │ └── parser.expect
│ │ ├── goxtest1/
│ │ │ ├── bar.gox
│ │ │ └── parser.expect
│ │ ├── goxtest2/
│ │ │ ├── bar.gox
│ │ │ └── parser.expect
│ │ ├── kwargs1/
│ │ │ ├── kwargs.xgo
│ │ │ └── parser.expect
│ │ ├── lambda1/
│ │ │ ├── lambda.xgo
│ │ │ └── parser.expect
│ │ ├── lambda2/
│ │ │ ├── lambda2.xgo
│ │ │ └── parser.expect
│ │ ├── lambda3/
│ │ │ ├── lambda3.xgo
│ │ │ └── parser.expect
│ │ ├── lambda4/
│ │ │ ├── lambda4.xgo
│ │ │ └── parser.expect
│ │ ├── listcompr/
│ │ │ ├── listcompr.xgo
│ │ │ └── parser.expect
│ │ ├── mapfunc/
│ │ │ ├── map.xgo
│ │ │ └── parser.expect
│ │ ├── matrix1/
│ │ │ ├── matrix.xgo
│ │ │ └── parser.expect
│ │ ├── matrix2/
│ │ │ ├── matrix.xgo
│ │ │ └── parser.expect
│ │ ├── mytest/
│ │ │ ├── mytest.xgo
│ │ │ └── parser.expect
│ │ ├── optparam/
│ │ │ ├── optparam.xgo
│ │ │ └── parser.expect
│ │ ├── overload1/
│ │ │ ├── overload.xgo
│ │ │ └── parser.expect
│ │ ├── overload2/
│ │ │ ├── overload2.xgo
│ │ │ └── parser.expect
│ │ ├── overloadop/
│ │ │ ├── op_overload.xgo
│ │ │ └── parser.expect
│ │ ├── printvariadic/
│ │ │ ├── parser.expect
│ │ │ └── printv.xgo
│ │ ├── pystr/
│ │ │ ├── parser.expect
│ │ │ └── pystr.xgo
│ │ ├── rangeexpr1/
│ │ │ ├── parser.expect
│ │ │ └── rangeexpr.xgo
│ │ ├── rangeexpr2/
│ │ │ ├── parser.expect
│ │ │ └── rangeexpr.xgo
│ │ ├── rangeexpr3/
│ │ │ ├── parser.expect
│ │ │ └── rangeexpr.xgo
│ │ ├── rational/
│ │ │ ├── parser.expect
│ │ │ └── rational.xgo
│ │ ├── selectdata/
│ │ │ ├── parser.expect
│ │ │ └── select.xgo
│ │ ├── slice1/
│ │ │ ├── parser.expect
│ │ │ └── slice.xgo
│ │ ├── slice2/
│ │ │ ├── parser.expect
│ │ │ └── slice2.xgo
│ │ ├── spxtest/
│ │ │ ├── foo.spx
│ │ │ └── parser.expect
│ │ ├── staticmthd1/
│ │ │ ├── parser.expect
│ │ │ └── static_method.xgo
│ │ ├── staticmthd2/
│ │ │ ├── a.gox
│ │ │ └── parser.expect
│ │ ├── stdtype/
│ │ │ ├── parser.expect
│ │ │ └── stdtype.xgo
│ │ ├── stringex1/
│ │ │ ├── parser.expect
│ │ │ └── string_lit.xgo
│ │ ├── stringex2/
│ │ │ ├── parser.expect
│ │ │ └── string_lit.xgo
│ │ ├── stringex3/
│ │ │ ├── parser.expect
│ │ │ └── string_lit.xgo
│ │ ├── tuplelit/
│ │ │ ├── parser.expect
│ │ │ └── tuplelit.xgo
│ │ ├── tupletype/
│ │ │ ├── parser.expect
│ │ │ └── tupletype.xgo
│ │ ├── typeof/
│ │ │ ├── parser.expect
│ │ │ └── typeof.xgo
│ │ ├── typeswitch/
│ │ │ ├── parser.expect
│ │ │ └── typeswitch.xgo
│ │ └── unit/
│ │ ├── parser.expect
│ │ └── step.xgo
│ ├── _testexpr/
│ │ └── lambda/
│ │ ├── in.xgo
│ │ └── out.expect
│ ├── fsx/
│ │ ├── fsys.go
│ │ └── memfs/
│ │ ├── fs.go
│ │ └── memfs.go
│ ├── interface.go
│ ├── parser.go
│ ├── parser_test.go
│ ├── parser_xgo.go
│ ├── parserdir_go118_test.go
│ ├── parserdir_test.go
│ └── parsertest/
│ └── parsertest.go
├── printer/
│ ├── _testdata/
│ │ ├── 02-Var-and-operator/
│ │ │ └── var_and_op.xgo
│ │ ├── 03-Import-go-package/
│ │ │ └── import.xgo
│ │ ├── 04-Func/
│ │ │ └── func.xgo
│ │ ├── 05-Closure/
│ │ │ └── closure.xgo
│ │ ├── 06-String-Map-Array-Slice/
│ │ │ └── datastruct.xgo
│ │ ├── 07-MapLit/
│ │ │ └── maplit.xgo
│ │ ├── 08-SliceLit/
│ │ │ └── slicelit.xgo
│ │ ├── 09-IfElse-SwitchCase/
│ │ │ └── flow.xgo
│ │ ├── 10-List-comprehension/
│ │ │ └── list_comprehens.xgo
│ │ ├── 11-Map-comprehension/
│ │ │ └── map_comprehens.xgo
│ │ ├── 12-Select-comprehension/
│ │ │ └── select.xgo
│ │ ├── 12-Select-comprehension2/
│ │ │ └── findscore.xgo
│ │ ├── 13-Exists-comprehension/
│ │ │ └── exists.xgo
│ │ ├── 14-Using-goplus-in-Go/
│ │ │ └── foo/
│ │ │ ├── foo.xgo
│ │ │ ├── foo_test.xgo
│ │ │ └── footest_test.xgo
│ │ ├── 15-ErrWrap/
│ │ │ └── err_wrap.xgo
│ │ ├── 16-Fib/
│ │ │ └── fib.xgo
│ │ ├── 17-Fibtc/
│ │ │ └── fibtc.xgo
│ │ ├── 18-Rational/
│ │ │ └── rational.xgo
│ │ ├── 21-Break-continue-goto/
│ │ │ └── flow.xgo
│ │ ├── 22-For-loop/
│ │ │ └── for.xgo
│ │ ├── 23-Defer/
│ │ │ └── defer.xgo
│ │ ├── 24-Goroutine/
│ │ │ └── goroutine.xgo
│ │ ├── 25-Struct/
│ │ │ └── struct.xgo
│ │ ├── 26-Method/
│ │ │ └── method.xgo
│ │ ├── 27-Func-Set/
│ │ │ └── func.xgo
│ │ ├── 28-Chan/
│ │ │ └── chan.xgo
│ │ ├── 29-CompareToNil/
│ │ │ └── ref.xgo
│ │ ├── 30-Recover/
│ │ │ └── recover.xgo
│ │ ├── 31-Builtin-Typecast/
│ │ │ └── builtin_and_typecast.xgo
│ │ ├── 32-Import-gop-package/
│ │ │ └── import_gop_pkg.xgo
│ │ ├── 33-Interface/
│ │ │ └── shape.xgo
│ │ ├── 34-Type-assert/
│ │ │ └── type_assert.xgo
│ │ ├── 35-Chan-select/
│ │ │ └── select.xgo
│ │ ├── 36-Auto-Property/
│ │ │ └── autoprop.xgo
│ │ ├── 37-Cmdline/
│ │ │ └── cmdline.xgo
│ │ ├── 38-Overload-operator/
│ │ │ └── overload_op.xgo
│ │ ├── 39-Lambda-expression/
│ │ │ └── lambda.xgo
│ │ ├── 40-Deduce-struct-type/
│ │ │ └── deduce.xgo
│ │ ├── 41-UDT-RangeForEach/
│ │ │ └── udt_range.xgo
│ │ ├── 42-UDT-RangeIterator/
│ │ │ └── udt_range_iter.xgo
│ │ └── 43-RangeExpr/
│ │ └── rangeexpr.xgo
│ ├── bugfix_test.go
│ ├── nodes.go
│ ├── printer.go
│ ├── printer_test.go
│ └── xgo_test.go
├── scanner/
│ ├── gop.go
│ └── scanner.go
├── test/
│ └── classfile.go
├── token/
│ ├── internal/
│ │ └── tokenutil/
│ │ ├── lines_go118.go
│ │ ├── lines_go120.go
│ │ ├── lines_go121.go
│ │ └── lines_test.go
│ ├── token.go
│ ├── token_test.go
│ └── types.go
├── tool/
│ ├── _gendeps.go
│ ├── build_install_run.go
│ ├── gengo.go
│ ├── imp.go
│ ├── load.go
│ ├── outline.go
│ └── tidy.go
├── tpl/
│ ├── README.md
│ ├── ast/
│ │ └── ast.go
│ ├── cl/
│ │ └── compile.go
│ ├── matcher/
│ │ └── match.go
│ ├── parser/
│ │ ├── _testdata/
│ │ │ ├── adjoin/
│ │ │ │ ├── in.xgo
│ │ │ │ └── out.expect
│ │ │ ├── pseudo/
│ │ │ │ ├── in.xgo
│ │ │ │ └── out.expect
│ │ │ ├── simple1/
│ │ │ │ ├── in.xgo
│ │ │ │ └── out.expect
│ │ │ └── simple2/
│ │ │ ├── in.xgo
│ │ │ └── out.expect
│ │ ├── parser.go
│ │ ├── parser_test.go
│ │ └── parsertest/
│ │ └── parsertest.go
│ ├── scanner/
│ │ ├── _testdata/
│ │ │ ├── cstr/
│ │ │ │ ├── go.expect
│ │ │ │ ├── gop.expect
│ │ │ │ ├── in.xgo
│ │ │ │ └── tpl.expect
│ │ │ ├── num/
│ │ │ │ ├── go.expect
│ │ │ │ ├── gop.expect
│ │ │ │ ├── in.xgo
│ │ │ │ └── tpl.expect
│ │ │ ├── pow/
│ │ │ │ ├── go.expect
│ │ │ │ ├── gop.expect
│ │ │ │ ├── in.xgo
│ │ │ │ └── tpl.expect
│ │ │ ├── rat/
│ │ │ │ ├── go.expect
│ │ │ │ ├── gop.expect
│ │ │ │ ├── in.xgo
│ │ │ │ └── tpl.expect
│ │ │ └── unit/
│ │ │ ├── go.expect
│ │ │ ├── gop.expect
│ │ │ ├── in.xgo
│ │ │ └── tpl.expect
│ │ ├── error.go
│ │ ├── scandir_test.go
│ │ ├── scanner.go
│ │ ├── scanner_test.go
│ │ └── scannertest/
│ │ └── scannertest.go
│ ├── token/
│ │ ├── token.go
│ │ ├── token_test.go
│ │ └── types.go
│ ├── tpl.go
│ ├── types/
│ │ └── types.go
│ └── variant/
│ ├── builtin/
│ │ └── builtin.go
│ ├── delay/
│ │ └── delay.go
│ ├── math/
│ │ └── math.go
│ ├── module.go
│ ├── time/
│ │ └── time.go
│ └── variant.go
└── x/
├── build/
│ ├── _testdata/
│ │ ├── hello/
│ │ │ ├── hello.expect
│ │ │ └── main.xgo
│ │ ├── multi/
│ │ │ ├── Rect.gox
│ │ │ ├── main.xgo
│ │ │ └── multi.expect
│ │ └── pkg/
│ │ ├── pkg.expect
│ │ └── pkg.xgo
│ ├── build.go
│ └── build_test.go
├── fakenet/
│ └── conn.go
├── format/
│ ├── README.md
│ ├── _testdata/
│ │ ├── collection/
│ │ │ ├── format.expect
│ │ │ └── index.xgo
│ │ ├── gopsyntax/
│ │ │ ├── format.expect
│ │ │ └── index.xgo
│ │ └── syntax/
│ │ ├── format.expect
│ │ └── index.xgo
│ ├── format.go
│ ├── gopstyle.go
│ ├── gopstyle_test.go
│ ├── gopstyledir_test.go
│ └── stmt_expr_or_type.go
├── fsnotify/
│ └── fsnotify.go
├── gocmd/
│ ├── build_install.go
│ ├── gocmd.go
│ └── run.go
├── jsonrpc2/
│ ├── conn.go
│ ├── frame.go
│ ├── internal/
│ │ └── stack/
│ │ ├── parse.go
│ │ ├── process.go
│ │ ├── stack.go
│ │ └── stacktest/
│ │ └── stacktest.go
│ ├── jsonrpc2.go
│ ├── jsonrpc2test/
│ │ ├── cases/
│ │ │ └── testcase.go
│ │ ├── jsonrpc2_test.go
│ │ ├── pipe.go
│ │ └── pipe_test.go
│ ├── messages.go
│ ├── serve.go
│ ├── stdio/
│ │ ├── server.go
│ │ └── stdio.go
│ └── wire.go
├── langserver/
│ ├── client.go
│ ├── serve_dial.go
│ └── server.go
├── typesutil/
│ ├── api.go
│ ├── builtin_test.go
│ ├── check.go
│ ├── check_test.go
│ ├── code_string.go
│ ├── codes.go
│ ├── eval.go
│ ├── exprstring.go
│ ├── exprstring_test.go
│ ├── gopinfo.go
│ ├── info_test.go
│ ├── internal/
│ │ └── typesutil/
│ │ └── types.go
│ └── typeparams/
│ └── typeparams.go
├── watcher/
│ ├── changes.go
│ └── watch.go
├── xgoenv/
│ └── env.go
└── xgoprojs/
├── proj.go
└── proj_test.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
*.expect text eol=lf
*.golden text eol=lf
*.xgo text eol=lf
*.gop text eol=lf
*.go text eol=lf
*.gox text eol=lf
================================================
FILE: .github/ISSUE_TEMPLATE/bug-report.yml
================================================
name: Bug Report
description: Create a report to help us improve
body:
- type: markdown
attributes:
value: |
⚠️ Make sure to browse the opened and closed issues before submit your issue.
- type: textarea
id: sample
attributes:
label: "The following program `sample.gop` triggers an unexpected result"
value: |
// add a sample
render: coffee
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected result
render: console
validations:
required: true
- type: textarea
id: got
attributes:
label: Got
description: |-
```console
$ gop run ./sample.gop
// output
```
placeholder: $ xgo run ./sample.gop
render: console
validations:
required: true
- type: input
id: version
attributes:
label: XGo Version
description: Can be a tag or a hash.
validations:
required: true
- type: textarea
id: additional
attributes:
label: Additional Notes
description: Use [Markdown syntax](https://help.github.com/articles/github-flavored-markdown) if needed.
validations:
required: false
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
contact_links:
- name: Visit the XGo website
url: https://xgo.dev
about: Much help can be found there
================================================
FILE: .github/ISSUE_TEMPLATE/enhancement.yml
================================================
name: Feature request
description: Propose a change to XGo
body:
- type: markdown
attributes:
value: |
⚠️ Make sure to browse the opened and closed issues before submit your issue.
- type: textarea
id: proposal
attributes:
label: Proposal
description: Write your feature request in the form of a proposal to be considered for implementation.
validations:
required: true
- type: textarea
id: background
attributes:
label: Background
description: Describe the background problem or need that led to this feature request.
validations:
required: true
- type: textarea
id: workarounds
attributes:
label: Workarounds
description: Are there any current workarounds that you're using that others in similar positions should know about?
validations:
required: true
================================================
FILE: .github/codecov.yml
================================================
coverage:
ignore:
- "builtin"
- "ast"
- "test"
- "scanner"
- "format"
- "demo"
- "demo/unit-test"
- "doc/spec"
- "cmd"
- "cl/cltest"
- "cl/outline"
- "cl/internal/dql"
- "cl/internal/huh"
- "cl/internal/llgo-hello"
- "cl/internal/mcp"
- "cl/internal/overload"
- "cl/internal/spx"
- "cl/internal/spx2"
- "cl/internal/spx3"
- "cl/internal/test"
- "cl/internal/unit"
- "parser/fsx"
- "parser/iox"
- "parser/parsertest"
- "x/jsonrpc2"
- "x/jsonrpc2/jsonrpc2test"
- "x/watcher"
- "x/langserver"
- "x/fsnotify"
- "x/fakenet"
- "x/typesutil"
- "x/gocmd"
- "x/gopenv"
- "tool"
- "encoding"
- "tpl"
- "dql"
================================================
FILE: .github/dependabot.yml
================================================
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: github-actions
directory: /
labels:
- dependabot
- actions
schedule:
interval: daily
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
================================================
FILE: .github/workflows/check_goreleaser_config.py
================================================
import os
import subprocess
import yaml
files = [f for f in os.listdir('.') if not f.startswith(
".") and f not in ["VERSION"]]
files.sort()
# filter out the files that are ignored by git
files = [f for f in files if subprocess.call(
["git", "ls-files", "--error-unmatch", f],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) == 0]
gorel = yaml.load(open(".goreleaser.yaml", "r"), Loader=yaml.FullLoader)
scfiles = [f["source"] for f in gorel["snapcrafts"][0]["extra_files"]]
scfiles.sort()
failed = False
if files != scfiles:
failed = True
print("Files in snapcraft are different from the ones in the repo")
print("Update .goreleaser.yaml in the snapcraft section:")
for f in files:
print(f" - source: \"{f}\"")
print(f" destination: \"{f}\"")
nfpms_files = [f["src"]
for f in gorel["nfpms"][0]["contents"] if f.get("type") != "symlink"]
nfpms_files.sort()
if files != nfpms_files:
failed = True
print("Files in nfpms are different from the ones in the repo")
print("Update .goreleaser.yaml in the nfpms section:")
for f in files:
print(f" - src: \"{f}\"")
print(f" dst: \"/usr/lib/{{{{ .ProjectName }}}}/{f}\"")
# Check archives[0].files
archives_files = gorel["archives"][0].get("files", [])
archives_files.sort()
if files != archives_files:
failed = True
print("Files in archives are different from the ones in the repo")
print("Update .goreleaser.yaml in the archives section:")
for f in files:
print(f" - \"{f}\"")
if failed:
exit(1)
print(".goreleaser checks passed")
================================================
FILE: .github/workflows/go.yml
================================================
name: XGo CI
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
jobs:
Check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check goreleaser files
run: |
pip install --no-input pyyaml
python .github/workflows/check_goreleaser_config.py
TestXGoInstaller:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Test XGo installer
run: |
git config --global user.email "build-robot@xgo.dev"
git config --global user.name "build robot"
go test -v cmd/make_test.go
Test:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
go:
- 1.24.x
- 1.25.x
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
- name: Run testcases
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./...
- name: Codecov
uses: codecov/codecov-action@v5
with:
slug: goplus/xgo
FormatCheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.24.2"
- name: Check formatting
run: |
if [ -n "$(go fmt ./... | grep -v xgo_autogen)" ]; then
echo "Some files are not properly formatted. Please run 'go fmt ./...'"
exit 1
fi
./all.bash
cd cmd/xgo; xgo fmt -t ./...
================================================
FILE: .github/workflows/release-build.yml
================================================
name: Release Build
on:
push:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check goreleaser files
run: |
pip install --no-input pyyaml
python .github/workflows/check_goreleaser_config.py
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v3
- name: Checkout tag
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
tag_name="${GITHUB_REF##*/}"
echo Current tag: $tag_name
git checkout $tag_name
echo "TAG_NAME=${tag_name}" >> $GITHUB_ENV
- name: Check pre-release
run: |
tag="${TAG_NAME}"
# check stable version format vX.Y.Z
if ! [[ $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "This is a pre-release: $tag"
echo "IS_PRERELEASE=true" >> $GITHUB_ENV
fi
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.24.x
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Release with goreleaser
uses: goreleaser/goreleaser-action@v7
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean -p 4
env:
GITHUB_TOKEN: ${{ github.token }}
DOCKER_IMAGE_REPO: ghcr.io/${{ github.repository }}
WINGET_PKGS_PRIVATE_KEY: ${{ secrets.WINGET_PKGS_PRIVATE_KEY }}
- name: Upload deb/rpm to Fury.io
if: env.IS_PRERELEASE != 'true'
run: |
for file in .dist/*.{deb,rpm}
do
echo "Uploading $file to Fury.io"
CODE=`curl --write-out '%{http_code}' --output /dev/null -sS -F package=@$file https://$FURY_TOKEN@push.fury.io/$GITHUB_REPOSITORY_OWNER/`
if [ "$CODE" != "200" ]; then
echo "Upload failed with code $CODE"
exit 1
fi
done
env:
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
================================================
FILE: .github/xgopilot.yml
================================================
claude:
model: "claude-4.6-opus"
================================================
FILE: .gitignore
================================================
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
*.txt
*.cache
.DS_Store
test.db
go.json
x.mod
# gop
# gopfmt
# goptestgo
# Folders
_obj
_test
_old
_t
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
coverage.txt
.xgo/
.gop/
gop_autogen*.go
xgo_autogen*.go
!dql/fetcher/**/xgo_autogen.go
!cmd/xgo/gop_autogen*.go
!cmd/xgo/xgo_autogen*.go
!cmd/hdq/xgo_autogen*.go
!demo/fullspec/mixgo-complex/xgo_autogen.go
!demo/mixgo/xgo_autogen.go
go.json
go.work*
format.result
*.cache
*.exe
*.test
*.prof
.vscode
.idea
cmd/qfmt/qfmt
bin/
go-num/
_todo*.go
.dist/
================================================
FILE: .goreleaser.yaml
================================================
version: 2
env:
- DOCKER_IMAGE_REPO={{ envOrDefault "DOCKER_IMAGE_REPO" "xgo" }}
dist: .dist
before:
hooks:
- go mod download
builds:
- id: xgo
main: ./cmd/xgo
binary: bin/xgo
flags:
- -trimpath
ldflags:
- -X github.com/goplus/xgo/env.buildVersion=v{{.Version}}
- -X github.com/goplus/xgo/env.buildDate={{.CommitDate}}
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
mod_timestamp: "{{ .CommitTimestamp }}"
- id: gop
main: ./cmd/xgo
binary: bin/gop
flags:
- -trimpath
ldflags:
- -X github.com/goplus/xgo/env.buildVersion=v{{.Version}}
- -X github.com/goplus/xgo/env.buildDate={{.CommitDate}}
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
mod_timestamp: "{{ .CommitTimestamp }}"
archives:
- format: tar.gz
name_template: >-
{{.ProjectName}}{{.Version}}.{{.Os}}-{{.Arch}}
{{- if .Arm}}v{{.Arm}}{{end}}
format_overrides:
- goos: windows
format: zip
files:
- "CLAUDE.md"
- "CODE_OF_CONDUCT.md"
- "Dockerfile"
- "LICENSE"
- "Makefile"
- "README.md"
- "all.bash"
- "all.bat"
- "ast"
- "tpl"
- "tool"
- "builtin"
- "cl"
- "cmd"
- "doc"
- "dql"
- "encoding"
- "env"
- "format"
- "go.mod"
- "go.sum"
- "make.bash"
- "make.bat"
- "parser"
- "printer"
- "scanner"
- "test"
- "demo"
- "token"
- "x"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
dockers_v2:
- id: xgo
dockerfile: Dockerfile
images:
- "{{ .Env.DOCKER_IMAGE_REPO }}"
tags:
- "{{ .Version }}"
- "{{ .Major }}.{{ .Minor }}"
- "{{ .Major }}"
- latest
platforms:
- linux/386
- linux/amd64
- linux/arm64
build_args:
USE_GORELEASER_ARTIFACTS: "1"
extra_files:
- ./
winget:
- name: goplus
homepage: "https://xgo.dev/"
publisher: goplus
publisher_url: https://github.com/goplus/xgo
publisher_support_url: "https://github.com/goplus/xgo/issues/new"
package_identifier: goplus.xgo
path: "manifests/g/goplus/xgo/{{.Version}}"
tags:
- golang
- go
- xgo
- goplus
- programming
- language
- compiler
- interpreter
- data science
- engineering
- education
short_description: The XGo Programming Language
description: |
The XGo programming language is designed for engineering, STEM education, and data science.
- For engineering: working in the simplest language that can be mastered by children.
- For STEM education: studying an engineering language that can be used for work in the future.
- For data science: communicating with engineers in the same language.
license: Apache-2.0
skip_upload: auto
release_notes: "{{.Changelog}}"
release_notes_url: "https://github.com/{{ .Env.GITHUB_REPOSITORY_OWNER }}/xgo/releases/tag/v{{.Version}}"
dependencies:
- package_identifier: GoLang.Go
minimum_version: 1.18.0
repository:
owner: goplus
name: winget-pkgs
branch: "{{.ProjectName}}-v{{.Version}}"
git:
url: "git@github.com:{{ .Env.GITHUB_REPOSITORY_OWNER }}/winget-pkgs.git"
private_key: "{{ .Env.WINGET_PKGS_PRIVATE_KEY }}"
pull_request:
enabled: true
draft: true
base:
owner: microsoft
name: winget-pkgs
branch: master
nfpms:
- package_name: xgo
vendor: goplus
homepage: https://xgo.dev/
maintainer: Li Jie <cpunion@gmail.com>
license: Apache-2.0
description: |
The XGo programming language is designed for engineering, STEM education, and data science.
- For engineering: working in the simplest language that can be mastered by children.
- For STEM education: studying an engineering language that can be used for work in the future.
- For data science: communicating with engineers in the same language.
formats:
- "deb"
- "rpm"
overrides:
deb:
dependencies:
- "golang-go (>= 1.18.0)"
rpm:
dependencies:
- "golang-bin >= 1.18.0"
file_name_template: >-
{{ .ProjectName }}{{.Version}}.{{ .Os }}-{{ .Arch }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
bindir: /usr/lib/{{ .ProjectName }}
contents:
# source folder
- src: "CLAUDE.md"
dst: "/usr/lib/{{ .ProjectName }}/CLAUDE.md"
- src: "CODE_OF_CONDUCT.md"
dst: "/usr/lib/{{ .ProjectName }}/CODE_OF_CONDUCT.md"
- src: "Dockerfile"
dst: "/usr/lib/{{ .ProjectName }}/Dockerfile"
- src: "LICENSE"
dst: "/usr/lib/{{ .ProjectName }}/LICENSE"
- src: "Makefile"
dst: "/usr/lib/{{ .ProjectName }}/Makefile"
- src: "README.md"
dst: "/usr/lib/{{ .ProjectName }}/README.md"
- src: "all.bash"
dst: "/usr/lib/{{ .ProjectName }}/all.bash"
- src: "all.bat"
dst: "/usr/lib/{{ .ProjectName }}/all.bat"
- src: "ast"
dst: "/usr/lib/{{ .ProjectName }}/ast"
- src: "tpl"
dst: "/usr/lib/{{ .ProjectName }}/tpl"
- src: "dql"
dst: "/usr/lib/{{ .ProjectName }}/dql"
- src: "tool"
dst: "/usr/lib/{{ .ProjectName }}/tool"
- src: "builtin"
dst: "/usr/lib/{{ .ProjectName }}/builtin"
- src: "cl"
dst: "/usr/lib/{{ .ProjectName }}/cl"
- src: "cmd"
dst: "/usr/lib/{{ .ProjectName }}/cmd"
- src: "doc"
dst: "/usr/lib/{{ .ProjectName }}/doc"
- src: "encoding"
dst: "/usr/lib/{{ .ProjectName }}/encoding"
- src: "env"
dst: "/usr/lib/{{ .ProjectName }}/env"
- src: "format"
dst: "/usr/lib/{{ .ProjectName }}/format"
- src: "go.mod"
dst: "/usr/lib/{{ .ProjectName }}/go.mod"
- src: "go.sum"
dst: "/usr/lib/{{ .ProjectName }}/go.sum"
- src: "make.bash"
dst: "/usr/lib/{{ .ProjectName }}/make.bash"
- src: "make.bat"
dst: "/usr/lib/{{ .ProjectName }}/make.bat"
- src: "parser"
dst: "/usr/lib/{{ .ProjectName }}/parser"
- src: "printer"
dst: "/usr/lib/{{ .ProjectName }}/printer"
- src: "scanner"
dst: "/usr/lib/{{ .ProjectName }}/scanner"
- src: "test"
dst: "/usr/lib/{{ .ProjectName }}/test"
- src: "demo"
dst: "/usr/lib/{{ .ProjectName }}/demo"
- src: "token"
dst: "/usr/lib/{{ .ProjectName }}/token"
- src: "x"
dst: "/usr/lib/{{ .ProjectName }}/x"
# symlinks to binaries
- src: "/usr/lib/{{ .ProjectName }}/bin/xgo"
dst: /usr/bin/xgo
type: symlink
- src: "/usr/lib/{{ .ProjectName }}/bin/xgo"
dst: /usr/bin/gop
type: symlink
snapcrafts:
- id: xgo
name: xgo
title: The XGo Programming Language
summary: The XGo Programming Language
description: |
The XGo programming language is designed for engineering, STEM education, and data science.
- For engineering: working in the simplest language that can be mastered by children.
- For STEM education: studying an engineering language that can be used for work in the future.
- For data science: communicating with engineers in the same language.
confinement: classic
license: Apache-2.0
name_template: >-
{{ .ProjectName }}{{.Version}}.{{ .Os }}-{{ .Arch }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
extra_files:
# source folder
- source: "CLAUDE.md"
destination: "CLAUDE.md"
- source: "CODE_OF_CONDUCT.md"
destination: "CODE_OF_CONDUCT.md"
- source: "Dockerfile"
destination: "Dockerfile"
- source: "LICENSE"
destination: "LICENSE"
- source: "Makefile"
destination: "Makefile"
- source: "README.md"
destination: "README.md"
- source: "all.bash"
destination: "all.bash"
- source: "all.bat"
destination: "all.bat"
- source: "ast"
destination: "ast"
- source: "tpl"
destination: "tpl"
- source: "dql"
destination: "dql"
- source: "tool"
destination: "tool"
- source: "builtin"
destination: "builtin"
- source: "cl"
destination: "cl"
- source: "cmd"
destination: "cmd"
- source: "doc"
destination: "doc"
- source: "encoding"
destination: "encoding"
- source: "env"
destination: "env"
- source: "format"
destination: "format"
- source: "go.mod"
destination: "go.mod"
- source: "go.sum"
destination: "go.sum"
- source: "make.bash"
destination: "make.bash"
- source: "make.bat"
destination: "make.bat"
- source: "parser"
destination: "parser"
- source: "printer"
destination: "printer"
- source: "scanner"
destination: "scanner"
- source: "test"
destination: "test"
- source: "demo"
destination: "demo"
- source: "token"
destination: "token"
- source: "x"
destination: "x"
apps:
xgo:
command: "xgo"
aliases: ["xgo", "gop"]
environment:
XGOROOT: "$SNAP"
checksum:
name_template: "{{ .ProjectName }}{{ .Version }}.checksums.txt"
release:
prerelease: auto
================================================
FILE: CLAUDE.md
================================================
# XGo Project AI Assistant Guide
## Project Overview
**XGo** is the first AI-native programming language that integrates software engineering into a unified whole.
**Key Characteristics**:
- Easy to learn with smaller syntax set than Go and Python
- Ready for large projects with unified ecosystem integration
## My Role & Your Role
- **My Role**: XGo language developer/contributor
- **Your Role**: Senior programming language development assistant specializing in syntax design and compiler implementation
## Workflow & Collaboration Style
### Adding New Syntax Features
When implementing new language syntax, follow this three-phase approach:
**IMPORTANT**: Each phase must be implemented in a separate pull request. Do NOT mix phases in a single PR. This separation ensures:
- Clear review focus (grammar vs semantics vs documentation)
- Easier rollback if issues are found
- Better git history and maintainability
- Allows grammar to be reviewed independently from implementation details
#### Phase 1: Grammar Definition (First Pull Request)
**Scope**: AST, parser, and printer modifications ONLY
- **AST**: Define new node types in `ast/` directory (if needed - often existing nodes can be reused)
- **Parser**: Implement parsing rules in `parser/` directory to recognize the new syntax
- **Printer**: Add formatting support for new syntax (inverse of parsing) in `printer/` directory
- **Testing**: Add test cases in `parser/_testdata/` for new syntax
- **Note**: Printer shares test cases with parser - do NOT create separate test files in `printer/_testdata/`
- **What NOT to include**: Do NOT add any code generation or semantic logic in `cl/` package - that belongs in Phase 2
#### Phase 2: Semantic Implementation (Second Pull Request)
**Scope**: Code generation via `cl` package ONLY
- **Code Generation**: Implement semantics using `github.com/goplus/gogen` package
- **Type Safety**: Leverage gogen's type information maintenance for semantic correctness
- **Testing**: Add comprehensive test cases in `cl/_testgop/` covering various usage scenarios
- **Prerequisite**: Phase 1 PR must be merged before starting Phase 2
#### Phase 3: Documentation (Third Pull Request)
**Scope**: User-facing documentation updates ONLY
- **Quick Start Guide**: Add feature documentation to `doc/docs.md` with practical examples
- **Table of Contents**: Update TOC in quick start to include new feature section
- **Language Specification**: Update specification documents (see Language Specification Structure below)
- **Examples**: Provide clear, runnable code examples demonstrating the feature
- **Prerequisite**: Phase 2 PR must be merged before starting Phase 3
### Language Specification Structure
XGo maintains two levels of language specifications to serve different user needs:
#### MiniSpec (Recommended Best Practices)
- **Purpose**: Simplified syntax set representing recommended best practices
- **Audience**: All XGo users - everyone should learn and apply this subset
- **Characteristics**: Simple, Turing-complete, and sufficient for elegant implementation of any business requirements
- **Files to update**:
- `doc/spec-mini.md` - MiniSpec documentation in markdown format
- `doc/spec/mini/mini.xgo` - MiniSpec grammar definition in XGo TPL (EBNF-like) syntax
#### FullSpec (Complete Language Syntax)
- **Purpose**: Complete syntax set including all language features
- **Audience**: Experts and library designers who need advanced features
- **Characteristics**: Comprehensive syntax including specialized features beyond MiniSpec
- **Files to update**:
- `doc/spec.md` - FullSpec documentation in markdown format
#### Determining Spec Classification for New Syntax
When adding new syntax to XGo, you must determine whether it belongs in the MiniSpec or FullSpec:
**Add to MiniSpec if the syntax**:
- Represents a recommended best practice for general use
- Is simple and intuitive for most users
- Solves common programming problems elegantly
- Should be learned by all XGo developers
**Add to FullSpec only if the syntax**:
- Is specialized for advanced use cases (e.g., library design)
- Adds complexity that most users don't need
- Provides alternative ways to accomplish tasks already covered in MiniSpec
- Is primarily intended for expert developers
**Update Process**:
1. Determine the appropriate specification level (MiniSpec or FullSpec)
2. Update the corresponding markdown documentation file(s)
3. If adding to MiniSpec, also update the TPL grammar file (`doc/spec/mini/mini.xgo`)
4. Ensure examples demonstrate the new syntax clearly
### Communication Protocol
- When I request syntax additions, first confirm the exact grammar specification
- Always consider backward compatibility with existing Go code
- For ambiguous requirements, ask clarifying questions about:
- Precedence and associativity rules
- Error handling expectations
- Integration with existing type system
## Technical Specifications
### Compiler Architecture
- **Target**: XGo compiles to Go code, not machine code
- **Foundation**: Built on `github.com/goplus/gogen` for robust Go AST generation
- **Key Benefit**: gogen maintains type information, ensuring both syntactic and semantic correctness
## Quality Standards
### Code Requirements
- Maintain full compatibility with existing Go ecosystem
- Ensure new syntax doesn't break existing XGo/Go code
- Follow Go idioms in generated code
- Provide comprehensive error messages
- **Code Formatting**: Run `go fmt` on any changed source files before committing
### Documentation Expectations
- Update language specification documents
- Add examples to Quick Start guide
- Document any limitations or special considerations
### Testing Requirements
- **Phase 1**: 100% test coverage for new syntax parsing in `parser/_testdata/`
- **Phase 2**: Comprehensive test coverage for semantic implementation in `cl/_testgop/` covering:
- Common usage scenarios
- Edge cases and error conditions
- Integration with existing type system
- **Phase 3**: Documentation validation
- Ensure all code examples in documentation are runnable and correct
- Verify documentation accurately reflects implemented behavior
- Check that TOC links work correctly
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
conduct@xgo.dev.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
================================================
FILE: Dockerfile
================================================
ARG BASE_IMAGE=golang:1.24-bookworm
FROM $BASE_IMAGE AS build
ARG TARGETPLATFORM
ARG USE_GORELEASER_ARTIFACTS=0
WORKDIR /usr/local/src/xgo
COPY . .
RUN << EOF
set -eux
XGOROOT=/usr/local/xgo
mkdir -p "$XGOROOT"
if [ "$USE_GORELEASER_ARTIFACTS" -eq 1 ]; then
cp -rp "$TARGETPLATFORM"/* "$XGOROOT"/
else
git ls-tree --full-tree --name-only -r HEAD | grep -vE "^\." | xargs -I {} cp --parents {} "$XGOROOT"/
./all.bash
mv bin "$XGOROOT"/
fi
EOF
FROM $BASE_IMAGE
ENV XGOROOT=/usr/local/xgo
COPY --from=build $XGOROOT/ $XGOROOT/
ENV PATH=$XGOROOT/bin:$PATH
WORKDIR /xgo
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: Makefile
================================================
NAME := gop
RELEASE_VERSION := `git describe --tags`
BUILD_ROOT_DIR := build-dir
.PHONY: clean all
all: build
clean:
rm -rf $(BUILD_ROOT_DIR)/*
rm -f bin/*
build:
go run cmd/make.go -build
dist:
$(MAKE) clean
mkdir -p bin/
go build -o $(BUILD_ROOT_DIR)/make cmd/make.go
$(MAKE) build-all
build-all: darwin-amd64.zip darwin-arm64.zip linux-386.zip linux-amd64.zip \
linux-armv7.zip windows-386.zip windows-amd64.zip windows-armv7.zip windows-arm64.zip
build-dist:
@mkdir -p bin/
@rm -rf bin/*
$(BUILD_ROOT_DIR)/make -build
%.zip: %
@echo "Building $(NAME)-$(RELEASE_VERSION)-$@"
@rm -f $(BUILD_ROOT_DIR)/$(NAME)-$(RELEASE_VERSION)-$@
zip -r $(BUILD_ROOT_DIR)/$(NAME)-$(RELEASE_VERSION)-$@ . -x ".*" -x "*/.*" -x "$(BUILD_ROOT_DIR)/*"
@echo "$(NAME)-$(RELEASE_VERSION)-$@ Done"
darwin-amd64:
$(MAKE) GOARCH=amd64 GOOS=darwin BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin build-dist
darwin-arm64:
$(MAKE) GOARCH=arm64 GOOS=darwin BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin build-dist
linux-386:
$(MAKE) GOARCH=386 GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin build-dist
linux-amd64:
$(MAKE) GOARCH=amd64 GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin build-dist
linux-armv7:
$(MAKE) GOARCH=arm GOOS=linux GOARM=7 BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin build-dist
windows-386:
$(MAKE) GOARCH=386 GOOS=windows EXE_SUFFIX=.exe BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin build-dist
windows-amd64:
$(MAKE) GOARCH=amd64 GOOS=windows EXE_SUFFIX=.exe BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin build-dist
windows-armv7:
$(MAKE) GOARCH=arm GOOS=windows EXE_SUFFIX=.exe GOARM=7 BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin build-dist
windows-arm64:
$(MAKE) GOARCH=arm64 GOOS=windows EXE_SUFFIX=.exe BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin build-dist
================================================
FILE: README.md
================================================
<div align="center">
<p></p>
<p>
<img width="80" src="https://xgo.dev/favicon.svg">
</p>
<h1>The XGo Programming Language</h1>
[xgo.dev](https://xgo.dev) | [Docs](doc/docs.md) | [XGo vs. Go](doc/xgo-vs-go.md) | [Tutorials](https://tutorial.xgo.dev) | [Playground](https://play.xgo.dev) | [XGo REPL (iXGo)](https://repl.xgo.dev) | [Contributing & compiler design](doc/contributing.md)
</div>
<div align="center">
<!--
[](https://github.com/gopcode/vscode-goplus)
[](https://discord.gg/mYjWCJDcAr)
[](https://github.com/goplus/ixgo)
-->
[](https://github.com/goplus/xgo/actions/workflows/go.yml)
[](https://goreportcard.com/report/github.com/goplus/xgo)
[](https://codecov.io/gh/goplus/xgo)
[](https://github.com/goplus/xgo/releases)
[](https://discord.com/invite/mYjWCJDcAr)
</div>
XGo is a programming language that reads like plain English. But it's also incredibly powerful — it lets you leverage assets from C/C++, Go, Python, and JavaScript/TypeScript, creating a unified software engineering ecosystem.
```
XGo := C * Go * Python * JavaScript + Scratch
```
Our vision is to **enable everyone to become a builder of the world**.
#### Easy to learn
* Simple and easy to understand
* Smaller syntax set than Go and Python in best practices
#### Ready for large projects
* Integrate C/C++, Go, Python, and JavaScript/TypeScript into a unified ecosystem
* Derived from Go and easy to build large projects from its good engineering foundation
The XGo programming language is designed for engineering, STEM education, and data science.
* **For engineering**: working in the simplest language that can be mastered by children.
* **For STEM education**: studying an engineering language that can be used for work in the future.
* **For data science**: communicating with engineers in the same language.
For more details, see [Quick Start](doc/docs.md).
## Key Features of XGo
* Approaching natural language expression and intuitive (see [How XGo simplifies Go's expressions](#how-xgo-simplifies-gos-expressions)).
* Smallest but Turing-complete syntax set in best practices (see [The XGo Mini Specification](doc/spec-mini.md)).
* Fully compatible with [Go](https://github.com/golang/go) and can mix Go/XGo code in the same package (see [The XGo Full Specification](doc/spec.md) and [Go/XGo Hybrid Programming](doc/docs.md#gogo-hybrid-programming)).
* Integrating with the C ecosystem including Python/JavaScript and providing limitless possibilities based on [LLGo](https://github.com/goplus/llgo) (see [Importing C/C++ and Python libraries](#importing-cc-and-python-libraries)).
* Does not support DSL (Domain-Specific Languages), but supports SDF (Specific Domain Friendliness) (see [XGo Classfiles](#xgo-classfiles) and [Domain Text Literals](doc/domian-text-lit.md)).
## How XGo simplifies Go's expressions
Different from the function call style of most languages, XGo recommends command style code:
```coffee
println "Hello world"
```
To emphasize our preference for command style, we introduce `echo` as an alias for `println`:
```coffee
echo "Hello world"
```
For more discussion on coding style, see https://tutorial.xgo.dev/hello-world.
Code style is just the first step. We have made many efforts to make the code more intuitive and closer to natural language expression. These include:
| Go code | XGo code | Note |
| ---- | ---- | ---- |
| package main<br><br>import "fmt"<br><br>func main() {<br> fmt.Println("Hi")<br>} | import "fmt"<br><br>fmt.Println("Hi")<br> | Program structure: XGo allows omitting `package main` and `func main` |
| fmt.Println("Hi") | echo("Hi") | [More builtin functions](doc/builtin.md): It simplifies the expression of the most common tasks |
| fmt.Println("Hi") | echo "Hi" | [Command-line](doc/fncall.md) style code: It reduces the number of parentheses in the code as much as possible, making it closer to natural language |
| name := "Ken"<br>fmt.Printf(<br> "Hi %s\n", name) | name := "Ken"<br>echo "Hi ${name}" | [Goodbye printf](doc/goodbye-printf.md), use `${expr}` in [string](doc/string.md) literals |
| a := []int{1, 2, 3} | a := [1, 2, 3] | [List/Slice](doc/slice.md) literals |
| a = append(a, 4)<br>a = append(a, 5, 6, 7) | a <- 4<br>a <- 5, 6, 7 | Append values to a list |
| a := map[string]int{<br> "Monday": 1,<br> "Tuesday": 2,<br>} | a := {<br> "Monday": 1,<br> "Tuesday": 2,<br>} | [Map](doc/map.md) literals |
| OnStart(func() {<br> ...<br>}) | onStart => {<br> ...<br>} | [Lambda](doc/func-closure.md) expressions |
| Play("1.mp3", &Options{Loop: true}) | play "1.mp3", loop = true | Python-like [keyword arguments](doc/func-closure.md#keyword-arguments) (kwargs) |
| type Rect struct {<br> Width float64<br> Height float64<br>}<br> | type Rect (width, height float64) | [Tuples vs. Structs](doc/struct-vs-tuple.md): We encourage using tuples to implement UDTs instead of structs. |
| type Rect struct {<br> Width float64<br> Height float64<br>}<br><br>func (this *Rect) Area() float64 { <br> return this.Width * this.Height<br>} | var (<br> Width float64<br> Height float64<br>)<br><br>func Area() float64 { <br> return Width * Height<br>} | [XGo Classfiles](doc/classfile.md): We can express OOP with global variables and functions. |
For more details, see [The XGo Mini Specification](doc/spec-mini.md).
## Importing C/C++ and Python libraries
XGo can choose different Go compilers as its underlying support. Currently known supported Go compilers include:
* [go](https://go.dev/) (The official Go compiler supported by Google)
* [llgo](https://github.com/goplus/llgo) (The Go compiler supported by the XGo team)
* [tinygo](https://tinygo.org/) (A Go compiler for small places)
Currently, XGo defaults to using [go](https://go.dev/) as its underlying support, but in the future, it will be [llgo](https://github.com/goplus/llgo).
LLGo is a Go compiler based on [LLVM](https://llvm.org/) in order to better integrate Go with the C ecosystem including Python and JavaScript. It aims to expand the boundaries of Go/XGo, providing limitless possibilities such as:
* Game development
* AI and data science
* WebAssembly
* Embedded development
* ...
If you wish to use [llgo](https://github.com/goplus/llgo), specify the `-llgo` flag when initializing an XGo module:
```sh
xgo mod init -llgo YourModulePath
```
This will generate a `go.mod` file with the following contents (It may vary slightly depending on the versions of local XGo and LLGo):
```go
module YourModulePath
go 1.21 // llgo 1.0
require github.com/goplus/lib v0.2.0
```
Based on LLGo, XGo can import libraries written in C/C++ and Python.
Here is an example (see [chello](demo/_llgo/chello/hello.xgo)) of printing `Hello world` using C's `printf`:
```go
import "c"
c.printf c"Hello world\n"
```
Here, `c"Hello world\n"` is a syntax supported by XGo, representing a null-terminated C-style string.
To run this example, you can:
```sh
cd YourModulePath # set work directory to your module
xgo mod tidy # for generating go.sum file
xgo run .
```
And here is an example (see [pyhello](demo/_llgo/pyhello/hello.xgo)) of printing `Hello world` using Python's `print`:
```go
import "py/std"
std.print py"Hello world"
```
Here, `py"Hello world"` is a syntax supported by XGo, representing a Python string.
Here are more examples of XGo calling C/C++ and Python libraries:
* [pytensor](demo/_llgo/pytensor/tensor.xgo): a simple demo using [py/torch](https://pkg.go.dev/github.com/goplus/lib/py/torch)
* [tetris](demo/_llgo/tetris/tetris.xgo): a tetris game based on [c/raylib](https://pkg.go.dev/github.com/goplus/lib/c/raylib)
* [sqlitedemo](demo/_llgo/sqlitedemo/sqlitedemo.xgo): a demo using [c/sqlite](https://pkg.go.dev/github.com/goplus/lib/c/sqlite)
To find out more about LLGo/XGo's support for C/C++ and Python in detail, please refer to homepage of [llgo](https://github.com/goplus/llgo).
## XGo Classfiles
```
One language can change the whole world.
XGo is a "DSL" for all domains.
```
Rob Pike once said that if he could only introduce one feature to Go, he would choose `interface` instead of `goroutine`. `classfile` (and `class framework`) is as important to XGo as `interface` is to Go.
In the design philosophy of XGo, we do not recommend `DSL` (Domain Specific Language). But `SDF` (Specific Domain Friendliness) is very important. The XGo philosophy about `SDF` is:
```
Don't define a language for specific domain.
Abstract domain knowledge for it.
```
XGo introduces `classfile` and `class framework` to abstract domain knowledge.
* [What's Classfile?](doc/classfile.md#whats-classfile)
* [Dive into XGo Classfiles](doc/classfile.md)
Sound a bit abstract? Let's see some XGo class frameworks.
* STEM Education: [spx: A Scratch Compatible 2D Game Engine](https://github.com/goplus/spx)
* AI Programming: [mcp: An XGo implementation of the Model Context Protocol (MCP)](https://github.com/goplus/mcp)
* AI Programming: [mcptest: An XGo MCP Test Framework](https://github.com/goplus/mcp/tree/main/mtest)
* Web Programming: [yap: Yet Another HTTP Web Framework](https://github.com/goplus/yap)
* Web Programming: [yaptest: An XGo HTTP Test Framework](https://github.com/goplus/yap/tree/main/ytest)
* Web Programming: [ydb: An XGo Database Framework](https://github.com/goplus/yap/tree/main/ydb)
* CLI Programming: [cobra: A Commander for modern XGo CLI interactions](https://github.com/goplus/cobra)
* CLI Programming: [gsh: An alternative to write shell scripts](https://github.com/qiniu/x/tree/main/gsh)
* Unit Test: [test: Unit Test](doc/classfile.md#class-framework-unit-test)
### yap: Yet Another HTTP Web Framework
This classfile has the file suffix `.yap`.
Create a file named [get.yap](https://github.com/goplus/yap/blob/main/demo/classfile2_hello/get.yap) with the following content:
```go
html `<html><body>Hello, YAP!</body></html>`
```
Execute the following commands:
```sh
xgo mod init hello
xgo get github.com/goplus/yap@latest
xgo mod tidy
xgo run .
```
A simplest web program is running now. At this time, if you visit http://localhost:8080, you will get:
```
Hello, YAP!
```
YAP uses filenames to define routes. `get.yap`'s route is `get "/"` (GET homepage), and `get_p_#id.yap`'s route is `get "/p/:id"` (In fact, the filename can also be `get_p_:id.yap`, but it is not recommended because `:` is not allowed to exist in filenames under Windows).
Let's create a file named [get_p_#id.yap](https://github.com/goplus/yap/blob/main/demo/classfile2_hello/get_p_%23id.yap) with the following content:
```coffee
json {
"id": ${id},
}
```
Execute `xgo run .` and visit http://localhost:8080/p/123, you will get:
```
{"id": "123"}
```
See [yap: Yet Another HTTP Web Framework](https://github.com/goplus/yap) for more details.
### spx: A Scratch Compatible 2D Game Engine
 
Through this example you can learn how to implement dialogues between multiple actors.
Here are some codes in [Kai.spx](https://github.com/goplus/spx/blob/v1/tutorial/01-Weather/Kai.spx):
```coffee
onStart => {
say "Where do you come from?", 2
broadcast "1"
}
onMsg "2", => {
say "What's the climate like in your country?", 3
broadcast "3"
}
```
We call `onStart` and `onMsg` to listen events. `onStart` is called when the program is started. And `onMsg` is called when someone calls `broadcast` to broadcast a message.
When the program starts, Kai says `Where do you come from?`, and then broadcasts the message `1`. Who will recieve this message? Let's see codes in [Jaime.spx](https://github.com/goplus/spx/blob/v1/tutorial/01-Weather/Jaime.spx):
```coffee
onMsg "1", => {
say "I come from England.", 2
broadcast "2"
}
```
Yes, Jaime recieves the message `1` and says `I come from England.`. Then he broadcasts the message `2`. Kai recieves it and says `What's the climate like in your country?`.
The following procedures are very similar. In this way you can implement dialogues between multiple actors.
See [spx: A Scratch Compatible 2D Game Engine](https://github.com/goplus/spx) for more details.
### gsh: XGo DevOps Tools
Yes, now you can write `shell script` in XGo. It supports all shell commands.
Let's create a file named [example.gsh](https://github.com/qiniu/x/blob/main/gsh/demo/hello/example.gsh) and write the following code:
```coffee
mkdir "testgsh"
```
Don't need a `go.mod` file, just enter `xgo run ./example.gsh` directly to run.
See [gsh: XGo DevOps Tools](https://github.com/qiniu/x/tree/main/gsh) for more details.
## How to install
Note: Requires go1.19 or later
### on Windows
```sh
winget install goplus.xgo
```
### on Debian/Ubuntu
```sh
sudo bash -c ' echo "deb [trusted=yes] https://pkgs.xgo.dev/apt/ /" > /etc/apt/sources.list.d/goplus.list'
sudo apt update
sudo apt install xgo
```
### on RedHat/CentOS/Fedora
```sh
sudo bash -c 'echo -e "[goplus]\nname=XGo Repo\nbaseurl=https://pkgs.xgo.dev/yum/\nenabled=1\ngpgcheck=0" > /etc/yum.repos.d/goplus.repo'
sudo yum install xgo
```
### on macOS/Linux (Homebrew)
Install via [brew](https://brew.sh/)
```sh
$ brew install xgo
```
### from source code
```bash
git clone https://github.com/goplus/xgo.git
cd xgo
# On mac/linux run:
./all.bash
# On Windows run:
all.bat
```
## XGo Applications
### Game Programming
* [A Scratch Compatible 2D Game Engine](https://github.com/goplus/spx)
* [Aircraft War](https://github.com/goplus/AircraftWar)
* [Flappy Bird](https://github.com/goplus/FlappyCalf)
* [Maze Play](https://github.com/goplus/MazePlay)
* [BetaGo](https://github.com/xushiwei/BetaGo)
* [Gobang](https://github.com/xushiwei/Gobang)
* [Dinosaur](https://github.com/xushiwei/Dinosaur)
### Web Programming
* [yap: Yet Another HTTP Web Framework](https://github.com/goplus/yap)
* [yaptest: HTTP Test Framework](https://github.com/goplus/yap/tree/main/ytest)
* [ydb: Database Framework](https://github.com/goplus/yap#ydb-database-framework)
### DevOps Tools
* [gsh: XGo DevOps Tools](https://github.com/qiniu/x/tree/main/gsh)
### Data Processing
* [hdq: HTML DOM Query Language for XGo](https://github.com/goplus/hdq)
## IDE Plugins
* vscode: [Go/XGo for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=goplus.gop)
## Contributing
The XGo project welcomes all contributors. We appreciate your help!
For more details, see [Contributing & compiler design](doc/contributing.md).
## Give a Star! ⭐
If you like or are using XGo to learn or start your projects, please give it a star. Thanks!
================================================
FILE: all.bash
================================================
#! /usr/bin/env bash
#
# Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -ex
go run cmd/make.go --install --regtest --autoproxy
================================================
FILE: all.bat
================================================
go run cmd/make.go --install --regtest --autoproxy
================================================
FILE: ast/ast.go
================================================
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Package ast declares the types used to represent syntax trees for XGo
// packages.
package ast
import (
"go/ast"
"github.com/goplus/xgo/token"
)
// ----------------------------------------------------------------------------
// Interfaces
//
// There are 3 main classes of nodes: Expressions and type nodes,
// statement nodes, and declaration nodes. The node names usually
// match the corresponding Go spec production names to which they
// correspond. The node fields correspond to the individual parts
// of the respective productions.
//
// All nodes contain position information marking the beginning of
// the corresponding source text segment; it is accessible via the
// Pos accessor method. Nodes may contain additional position info
// for language constructs where comments may be found between parts
// of the construct (typically any larger, parenthesized subpart).
// That position information is needed to properly position comments
// when printing the construct.
// Node interface: all node types implement the Node interface.
type Node = ast.Node
// Expr interface: all expression nodes implement the Expr interface.
type Expr interface {
Node
exprNode()
}
// Stmt interface: all statement nodes implement the Stmt interface.
type Stmt interface {
Node
stmtNode()
}
// Decl interface: all declaration nodes implement the Decl interface.
type Decl interface {
Node
declNode()
}
// ----------------------------------------------------------------------------
// Comments
// A Comment node represents a single //-style 、#-style or /*-style comment.
type Comment = ast.Comment
// A CommentGroup represents a sequence of comments
// with no other tokens and no empty lines between.
type CommentGroup = ast.CommentGroup
// ----------------------------------------------------------------------------
// Expressions and types
// A Field represents a Field declaration list in a struct type,
// a method list in an interface type, or a parameter/result declaration
// in a signature.
// Field.Names is nil for unnamed parameters (parameter lists which only contain types)
// and embedded struct fields. In the latter case, the field name is the type name.
type Field struct {
Doc *CommentGroup // associated documentation; or nil
Names []*Ident // field/method/parameter names; or nil
Type Expr // field/method/parameter type
Tag *BasicLit // field tag; or nil
Comment *CommentGroup // line comments; or nil
Optional token.Pos // position of "?", or NoPos if not optional
}
// Pos returns position of first character belonging to the node.
func (f *Field) Pos() token.Pos {
if len(f.Names) > 0 {
return f.Names[0].Pos()
}
return f.Type.Pos()
}
// End returns position of first character immediately after the node.
func (f *Field) End() token.Pos {
if f.Tag != nil {
return f.Tag.End()
}
if f.Optional.IsValid() {
return f.Optional + 1
}
return f.Type.End()
}
// A FieldList represents a list of Fields, enclosed by parentheses or braces.
type FieldList struct {
Opening token.Pos // position of opening parenthesis/brace, if any
List []*Field // field list; or nil
Closing token.Pos // position of closing parenthesis/brace, if any
}
// Pos returns position of first character belonging to the node.
func (f *FieldList) Pos() token.Pos {
if f.Opening.IsValid() {
return f.Opening
}
// the list should not be empty in this case;
// be conservative and guard against bad ASTs
if len(f.List) > 0 {
return f.List[0].Pos()
}
return token.NoPos
}
// End returns position of first character immediately after the node.
func (f *FieldList) End() token.Pos {
if f.Closing.IsValid() {
return f.Closing + 1
}
// the list should not be empty in this case;
// be conservative and guard against bad ASTs
if n := len(f.List); n > 0 {
return f.List[n-1].End()
}
return token.NoPos
}
// NumFields returns the number of parameters or struct fields represented by a FieldList.
func (f *FieldList) NumFields() int {
n := 0
if f != nil {
for _, g := range f.List {
m := len(g.Names)
if m == 0 {
m = 1
}
n += m
}
}
return n
}
// An expression is represented by a tree consisting of one
// or more of the following concrete expression nodes.
type (
// A BadExpr node is a placeholder for expressions containing
// syntax errors for which no correct expression nodes can be
// created.
BadExpr struct {
From, To token.Pos // position range of bad expression
}
// An Ident node represents an identifier.
Ident struct {
NamePos token.Pos // identifier position
Name string // identifier name
Obj *Object // denoted object; or nil
}
// An Ellipsis node stands for the "..." type in a
// parameter list or the "..." length in an array type.
Ellipsis struct {
Ellipsis token.Pos // position of "..."
Elt Expr // ellipsis element type (parameter lists only); or nil
}
// A FuncLit node represents a function literal.
FuncLit struct {
Type *FuncType // function type
Body *BlockStmt // function body
}
// A CompositeLit node represents a composite literal.
CompositeLit struct {
Type Expr // literal type; or nil
Lbrace token.Pos // position of "{"
Elts []Expr // list of composite elements; or nil
Rbrace token.Pos // position of "}"
Incomplete bool // true if (source) expressions are missing in the Elts list
}
// A ParenExpr node represents a parenthesized expression.
ParenExpr struct {
Lparen token.Pos // position of "("
X Expr // parenthesized expression
Rparen token.Pos // position of ")"
}
// A SelectorExpr node represents an expression followed by a selector.
// Sel may not be a simple identifier. For example:
// - x.field
// - x."field-name"
// - x.$attr
// - x.$"attr-name"
// - x.0, x.1, ...
// - x.*
SelectorExpr struct {
X Expr // expression
Sel *Ident // field selector (it may not be a simple identifier)
}
// An IndexExpr node represents an expression followed by an index.
IndexExpr struct {
X Expr // expression
Lbrack token.Pos // position of "["
Index Expr // index expression
Rbrack token.Pos // position of "]"
}
// An IndexListExpr node represents an expression followed by multiple
// indices.
IndexListExpr struct {
X Expr // expression
Lbrack token.Pos // position of "["
Indices []Expr // index expressions
Rbrack token.Pos // position of "]"
}
// A SliceExpr node represents an expression followed by slice indices.
SliceExpr struct {
X Expr // expression
Lbrack token.Pos // position of "["
Low Expr // begin of slice range; or nil
High Expr // end of slice range; or nil
Max Expr // maximum capacity of slice; or nil
Slice3 bool // true if 3-index slice (2 colons present)
Rbrack token.Pos // position of "]"
}
// A TypeAssertExpr node represents an expression followed by a
// type assertion.
TypeAssertExpr struct {
X Expr // expression
Lparen token.Pos // position of "("
Type Expr // asserted type; nil means type switch X.(type)
Rparen token.Pos // position of ")"
}
// A StarExpr node represents an expression of the form "*" Expression.
// Semantically it could be a unary "*" expression, or a pointer type.
StarExpr struct {
Star token.Pos // position of "*"
X Expr // operand
}
// A UnaryExpr node represents a unary expression.
// Unary "*" expressions are represented via StarExpr nodes.
UnaryExpr struct {
OpPos token.Pos // position of Op
Op token.Token // operator
X Expr // operand
}
// A BinaryExpr node represents a binary expression.
BinaryExpr struct {
X Expr // left operand
OpPos token.Pos // position of Op
Op token.Token // operator
Y Expr // right operand
}
// A KeyValueExpr node represents (key : value) pairs
// in composite literals.
KeyValueExpr struct {
Key Expr
Colon token.Pos // position of ":"
Value Expr
}
)
// ChanDir is the direction of a channel type is indicated by a bit
// mask including one or both of the following constants.
type ChanDir int
const (
// SEND - ChanDir
SEND ChanDir = 1 << iota
// RECV - ChanDir
RECV
)
// A type is represented by a tree consisting of one
// or more of the following type-specific expression
// nodes.
type (
// An ArrayType node represents an array or slice type.
ArrayType struct {
Lbrack token.Pos // position of "["
Len Expr // Ellipsis node for [...]T array types, nil for slice types
Elt Expr // element type
}
// A StructType node represents a struct type.
StructType struct {
Struct token.Pos // position of "struct" keyword
Fields *FieldList // list of field declarations
Incomplete bool // true if (source) fields are missing in the Fields list
}
// Pointer types are represented via StarExpr nodes.
// A FuncType node represents a function type.
FuncType struct {
Func token.Pos // position of "func" keyword (token.NoPos if there is no "func")
TypeParams *FieldList // type parameters; or nil
Params *FieldList // (incoming) parameters; non-nil
Results *FieldList // (outgoing) results; or nil
}
// An InterfaceType node represents an interface type.
InterfaceType struct {
Interface token.Pos // position of "interface" keyword
Methods *FieldList // list of methods
Incomplete bool // true if (source) methods are missing in the Methods list
}
// A MapType node represents a map type.
MapType struct {
Map token.Pos // position of "map" keyword
Key Expr
Value Expr
}
// A ChanType node represents a channel type.
ChanType struct {
Begin token.Pos // position of "chan" keyword or "<-" (whichever comes first)
Arrow token.Pos // position of "<-" (token.NoPos if there is no "<-")
Dir ChanDir // channel direction
Value Expr // value type
}
// A TupleType node represents a tuple type.
// Tuple types are syntactic sugar for anonymous structs with ordinal field names.
// Examples:
// () ≡ struct{}
// (T) ≡ T (degenerates to the type itself)
// (T0, T1, ..., TN) ≡ struct{ _0 T0; _1 T1; ...; _N TN }
// (name0 T0, name1 T1, ..., nameN TN) ≡ struct{ _0 T0; _1 T1; ...; _N TN }
// Named fields are compile-time aliases only; runtime uses ordinal fields.
TupleType struct {
Lparen token.Pos // position of "("
Fields *FieldList // tuple element types (and optional names)
Rparen token.Pos // position of ")"
}
)
// Pos and End implementations for expression/type nodes.
// Pos returns position of first character belonging to the node.
func (x *BadExpr) Pos() token.Pos { return x.From }
// Pos returns position of first character belonging to the node.
func (x *Ident) Pos() token.Pos { return x.NamePos }
// Pos returns position of first character belonging to the node.
func (x *Ellipsis) Pos() token.Pos { return x.Ellipsis }
// Pos returns position of first character belonging to the node.
func (x *FuncLit) Pos() token.Pos { return x.Type.Pos() }
// Pos returns position of first character belonging to the node.
func (x *CompositeLit) Pos() token.Pos {
if x.Type != nil {
return x.Type.Pos()
}
return x.Lbrace
}
// Pos returns position of first character belonging to the node.
func (x *ParenExpr) Pos() token.Pos { return x.Lparen }
// Pos returns position of first character belonging to the node.
func (x *SelectorExpr) Pos() token.Pos { return x.X.Pos() }
// Pos returns position of first character belonging to the node.
func (x *IndexExpr) Pos() token.Pos { return x.X.Pos() }
// Pos returns position of first character belonging to the node.
func (x *IndexListExpr) Pos() token.Pos { return x.X.Pos() }
// Pos returns position of first character belonging to the node.
func (x *SliceExpr) Pos() token.Pos { return x.X.Pos() }
// Pos returns position of first character belonging to the node.
func (x *TypeAssertExpr) Pos() token.Pos { return x.X.Pos() }
// Pos returns position of first character belonging to the node.
func (x *StarExpr) Pos() token.Pos { return x.Star }
// Pos returns position of first character belonging to the node.
func (x *UnaryExpr) Pos() token.Pos { return x.OpPos }
// Pos returns position of first character belonging to the node.
func (x *BinaryExpr) Pos() token.Pos { return x.X.Pos() }
// Pos returns position of first character belonging to the node.
func (x *KeyValueExpr) Pos() token.Pos { return x.Key.Pos() }
// Pos returns position of first character belonging to the node.
func (x *ArrayType) Pos() token.Pos { return x.Lbrack }
// Pos returns position of first character belonging to the node.
func (x *StructType) Pos() token.Pos { return x.Struct }
// Pos returns position of first character belonging to the node.
func (x *FuncType) Pos() token.Pos {
if x.Func.IsValid() || x.Params == nil { // see issue 3870
return x.Func
}
return x.Params.Pos() // interface method declarations have no "func" keyword
}
// Pos returns position of first character belonging to the node.
func (x *InterfaceType) Pos() token.Pos { return x.Interface }
// Pos returns position of first character belonging to the node.
func (x *MapType) Pos() token.Pos { return x.Map }
// Pos returns position of first character belonging to the node.
func (x *ChanType) Pos() token.Pos { return x.Begin }
// Pos returns position of first character belonging to the node.
func (x *TupleType) Pos() token.Pos { return x.Lparen }
// End returns position of first character immediately after the node.
func (x *BadExpr) End() token.Pos { return x.To }
// End returns position of first character immediately after the node.
func (x *Ident) End() token.Pos {
if x.Implicit() { // implicitly declared
return x.NamePos
}
return x.NamePos + token.Pos(len(x.Name))
}
// Implicit reports whether the identifier was implicitly declared
func (x *Ident) Implicit() bool {
o := x.Obj
return o != nil && o.Kind >= implicitBase
}
// End returns position of first character immediately after the node.
func (x *Ellipsis) End() token.Pos {
if x.Elt != nil {
return x.Elt.End()
}
return x.Ellipsis + 3 // len("...")
}
// End returns position of first character immediately after the node.
func (x *FuncLit) End() token.Pos { return x.Body.End() }
// End returns position of first character immediately after the node.
func (x *CompositeLit) End() token.Pos { return x.Rbrace + 1 }
// End returns position of first character immediately after the node.
func (x *ParenExpr) End() token.Pos { return x.Rparen + 1 }
// End returns position of first character immediately after the node.
func (x *SelectorExpr) End() token.Pos { return x.Sel.End() }
// End returns position of first character immediately after the node.
func (x *IndexExpr) End() token.Pos { return x.Rbrack + 1 }
// End returns position of first character immediately after the node.
func (x *IndexListExpr) End() token.Pos { return x.Rbrack + 1 }
// End returns position of first character immediately after the node.
func (x *SliceExpr) End() token.Pos { return x.Rbrack + 1 }
// End returns position of first character immediately after the node.
func (x *TypeAssertExpr) End() token.Pos { return x.Rparen + 1 }
// End returns position of first character immediately after the node.
func (x *StarExpr) End() token.Pos { return x.X.End() }
// End returns position of first character immediately after the node.
func (x *UnaryExpr) End() token.Pos { return x.X.End() }
// End returns position of first character immediately after the node.
func (x *BinaryExpr) End() token.Pos { return x.Y.End() }
// End returns position of first character immediately after the node.
func (x *KeyValueExpr) End() token.Pos { return x.Value.End() }
// End returns position of first character immediately after the node.
func (x *ArrayType) End() token.Pos { return x.Elt.End() }
// End returns position of first character immediately after the node.
func (x *StructType) End() token.Pos { return x.Fields.End() }
// End returns position of first character immediately after the node.
func (x *FuncType) End() token.Pos {
if x.Results != nil {
return x.Results.End()
}
return x.Params.End()
}
// End returns position of first character immediately after the node.
func (x *InterfaceType) End() token.Pos { return x.Methods.End() }
// End returns position of first character immediately after the node.
func (x *MapType) End() token.Pos { return x.Value.End() }
// End returns position of first character immediately after the node.
func (x *ChanType) End() token.Pos { return x.Value.End() }
// End returns position of first character immediately after the node.
func (x *TupleType) End() token.Pos { return x.Rparen + 1 }
// exprNode() ensures that only expression/type nodes can be
// assigned to an Expr.
func (*BadExpr) exprNode() {}
func (*Ident) exprNode() {}
func (*Ellipsis) exprNode() {}
func (*FuncLit) exprNode() {}
func (*CompositeLit) exprNode() {}
func (*ParenExpr) exprNode() {}
func (*SelectorExpr) exprNode() {}
func (*IndexExpr) exprNode() {}
func (*IndexListExpr) exprNode() {}
func (*SliceExpr) exprNode() {}
func (*TypeAssertExpr) exprNode() {}
func (*StarExpr) exprNode() {}
func (*UnaryExpr) exprNode() {}
func (*BinaryExpr) exprNode() {}
func (*KeyValueExpr) exprNode() {}
func (*ArrayType) exprNode() {}
func (*StructType) exprNode() {}
func (*FuncType) exprNode() {}
func (*InterfaceType) exprNode() {}
func (*MapType) exprNode() {}
func (*ChanType) exprNode() {}
func (*TupleType) exprNode() {}
// ----------------------------------------------------------------------------
// Convenience functions for Idents
// NewIdent creates a new Ident without position.
// Useful for ASTs generated by code other than the XGo parser.
func NewIdent(name string) *Ident { return &Ident{token.NoPos, name, nil} }
// NewIdentEx creates a new Ident with position and with the given kind.
func NewIdentEx(pos token.Pos, name string, kind ObjKind) *Ident {
return &Ident{pos, name, NewObj(kind, name)}
}
// IsExported reports whether name starts with an upper-case letter.
func IsExported(name string) bool { return token.IsExported(name) }
// IsExported reports whether id starts with an upper-case letter.
func (x *Ident) IsExported() bool { return token.IsExported(x.Name) }
func (x *Ident) String() string {
if x != nil {
return x.Name
}
return "<nil>"
}
// ----------------------------------------------------------------------------
// Statements
// A statement is represented by a tree consisting of one
// or more of the following concrete statement nodes.
type (
// A BadStmt node is a placeholder for statements containing
// syntax errors for which no correct statement nodes can be
// created.
//
BadStmt struct {
From, To token.Pos // position range of bad statement
}
// A DeclStmt node represents a declaration in a statement list.
DeclStmt struct {
Decl Decl // *GenDecl with CONST, TYPE, or VAR token
}
// An EmptyStmt node represents an empty statement.
// The "position" of the empty statement is the position
// of the immediately following (explicit or implicit) semicolon.
//
EmptyStmt struct {
Semicolon token.Pos // position of following ";"
Implicit bool // if set, ";" was omitted in the source
}
// A LabeledStmt node represents a labeled statement.
LabeledStmt struct {
Label *Ident
Colon token.Pos // position of ":"
Stmt Stmt
}
// An ExprStmt node represents a (stand-alone) expression
// in a statement list.
//
ExprStmt struct {
X Expr // expression
}
// An IncDecStmt node represents an increment or decrement statement.
IncDecStmt struct {
X Expr
TokPos token.Pos // position of Tok
Tok token.Token // INC or DEC
}
// An AssignStmt node represents an assignment or
// a short variable declaration.
//
AssignStmt struct {
Lhs []Expr // left hand side expressions
TokPos token.Pos // position of Tok
Tok token.Token // assignment token, DEFINE
Rhs []Expr // right hand side expressions
}
// A GoStmt node represents a go statement.
GoStmt struct {
Go token.Pos // position of "go" keyword
Call *CallExpr
}
// A DeferStmt node represents a defer statement.
DeferStmt struct {
Defer token.Pos // position of "defer" keyword
Call *CallExpr
}
// A ReturnStmt node represents a return statement.
ReturnStmt struct {
Return token.Pos // position of "return" keyword
Results []Expr // result expressions; or nil
}
// A BranchStmt node represents a break, continue, goto,
// or fallthrough statement.
//
BranchStmt struct {
TokPos token.Pos // position of Tok
Tok token.Token // keyword token (BREAK, CONTINUE, GOTO, FALLTHROUGH)
Label *Ident // label name; or nil
}
// A BlockStmt node represents a braced statement list.
BlockStmt struct {
Lbrace token.Pos // position of "{"
List []Stmt
Rbrace token.Pos // position of "}", if any (may be absent due to syntax error)
}
// An IfStmt node represents an if statement.
IfStmt struct {
If token.Pos // position of "if" keyword
Init Stmt // initialization statement; or nil
Cond Expr // condition
Body *BlockStmt
Else Stmt // else branch; or nil
}
// A CaseClause represents a case of an expression or type switch statement.
CaseClause struct {
Case token.Pos // position of "case" or "default" keyword
List []Expr // list of expressions or types; nil means default case
Colon token.Pos // position of ":"
Body []Stmt // statement list; or nil
}
// A SwitchStmt node represents an expression switch statement.
SwitchStmt struct {
Switch token.Pos // position of "switch" keyword
Init Stmt // initialization statement; or nil
Tag Expr // tag expression; or nil
Body *BlockStmt // CaseClauses only
}
// A TypeSwitchStmt node represents a type switch statement.
TypeSwitchStmt struct {
Switch token.Pos // position of "switch" keyword
Init Stmt // initialization statement; or nil
Assign Stmt // x := y.(type) or y.(type)
Body *BlockStmt // CaseClauses only
}
// A CommClause node represents a case of a select statement.
CommClause struct {
Case token.Pos // position of "case" or "default" keyword
Comm Stmt // send or receive statement; nil means default case
Colon token.Pos // position of ":"
Body []Stmt // statement list; or nil
}
// A SelectStmt node represents a select statement.
SelectStmt struct {
Select token.Pos // position of "select" keyword
Body *BlockStmt // CommClauses only
}
// A ForStmt represents a `for init; cond; post { ... }` statement.
ForStmt struct {
For token.Pos // position of "for" keyword
Init Stmt // initialization statement; or nil
Cond Expr // condition; or nil
Post Stmt // post iteration statement; or nil
Body *BlockStmt
}
// A RangeStmt represents a for statement with a range clause.
RangeStmt struct {
For token.Pos // position of "for" keyword
Key, Value Expr // Key, Value may be nil
TokPos token.Pos // position of Tok; invalid if Key == nil
Tok token.Token // ILLEGAL if Key == nil, ASSIGN, DEFINE
X Expr // value to range over
Body *BlockStmt
NoRangeOp bool
}
)
// Pos and End implementations for statement nodes.
// Pos returns position of first character belonging to the node.
func (s *BadStmt) Pos() token.Pos { return s.From }
// Pos returns position of first character belonging to the node.
func (s *DeclStmt) Pos() token.Pos { return s.Decl.Pos() }
// Pos returns position of first character belonging to the node.
func (s *EmptyStmt) Pos() token.Pos { return s.Semicolon }
// Pos returns position of first character belonging to the node.
func (s *LabeledStmt) Pos() token.Pos { return s.Label.Pos() }
// Pos returns position of first character belonging to the node.
func (s *ExprStmt) Pos() token.Pos { return s.X.Pos() }
// Pos returns position of first character belonging to the node.
func (s *SendStmt) Pos() token.Pos { return s.Chan.Pos() }
// Pos returns position of first character belonging to the node.
func (s *IncDecStmt) Pos() token.Pos { return s.X.Pos() }
// Pos returns position of first character belonging to the node.
func (s *AssignStmt) Pos() token.Pos { return s.Lhs[0].Pos() }
// Pos returns position of first character belonging to the node.
func (s *GoStmt) Pos() token.Pos { return s.Go }
// Pos returns position of first character belonging to the node.
func (s *DeferStmt) Pos() token.Pos { return s.Defer }
// Pos returns position of first character belonging to the node.
func (s *ReturnStmt) Pos() token.Pos { return s.Return }
// Pos returns position of first character belonging to the node.
func (s *BranchStmt) Pos() token.Pos { return s.TokPos }
// Pos returns position of first character belonging to the node.
func (s *BlockStmt) Pos() token.Pos { return s.Lbrace }
// Pos returns position of first character belonging to the node.
func (s *IfStmt) Pos() token.Pos { return s.If }
// Pos returns position of first character belonging to the node.
func (s *CaseClause) Pos() token.Pos { return s.Case }
// Pos returns position of first character belonging to the node.
func (s *SwitchStmt) Pos() token.Pos { return s.Switch }
// Pos returns position of first character belonging to the node.
func (s *TypeSwitchStmt) Pos() token.Pos { return s.Switch }
// Pos returns position of first character belonging to the node.
func (s *CommClause) Pos() token.Pos { return s.Case }
// Pos returns position of first character belonging to the node.
func (s *SelectStmt) Pos() token.Pos { return s.Select }
// Pos returns position of first character belonging to the node.
func (s *ForStmt) Pos() token.Pos { return s.For }
// Pos returns position of first character belonging to the node.
func (s *RangeStmt) Pos() token.Pos { return s.For }
// End returns position of first character immediately after the node.
func (s *BadStmt) End() token.Pos { return s.To }
// End returns position of first character immediately after the node.
func (s *DeclStmt) End() token.Pos { return s.Decl.End() }
// End returns position of first character immediately after the node.
func (s *EmptyStmt) End() token.Pos {
if s.Implicit {
return s.Semicolon
}
return s.Semicolon + 1 /* len(";") */
}
// End returns position of first character immediately after the node.
func (s *LabeledStmt) End() token.Pos { return s.Stmt.End() }
// End returns position of first character immediately after the node.
func (s *ExprStmt) End() token.Pos { return s.X.End() }
// End returns position of first character immediately after the node.
func (s *IncDecStmt) End() token.Pos {
return s.TokPos + 2 /* len("++") */
}
// End returns position of first character immediately after the node.
func (s *AssignStmt) End() token.Pos { return s.Rhs[len(s.Rhs)-1].End() }
// End returns position of first character immediately after the node.
func (s *GoStmt) End() token.Pos { return s.Call.End() }
// End returns position of first character immediately after the node.
func (s *DeferStmt) End() token.Pos { return s.Call.End() }
// End returns position of first character immediately after the node.
func (s *ReturnStmt) End() token.Pos {
if n := len(s.Results); n > 0 {
return s.Results[n-1].End()
}
return s.Return + 6 // len("return")
}
// End returns position of first character immediately after the node.
func (s *BranchStmt) End() token.Pos {
if s.Label != nil {
return s.Label.End()
}
return token.Pos(int(s.TokPos) + len(s.Tok.String()))
}
// End returns position of first character immediately after the node.
func (s *BlockStmt) End() token.Pos {
if s.Rbrace.IsValid() {
return s.Rbrace + 1
}
if n := len(s.List); n > 0 {
return s.List[n-1].End()
}
return s.Lbrace + 1
}
// End returns position of first character immediately after the node.
func (s *IfStmt) End() token.Pos {
if s.Else != nil {
return s.Else.End()
}
return s.Body.End()
}
// End returns position of first character immediately after the node.
func (s *CaseClause) End() token.Pos {
if n := len(s.Body); n > 0 {
return s.Body[n-1].End()
}
return s.Colon + 1
}
// End returns position of first character immediately after the node.
func (s *SwitchStmt) End() token.Pos { return s.Body.End() }
// End returns position of first character immediately after the node.
func (s *TypeSwitchStmt) End() token.Pos { return s.Body.End() }
// End returns position of first character immediately after the node.
func (s *CommClause) End() token.Pos {
if n := len(s.Body); n > 0 {
return s.Body[n-1].End()
}
return s.Colon + 1
}
// End returns position of first character immediately after the node.
func (s *SelectStmt) End() token.Pos { return s.Body.End() }
// End returns position of first character immediately after the node.
func (s *ForStmt) End() token.Pos { return s.Body.End() }
// End returns position of first character immediately after the node.
func (s *RangeStmt) End() token.Pos { return s.Body.End() }
// stmtNode() ensures that only statement nodes can be
// assigned to a Stmt.
func (*BadStmt) stmtNode() {}
func (*DeclStmt) stmtNode() {}
func (*EmptyStmt) stmtNode() {}
func (*LabeledStmt) stmtNode() {}
func (*ExprStmt) stmtNode() {}
func (*SendStmt) stmtNode() {}
func (*IncDecStmt) stmtNode() {}
func (*AssignStmt) stmtNode() {}
func (*GoStmt) stmtNode() {}
func (*DeferStmt) stmtNode() {}
func (*ReturnStmt) stmtNode() {}
func (*BranchStmt) stmtNode() {}
func (*BlockStmt) stmtNode() {}
func (*IfStmt) stmtNode() {}
func (*CaseClause) stmtNode() {}
func (*SwitchStmt) stmtNode() {}
func (*TypeSwitchStmt) stmtNode() {}
func (*CommClause) stmtNode() {}
func (*SelectStmt) stmtNode() {}
func (*ForStmt) stmtNode() {}
func (*RangeStmt) stmtNode() {}
// ----------------------------------------------------------------------------
// Declarations
// A Spec node represents a single (non-parenthesized) import,
// constant, type, or variable declaration.
type (
// The Spec type stands for any of *ImportSpec, *ValueSpec, and *TypeSpec.
Spec interface {
Node
specNode()
}
// An ImportSpec node represents a single package import.
ImportSpec struct {
Doc *CommentGroup // associated documentation; or nil
Name *Ident // local package name (including "."); or nil
Path *BasicLit // import path
Comment *CommentGroup // line comments; or nil
EndPos token.Pos // end of spec (overrides Path.Pos if nonzero)
}
// A ValueSpec node represents a constant or variable declaration
// (ConstSpec or VarSpec production).
//
ValueSpec struct {
Doc *CommentGroup // associated documentation; or nil
Names []*Ident // value names (len(Names) > 0)
Type Expr // value type; or nil
Tag *BasicLit // classfile field tag; or nil
Values []Expr // initial values; or nil
Comment *CommentGroup // line comments; or nil
}
// A TypeSpec node represents a type declaration (TypeSpec production).
TypeSpec struct {
Doc *CommentGroup // associated documentation; or nil
Name *Ident // type name
TypeParams *FieldList // type parameters; or nil
Assign token.Pos // position of '=', if any
Type Expr // *Ident, *ParenExpr, *SelectorExpr, *StarExpr, or any of the *XxxTypes
Comment *CommentGroup // line comments; or nil
}
)
// Pos and End implementations for spec nodes.
// Pos returns position of first character belonging to the node.
func (s *ImportSpec) Pos() token.Pos {
if s.Name != nil {
return s.Name.Pos()
}
return s.Path.Pos()
}
// Pos returns position of first character belonging to the node.
func (s *ValueSpec) Pos() token.Pos {
if len(s.Names) == 0 {
return s.Type.Pos()
}
return s.Names[0].Pos()
}
// Pos returns position of first character belonging to the node.
func (s *TypeSpec) Pos() token.Pos { return s.Name.Pos() }
// End returns position of first character immediately after the node.
func (s *ImportSpec) End() token.Pos {
if s.EndPos != 0 {
return s.EndPos
}
return s.Path.End()
}
// End returns position of first character immediately after the node.
func (s *ValueSpec) End() token.Pos {
if n := len(s.Values); n > 0 {
return s.Values[n-1].End()
}
if s.Type != nil {
return s.Type.End()
}
return s.Names[len(s.Names)-1].End()
}
// End returns position of first character immediately after the node.
func (s *TypeSpec) End() token.Pos { return s.Type.End() }
// specNode() ensures that only spec nodes can be
// assigned to a Spec.
func (*ImportSpec) specNode() {}
func (*ValueSpec) specNode() {}
func (*TypeSpec) specNode() {}
// A declaration is represented by one of the following declaration nodes.
type (
// A BadDecl node is a placeholder for declarations containing
// syntax errors for which no correct declaration nodes can be
// created.
//
BadDecl struct {
From, To token.Pos // position range of bad declaration
}
// A GenDecl node (generic declaration node) represents an import,
// constant, type or variable declaration. A valid Lparen position
// (Lparen.IsValid()) indicates a parenthesized declaration.
//
// Relationship between Tok value and Specs element type:
//
// token.IMPORT *ImportSpec
// token.CONST *ValueSpec
// token.TYPE *TypeSpec
// token.VAR *ValueSpec
//
GenDecl struct {
Doc *CommentGroup // associated documentation; or nil
TokPos token.Pos // position of Tok
Tok token.Token // IMPORT, CONST, TYPE, VAR
Lparen token.Pos // position of '(', if any
Specs []Spec
Rparen token.Pos // position of ')', if any
}
// A FuncDecl node represents a function declaration.
FuncDecl struct {
Doc *CommentGroup // associated documentation; or nil
Recv *FieldList // receiver (methods); or nil (functions)
Name *Ident // function/method name
Type *FuncType // function signature: parameters, results, and position of "func" keyword
Body *BlockStmt // function body; or nil for external (non-Go) function
Operator bool // is operator or not
Shadow bool // is a shadow entry
IsClass bool // recv set by class
Static bool // recv is static (class method)
}
)
// Pos and End implementations for declaration nodes.
// Pos returns position of first character belonging to the node.
func (d *BadDecl) Pos() token.Pos { return d.From }
// Pos returns position of first character belonging to the node.
func (d *GenDecl) Pos() token.Pos { return d.TokPos }
// Pos returns position of first character belonging to the node.
func (d *FuncDecl) Pos() token.Pos { return d.Type.Pos() }
// End returns position of first character immediately after the node.
func (d *BadDecl) End() token.Pos { return d.To }
// End returns position of first character immediately after the node.
func (d *GenDecl) End() token.Pos {
if d.Rparen.IsValid() {
return d.Rparen + 1
}
return d.Specs[0].End()
}
// End returns position of first character immediately after the node.
func (d *FuncDecl) End() token.Pos {
if d.Body != nil {
return d.Body.End()
}
return d.Type.End()
}
// declNode() ensures that only declaration nodes can be
// assigned to a Decl.
func (*BadDecl) declNode() {}
func (*GenDecl) declNode() {}
func (*FuncDecl) declNode() {}
// ----------------------------------------------------------------------------
// A Package node represents a set of source files
// collectively building an XGo package.
type Package struct {
Name string // package name
Imports map[string]*Object // map of package id -> package object
Files map[string]*File // XGo source files by filename
GoFiles map[string]*ast.File // Go source files by filename
}
// Pos returns position of first character belonging to the node.
func (p *Package) Pos() token.Pos { return token.NoPos }
// End returns position of first character immediately after the node.
func (p *Package) End() token.Pos { return token.NoPos }
// ----------------------------------------------------------------------------
================================================
FILE: ast/ast_xgo.go
================================================
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ast
import (
"github.com/goplus/xgo/token"
)
// -----------------------------------------------------------------------------
// OverloadFuncDecl node represents an overload function declaration:
//
// `func name = (overloadFuncs)`
// `func (T).nameOrOp = (overloadFuncs)`
//
// here overloadFunc represents
//
// `func(params) results {...}`
// `funcName`
// `(*T).methodName`
type OverloadFuncDecl struct {
Doc *CommentGroup // associated documentation; or nil
Func token.Pos // position of "func" keyword
Recv *FieldList // receiver (methods); or nil (functions)
Name *Ident // function/method name
Assign token.Pos // position of token "="
Lparen token.Pos // position of "("
Funcs []Expr // overload functions. here `Expr` can be *FuncLit, *Ident or *SelectorExpr
Rparen token.Pos // position of ")"
Operator bool // is operator or not
IsClass bool // recv set by class
}
// Pos - position of first character belonging to the node.
func (p *OverloadFuncDecl) Pos() token.Pos {
return p.Func
}
// End - position of first character immediately after the node.
func (p *OverloadFuncDecl) End() token.Pos {
return p.Rparen + 1
}
func (*OverloadFuncDecl) declNode() {}
// -----------------------------------------------------------------------------
// A CallExpr node represents an expression followed by an argument list.
// The argument list may include positional arguments (Args) and/or
// keyword arguments (Kwargs).
type CallExpr struct {
Fun Expr // function expression
Lparen token.Pos // position of "("
Args []Expr // positional arguments; or nil
Ellipsis token.Pos // position of "..." (token.NoPos if there is no "...")
Kwargs []*KwargExpr // keyword arguments; or nil
Rparen token.Pos // position of ")"
NoParenEnd token.Pos
}
// Pos returns position of first character belonging to the node.
func (x *CallExpr) Pos() token.Pos { return x.Fun.Pos() }
// End returns position of first character immediately after the node.
func (x *CallExpr) End() token.Pos {
if x.NoParenEnd != token.NoPos {
return x.NoParenEnd
}
return x.Rparen + 1
}
func (*CallExpr) exprNode() {}
// IsCommand returns if a CallExpr is a command style CallExpr or not.
func (x *CallExpr) IsCommand() bool {
return x.NoParenEnd != token.NoPos
}
// A KwargExpr node represents a keyword argument expression.
type KwargExpr struct {
Name *Ident // argument name
Value Expr // argument value
}
func (p *KwargExpr) Pos() token.Pos {
return p.Name.Pos()
}
func (p *KwargExpr) End() token.Pos {
return p.Value.End()
}
func (p *KwargExpr) exprNode() {}
// -----------------------------------------------------------------------------
// A DomainTextLit node represents a domain-specific text literal.
// https://github.com/goplus/xgo/issues/2143
//
// domainTag`...`
// domainTag`> arg1, arg2, ...
// ...
// `
type DomainTextLit struct {
Domain *Ident // domain name
ValuePos token.Pos // literal position
Value string // literal string; e.g. `\m\n\o`
Extra any // *DomainTextLitEx or *xgo/tpl/ast.File, optional
}
// DomainTextLitEx represents extra information for domain text literal.
type DomainTextLitEx struct {
Args []Expr // domain text arguments; or nil
RawPos token.Pos // position of the first character of the raw string
Raw string // raw string without backquote
}
// Pos returns position of first character belonging to the node.
func (x *DomainTextLit) Pos() token.Pos { return x.Domain.NamePos }
// End returns position of first character immediately after the node.
func (x *DomainTextLit) End() token.Pos { return token.Pos(int(x.ValuePos) + len(x.Value)) }
func (*DomainTextLit) exprNode() {}
// -----------------------------------------------------------------------------
// A BasicLit node represents a literal of basic type.
type BasicLit struct {
ValuePos token.Pos // literal position
Kind token.Token // token.INT, token.FLOAT, token.IMAG, token.RAT, token.CHAR, token.STRING, token.CSTRING
Value string // literal string; e.g. 42, 0x7f, 3.14, 1e-9, 2.4i, 3r, 'a', '\x7f', "foo" or `\m\n\o`
Extra *StringLitEx // optional (only available when Kind == token.STRING)
}
type StringLitEx struct {
Parts []any // can be (val string) or (xval Expr)
}
// NextPartPos - position of first character of next part.
// pos - position of this part (not including quote character).
func NextPartPos(pos token.Pos, part any) (nextPos token.Pos) {
switch v := part.(type) {
case string: // normal string literal or end with "$$"
return pos + token.Pos(len(v))
case Expr:
return v.End()
}
panic("NextPartPos: unexpected parameters")
}
// Pos returns position of first character belonging to the node.
func (x *BasicLit) Pos() token.Pos { return x.ValuePos }
// End returns position of first character immediately after the node.
func (x *BasicLit) End() token.Pos { return token.Pos(int(x.ValuePos) + len(x.Value)) }
func (*BasicLit) exprNode() {}
// -----------------------------------------------------------------------------
// A NumberUnitLit node represents a number with unit.
type NumberUnitLit struct {
ValuePos token.Pos // literal position
Kind token.Token // token.INT or token.FLOAT
Value string // literal string of the number; e.g. 42, 0x7f, 3.14, 1e-9
Unit string // unit string of the number; e.g. "px", "em", "rem"
}
func (*NumberUnitLit) exprNode() {}
func (x *NumberUnitLit) Pos() token.Pos {
return x.ValuePos
}
func (x *NumberUnitLit) End() token.Pos {
return token.Pos(int(x.ValuePos) + len(x.Value) + len(x.Unit))
}
// -----------------------------------------------------------------------------
// A EnvExpr node represents a ${name} expression.
type EnvExpr struct {
TokPos token.Pos // position of "$"
Lbrace token.Pos // position of "{"
Name *Ident // name
Rbrace token.Pos // position of "}"
}
// Pos - position of first character belonging to the node.
func (p *EnvExpr) Pos() token.Pos {
return p.TokPos
}
// End - position of first character immediately after the node.
func (p *EnvExpr) End() token.Pos {
if p.Rbrace != token.NoPos {
return p.Rbrace
}
return p.Name.End()
}
// HasBrace checks is this EnvExpr ${name} or $name.
func (p *EnvExpr) HasBrace() bool {
return p.Rbrace != token.NoPos
}
func (*EnvExpr) exprNode() {}
// -----------------------------------------------------------------------------
// AnySelectorExpr represents `X.**.Sel` expression, which selects any field
// named Sel in the nested object X.
// Sel may not be a simple identifier. For example:
// - x.**.field
// - x.**."field-name"
// - x.**.*
type AnySelectorExpr struct {
X Expr // expression
TokPos token.Pos // position of "**"
Sel *Ident // field selector (it may not be a simple identifier)
}
// Pos - position of first character belonging to the node.
func (p *AnySelectorExpr) Pos() token.Pos {
return p.X.Pos()
}
// End - position of first character immediately after the node.
func (p *AnySelectorExpr) End() token.Pos {
return p.Sel.End()
}
func (*AnySelectorExpr) exprNode() {}
// -----------------------------------------------------------------------------
// A CondExpr node represents a conditional expression: `expr @ cond`.
// - ns@(condExpr)
// - ns@fn(args)
// - ns@"elem-name" (Cond will be a *Ident with name "elem-name", not a *BasicLit)
// - ns@name
type CondExpr struct {
X Expr // expression
OpPos token.Pos // position of "@"
Cond Expr // condition expression (can be *CallExpr, *ParenExpr or *Ident)
}
// Pos - position of first character belonging to the node.
func (p *CondExpr) Pos() token.Pos {
return p.X.Pos()
}
// End - position of first character immediately after the node.
func (p *CondExpr) End() token.Pos {
return p.Cond.End()
}
func (*CondExpr) exprNode() {}
// -----------------------------------------------------------------------------
// A SliceLit node represents a slice literal.
type SliceLit struct {
Lbrack token.Pos // position of "["
Elts []Expr // list of slice elements; or nil
Rbrack token.Pos // position of "]"
Incomplete bool // true if (source) expressions are missing in the Elts list
}
// Pos - position of first character belonging to the node.
func (p *SliceLit) Pos() token.Pos {
return p.Lbrack
}
// End - position of first character immediately after the node.
func (p *SliceLit) End() token.Pos {
return p.Rbrack + 1
}
func (*SliceLit) exprNode() {}
// -----------------------------------------------------------------------------
// A TupleLit node represents a tuple literal.
type TupleLit struct {
Lparen token.Pos // position of "("
Elts []Expr // list of tuple elements; or nil
Ellipsis token.Pos // position of "..." (token.NoPos if there is no "...")
Rparen token.Pos // position of ")"
}
// Pos - position of first character belonging to the node.
func (p *TupleLit) Pos() token.Pos {
return p.Lparen
}
// End - position of first character immediately after the node.
func (p *TupleLit) End() token.Pos {
return p.Rparen + 1
}
func (*TupleLit) exprNode() {}
// -----------------------------------------------------------------------------
// A MatrixLit node represents a matrix literal.
type MatrixLit struct {
Lbrack token.Pos // position of "["
Elts [][]Expr // list of matrix elements
Rbrack token.Pos // position of "]"
Incomplete bool // true if (source) expressions are missing in the Elts list
}
// Pos - position of first character belonging to the node.
func (p *MatrixLit) Pos() token.Pos {
return p.Lbrack
}
// End - position of first character immediately after the node.
func (p *MatrixLit) End() token.Pos {
return p.Rbrack + 1
}
func (*MatrixLit) exprNode() {}
// -----------------------------------------------------------------------------
// A ElemEllipsis node represents a matrix row elements.
type ElemEllipsis struct {
Elt Expr // ellipsis element
Ellipsis token.Pos // position of "..."
}
// Pos - position of first character belonging to the node.
func (p *ElemEllipsis) Pos() token.Pos {
return p.Elt.Pos()
}
// End - position of first character immediately after the node.
func (p *ElemEllipsis) End() token.Pos {
return p.Ellipsis + 3
}
func (*ElemEllipsis) exprNode() {}
// -----------------------------------------------------------------------------
// ErrWrapExpr represents `expr!`, `expr?` or `expr?:defaultValue`.
type ErrWrapExpr struct {
X Expr
Tok token.Token // ! or ?
TokPos token.Pos
Default Expr // can be nil
}
// Pos - position of first character belonging to the node.
func (p *ErrWrapExpr) Pos() token.Pos {
return p.X.Pos()
}
// End - position of first character immediately after the node.
func (p *ErrWrapExpr) End() token.Pos {
if p.Default != nil {
return p.Default.End()
}
return p.TokPos + 1
}
func (*ErrWrapExpr) exprNode() {}
// -----------------------------------------------------------------------------
// LambdaExpr represents one of the following expressions:
//
// `(x, y, ...) => exprOrExprTuple`
// `x => exprOrExprTuple`
// `=> exprOrExprTuple`
//
// here exprOrExprTuple represents
//
// `expr`
// `(expr1, expr2, ...)`
type LambdaExpr struct {
First token.Pos
Lhs []*Ident
Rarrow token.Pos
Rhs []Expr
Last token.Pos
LhsHasParen bool
RhsHasParen bool
}
// LambdaExpr2 represents one of the following expressions:
//
// `(x, y, ...) => { ... }`
// `x => { ... }`
// `=> { ... }`
type LambdaExpr2 struct {
First token.Pos
Lhs []*Ident
Rarrow token.Pos
Body *BlockStmt
LhsHasParen bool
}
// Pos - position of first character belonging to the node.
func (p *LambdaExpr) Pos() token.Pos {
return p.First
}
// End - position of first character immediately after the node.
func (p *LambdaExpr) End() token.Pos {
return p.Last
}
// Pos - position of first character belonging to the node.
func (p *LambdaExpr2) Pos() token.Pos {
return p.First
}
// End - position of first character immediately after the node.
func (p *LambdaExpr2) End() token.Pos {
if p.Body == nil {
return p.Rarrow + 2
}
return p.Body.End()
}
func (*LambdaExpr) exprNode() {}
func (*LambdaExpr2) exprNode() {}
// -----------------------------------------------------------------------------
// A RangeExpr node represents a range expression.
type RangeExpr struct {
First Expr // start of composite elements; or nil
To token.Pos // position of ":"
Last Expr // end of composite elements
Colon2 token.Pos // position of ":" or token.NoPos
Expr3 Expr // step (or max) of composite elements; or nil
}
// Pos - position of first character belonging to the node.
func (p *RangeExpr) Pos() token.Pos {
if p.First != nil {
return p.First.Pos()
}
return p.To
}
// End - position of first character immediately after the node.
func (p *RangeExpr) End() token.Pos {
if p.Expr3 != nil {
return p.Expr3.End()
}
if p.Colon2 != token.NoPos {
return p.Colon2 + 1
}
if p.Last != nil {
return p.Last.End()
}
return p.To + 1
}
func (*RangeExpr) exprNode() {}
// -----------------------------------------------------------------------------
// ForPhrase represents `for k, v in container if init; cond` phrase.
type ForPhrase struct {
For token.Pos // position of "for" keyword
Key, Value *Ident // Key may be nil
TokPos token.Pos // position of "in" operator
X Expr // value to range over
IfPos token.Pos // position of if or comma; or NoPos
Init Stmt // initialization statement; or nil
Cond Expr // value filter, can be nil
}
// Pos returns position of first character belonging to the node.
func (p *ForPhrase) Pos() token.Pos { return p.For }
// End returns position of first character immediately after the node.
func (p *ForPhrase) End() token.Pos {
if p.Cond != nil {
return p.Cond.End()
}
return p.X.End()
}
func (p *ForPhrase) exprNode() {}
// ComprehensionExpr represents one of the following expressions:
//
// `[vexpr for k1, v1 in container1, cond1 ...]` or
// `{vexpr for k1, v1 in container1, cond1 ...}` or
// `{kexpr: vexpr for k1, v1 in container1, cond1 ...}` or
// `{for k1, v1 in container1, cond1 ...}`
type ComprehensionExpr struct {
Lpos token.Pos // position of "[" or "{"
Tok token.Token // token.LBRACK '[' or token.LBRACE '{'
Elt Expr // *KeyValueExpr or Expr or nil
Fors []*ForPhrase
Rpos token.Pos // position of "]" or "}"
}
// Pos - position of first character belonging to the node.
func (p *ComprehensionExpr) Pos() token.Pos {
return p.Lpos
}
// End - position of first character immediately after the node.
func (p *ComprehensionExpr) End() token.Pos {
return p.Rpos + 1
}
func (*ComprehensionExpr) exprNode() {}
// -----------------------------------------------------------------------------
// A ForPhraseStmt represents a for statement with a for..in clause.
type ForPhraseStmt struct {
*ForPhrase
Body *BlockStmt
}
// Pos - position of first character belonging to the node.
func (p *ForPhraseStmt) Pos() token.Pos {
return p.For
}
// End - position of first character immediately after the node.
func (p *ForPhraseStmt) End() token.Pos {
return p.Body.End()
}
func (*ForPhraseStmt) stmtNode() {}
// -----------------------------------------------------------------------------
// A SendStmt node represents a send statement.
type SendStmt struct {
Chan Expr
Arrow token.Pos // position of "<-"
Values []Expr // len(Values) must > 0
Ellipsis token.Pos // position of "..."
}
// End returns position of first character immediately after the node.
func (s *SendStmt) End() token.Pos {
if s.Ellipsis != token.NoPos {
return s.Ellipsis + 3
}
vals := s.Values
return vals[len(vals)-1].End()
}
// -----------------------------------------------------------------------------
// A File node represents an XGo source file.
//
// The Comments list contains all comments in the source file in order of
// appearance, including the comments that are pointed to from other nodes
// via Doc and Comment fields.
//
// For correct printing of source code containing comments (using packages
// go/format and go/printer), special care must be taken to update comments
// when a File's syntax tree is modified: For printing, comments are interspersed
// between tokens based on their position. If syntax tree nodes are
// removed or moved, relevant comments in their vicinity must also be removed
// (from the File.Comments list) or moved accordingly (by updating their
// positions). A CommentMap may be used to facilitate some of these operations.
//
// Whether and how a comment is associated with a node depends on the
// interpretation of the syntax tree by the manipulating program: Except for Doc
// and Comment comments directly associated with nodes, the remaining comments
// are "free-floating" (see also issues #18593, #20744).
type File struct {
Doc *CommentGroup // associated documentation; or nil
Package token.Pos // position of "package" keyword; or NoPos
Name *Ident // package name
Decls []Decl // top-level declarations; or nil
Imports []*ImportSpec // imports in this file
Comments []*CommentGroup // list of all comments in the source file
Code []byte
ShadowEntry *FuncDecl // indicate the module entry point.
NoPkgDecl bool // no `package xxx` declaration
IsClass bool // is a classfile (including normal .gox file)
IsProj bool // is a project classfile
IsNormalGox bool // is a normal .gox file
}
// There is no entrypoint func to indicate the module entry point.
func (f *File) HasShadowEntry() bool {
return f.ShadowEntry != nil
}
// HasPkgDecl checks if `package xxx` exists or not.
func (f *File) HasPkgDecl() bool {
return f.Package != token.NoPos
}
// ClassFieldsDecl returns the class fields declaration.
func (f *File) ClassFieldsDecl() *GenDecl {
if f.IsClass {
for _, decl := range f.Decls {
if g, ok := decl.(*GenDecl); ok {
if g.Tok == token.VAR {
return g
}
continue
}
break
}
}
return nil
}
// Pos returns position of first character belonging to the node.
func (f *File) Pos() token.Pos {
if f.Package != token.NoPos {
return f.Package
}
// if no package clause, name records the position of the first token in the file
return f.Name.NamePos
}
// End returns position of first character immediately after the node.
func (f *File) End() token.Pos {
if f.ShadowEntry != nil { // has shadow entry
return f.ShadowEntry.End()
}
for n := len(f.Decls) - 1; n >= 0; n-- {
d := f.Decls[n]
if fn, ok := d.(*FuncDecl); ok && fn.Shadow {
// skip shadow functions like Classfname (see cl.astFnClassfname)
continue
}
return d.End()
}
if f.Package != token.NoPos { // has package clause
return f.Name.End()
}
return f.Name.Pos()
}
// -----------------------------------------------------------------------------
================================================
FILE: ast/commentmap.go
================================================
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ast
import (
"bytes"
"fmt"
"sort"
"github.com/goplus/xgo/token"
)
type byPos []*CommentGroup
func (a byPos) Len() int { return len(a) }
func (a byPos) Less(i, j int) bool { return a[i].Pos() < a[j].Pos() }
func (a byPos) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
// sortComments sorts the list of comment groups in source order.
func sortComments(list []*CommentGroup) {
// TODO(gri): Does it make sense to check for sorted-ness
// first (because we know that sorted-ness is
// very likely)?
if orderedList := byPos(list); !sort.IsSorted(orderedList) {
sort.Sort(orderedList)
}
}
// A CommentMap maps an AST node to a list of comment groups
// associated with it. See NewCommentMap for a description of
// the association.
type CommentMap map[Node][]*CommentGroup
func (cmap CommentMap) addComment(n Node, c *CommentGroup) {
list := cmap[n]
if len(list) == 0 {
list = []*CommentGroup{c}
} else {
list = append(list, c)
}
cmap[n] = list
}
// nodeList returns the list of nodes of the AST n in source order.
func nodeList(n Node) []Node {
var list []Node
Inspect(n, func(n Node) bool {
// don't collect comments
switch n.(type) {
case nil, *CommentGroup, *Comment:
return false
}
list = append(list, n)
return true
})
// Note: The current implementation assumes that Inspect traverses the
// AST in depth-first and thus _source_ order. If AST traversal
// does not follow source order, the sorting call below will be
// required.
// sort.Sort(byInterval(list))
return list
}
// A commentListReader helps iterating through a list of comment groups.
type commentListReader struct {
fset *token.FileSet
list []*CommentGroup
index int
comment *CommentGroup // comment group at current index
pos, end token.Position // source interval of comment group at current index
}
func (r *commentListReader) eol() bool {
return r.index >= len(r.list)
}
func (r *commentListReader) next() {
if !r.eol() {
r.comment = r.list[r.index]
r.pos = r.fset.Position(r.comment.Pos())
r.end = r.fset.Position(r.comment.End())
r.index++
}
}
// A nodeStack keeps track of nested nodes.
// A node lower on the stack lexically contains the nodes higher on the stack.
type nodeStack []Node
// push pops all nodes that appear lexically before n
// and then pushes n on the stack.
func (s *nodeStack) push(n Node) {
s.pop(n.Pos())
*s = append((*s), n)
}
// pop pops all nodes that appear lexically before pos
// (i.e., whose lexical extent has ended before or at pos).
// It returns the last node popped.
func (s *nodeStack) pop(pos token.Pos) (top Node) {
i := len(*s)
for i > 0 && (*s)[i-1].End() <= pos {
top = (*s)[i-1]
i--
}
*s = (*s)[0:i]
return top
}
// NewCommentMap creates a new comment map by associating comment groups
// of the comments list with the nodes of the AST specified by node.
//
// A comment group g is associated with a node n if:
//
// - g starts on the same line as n ends
// - g starts on the line immediately following n, and there is
// at least one empty line after g and before the next node
// - g starts before n and is not associated to the node before n
// via the previous rules
//
// NewCommentMap tries to associate a comment group to the "largest"
// node possible: For instance, if the comment is a line comment
// trailing an assignment, the comment is associated with the entire
// assignment rather than just the last operand in the assignment.
func NewCommentMap(fset *token.FileSet, node Node, comments []*CommentGroup) CommentMap {
if len(comments) == 0 {
return nil // no comments to map
}
cmap := make(CommentMap)
// set up comment reader r
tmp := make([]*CommentGroup, len(comments))
copy(tmp, comments) // don't change incoming comments
sortComments(tmp)
r := commentListReader{fset: fset, list: tmp} // !r.eol() because len(comments) > 0
r.next()
// create node list in lexical order
nodes := nodeList(node)
nodes = append(nodes, nil) // append sentinel
// set up iteration variables
var (
p Node // previous node
pend token.Position // end of p
pg Node // previous node group (enclosing nodes of "importance")
pgend token.Position // end of pg
stack nodeStack // stack of node groups
)
for _, q := range nodes {
var qpos token.Position
if q != nil {
qpos = fset.Position(q.Pos()) // current node position
} else {
// set fake sentinel position to infinity so that
// all comments get processed before the sentinel
const infinity = 1 << 30
qpos.Offset = infinity
qpos.Line = infinity
}
// process comments before current node
for r.end.Offset <= qpos.Offset {
// determine recent node group
if top := stack.pop(r.comment.Pos()); top != nil {
pg = top
pgend = fset.Position(pg.End())
}
// Try to associate a comment first with a node group
// (i.e., a node of "importance" such as a declaration);
// if that fails, try to associate it with the most recent
// node.
// TODO(gri) try to simplify the logic below
var assoc Node
switch {
case pg != nil &&
(pgend.Line == r.pos.Line ||
pgend.Line+1 == r.pos.Line && r.end.Line+1 < qpos.Line):
// 1) comment starts on same line as previous node group ends, or
// 2) comment starts on the line immediately after the
// previous node group and there is an empty line before
// the current node
// => associate comment with previous node group
assoc = pg
case p != nil &&
(pend.Line == r.pos.Line ||
pend.Line+1 == r.pos.Line && r.end.Line+1 < qpos.Line ||
q == nil):
// same rules apply as above for p rather than pg,
// but also associate with p if we are at the end (q == nil)
assoc = p
default:
// otherwise, associate comment with current node
if q == nil {
// we can only reach here if there was no p
// which would imply that there were no nodes
panic("internal error: no comments should be associated with sentinel")
}
assoc = q
}
cmap.addComment(assoc, r.comment)
if r.eol() {
return cmap
}
r.next()
}
// update previous node
p = q
pend = fset.Position(p.End())
// update previous node group if we see an "important" node
switch q.(type) {
case *File, *Field, Decl, Spec, Stmt:
stack.push(q)
}
}
return cmap
}
// Update replaces an old node in the comment map with the new node
// and returns the new node. Comments that were associated with the
// old node are associated with the new node.
func (cmap CommentMap) Update(old, new Node) Node {
if list := cmap[old]; len(list) > 0 {
delete(cmap, old)
cmap[new] = append(cmap[new], list...)
}
return new
}
// Filter returns a new comment map consisting of only those
// entries of cmap for which a corresponding node exists in
// the AST specified by node.
func (cmap CommentMap) Filter(node Node) CommentMap {
umap := make(CommentMap)
Inspect(node, func(n Node) bool {
if g := cmap[n]; len(g) > 0 {
umap[n] = g
}
return true
})
return umap
}
// Comments returns the list of comment groups in the comment map.
// The result is sorted in source order.
func (cmap CommentMap) Comments() []*CommentGroup {
list := make([]*CommentGroup, 0, len(cmap))
for _, e := range cmap {
list = append(list, e...)
}
sortComments(list)
return list
}
func summary(list []*CommentGroup) string {
const maxLen = 40
var buf bytes.Buffer
// collect comments text
loop:
for _, group := range list {
// Note: CommentGroup.Text() does too much work for what we
// need and would only replace this innermost loop.
// Just do it explicitly.
for _, comment := range group.List {
if buf.Len() >= maxLen {
break loop
}
buf.WriteString(comment.Text)
}
}
// truncate if too long
if buf.Len() > maxLen {
buf.Truncate(maxLen - 3)
buf.WriteString("...")
}
// replace any invisibles with blanks
bytes := buf.Bytes()
for i, b := range bytes {
switch b {
case '\t', '\n', '\r':
bytes[i] = ' '
}
}
return string(bytes)
}
func (cmap CommentMap) String() string {
var buf bytes.Buffer
fmt.Fprintln(&buf, "CommentMap {")
for node, comment := range cmap {
// print name of identifiers; print node type for other nodes
var s string
if ident, ok := node.(*Ident); ok {
s = ident.Name
} else {
s = fmt.Sprintf("%T", node)
}
fmt.Fprintf(&buf, "\t%p %20s: %s\n", node, s, summary(comment))
}
fmt.Fprintln(&buf, "}")
return buf.String()
}
================================================
FILE: ast/filter.go
================================================
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ast
import (
"sort"
"github.com/goplus/xgo/token"
)
// ----------------------------------------------------------------------------
// Export filtering
// exportFilter is a special filter function to extract exported nodes.
func exportFilter(name string) bool {
return IsExported(name)
}
// FileExports trims the AST for a Go source file in place such that
// only exported nodes remain: all top-level identifiers which are not exported
// and their associated information (such as type, initial value, or function
// body) are removed. Non-exported fields and methods of exported types are
// stripped. The File.Comments list is not changed.
//
// FileExports reports whether there are exported declarations.
func FileExports(src *File) bool {
return filterFile(src, exportFilter, true)
}
// PackageExports trims the AST for a Go package in place such that
// only exported nodes remain. The pkg.Files list is not changed, so that
// file names and top-level package comments don't get lost.
//
// PackageExports reports whether there are exported declarations;
// it returns false otherwise.
func PackageExports(pkg *Package) bool {
return filterPackage(pkg, exportFilter, true)
}
// ----------------------------------------------------------------------------
// General filtering
// Filter type
type Filter func(string) bool
func filterIdentList(list []*Ident, f Filter) []*Ident {
j := 0
for _, x := range list {
if f(x.Name) {
list[j] = x
j++
}
}
return list[0:j]
}
// fieldName assumes that x is the type of an anonymous field and
// returns the corresponding field name. If x is not an acceptable
// anonymous field, the result is nil.
func fieldName(x Expr) *Ident {
switch t := x.(type) {
case *Ident:
return t
case *SelectorExpr:
if _, ok := t.X.(*Ident); ok {
return t.Sel
}
case *StarExpr:
return fieldName(t.X)
}
return nil
}
func filterFieldList(fields *FieldList, filter Filter, export bool) (removedFields bool) {
if fields == nil {
return false
}
list := fields.List
j := 0
for _, f := range list {
var keepField bool
if len(f.Names) == 0 {
// anonymous field
name := fieldName(f.Type)
keepField = name != nil && filter(name.Name)
} else {
n := len(f.Names)
f.Names = filterIdentList(f.Names, filter)
if len(f.Names) < n {
removedFields = true
}
keepField = len(f.Names) > 0
}
if keepField {
if export {
filterType(f.Type, filter, export)
}
list[j] = f
j++
}
}
if j < len(list) {
removedFields = true
}
fields.List = list[0:j]
return
}
func filterCompositeLit(lit *CompositeLit, filter Filter, export bool) {
n := len(lit.Elts)
lit.Elts = filterExprList(lit.Elts, filter, export)
if len(lit.Elts) < n {
lit.Incomplete = true
}
}
func filterExprList(list []Expr, filter Filter, export bool) []Expr {
j := 0
for _, exp := range list {
switch x := exp.(type) {
case *CompositeLit:
filterCompositeLit(x, filter, export)
case *KeyValueExpr:
if x, ok := x.Key.(*Ident); ok && !filter(x.Name) {
continue
}
if x, ok := x.Value.(*CompositeLit); ok {
filterCompositeLit(x, filter, export)
}
}
list[j] = exp
j++
}
return list[0:j]
}
func filterParamList(fields *FieldList, filter Filter, export bool) bool {
if fields == nil {
return false
}
var b bool
for _, f := range fields.List {
if filterType(f.Type, filter, export) {
b = true
}
}
return b
}
func filterType(typ Expr, f Filter, export bool) bool {
switch t := typ.(type) {
case *Ident:
return f(t.Name)
case *ParenExpr:
return filterType(t.X, f, export)
case *ArrayType:
return filterType(t.Elt, f, export)
case *StructType:
if filterFieldList(t.Fields, f, export) {
t.Incomplete = true
}
return len(t.Fields.List) > 0
case *FuncType:
b1 := filterParamList(t.Params, f, export)
b2 := filterParamList(t.Results, f, export)
return b1 || b2
case *InterfaceType:
if filterFieldList(t.Methods, f, export) {
t.Incomplete = true
}
return len(t.Methods.List) > 0
case *MapType:
b1 := filterType(t.Key, f, export)
b2 := filterType(t.Value, f, export)
return b1 || b2
case *ChanType:
return filterType(t.Value, f, export)
case *TupleType:
if filterFieldList(t.Fields, f, export) {
// Note: TupleType doesn't have an Incomplete field like StructType
}
return t.Fields != nil && len(t.Fields.List) > 0
}
return false
}
func filterSpec(spec Spec, f Filter, export bool) bool {
switch s := spec.(type) {
case *ValueSpec:
s.Names = filterIdentList(s.Names, f)
s.Values = filterExprList(s.Values, f, export)
if len(s.Names) > 0 {
if export {
filterType(s.Type, f, export)
}
return true
}
case *TypeSpec:
if f(s.Name.Name) {
if export {
filterType(s.Type, f, export)
}
return true
}
if !export {
// For general filtering (not just exports),
// filter type even if name is not filtered
// out.
// If the type contains filtered elements,
// keep the declaration.
return filterType(s.Type, f, export)
}
}
return false
}
func filterSpecList(list []Spec, f Filter, export bool) []Spec {
j := 0
for _, s := range list {
if filterSpec(s, f, export) {
list[j] = s
j++
}
}
return list[0:j]
}
// FilterDecl trims the AST for a Go declaration in place by removing
// all names (including struct field and interface method names, but
// not from parameter lists) that don't pass through the filter f.
//
// FilterDecl reports whether there are any declared names left after
// filtering.
func FilterDecl(decl Decl, f Filter) bool {
return filterDecl(decl, f, false)
}
func filterDecl(decl Decl, f Filter, export bool) bool {
switch d := decl.(type) {
case *GenDecl:
d.Specs = filterSpecList(d.Specs, f, export)
return len(d.Specs) > 0
case *FuncDecl:
return f(d.Name.Name)
}
return false
}
// FilterFile trims the AST for a Go file in place by removing all
// names from top-level declarations (including struct field and
// interface method names, but not from parameter lists) that don't
// pass through the filter f. If the declaration is empty afterwards,
// the declaration is removed from the AST. Import declarations are
// always removed. The File.Comments list is not changed.
//
// FilterFile reports whether there are any top-level declarations
// left after filtering.
func FilterFile(src *File, f Filter) bool {
return filterFile(src, f, false)
}
func filterFile(src *File, f Filter, export bool) bool {
j := 0
for _, d := range src.Decls {
if filterDecl(d, f, export) {
src.Decls[j] = d
j++
}
}
src.Decls = src.Decls[0:j]
return j > 0
}
// FilterPackage trims the AST for a Go package in place by removing
// all names from top-level declarations (including struct field and
// interface method names, but not from parameter lists) that don't
// pass through the filter f. If the declaration is empty afterwards,
// the declaration is removed from the AST. The pkg.Files list is not
// changed, so that file names and top-level package comments don't get
// lost.
//
// FilterPackage reports whether there are any top-level declarations
// left after filtering.
func FilterPackage(pkg *Package, f Filter) bool {
return filterPackage(pkg, f, false)
}
func filterPackage(pkg *Package, f Filter, export bool) bool {
hasDecls := false
for _, src := range pkg.Files {
if filterFile(src, f, export) {
hasDecls = true
}
}
return hasDecls
}
// ----------------------------------------------------------------------------
// Merging of package files
// The MergeMode flags control the behavior of MergePackageFiles.
type MergeMode uint
const (
// FilterFuncDuplicates - If set, duplicate function declarations are excluded.
FilterFuncDuplicates MergeMode = 1 << iota
// FilterUnassociatedComments - If set, comments that are not associated with a specific
// AST node (as Doc or Comment) are excluded.
FilterUnassociatedComments
// FilterImportDuplicates - If set, duplicate import declarations are excluded.
FilterImportDuplicates
)
// nameOf returns the function (foo) or method name (foo.bar) for
// the given function declaration. If the AST is incorrect for the
// receiver, it assumes a function instead.
func nameOf(f *FuncDecl) string {
if r := f.Recv; r != nil && len(r.List) == 1 {
// looks like a correct receiver declaration
t := r.List[0].Type
// dereference pointer receiver types
if p, _ := t.(*StarExpr); p != nil {
t = p.X
}
// the receiver type must be a type name
if p, _ := t.(*Ident); p != nil {
return p.Name + "." + f.Name.Name
}
// otherwise assume a function instead
}
return f.Name.Name
}
// separator is an empty //-style comment that is interspersed between
// different comment groups when they are concatenated into a single group
var separator = &Comment{Slash: token.NoPos, Text: "//"}
// MergePackageFiles creates a file AST by merging the ASTs of the
// files belonging to a package. The mode flags control merging behavior.
func MergePackageFiles(pkg *Package, mode MergeMode) *File {
// Count the number of package docs, comments and declarations across
// all package files. Also, compute sorted list of filenames, so that
// subsequent iterations can always iterate in the same order.
ndocs := 0
ncomments := 0
ndecls := 0
filenames := make([]string, len(pkg.Files))
i := 0
for filename, f := range pkg.Files {
filenames[i] = filename
i++
if f.Doc != nil {
ndocs += len(f.Doc.List) + 1 // +1 for separator
}
ncomments += len(f.Comments)
ndecls += len(f.Decls)
}
sort.Strings(filenames)
// Collect package comments from all package files into a single
// CommentGroup - the collected package documentation. In general
// there should be only one file with a package comment; but it's
// better to collect extra comments than drop them on the floor.
var doc *CommentGroup
var pos token.Pos
if ndocs > 0 {
list := make([]*Comment, ndocs-1) // -1: no separator before first group
i := 0
for _, filename := range filenames {
f := pkg.Files[filename]
if f.Doc != nil {
if i > 0 {
// not the first group - add separator
list[i] = separator
i++
}
for _, c := range f.Doc.List {
list[i] = c
i++
}
if f.Package > pos {
// Keep the maximum package clause position as
// position for the package clause of the merged
// files.
pos = f.Package
}
}
}
doc = &CommentGroup{List: list}
}
// Collect declarations from all package files.
var decls []Decl
if ndecls > 0 {
decls = make([]Decl, ndecls)
funcs := make(map[string]int) // map of func name -> decls index
i := 0 // current index
n := 0 // number of filtered entries
for _, filename := range filenames {
f := pkg.Files[filename]
for _, d := range f.Decls {
if mode&FilterFuncDuplicates != 0 {
// A language entity may be declared multiple
// times in different package files; only at
// build time declarations must be unique.
// For now, exclude multiple declarations of
// functions - keep the one with documentation.
//
// TODO(gri): Expand this filtering to other
// entities (const, type, vars) if
// multiple declarations are common.
if f, isFun := d.(*FuncDecl); isFun {
name := nameOf(f)
if j, exists := funcs[name]; exists {
// function declared already
if decls[j] != nil && decls[j].(*FuncDecl).Doc == nil {
// existing declaration has no documentation;
// ignore the existing declaration
decls[j] = nil
} else {
// ignore the new declaration
d = nil
}
n++ // filtered an entry
} else {
funcs[name] = i
}
}
}
decls[i] = d
i++
}
}
// Eliminate nil entries from the decls list if entries were
// filtered. We do this using a 2nd pass in order to not disturb
// the original declaration order in the source (otherwise, this
// would also invalidate the monotonically increasing position
// info within a single file).
if n > 0 {
i = 0
for _, d := range decls {
if d != nil {
decls[i] = d
i++
}
}
decls = decls[0:i]
}
}
// Collect import specs from all package files.
var imports []*ImportSpec
if mode&FilterImportDuplicates != 0 {
seen := make(map[string]bool)
for _, filename := range filenames {
f := pkg.Files[filename]
for _, imp := range f.Imports {
if path := imp.Path.Value; !seen[path] {
// TODO: consider handling cases where:
// - 2 imports exist with the same import path but
// have different local names (one should probably
// keep both of them)
// - 2 imports exist but only one has a comment
// - 2 imports exist and they both have (possibly
// different) comments
imports = append(imports, imp)
seen[path] = true
}
}
}
} else {
// Iterate over filenames for deterministic order.
for _, filename := range filenames {
f := pkg.Files[filename]
imports = append(imports, f.Imports...)
}
}
// Collect comments from all package files.
var comments []*CommentGroup
if mode&FilterUnassociatedComments == 0 {
comments = make([]*CommentGroup, ncomments)
i := 0
for _, filename := range filenames {
f := pkg.Files[filename]
i += copy(comments[i:], f.Comments)
}
}
// TODO(gri) need to compute unresolved identifiers!
return &File{
doc, pos, NewIdent(pkg.Name), decls,
imports, comments, nil, nil, false, false, false, false,
}
}
================================================
FILE: ast/fromgo/gopast.go
================================================
/*
* Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fromgo
import (
"go/ast"
"go/token"
"log"
"reflect"
gopast "github.com/goplus/xgo/ast"
goptoken "github.com/goplus/xgo/token"
"github.com/goplus/xgo/ast/fromgo/typeparams"
)
// ----------------------------------------------------------------------------
func gopExpr(val ast.Expr) gopast.Expr {
if val == nil {
return nil
}
switch v := val.(type) {
case *ast.Ident:
return gopIdent(v)
case *ast.SelectorExpr:
return &gopast.SelectorExpr{
X: gopExpr(v.X),
Sel: gopIdent(v.Sel),
}
case *ast.SliceExpr:
return &gopast.SliceExpr{
X: gopExpr(v.X),
Lbrack: v.Lbrack,
Low: gopExpr(v.Low),
High: gopExpr(v.High),
Max: gopExpr(v.Max),
Slice3: v.Slice3,
Rbrack: v.Rbrack,
}
case *ast.StarExpr:
return &gopast.StarExpr{
Star: v.Star,
X: gopExpr(v.X),
}
case *ast.MapType:
return &gopast.MapType{
Map: v.Map,
Key: gopType(v.Key),
Value: gopType(v.Value),
}
case *ast.StructType:
return &gopast.StructType{
Struct: v.Struct,
Fields: gopFieldList(v.Fields),
}
case *ast.FuncType:
return gopFuncType(v)
case *ast.InterfaceType:
return &gopast.InterfaceType{
Interface: v.Interface,
Methods: gopFieldList(v.Methods),
}
case *ast.ArrayType:
return &gopast.ArrayType{
Lbrack: v.Lbrack,
Len: gopExpr(v.Len),
Elt: gopType(v.Elt),
}
case *ast.ChanType:
return &gopast.ChanType{
Begin: v.Begin,
Arrow: v.Arrow,
Dir: gopast.ChanDir(v.Dir),
Value: gopType(v.Value),
}
case *ast.BasicLit:
return gopBasicLit(v)
case *ast.BinaryExpr:
return &gopast.BinaryExpr{
X: gopExpr(v.X),
OpPos: v.OpPos,
Op: goptoken.Token(v.Op),
Y: gopExpr(v.Y),
}
case *ast.UnaryExpr:
return &gopast.UnaryExpr{
OpPos: v.OpPos,
Op: goptoken.Token(v.Op),
X: gopExpr(v.X),
}
case *ast.CallExpr:
return &gopast.CallExpr{
Fun: gopExpr(v.Fun),
Lparen: v.Lparen,
Args: gopExprs(v.Args),
Ellipsis: v.Ellipsis,
Rparen: v.Rparen,
}
case *ast.IndexExpr:
return &gopast.IndexExpr{
X: gopExpr(v.X),
Lbrack: v.Lbrack,
Index: gopExpr(v.Index),
Rbrack: v.Rbrack,
}
case *typeparams.IndexListExpr:
return &gopast.IndexListExpr{
X: gopExpr(v.X),
Lbrack: v.Lbrack,
Indices: gopExprs(v.Indices),
Rbrack: v.Rbrack,
}
case *ast.ParenExpr:
return &gopast.ParenExpr{
Lparen: v.Lparen,
X: gopExpr(v.X),
Rparen: v.Rparen,
}
case *ast.CompositeLit:
return &gopast.CompositeLit{
Type: gopType(v.Type),
Lbrace: v.Lbrace,
Elts: gopExprs(v.Elts),
Rbrace: v.Rbrace,
}
case *ast.FuncLit:
return &gopast.FuncLit{
Type: gopFuncType(v.Type),
Body: &gopast.BlockStmt{}, // skip closure body
}
case *ast.TypeAssertExpr:
return &gopast.TypeAssertExpr{
X: gopExpr(v.X),
Lparen: v.Lparen,
Type: gopType(v.Type),
Rparen: v.Rparen,
}
case *ast.KeyValueExpr:
return &gopast.KeyValueExpr{
Key: gopExpr(v.Key),
Colon: v.Colon,
Value: gopExpr(v.Value),
}
case *ast.Ellipsis:
return &gopast.Ellipsis{
Ellipsis: v.Ellipsis,
Elt: gopExpr(v.Elt),
}
}
log.Panicln("gopExpr: unknown expr -", reflect.TypeOf(val))
return nil
}
func gopExprs(vals []ast.Expr) []gopast.Expr {
n := len(vals)
if n == 0 {
return nil
}
ret := make([]gopast.Expr, n)
for i, v := range vals {
ret[i] = gopExpr(v)
}
return ret
}
// ----------------------------------------------------------------------------
func gopFuncType(v *ast.FuncType) *gopast.FuncType {
return &gopast.FuncType{
Func: v.Func,
TypeParams: gopFieldList(typeparams.ForFuncType(v)),
Params: gopFieldList(v.Params),
Results: gopFieldList(v.Results),
}
}
func gopType(v ast.Expr) gopast.Expr {
return gopExpr(v)
}
func gopBasicLit(v *ast.BasicLit) *gopast.BasicLit {
if v == nil {
return nil
}
return &gopast.BasicLit{
ValuePos: v.ValuePos,
Kind: goptoken.Token(v.Kind),
Value: v.Value,
}
}
func gopIdent(v *ast.Ident) *gopast.Ident {
if v == nil {
return nil
}
return &gopast.Ident{
NamePos: v.NamePos,
Name: v.Name,
Obj: &gopast.Object{Data: v},
}
}
// CheckIdent checks if an XGo ast.Ident is converted from a Go ast.Ident or not.
// If it is, CheckIdent returns the original Go ast.Ident object.
func CheckIdent(v *gopast.Ident) (id *ast.Ident, ok bool) {
if o := v.Obj; o != nil && o.Kind == 0 && o.Data != nil {
id, ok = o.Data.(*ast.Ident)
}
return
}
func gopIdents(names []*ast.Ident) []*gopast.Ident {
ret := make([]*gopast.Ident, len(names))
for i, v := range names {
ret[i] = gopIdent(v)
}
return ret
}
// ----------------------------------------------------------------------------
func gopField(v *ast.Field) *gopast.Field {
return &gopast.Field{
Names: gopIdents(v.Names),
Type: gopType(v.Type),
Tag: gopBasicLit(v.Tag),
}
}
func gopFieldList(v *ast.FieldList) *gopast.FieldList {
if v == nil {
return nil
}
list := make([]*gopast.Field, len(v.List))
for i, item := range v.List {
list[i] = gopField(item)
}
return &gopast.FieldList{Opening: v.Opening, List: list, Closing: v.Closing}
}
func gopFuncDecl(v *ast.FuncDecl) *gopast.FuncDecl {
return &gopast.FuncDecl{
Doc: v.Doc,
Recv: gopFieldList(v.Recv),
Name: gopIdent(v.Name),
Type: gopFuncType(v.Type),
Body: &gopast.BlockStmt{}, // ignore function body
}
}
// ----------------------------------------------------------------------------
func gopImportSpec(spec *ast.ImportSpec) *gopast.ImportSpec {
return &gopast.ImportSpec{
Name: gopIdent(spec.Name),
Path: gopBasicLit(spec.Path),
EndPos: spec.EndPos,
}
}
func gopTypeSpec(spec *ast.TypeSpec) *gopast.TypeSpec {
return &gopast.TypeSpec{
Name: gopIdent(spec.Name),
TypeParams: gopFieldList(typeparams.ForTypeSpec(spec)),
Assign: spec.Assign,
Type: gopType(spec.Type),
}
}
func gopValueSpec(spec *ast.ValueSpec) *gopast.ValueSpec {
return &gopast.ValueSpec{
Names: gopIdents(spec.Names),
Type: gopType(spec.Type),
Values: gopExprs(spec.Values),
}
}
func gopGenDecl(v *ast.GenDecl) *gopast.GenDecl {
specs := make([]gopast.Spec, len(v.Specs))
for i, spec := range v.Specs {
switch v.Tok {
case token.IMPORT:
specs[i] = gopImportSpec(spec.(*ast.ImportSpec))
case token.TYPE:
specs[i] = gopTypeSpec(spec.(*ast.TypeSpec))
case token.VAR, token.CONST:
specs[i] = gopValueSpec(spec.(*ast.ValueSpec))
default:
log.Panicln("gopGenDecl: unknown spec -", v.Tok)
}
}
return &gopast.GenDecl{
Doc: v.Doc,
TokPos: v.TokPos,
Tok: goptoken.Token(v.Tok),
Lparen: v.Lparen,
Specs: specs,
Rparen: v.Rparen,
}
}
// ----------------------------------------------------------------------------
func gopDecl(decl ast.Decl) gopast.Decl {
switch v := decl.(type) {
case *ast.GenDecl:
return gopGenDecl(v)
case *ast.FuncDecl:
return gopFuncDecl(v)
}
log.Panicln("gopDecl: unknown decl -", reflect.TypeOf(decl))
return nil
}
func gopDecls(decls []ast.Decl) []gopast.Decl {
ret := make([]gopast.Decl, len(decls))
for i, decl := range decls {
ret[i] = gopDecl(decl)
}
return ret
}
// ----------------------------------------------------------------------------
const (
KeepFuncBody = 1 << iota
KeepCgo
)
// ASTFile converts a Go ast.File into an XGo ast.File object.
func ASTFile(f *ast.File, mode int) *gopast.File {
if (mode & KeepFuncBody) != 0 {
log.Panicln("ASTFile: doesn't support keeping func body now")
}
if (mode & KeepCgo) != 0 {
log.Panicln("ASTFile: doesn't support keeping cgo now")
}
return &gopast.File{
Doc: f.Doc,
Package: f.Package,
Name: gopIdent(f.Name),
Decls: gopDecls(f.Decls),
}
}
// ----------------------------------------------------------------------------
================================================
FILE: ast/fromgo/gopast_test.go
================================================
/*
* Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fromgo
import (
"bytes"
"go/ast"
"go/parser"
"go/token"
"testing"
gopast "github.com/goplus/xgo/ast"
"github.com/goplus/xgo/format"
)
func testAST(t *testing.T, from, to string) {
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "foo.go", from, 0)
if err != nil {
t.Fatal("parser.ParseFile:", err)
}
gopf := ASTFile(f, 0)
var b bytes.Buffer
err = format.Node(&b, fset, gopf)
if err != nil {
t.Fatal("format.Node:", err)
}
result := b.String()
if to != result {
t.Fatalf("\nResult:\n%s\nExpected:\n%s\n", result, to)
}
}
func test(t *testing.T, src string) {
testAST(t, src, src)
}
func testPanic(t *testing.T, panicMsg string, doPanic func()) {
t.Run(panicMsg, func(t *testing.T) {
defer func() {
if e := recover(); e == nil {
t.Fatal("testPanic: no error?")
} else if msg := e.(string); msg != panicMsg {
t.Fatalf("\nResult:\n%s\nExpected Panic:\n%s\n", msg, panicMsg)
}
}()
doPanic()
})
}
func TestErrASTFile(t *testing.T) {
testPanic(t, "ASTFile: doesn't support keeping cgo now\n", func() {
ASTFile(nil, KeepCgo)
})
testPanic(t, "ASTFile: doesn't support keeping func body now\n", func() {
ASTFile(nil, KeepFuncBody)
})
}
func TestErrDecl(t *testing.T) {
testPanic(t, "gopDecl: unknown decl - <nil>\n", func() {
gopDecl(nil)
})
testPanic(t, "gopGenDecl: unknown spec - ILLEGAL\n", func() {
gopGenDecl(&ast.GenDecl{
Specs: []ast.Spec{nil},
})
})
}
func TestErrExpr(t *testing.T) {
testPanic(t, "gopExpr: unknown expr - *ast.BadExpr\n", func() {
gopExpr(&ast.BadExpr{})
})
}
func TestBasic(t *testing.T) {
test(t, `package main
import "fmt"
type a struct {
v map[int]chan int
arr *[2]func()
i interface{}
}
var b = &a{
arr: &[2]func(){
nil,
func() {},
},
}
const c = (10 + 20) * 2
var d = b.arr[1]
var e = b.arr[:1]
var f = a.i.(func() (int))()
func foo(v ...interface{}) {}
`)
}
func TestMethod(t *testing.T) {
test(t, `package main
type foo int
func (a foo) Str() (string) {}
`)
}
func TestCheckIdent(t *testing.T) {
if _, ok := CheckIdent(&gopast.Ident{}); ok {
t.Fatal("CheckIdent: found?")
}
if _, ok := CheckIdent(&gopast.Ident{Obj: &gopast.Object{
Data: &ast.Ident{},
}}); !ok {
t.Fatal("CheckIdent: not found?")
}
}
================================================
FILE: ast/fromgo/typeparams/typeparams_go117.go
================================================
//go:build !go1.18
// +build !go1.18
package typeparams
import (
"go/ast"
"go/token"
)
func unsupported() {
panic("type parameters are unsupported at this go version")
}
// IndexListExpr is a placeholder type, as type parameters are not supported at
// this Go version. Its methods panic on use.
type IndexListExpr struct {
ast.Expr
X ast.Expr // expression
Lbrack token.Pos // position of "["
Indices []ast.Expr // index expressions
Rbrack token.Pos // position of "]"
}
func (*IndexListExpr) Pos() token.Pos { unsupported(); return token.NoPos }
func (*IndexListExpr) End() token.Pos { unsupported(); return token.NoPos }
// ForFuncType returns an empty field list, as type parameters are not
// supported at this Go version.
func ForFuncType(*ast.FuncType) *ast.FieldList {
return nil
}
// ForTypeSpec returns an empty field list, as type parameters are not
// supported at this Go version.
func ForTypeSpec(*ast.TypeSpec) *ast.FieldList {
return nil
}
================================================
FILE: ast/fromgo/typeparams/typeparams_go118.go
================================================
//go:build go1.18
// +build go1.18
package typeparams
import "go/ast"
// IndexListExpr is an alias for ast.IndexListExpr.
type IndexListExpr = ast.IndexListExpr
// ForFuncType returns n.TypeParams.
func ForFuncType(n *ast.FuncType) *ast.FieldList {
if n == nil {
return nil
}
return n.TypeParams
}
// ForTypeSpec returns n.TypeParams.
func ForTypeSpec(n *ast.TypeSpec) *ast.FieldList {
if n == nil {
return nil
}
return n.TypeParams
}
================================================
FILE: ast/fromgo/typeparams_test.go
================================================
//go:build go1.18
// +build go1.18
package fromgo
import "testing"
func TestIndexListExpr(t *testing.T) {
test(t, `package main
type N1 = T1[int]
type N2 = T2[string, int]
var f = test[string, int](1, 2)
`)
}
================================================
FILE: ast/gopq/dom.go
================================================
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gopq
import (
"github.com/goplus/xgo/ast"
"github.com/goplus/xgo/token"
)
// -----------------------------------------------------------------------------
type astPackages map[string]*ast.Package
func (p astPackages) Pos() token.Pos { return token.NoPos }
func (p astPackages) End() token.Pos { return token.NoPos }
func (p astPackages) ForEach(filter func(node Node) error) error {
for _, pkg := range p {
node := astPackage{pkg}
if err := filter(node); err == ErrBreak {
return err
}
}
return nil
}
func (p astPackages) Obj() any {
return p
}
// -----------------------------------------------------------------------------
type astPackage struct {
*ast.Package
}
func (p astPackage) ForEach(filter func(node Node) error) error {
for _, file := range p.Files {
node := astFile{file}
if err := filter(node); err == ErrBreak {
return err
}
}
return nil
}
func (p astPackage) Obj() any {
return p.Package
}
// -----------------------------------------------------------------------------
type astFile struct {
*ast.File
}
func (p astFile) ForEach(filter func(node Node) error) error {
for _, decl := range p.Decls {
node := &astDecl{decl}
if err := filter(node); err == ErrBreak {
return err
}
}
return nil
}
func (p astFile) Obj() any {
return p.File
}
// -----------------------------------------------------------------------------
type astDecl struct {
ast.Decl
}
func (p *astDecl) ForEach(filter func(node Node) error) error {
if decl, ok := p.Decl.(*ast.GenDecl); ok {
for _, spec := range decl.Specs {
node := &astSpec{spec}
if err := filter(node); err == ErrBreak {
return err
}
}
}
return nil
}
func (p *astDecl) Obj() any {
return p.Decl
}
// -----------------------------------------------------------------------------
type astSpec struct {
ast.Spec
}
func (p *astSpec) ForEach(filter func(node Node) error) error {
return nil
}
func (p *astSpec) Obj() any {
return p.Spec
}
// -----------------------------------------------------------------------------
func visitStmt(stmt ast.Stmt, filter func(node Node) error) error {
if stmt != nil {
return filter(&astStmt{stmt})
}
return nil
}
type astStmt struct {
ast.Stmt
}
func (p *astStmt) ForEach(filter func(node Node) error) error {
switch stmt := p.Stmt.(type) {
case *ast.IfStmt:
if err := visitStmt(stmt.Init, filter); err == ErrBreak {
return err
}
if err := filter(&astStmt{stmt.Body}); err == ErrBreak {
return err
}
if err := visitStmt(stmt.Else, filter); err == ErrBreak {
return err
}
case *ast.BlockStmt:
for _, stmt := range stmt.List {
node := &astStmt{stmt}
if err := filter(node); err == ErrBreak {
return err
}
}
}
// TODO(xsw): visit other stmts
return nil
}
func (p *astStmt) Obj() any {
return p.Stmt
}
// -----------------------------------------------------------------------------
type astExpr struct {
ast.Expr
}
func (p *astExpr) ForEach(filter func(node Node) error) error {
return nil
}
func (p *astExpr) Obj() any {
return p.Expr
}
// -----------------------------------------------------------------------------
================================================
FILE: ast/gopq/gopq.go
================================================
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gopq
import (
"errors"
"io/fs"
"syscall"
"github.com/goplus/xgo/ast"
"github.com/goplus/xgo/parser"
"github.com/goplus/xgo/parser/fsx"
"github.com/goplus/xgo/token"
)
// -----------------------------------------------------------------------------
const (
GopPackage = true
)
var (
// ErrBreak - break
ErrBreak = syscall.ELOOP
// ErrNotFound - not found
ErrNotFound = errors.New("not found")
// ErrTooManyNodes - too may nodes
ErrTooManyNodes = errors.New("too many nodes")
// ErrUnexpectedNode - unexpected node
ErrUnexpectedNode = errors.New("unexpected node")
)
// Node - node interface
type Node interface {
ast.Node
ForEach(filter func(node Node) error) error
Obj() any
}
// NodeEnum - node enumerator
type NodeEnum interface {
ForEach(filter func(node Node) error) error
}
// NodeSet - node set
type NodeSet struct {
Data NodeEnum
Err error
}
// FromFile calls ParseFile for a single file and returns *ast.File node set.
func FromFile(fset *token.FileSet, filename string, src any, mode parser.Mode) (doc NodeSet, err error) {
file, err := parser.ParseFile(fset, filename, src, mode)
if err != nil {
return
}
return NodeSet{Data: &oneNode{astFile{file}}}, nil
}
// FromFSFile calls ParseFSFile for a single file and returns *ast.File node set.
func FromFSFile(
fset *token.FileSet, fs fsx.FileSystem,
filename string, src any, mode parser.Mode) (doc NodeSet, err error) {
file, err := parser.ParseFSFile(fset, fs, filename, src, mode)
if err != nil {
return
}
return NodeSet{Data: &oneNode{astFile{file}}}, nil
}
// FromDir calls ParseFile for all XGo files in the directory specified by path
// and returns a map of package name -> package AST with all the packages found.
//
// If filter != nil, only the XGo files with fs.FileInfo entries passing through
// the filter are considered. The mode bits are passed to ParseFile unchanged.
// Position information is recorded in fset, which must not be nil.
//
// If the directory couldn't be read, a nil map and the respective error are
// returned. If a parse error occurred, a non-nil but incomplete map and the
// first error encountered are returned.
func FromDir(
fset *token.FileSet, path string,
filter func(fs.FileInfo) bool, mode parser.Mode) (doc NodeSet, err error) {
pkgs, err := parser.ParseDir(fset, path, filter, mode)
if err != nil {
return
}
return NodeSet{Data: &oneNode{astPackages(pkgs)}}, nil
}
// FromFSDir calls ParseFile for all XGo files in the directory specified by path
// and returns a map of package name -> package AST with all the packages found.
//
// If filter != nil, only the XGo files with fs.FileInfo entries passing through
// the filter are considered. The mode bits are passed to ParseFile unchanged.
// Position information is recorded in fset, which must not be nil.
//
// If the directory couldn't be read, a nil map and the respective error are
// returned. If a parse error occurred, a non-nil but incomplete map and the
// first error encountered are returned.
func FromFSDir(
fset *token.FileSet, fs parser.FileSystem, path string,
filter func(fs.FileInfo) bool, mode parser.Mode) (doc NodeSet, err error) {
pkgs, err := parser.ParseFSDir(fset, fs, path, parser.Config{Filter: filter, Mode: mode})
if err != nil {
return
}
return NodeSet{Data: &oneNode{astPackages(pkgs)}}, nil
}
// Ok returns if node set is valid or not.
func (p NodeSet) Ok() bool {
return p.Err == nil
}
// -----------------------------------------------------------------------------
// FuncDecl returns *ast.FuncDecl node set.
func (p NodeSet) FuncDecl__0() NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astDecl); ok {
_, ok = node.Decl.(*ast.FuncDecl)
return ok
}
return false
})
}
// FuncDecl returns *ast.FuncDecl node set.
func (p NodeSet) FuncDecl__1(name string) NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astDecl); ok {
if fn, ok := node.Decl.(*ast.FuncDecl); ok {
return fn.Name.Name == name
}
}
return false
})
}
// GenDecl returns *ast.GenDecl node set.
func (p NodeSet) GenDecl__0(tok token.Token) NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astDecl); ok {
if decl, ok := node.Decl.(*ast.GenDecl); ok {
return decl.Tok == tok
}
}
return false
})
}
// TypeSpec returns *ast.TypeSpec node set.
func (p NodeSet) TypeSpec() NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astSpec); ok {
_, ok = node.Spec.(*ast.TypeSpec)
return ok
}
return false
})
}
// ValueSpec returns *ast.ValueSpec node set.
func (p NodeSet) ValueSpec() NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astSpec); ok {
_, ok = node.Spec.(*ast.ValueSpec)
return ok
}
return false
})
}
// ImportSpec returns *ast.ImportSpec node set.
func (p NodeSet) ImportSpec() NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astSpec); ok {
_, ok = node.Spec.(*ast.ImportSpec)
return ok
}
return false
})
}
// ExprStmt returns *ast.ExprStmt node set.
func (p NodeSet) ExprStmt() NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astStmt); ok {
_, ok = node.Stmt.(*ast.ExprStmt)
return ok
}
return false
})
}
// AssignStmt returns *ast.AssignStmt node set.
func (p NodeSet) AssignStmt() NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astStmt); ok {
_, ok = node.Stmt.(*ast.AssignStmt)
return ok
}
return false
})
}
// CallExpr returns *ast.CallExpr node set.
func (p NodeSet) CallExpr__0() NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astExpr); ok {
_, ok = node.Expr.(*ast.CallExpr)
return ok
}
return false
})
}
// CallExpr returns *ast.CallExpr node set.
func (p NodeSet) CallExpr__1(name string) NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astExpr); ok {
if expr, ok := node.Expr.(*ast.CallExpr); ok {
return getName(expr.Fun, true) == name
}
}
return false
})
}
// CompositeLit returns *ast.CompositeLit node set.
func (p NodeSet) CompositeLit__0() NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astExpr); ok {
_, ok = node.Expr.(*ast.CompositeLit)
return ok
}
return false
})
}
// CompositeLit returns *ast.CompositeLit node set.
func (p NodeSet) CompositeLit__1(name string) NodeSet {
return p.Match(func(node Node) bool {
if node, ok := node.(*astExpr); ok {
if lit, ok := node.Expr.(*ast.CompositeLit); ok && lit.Type != nil {
return getName(lit.Type, true) == name
}
}
return false
})
}
// -----------------------------------------------------------------------------
func (p NodeSet) Gop_Enum(callback func(node NodeSet)) {
if p.Err == nil {
p.Data.ForEach(func(node Node) error {
t := NodeSet{Data: &oneNode{node}}
callback(t)
return nil
})
}
}
func (p NodeSet) ForEach(callback func(node NodeSet)) {
p.Gop_Enum(callback)
}
// -----------------------------------------------------------------------------
type oneNode struct {
Node
}
func (p *oneNode) ForEach(filter func(node Node) error) error {
return filter(p.Node)
}
func (p *oneNode) Cached() int {
return 1
}
// One returns the first node as a node set.
func (p NodeSet) One() NodeSet {
if _, ok := p.Data.(*oneNode); ok {
return p
}
node, err := p.CollectOne__0()
if err != nil {
return NodeSet{Err: err}
}
return NodeSet{Data: &oneNode{node}}
}
// One creates a node set that only contains a signle node.
func One__0(node Node) NodeSet {
return NodeSet{Data: &oneNode{node}}
}
// One creates a node set that only contains a signle node.
func One__1(f *ast.File) NodeSet {
return NodeSet{Data: &oneNode{astFile{f}}}
}
// One creates a node set that only contains a signle node.
func One__2(pkg *ast.Package) NodeSet {
return NodeSet{Data: &oneNode{astPackage{pkg}}}
}
// -----------------------------------------------------------------------------
type fixNodes struct {
nodes []Node
}
func (p *fixNodes) ForEach(filter func(node Node) error) error {
for _, node := range p.nodes {
if filter(node) == ErrBreak {
return ErrBreak
}
}
return nil
}
func (p *fixNodes) Cached() int {
return len(p.nodes)
}
// Nodes creates a fixed node set.
func Nodes(nodes ...Node) NodeSet {
return NodeSet{Data: &fixNodes{nodes}}
}
// -----------------------------------------------------------------------------
type cached interface {
Cached() int
}
// Cache caches node set.
func (p NodeSet) Cache() NodeSet {
if _, ok := p.Data.(cached); ok {
return p
}
nodes, err := p.Collect()
if err != nil {
return NodeSet{Err: err}
}
return NodeSet{Data: &fixNodes{nodes}}
}
// -----------------------------------------------------------------------------
type anyNodes struct {
data NodeEnum
}
func (p *anyNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
return anyForEach(node, filter)
})
}
func anyForEach(p Node, filter func(node Node) error) error {
if err := filter(p); err == ErrBreak {
return err
}
return p.ForEach(func(node Node) error {
return anyForEach(node, filter)
})
}
// Any returns deeply visiting node set.
func (p NodeSet) Any() (ret NodeSet) {
if p.Err != nil {
return p
}
return NodeSet{Data: &anyNodes{p.Data}}
}
// -----------------------------------------------------------------------------
type childNodes struct {
data NodeEnum
}
func (p *childNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
return node.ForEach(filter)
})
}
// Child returns child node set.
func (p NodeSet) Child() NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &childNodes{p.Data}}
}
// -----------------------------------------------------------------------------
type bodyNodes struct {
data NodeEnum
}
func (p *bodyNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
switch node := node.(type) {
case *astDecl:
if fn, ok := node.Decl.(*ast.FuncDecl); ok && fn.Body != nil {
return filter(&astStmt{fn.Body})
}
}
return ErrNotFound
})
}
// Body returns body node set.
func (p NodeSet) Body() NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &bodyNodes{p.Data}}
}
// -----------------------------------------------------------------------------
type xNodes struct {
data NodeEnum
}
func (p *xNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
switch node := node.(type) {
case *astStmt:
switch stmt := node.Stmt.(type) {
case *ast.ExprStmt:
return filter(&astExpr{stmt.X})
}
case *astExpr:
switch expr := node.Expr.(type) {
case *ast.SelectorExpr:
return filter(&astExpr{expr.X})
case *ast.UnaryExpr:
return filter(&astExpr{expr.X})
}
}
return ErrNotFound
})
}
// X returns x node set.
func (p NodeSet) X() NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &xNodes{p.Data}}
}
// -----------------------------------------------------------------------------
type funNodes struct {
data NodeEnum
}
func (p *funNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
switch node := node.(type) {
case *astExpr:
switch expr := node.Expr.(type) {
case *ast.CallExpr:
return filter(&astExpr{expr.Fun})
}
}
return ErrNotFound
})
}
// Fun returns fun node set.
func (p NodeSet) Fun() NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &funNodes{p.Data}}
}
// -----------------------------------------------------------------------------
type argNodes struct {
data NodeEnum
i int
varg bool
}
func (p *argNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
switch node := node.(type) {
case *astExpr:
switch expr := node.Expr.(type) {
case *ast.CallExpr:
args := expr.Args
if p.varg {
for i, n := p.i, len(args); i < n; i++ {
if err := filter(&astExpr{args[i]}); err == ErrBreak {
return err
}
}
return nil
} else {
return filter(&astExpr{args[p.i]})
}
}
}
return ErrNotFound
})
}
// Arg returns args[i] node set.
func (p NodeSet) Arg(i int) NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &argNodes{p.Data, i, false}}
}
// Varg returns args[i:] node set.
func (p NodeSet) Varg(i int) NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &argNodes{p.Data, i, true}}
}
// -----------------------------------------------------------------------------
type ieltNodes struct {
data NodeEnum
i int
}
func (p *ieltNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
switch node := node.(type) {
case *astExpr:
switch expr := node.Expr.(type) {
case *ast.CompositeLit:
if i := p.i; i == -1 {
for _, elt := range expr.Elts {
if err := filter(&astExpr{elt}); err == ErrBreak {
return err
}
}
} else {
return filter(&astExpr{expr.Elts[i]})
}
}
}
return ErrNotFound
})
}
// Elt returns elts[i] node set.
func (p NodeSet) Elt__0(i int) NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &ieltNodes{p.Data, i}}
}
// Elt returns elts[:] node set.
func (p NodeSet) Elt__1() NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &ieltNodes{p.Data, -1}}
}
// -----------------------------------------------------------------------------
type eltNodes struct {
data NodeEnum
name string
}
func (p *eltNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
switch node := node.(type) {
case *astExpr:
switch expr := node.Expr.(type) {
case *ast.CompositeLit:
if elt, ok := getElt(expr.Elts, p.name); ok {
return filter(&astExpr{elt})
}
}
}
return ErrNotFound
})
}
// Elt returns elts[name] node set.
func (p NodeSet) Elt__2(name string) NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &eltNodes{p.Data, name}}
}
// -----------------------------------------------------------------------------
type rhsNodes struct {
data NodeEnum
i int
}
func (p *rhsNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
switch node := node.(type) {
case *astStmt:
switch stmt := node.Stmt.(type) {
case *ast.AssignStmt:
return filter(&astExpr{stmt.Rhs[p.i]})
}
}
return ErrNotFound
})
}
// Rhs returns rhs[i] node set.
func (p NodeSet) Rhs(i int) NodeSet {
if p.Err != nil {
return p
}
return NodeSet{Data: &rhsNodes{p.Data, i}}
}
// -----------------------------------------------------------------------------
type matchedNodes struct {
data NodeEnum
match func(node Node) bool
}
func (p *matchedNodes) ForEach(filter func(node Node) error) error {
return p.data.ForEach(func(node Node) error {
if p.match(node) {
return filter(node)
}
return ErrNotFound
})
}
// Match filters the node set.
func (p NodeSet) Match(match func(node Node) bool) (ret NodeSet) {
if p.Err != nil {
return p
}
return NodeSet{Data: &matchedNodes{p.Data, match}}
}
// -----------------------------------------------------------------------------
// Name returns names of the node set.
func (p NodeSet) Name() []string {
return p.ToString(NameOf)
}
// ToString returns string values of the node set.
func (p NodeSet) ToString(str func(node Node) string) (items []string) {
if p.Err != nil {
return nil
}
p.Data.ForEach(func(node Node) error {
items = append(items, str(node))
return nil
})
return
}
// Collect collects all nodes of the node set.
func (p NodeSet) Collect() (items []Node, err error) {
if p.Err != nil {
return nil, p.Err
}
p.Data.ForEach(func(node Node) error {
items = append(items, node)
return nil
})
return
}
// CollectOne collects one node of a node set.
// If exactly is true, it returns ErrTooManyNodes when node set is more than one.
func (p NodeSet) CollectOne__1(exactly bool) (item Node, err error) {
if p.Err != nil {
return nil, p.Err
}
err = ErrNotFound
if exactly {
p.Data.ForEach(func(node Node) error {
if err == ErrNotFound {
item, err = node, nil
return nil
}
err = ErrTooManyNodes
return ErrBreak
})
} else {
p.Data.ForEach(func(node Node) error {
item, err = node, nil
return ErrBreak
})
}
return
}
// CollectOne returns the first node.
func (p NodeSet) CollectOne__0() (item Node, err error) {
return p.CollectOne__1(false)
}
// -----------------------------------------------------------------------------
================================================
FILE: ast/gopq/helper.go
================================================
/*
* Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gopq
import (
"strconv"
"github.com/goplus/xgo/ast"
"github.com/goplus/xgo/token"
)
// -----------------------------------------------------------------------------
// Funcs returns all `*ast.FuncDecl` nodes.
func (p NodeSet) Funcs() NodeSet {
return p.Any().FuncDecl__0().Cache()
}
// -----------------------------------------------------------------------------
func (p NodeSet) UnquotedString__1(exactly bool) (ret string, err error) {
item, err := p.CollectOne__1(exactly)
if err != nil {
return
}
if lit, ok := item.Obj().(*ast.BasicLit); ok && lit.Kind == token.STRING {
return strconv.Unquote(lit.Value)
}
return "", ErrUnexpectedNode
}
func (p NodeSet) UnquotedString__0() (ret string, err error) {
return p.UnquotedString__1(false)
}
// -----------------------------------------------------------------------------
func (p NodeSet) UnquotedStringElts__1(exactly bool) (ret []string, err error) {
item, err := p.CollectOne__1(exactly)
if err != nil {
return
}
if lit, ok := item.Obj().(*ast.CompositeLit); ok {
ret = make([]string, len(lit.Elts))
for i, elt := range lit.Elts {
if lit, ok := elt.(*ast.BasicLit); ok && lit.Kind == token.STRING {
if ret[i], err = strconv.Unquote(lit.Value); err != nil {
return
}
} else {
return nil, ErrUnexpectedNode
}
}
return
}
return nil, ErrUnexpectedNode
}
func (p NodeSet) UnquotedStringElts__0() (ret []string, err error) {
return p.UnquotedStringElts__1(false)
}
// -----------------------------------------------------------------------------
func (p NodeSet) Positions__1(exactly bool) (ret []token.Pos, err error) {
item, err := p.CollectOne__1(exactly)
if err != nil {
return
}
switch o := item.Obj().(type) {
case *ast.CompositeLit:
return []token.Pos{o.Pos(), o.End(), o.Lbrace, o.Rbrace}, nil
case ast.Node:
return []token.Pos{o.Pos(), o.End()}, nil
}
return nil, ErrUnexpectedNode
}
func (p NodeSet) Positions__0() (ret []token.Pos, err error) {
return p.Positions__1(false)
}
// -----------------------------------------------------------------------------
func (p NodeSet) EltLen__1(exactly bool) (ret int, err error) {
item, err := p.CollectOne__1(exactly)
if err != nil {
return
}
if lit, ok := item.Obj().(*ast.CompositeLit); ok {
return len(lit.Elts), nil
}
return 0, ErrUnexpectedNode
}
func (p NodeSet) EltLen__0() (ret int, err error) {
return p.EltLen__1(false)
}
// -----------------------------------------------------------------------------
func (p NodeSet) Ident__1(exactly bool) (ret string, err error) {
item, err := p.CollectOne__1(exactly)
if err != nil {
return
}
if ident, ok := item.Obj().(*ast.Ident); ok {
return ident.Name, nil
}
return "", ErrUnexpectedNode
}
func (p NodeSet) Ident__0() (ret string, err error) {
return p.Ident__1(false)
}
// -----------------------------------------------------------------------------
func getElt(elts []ast.Expr, name string) (ast.Expr, bool) {
for _, elt := range elts {
if kv, ok := elt.(*ast.KeyValueExpr); ok {
if ident, ok := kv.Key.(*ast.Ident); ok && ident.Name == name {
return kv.Value, true
}
}
}
return nil, false
}
// -----------------------------------------------------------------------------
// NameOf returns name of an ast node.
func NameOf(node Node) string {
return getName(node.Obj(), false)
}
func getName(v any, useEmpty bool) string {
switch v := v.(type) {
case *ast.FuncDecl:
return v.Name.Name
case *ast.ImportSpec:
n := v.Name
if n == nil {
return ""
}
return n.Name
case *ast.Ident:
return v.Name
case *ast.SelectorExpr:
return getName(v.X, useEmpty) + "." + v.Sel.Name
}
if useEmpty {
return ""
}
panic("node doesn't contain the `name` property")
}
// -----------------------------------------------------------------------------
func CodeOf(fset *token.FileSet, f *ast.File, start, end token.Pos) string {
pos := fset.Position(start)
n := int(end - start)
return string(f.Code[pos.Offset : pos.Offset+n])
}
// -----------------------------------------------------------------------------
================================================
FILE: ast/goptest/gopq.go
================================================
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package goptest
import (
"go/token"
"github.com/goplus/xgo/ast/gopq"
"github.com/goplus/xgo/parser/fsx/memfs"
)
const (
GopPackage = "github.com/goplus/xgo/ast/gopq"
)
// -----------------------------------------------------------------------------
// New creates a nodeset object that represents an XGo dom tree.
func New(script string) (gopq.NodeSet, error) {
fset := token.NewFileSet()
fs := memfs.SingleFile("/foo", "bar.xgo", script)
return gopq.FromFSDir(fset, fs, "/foo", nil, 0)
}
// -----------------------------------------------------------------------------
================================================
FILE: ast/import.go
================================================
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ast
import (
"sort"
"strconv"
"github.com/goplus/xgo/token"
)
// SortImports sorts runs of consecutive import lines in import blocks in f.
// It also removes duplicate imports when it is possible to do so without data loss.
func SortImports(fset *token.FileSet, f *File) {
for _, d := range f.Decls {
d, ok := d.(*GenDecl)
if !ok || d.Tok != token.IMPORT {
// Not an import declaration, so we're done.
// Imports are always first.
break
}
if !d.Lparen.IsValid() {
// Not a block: sorted by default.
continue
}
// Identify and sort runs of specs on successive lines.
i := 0
specs := d.Specs[:0]
for j, s := range d.Specs {
if j > i && lineAt(fset, s.Pos()) > 1+lineAt(fset, d.Specs[j-1].End()) {
// j begins a new run. End this one.
specs = append(specs, sortSpecs(fset, f, d.Specs[i:j])...)
i = j
}
}
specs = append(specs, sortSpecs(fset, f, d.Specs[i:])...)
d.Specs = specs
// Deduping can leave a blank line before the rparen; clean that up.
if len(d.Specs) > 0 {
lastSpec := d.Specs[len(d.Specs)-1]
lastLine := lineAt(fset, lastSpec.Pos())
rParenLine := lineAt(fset, d.Rparen)
for rParenLine > lastLine+1 {
rParenLine--
fset.File(d.Rparen).MergeLine(rParenLine)
}
}
}
}
func lineAt(fset *token.FileSet, pos token.Pos) int {
return fset.PositionFor(pos, false).Line
}
func importPath(s Spec) string {
t, err := strconv.Unquote(s.(*ImportSpec).Path.Value)
if err == nil {
return t
}
return ""
}
func importName(s Spec) string {
n := s.(*ImportSpec).Name
if n == nil {
return ""
}
return n.Name
}
func importComment(s Spec) string {
c := s.(*ImportSpec).Comment
if c == nil {
return ""
}
return c.Text()
}
// collapse indicates whether prev may be removed, leaving only next.
func collapse(prev, next Spec) bool {
if importPath(next) != importPath(prev) || importName(next) != importName(prev) {
return false
}
return prev.(*ImportSpec).Comment == nil
}
type posSpan struct {
Start token.Pos
End token.Pos
}
type cgPos struct {
left bool // true if comment is to the left of the spec, false otherwise.
cg *CommentGroup
}
func sortSpecs(fset *token.FileSet, f *File, specs []Spec) []Spec {
// Can't short-circuit here even if specs are already sorted,
// since they might yet need deduplication.
// A lone import, however, may be safely ignored.
if len(specs) <= 1 {
return specs
}
// Record positions for specs.
pos := make([]posSpan, len(specs))
for i, s := range specs {
pos[i] = posSpan{s.Pos(), s.End()}
}
// Identify comments in this range.
begSpecs := pos[0].Start
endSpecs := pos[len(pos)-1].End
beg := fset.File(begSpecs).LineStart(lineAt(fset, begSpecs))
endLine := lineAt(fset, endSpecs)
endFile := fset.File(endSpecs)
var end token.Pos
if endLine == endFile.LineCount() {
end = endSpecs
} else {
end = endFile.LineStart(endLine + 1) // beginning of next line
}
first := len(f.Comments)
last := -1
for i, g := range f.Comments {
if g.End() >= end {
break
}
// g.End() < end
if beg <= g.Pos() {
// comment is within the range [beg, end[ of import declarations
if i < first {
first = i
}
if i > last {
last = i
}
}
}
var comments []*CommentGroup
if last >= 0 {
comments = f.Comments[first : last+1]
}
// Assign each comment to the import spec on the same line.
importComments := map[*ImportSpec][]cgPos{}
specIndex := 0
for _, g := range comments {
for specIndex+1 < len(specs) && pos[specIndex+1].Start <= g.Pos() {
specIndex++
}
var left bool
// A block comment can appear before the first import spec.
if specIndex == 0 && pos[specIndex].Start > g.Pos() {
left = true
} else if specIndex+1 < len(specs) && // Or it can appear on the left of an import spec.
lineAt(fset, pos[specIndex].Start)+1 == lineAt(fset, g.Pos()) {
specIndex++
left = true
}
s := specs[specIndex].(*ImportSpec)
importComments[s] = append(importComments[s], cgPos{left: left, cg: g})
}
// Sort the import specs by import path.
// Remove duplicates, when possible without data loss.
// Reassign the import paths to have the same position sequence.
// Reassign each comment to the spec on the same line.
// Sort the comments by new position.
sort.Slice(specs, func(i, j int) bool {
ipath := importPath(specs[i])
jpath := importPath(specs[j])
if ipath != jpath {
return ipath < jpath
}
iname := importName(specs[i])
jname := importName(specs[j])
if iname != jname {
return iname < jname
}
return importComment(specs[i]) < importComment(specs[j])
})
// Dedup. Thanks to our sorting, we can just consider
// adjacent pairs of imports.
deduped := specs[:0]
for i, s := range specs {
if i == len(specs)-1 || !collapse(s, specs[i+1]) {
deduped = append(deduped, s)
} else {
p := s.Pos()
fset.File(p).MergeLine(lineAt(fset, p))
}
}
specs = deduped
// Fix up comment positions
for i, s := range specs {
s := s.(*ImportSpec)
if s.Name != nil {
s.Name.NamePos = pos[i].Start
}
s.Path.ValuePos = pos[i].Start
s.EndPos = pos[i].End
for _, g := range importComments[s] {
for _, c := range g.cg.List {
if g.left {
c.Slash = pos[i].Start - 1
} else {
// An import spec can have both block comment and a line comment
// to its right. In that case, both of them will have the same pos.
// But while formatting the AST, the line comment gets moved to
// after the block comment.
c.Slash = pos[i].End
}
}
}
}
sort.Slice(comments, func(i, j int) bool {
return comments[i].Pos() < comments[j].Pos()
})
return specs
}
================================================
FILE: ast/mod/deps.go
================================================
/*
* Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package mod
import (
"strconv"
"strings"
goast "go/ast"
gotoken "go/token"
"github.com/goplus/xgo/ast"
"github.com/goplus/xgo/token"
)
// ----------------------------------------------------------------------------
type Deps struct {
HandlePkg func(pkgPath string)
}
func (p Deps) Load(pkg *ast.Package, withXgoStd bool) {
for _, f := range pkg.Files {
p.LoadFile(f, withXgoStd)
}
for _, f := range pkg.GoFiles {
p.LoadGoFile(f)
}
}
func (p Deps) LoadGoFile(f *goast.File) {
for _, imp := range f.Imports {
path := imp.Path
if path.Kind == gotoken.STRING {
if s, err := strconv.Unquote(path.Value); err == nil {
if s == "C" {
continue
}
p.HandlePkg(s)
}
}
}
}
func (p Deps) LoadFile(f *ast.File, withXgoStd bool) {
for _, imp := range f.Imports {
path := imp.Path
if path.Kind == token.STRING {
if s, err := strconv.Unquote(path.Value); err == nil {
p.xgoPkgPath(s, withXgoStd)
}
}
}
}
func (p Deps) xgoPkgPath(s string, withXgoStd bool) {
if strings.HasPrefix(s, "xgo/") || strings.HasPrefix(s, "gop/") {
if !withXgoStd {
return
}
s = "github.com/goplus/xgo/" + s[4:]
} else if strings.HasPrefix(s, "C") {
if len(s) == 1 {
s = "github.com/goplus/libc"
} else if s[1] == '/' {
s = s[2:]
if strings.IndexByte(s, '/') < 0 {
s = "github.com/goplus/" + s
}
}
}
p.HandlePkg(s)
}
// ----------------------------------------------------------------------------
================================================
FILE: ast/print.go
================================================
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This file contains printing support for ASTs.
package ast
import (
"fmt"
"io"
"os"
"reflect"
"github.com/goplus/xgo/token"
)
// A FieldFilter may be provided to Fprint to control the output.
type FieldFilter func(name string, value reflect.Value) bool
// NotNilFilter returns true for field values that are not nil;
// it returns false otherwise.
func NotNilFilter(_ string, v reflect.Value) bool {
switch v.Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
return !v.IsNil()
}
return true
}
// Fprint prints the (sub-)tree starting at AST node x to w.
// If fset != nil, position information is interpreted relative
// to that file set. Otherwise positions are printed as integer
// values (file set specific offsets).
//
// A non-nil FieldFilter f may be provided to control the output:
// struct fields for which f(fieldname, fieldvalue) is true are
// printed; all others are filtered from the output. Unexported
// struct fields are never printed.
func Fprint(w io.Writer, fset *token.FileSet, x any, f FieldFilter) error {
return fprint(w, fset, x, f)
}
func fprint(w io.Writer, fset *token.FileSet, x any, f FieldFilter) (err error) {
// setup printer
p := printer{
output: w,
fset: fset,
filter: f,
ptrmap: make(map[any]int),
last: '\n', // force printing of line number on first line
}
// install error handler
defer func() {
if e := recover(); e != nil {
err = e.(localError).err // re-panics if it's not a localError
}
}()
// print x
if x == nil {
p.printf("nil\n")
return
}
p.print(reflect.ValueOf(x))
p.printf("\n")
return
}
// Print prints x to standard output, skipping nil fields.
// Print(fset, x) is the same as Fprint(os.Stdout, fset, x, NotNilFilter).
func Print(fset *token.FileSet, x any) error {
return Fprint(os.Stdout, fset, x, NotNilFilter)
}
type printer struct {
output io.Writer
fset *token.FileSet
filter FieldFilter
ptrmap map[any]int // *T -> line number
indent int // current indentation level
last byte // the last byte processed by Write
line int // current line number
}
var indent = []byte(". ")
func (p *printer) Write(data []byte) (n int, err error) {
var m int
for i, b := range data {
// invariant: data[0:n] has been written
if b == '\n' {
m, err = p.output.Write(data[n : i+1])
n += m
if err != nil {
return
}
p.line++
} else if p.last == '\n' {
_, err = fmt.Fprintf(p.output, "%6d ", p.line)
if err != nil {
return
}
for j := p.indent; j > 0; j-- {
_, err = p.output.Write(indent)
if err != nil {
return
}
}
}
p.last = b
}
if len(data) > n {
m, err = p.output.Write(data[n:])
n += m
}
return
}
// localError wraps locally caught errors so we can distinguish
// them from genuine panics which we don't want to return as errors.
type localError struct {
err error
}
// printf is a convenience wrapper that takes care of print errors.
func (p *printer) printf(format string, args ...any) {
if _, err := fmt.Fprintf(p, format, args...); err != nil {
panic(localError{err})
}
}
// Implementation note: Print is written for AST nodes but could be
// used to print arbitrary data structures; such a version should
// probably be in a different package.
//
// Note: This code detects (some) cycles created via pointers but
// not cycles that are created via slices or maps containing the
// same slice or map. Code for general data structures probably
// should catch those as well.
func (p *printer) print(x reflect.Value) {
if !NotNilFilter("", x) {
p.printf("nil")
return
}
switch x.Kind() {
case reflect.Interface:
p.print(x.Elem())
case reflect.Map:
p.printf("%s (len = %d) {", x.Type(), x.Len())
if x.Len() > 0 {
p.indent++
p.printf("\n")
for _, key := range x.MapKeys() {
p.print(key)
p.printf(": ")
p.print(x.MapIndex(key))
p.printf("\n")
}
p.indent--
}
p.printf("}")
case reflect.Ptr:
p.printf("*")
// type-checked ASTs may contain cycles - use ptrmap
// to keep track of objects that have been printed
// already and print the respective line number instead
ptr := x.Interface()
if line, exists := p.ptrmap[ptr]; exists {
p.printf("(obj @ %d)", line)
} else {
p.ptrmap[ptr] = p.line
p.print(x.Elem())
}
case reflect.Array:
p.printf("%s {", x.Type())
if x.Len() > 0 {
p.indent++
p.printf("\n")
for i, n :=
gitextract_31rdv4zt/
├── .gitattributes
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug-report.yml
│ │ ├── config.yml
│ │ └── enhancement.yml
│ ├── codecov.yml
│ ├── dependabot.yml
│ ├── workflows/
│ │ ├── check_goreleaser_config.py
│ │ ├── go.yml
│ │ └── release-build.yml
│ └── xgopilot.yml
├── .gitignore
├── .goreleaser.yaml
├── CLAUDE.md
├── CODE_OF_CONDUCT.md
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── all.bash
├── all.bat
├── ast/
│ ├── ast.go
│ ├── ast_xgo.go
│ ├── commentmap.go
│ ├── filter.go
│ ├── fromgo/
│ │ ├── gopast.go
│ │ ├── gopast_test.go
│ │ ├── typeparams/
│ │ │ ├── typeparams_go117.go
│ │ │ └── typeparams_go118.go
│ │ └── typeparams_test.go
│ ├── gopq/
│ │ ├── dom.go
│ │ ├── gopq.go
│ │ └── helper.go
│ ├── goptest/
│ │ └── gopq.go
│ ├── import.go
│ ├── mod/
│ │ └── deps.go
│ ├── print.go
│ ├── resolve.go
│ ├── scope.go
│ ├── togo/
│ │ ├── goast.go
│ │ └── goast_test.go
│ └── walk.go
├── builtin/
│ └── doc.xgo
├── cl/
│ ├── _testc/
│ │ └── hello/
│ │ ├── in.xgo
│ │ └── out.go
│ ├── _testgop/
│ │ ├── _matrix/
│ │ │ └── in.xgo
│ │ ├── append1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── append2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── autoref-2484/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── builtin/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-html/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-huh/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-json/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-md/
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-regexp/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintext-tpl/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── domaintpl/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql3/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql4/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql5/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql6/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── dql7/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── enumlines-rdr/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── enumlines-stdin/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── errwrap1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── errwrap2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── errwrap3/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── fatal/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── for-in/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── for-range/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── implicit-cast-2439/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── kwargs1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── kwargs2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── kwargs3/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── kwargs4/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── list-compr1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── list-compr2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-compr-cond1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-compr-cond2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-compr1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-field-access1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── map-field-access2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── optparam/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── optparam2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── rangeexpr/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── repeatuntil/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── select-compr-twovalue1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── select-compr-twovalue2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── select-compr1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── structtag/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── tuplelit/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── tupletype1/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ ├── tupletype2/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ └── unit/
│ │ ├── in.xgo
│ │ └── out.go
│ ├── _testpy/
│ │ ├── _matrix/
│ │ │ └── in.xgo
│ │ ├── hello/
│ │ │ ├── in.xgo
│ │ │ └── out.go
│ │ └── pycall/
│ │ ├── in.xgo
│ │ └── out.go
│ ├── _testspx/
│ │ ├── basic/
│ │ │ ├── Game.tgmx
│ │ │ ├── Kai.tspx
│ │ │ └── out.go
│ │ ├── clsinit1/
│ │ │ ├── Rect.gox
│ │ │ └── out.go
│ │ ├── clsinit2/
│ │ │ ├── Rect.gox
│ │ │ └── out.go
│ │ ├── execgsh/
│ │ │ ├── demo.gsh
│ │ │ └── out.go
│ │ ├── gshself/
│ │ │ ├── demo.gsh
│ │ │ └── out.go
│ │ ├── init/
│ │ │ ├── init.tspx
│ │ │ └── out.go
│ │ ├── multiworks/
│ │ │ ├── foo_prompt.gox
│ │ │ ├── hello_tool.gox
│ │ │ ├── main_mcp.gox
│ │ │ └── out.go
│ │ ├── newobj/
│ │ │ ├── Kai_spx.gox
│ │ │ ├── main_spx.gox
│ │ │ └── out.go
│ │ ├── nogame/
│ │ │ ├── bar.tspx
│ │ │ └── out.go
│ │ ├── singlework/
│ │ │ ├── Kai_spx.gox
│ │ │ ├── main_spx.gox
│ │ │ └── out.go
│ │ └── xgoinit_dup/
│ │ ├── Spr_spx.gox
│ │ ├── main_spx.gox
│ │ └── out.go
│ ├── builtin.go
│ ├── builtin_test.go
│ ├── c.go
│ ├── classfile.go
│ ├── cltest/
│ │ ├── cltest.go
│ │ ├── error_msg.go
│ │ ├── recorder.go
│ │ └── spx.go
│ ├── compile.go
│ ├── compile_spx_test.go
│ ├── compile_test.go
│ ├── compile_testdir_test.go
│ ├── compile_xgo_test.go
│ ├── error_msg_test.go
│ ├── expr.go
│ ├── func_type_and_var.go
│ ├── internal/
│ │ ├── .gitignore
│ │ ├── dql/
│ │ │ └── dql.go
│ │ ├── gop-in-go/
│ │ │ └── foo/
│ │ │ ├── foo.xgo
│ │ │ ├── foo_test.xgo
│ │ │ └── footest_test.xgo
│ │ ├── huh/
│ │ │ └── huh.go
│ │ ├── llgo-hello/
│ │ │ └── hello.go
│ │ ├── mcp/
│ │ │ └── classfile.go
│ │ ├── overload/
│ │ │ ├── bar/
│ │ │ │ └── bar.go
│ │ │ └── foo/
│ │ │ └── foo.go
│ │ ├── spx/
│ │ │ ├── game.go
│ │ │ ├── pkg/
│ │ │ │ └── pkg.go
│ │ │ └── sprite.go
│ │ ├── spx2/
│ │ │ └── spx2.go
│ │ ├── spx3/
│ │ │ ├── jwt/
│ │ │ │ └── jwt.go
│ │ │ └── spx3.go
│ │ ├── spx4/
│ │ │ ├── game.go
│ │ │ ├── pkg/
│ │ │ │ └── pkg.go
│ │ │ └── sprite.go
│ │ ├── test/
│ │ │ ├── case.go
│ │ │ └── match.go
│ │ ├── testutil/
│ │ │ └── testutil.go
│ │ ├── typesutil/
│ │ │ ├── api.go
│ │ │ ├── api_test.go
│ │ │ ├── mode.go
│ │ │ └── mode_go123.go
│ │ └── unit/
│ │ └── unit.go
│ ├── outline/
│ │ └── outline.go
│ ├── recorder.go
│ ├── run_test.go
│ ├── stmt.go
│ ├── typeparams.go
│ └── typeparams_test.go
├── cmd/
│ ├── chore/
│ │ ├── goptestgo/
│ │ │ └── goptestgo.go
│ │ ├── xgobuiltingen/
│ │ │ ├── builtin.gox
│ │ │ ├── builtingen.gox
│ │ │ ├── helper.xgo
│ │ │ └── reference.gox
│ │ ├── xgofullspec/
│ │ │ └── fullspec.xgo
│ │ └── xgominispec/
│ │ └── minispec.xgo
│ ├── hdq/
│ │ ├── fetch_cmd.gox
│ │ ├── list_cmd.gox
│ │ ├── main_app.gox
│ │ └── xgo_autogen.go
│ ├── internal/
│ │ ├── base/
│ │ │ ├── base.go
│ │ │ └── pass.go
│ │ ├── bug/
│ │ │ └── bug.go
│ │ ├── build/
│ │ │ └── build.go
│ │ ├── clean/
│ │ │ └── clean.go
│ │ ├── deps/
│ │ │ └── deps.go
│ │ ├── doc/
│ │ │ └── doc.go
│ │ ├── env/
│ │ │ └── env.go
│ │ ├── gengo/
│ │ │ └── go.go
│ │ ├── gopfmt/
│ │ │ └── fmt.go
│ │ ├── gopget/
│ │ │ └── get.go
│ │ ├── help/
│ │ │ └── help.go
│ │ ├── install/
│ │ │ └── install.go
│ │ ├── list/
│ │ │ └── list.go
│ │ ├── mod/
│ │ │ ├── download.go
│ │ │ ├── init.go
│ │ │ ├── mod.go
│ │ │ └── tidy.go
│ │ ├── run/
│ │ │ └── run.go
│ │ ├── serve/
│ │ │ └── serve.go
│ │ ├── test/
│ │ │ ├── test.go
│ │ │ └── testflag.go
│ │ ├── version/
│ │ │ └── ver.go
│ │ └── watch/
│ │ └── watch.go
│ ├── make.go
│ ├── make_test.go
│ └── xgo/
│ ├── bug_cmd.gox
│ ├── build_cmd.gox
│ ├── clean_cmd.gox
│ ├── doc_cmd.gox
│ ├── env_cmd.gox
│ ├── fmt_cmd.gox
│ ├── get_cmd.gox
│ ├── go_cmd.gox
│ ├── install_cmd.gox
│ ├── main_app.gox
│ ├── mod_cmd.gox
│ ├── mod_download_cmd.gox
│ ├── mod_init_cmd.gox
│ ├── mod_tidy_cmd.gox
│ ├── run_cmd.gox
│ ├── serve_cmd.gox
│ ├── test_cmd.gox
│ ├── version_cmd.gox
│ ├── watch_cmd.gox
│ └── xgo_autogen.go
├── demo/
│ ├── _llgo/
│ │ ├── callpy/
│ │ │ └── callpy.xgo
│ │ ├── chello/
│ │ │ └── hello.xgo
│ │ ├── cpphello/
│ │ │ └── cpphello.xgo
│ │ ├── defer/
│ │ │ └── defer.xgo
│ │ ├── errors/
│ │ │ └── errors.xgo
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── goroutine/
│ │ │ └── goroutine.xgo
│ │ ├── hello/
│ │ │ └── hello.xgo
│ │ ├── hellollgo/
│ │ │ ├── README.md
│ │ │ └── hello.xgo
│ │ ├── matrix/
│ │ │ └── matrix.xgo
│ │ ├── pyhello/
│ │ │ └── hello.xgo
│ │ ├── pymax/
│ │ │ └── pymax.xgo
│ │ ├── pyprint/
│ │ │ └── print.xgo
│ │ ├── pytensor/
│ │ │ └── tensor.xgo
│ │ ├── qsort/
│ │ │ └── qsort.xgo
│ │ ├── reflect/
│ │ │ └── reflect.xgo
│ │ ├── sqlitedemo/
│ │ │ └── sqlitedemo.xgo
│ │ ├── statistics/
│ │ │ └── statistics.xgo
│ │ └── tetris/
│ │ └── tetris.xgo
│ ├── _tinygo/
│ │ ├── blink/
│ │ │ └── blink.xgo
│ │ ├── go.mod
│ │ └── sortdemo/
│ │ └── sort.xgo
│ ├── clsinit/
│ │ └── Rect.gox
│ ├── domaintext/
│ │ └── domaintext.xgo
│ ├── dql-fs/
│ │ └── fsq.xgo
│ ├── dql-json/
│ │ └── jq.xgo
│ ├── dql-links/
│ │ └── links.xgo
│ ├── dql-xgo/
│ │ └── xgoq.xgo
│ ├── dql-yaml/
│ │ └── yq.xgo
│ ├── fullspec/
│ │ ├── mixgo-complex/
│ │ │ ├── bar.go
│ │ │ ├── foo.xgo
│ │ │ └── xgo_autogen.go
│ │ ├── overloadfunc1/
│ │ │ └── add.xgo
│ │ ├── overloadfunc2/
│ │ │ └── mul.xgo
│ │ ├── overloadmethod/
│ │ │ └── method.xgo
│ │ ├── overloadop1/
│ │ │ └── overloadop.xgo
│ │ ├── overloadop2/
│ │ │ └── overloadop.xgo
│ │ └── tpl-gen-ast/
│ │ └── gen_calc_ast.xgo
│ ├── gsh-exec/
│ │ ├── exec.gsh
│ │ └── foo/
│ │ └── foo.xgo
│ ├── kwargs/
│ │ └── run.xgo
│ ├── lambda1/
│ │ └── lambda.xgo
│ ├── mapliteral/
│ │ └── mapliteral.xgo
│ ├── mixgo/
│ │ ├── README.md
│ │ ├── a.go
│ │ ├── b.xgo
│ │ └── xgo_autogen.go
│ ├── sliceliteral/
│ │ └── sliceliteral.xgo
│ ├── stringtrans/
│ │ └── transform.xgo
│ ├── tpl-calc/
│ │ └── calc.xgo
│ ├── tpl-calc-dump/
│ │ └── calc_dump.xgo
│ ├── tpl-intlist/
│ │ └── ints.xgo
│ ├── tpl-natural-lang/
│ │ └── nlang.xgo
│ ├── tpl-parser-demo/
│ │ └── demo.xgo
│ ├── tpl-pseudo/
│ │ ├── gauss.pseudo
│ │ └── pseudo.gox
│ ├── tpl-vcalc/
│ │ └── variant_calc.xgo
│ ├── tupletype/
│ │ └── tuple.xgo
│ ├── typeasparamsfunc/
│ │ ├── col.go
│ │ └── typeAsParamsFunc.xgo
│ ├── typeasparamsmethod/
│ │ ├── col.go
│ │ └── typeAsParamsMethod.xgo
│ ├── typeparamscast/
│ │ ├── foo.go
│ │ └── typecast.xgo
│ ├── unit-test/
│ │ ├── foo.xgo
│ │ └── foo_test.gox
│ ├── unitliteral/
│ │ └── unitlit.xgo
│ ├── xgo-calc/
│ │ └── calc.xgo
│ ├── xgo-parser/
│ │ └── parser.xgo
│ ├── xgo-sample/
│ │ ├── a.xgo
│ │ ├── b.xgo
│ │ └── cpkag/
│ │ └── b/
│ │ └── ab.go
│ ├── xgo-scanner/
│ │ ├── rpncalc/
│ │ │ └── rpncalc.xgo
│ │ ├── scanner.xgo
│ │ └── simplecalc/
│ │ └── calc.xgo
│ └── xgo-typeof/
│ └── typeof.xgo
├── doc/
│ ├── _testdata/
│ │ ├── gopoFn/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ ├── gopoMethod/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ ├── overloadFn/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ ├── overloadMethod/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ ├── xgoOverloadFn/
│ │ │ ├── in.go
│ │ │ └── out.expect
│ │ └── xgoOverloadMethod/
│ │ ├── in.go
│ │ └── out.expect
│ ├── builtin.md
│ ├── classfile.md
│ ├── code-coverage.md
│ ├── contributing.md
│ ├── docs.md
│ ├── domian-text-lit.md
│ ├── fncall.md
│ ├── func-closure.md
│ ├── goodbye-printf.md
│ ├── map.md
│ ├── overload.md
│ ├── slice.md
│ ├── spec/
│ │ └── mini/
│ │ └── mini.xgo
│ ├── spec-mini.md
│ ├── spec.md
│ ├── string.md
│ ├── struct-vs-tuple.md
│ ├── xgo-vs-go.md
│ ├── z_gop.go
│ ├── z_test.go
│ └── z_transform.go
├── dql/
│ ├── README.md
│ ├── dql.go
│ ├── fetcher/
│ │ ├── fetch.go
│ │ ├── github.com/
│ │ │ ├── issueTask/
│ │ │ │ ├── issueTask.xgo
│ │ │ │ └── xgo_autogen.go
│ │ │ └── repoList/
│ │ │ ├── repoList.xgo
│ │ │ └── xgo_autogen.go
│ │ ├── hrefs/
│ │ │ ├── hrefs.xgo
│ │ │ └── xgo_autogen.go
│ │ ├── pkg.go.dev/
│ │ │ └── importedBy/
│ │ │ ├── importedBy.xgo
│ │ │ └── xgo_autogen.go
│ │ └── pytorch.org/
│ │ └── fndoc/
│ │ ├── fndoc.xgo
│ │ └── xgo_autogen.go
│ ├── fs/
│ │ └── fs.go
│ ├── golang/
│ │ ├── golang.go
│ │ └── parse.go
│ ├── html/
│ │ ├── html.go
│ │ ├── html_test.go
│ │ ├── node.go
│ │ └── text.go
│ ├── json/
│ │ └── json.go
│ ├── maps/
│ │ ├── maps.go
│ │ └── node.go
│ ├── reflects/
│ │ ├── node.go
│ │ └── reflects.go
│ ├── xgo/
│ │ ├── parse.go
│ │ └── xgo.go
│ ├── xml/
│ │ ├── node.go
│ │ ├── text.go
│ │ └── xml.go
│ └── yaml/
│ └── yaml.go
├── encoding/
│ ├── csv/
│ │ └── csv.go
│ ├── fs/
│ │ └── fs.go
│ ├── golang/
│ │ └── golang.go
│ ├── html/
│ │ └── html.go
│ ├── json/
│ │ └── json.go
│ ├── regexp/
│ │ └── regexp.go
│ ├── regexposix/
│ │ └── regexp.go
│ ├── xgo/
│ │ └── xgo.go
│ ├── xml/
│ │ └── xml.go
│ └── yaml/
│ └── yaml.go
├── env/
│ ├── build.go
│ ├── goenv.go
│ ├── gop_nonwindows.go
│ ├── path.go
│ ├── path_test.go
│ ├── sys_others.go
│ ├── sys_plan9.go
│ ├── sys_windows.go
│ ├── version.go
│ └── version_test.go
├── format/
│ ├── format.go
│ ├── formatutil/
│ │ ├── _testdata/
│ │ │ ├── format/
│ │ │ │ ├── basic/
│ │ │ │ │ ├── in.data
│ │ │ │ │ └── out.expect
│ │ │ │ └── nondecl/
│ │ │ │ ├── in.data
│ │ │ │ └── out.expect
│ │ │ ├── rearrange/
│ │ │ │ ├── noeol/
│ │ │ │ │ ├── in.data
│ │ │ │ │ └── out.expect
│ │ │ │ └── nondecl/
│ │ │ │ ├── in.data
│ │ │ │ └── out.expect
│ │ │ └── splitstmts/
│ │ │ └── basic/
│ │ │ ├── in.data
│ │ │ └── out.expect
│ │ ├── format_gop.go
│ │ └── format_test.go
│ └── internal.go
├── go.mod
├── go.sum
├── make.bash
├── make.bat
├── parser/
│ ├── _instance/
│ │ ├── instance1/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── instance2/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── instance3/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── instance4/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ └── instance5/
│ │ ├── cmd.xgo
│ │ └── parser.expect
│ ├── _nofmt/
│ │ ├── cmdlinestyle1/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle2/
│ │ │ ├── cmd2.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle3/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── exists/
│ │ │ ├── exists.xgo
│ │ │ └── parser.expect
│ │ ├── forloop/
│ │ │ ├── forloop.xgo
│ │ │ └── parser.expect
│ │ ├── listcompr/
│ │ │ ├── listcompr.xgo
│ │ │ └── parser.expect
│ │ ├── matrix1/
│ │ │ ├── matrix.xgo
│ │ │ └── parser.expect
│ │ ├── printvariadic/
│ │ │ ├── parser.expect
│ │ │ └── printv.xgo
│ │ ├── rangeexpr1/
│ │ │ ├── parser.expect
│ │ │ └── rangeexpr.xgo
│ │ ├── selectdata/
│ │ │ ├── parser.expect
│ │ │ └── select.xgo
│ │ ├── structtag/
│ │ │ ├── parser.expect
│ │ │ └── tag.xgo
│ │ └── tupletype/
│ │ ├── parser.expect
│ │ └── tuple.xgo
│ ├── _testdata/
│ │ ├── append1/
│ │ │ ├── append.xgo
│ │ │ └── parser.expect
│ │ ├── append2/
│ │ │ ├── append.xgo
│ │ │ └── parser.expect
│ │ ├── arrowop/
│ │ │ ├── arrowop.xgo
│ │ │ └── parser.expect
│ │ ├── autoprop/
│ │ │ ├── goto.xgo
│ │ │ └── parser.expect
│ │ ├── build/
│ │ │ ├── build.xgo
│ │ │ └── parser.expect
│ │ ├── c2gohello/
│ │ │ ├── hello.xgo
│ │ │ └── parser.expect
│ │ ├── classfile_init1/
│ │ │ ├── Rect.gox
│ │ │ └── parser.expect
│ │ ├── classfile_init2/
│ │ │ ├── Rect.gox
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle1/
│ │ │ ├── cmd.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle2/
│ │ │ ├── cmd2.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle3/
│ │ │ ├── cmd3.xgo
│ │ │ └── parser.expect
│ │ ├── cmdlinestyle4/
│ │ │ ├── cmd4.xgo
│ │ │ └── parser.expect
│ │ ├── collection/
│ │ │ ├── collection.xgo
│ │ │ └── parser.expect
│ │ ├── complit/
│ │ │ ├── complit.xgo
│ │ │ └── parser.expect
│ │ ├── domainhuh/
│ │ │ ├── huh.xgo
│ │ │ └── parser.expect
│ │ ├── domaintext/
│ │ │ ├── parser.expect
│ │ │ └── tpl.xgo
│ │ ├── domaintpl/
│ │ │ ├── parser.expect
│ │ │ └── tpl.xgo
│ │ ├── dql1/
│ │ │ ├── dql.xgo
│ │ │ └── parser.expect
│ │ ├── dql2/
│ │ │ ├── dql.xgo
│ │ │ └── parser.expect
│ │ ├── dql3/
│ │ │ ├── dql.xgo
│ │ │ └── parser.expect
│ │ ├── embedded1/
│ │ │ ├── embtype.xgo
│ │ │ └── parser.expect
│ │ ├── envop1/
│ │ │ ├── envop.xgo
│ │ │ └── parser.expect
│ │ ├── envop2/
│ │ │ ├── envop.xgo
│ │ │ └── parser.expect
│ │ ├── errwrap1/
│ │ │ ├── errwrap.xgo
│ │ │ └── parser.expect
│ │ ├── errwrap2/
│ │ │ ├── errwrap2.xgo
│ │ │ └── parser.expect
│ │ ├── errwrap3/
│ │ │ ├── errwrap3.xgo
│ │ │ └── parser.expect
│ │ ├── exists/
│ │ │ ├── exists.xgo
│ │ │ └── parser.expect
│ │ ├── fnbody/
│ │ │ ├── fnbody.xgo
│ │ │ └── parser.expect
│ │ ├── fncall/
│ │ │ ├── fncall.xgo
│ │ │ └── parser.expect
│ │ ├── forloop/
│ │ │ ├── forloop.xgo
│ │ │ └── parser.expect
│ │ ├── funcdecl1/
│ │ │ ├── fndecl.xgo
│ │ │ └── parser.expect
│ │ ├── funcdecl2/
│ │ │ ├── fndecl.xgo
│ │ │ └── parser.expect
│ │ ├── funcdecl3/
│ │ │ ├── fndecl.xgo
│ │ │ └── parser.expect
│ │ ├── funcdoc/
│ │ │ ├── funcdoc.xgo
│ │ │ └── parser.expect
│ │ ├── funclit/
│ │ │ ├── funclit.xgo
│ │ │ └── parser.expect
│ │ ├── functype/
│ │ │ ├── dummy/
│ │ │ │ └── dummy.md
│ │ │ ├── functype.go
│ │ │ └── parser.expect
│ │ ├── gmxtest/
│ │ │ ├── foo.gmx
│ │ │ └── parser.expect
│ │ ├── goto1/
│ │ │ ├── goto.xgo
│ │ │ └── parser.expect
│ │ ├── goto2/
│ │ │ ├── goto.xgo
│ │ │ └── parser.expect
│ │ ├── goxtest1/
│ │ │ ├── bar.gox
│ │ │ └── parser.expect
│ │ ├── goxtest2/
│ │ │ ├── bar.gox
│ │ │ └── parser.expect
│ │ ├── kwargs1/
│ │ │ ├── kwargs.xgo
│ │ │ └── parser.expect
│ │ ├── lambda1/
│ │ │ ├── lambda.xgo
│ │ │ └── parser.expect
│ │ ├── lambda2/
│ │ │ ├── lambda2.xgo
│ │ │ └── parser.expect
│ │ ├── lambda3/
│ │ │ ├── lambda3.xgo
│ │ │ └── parser.expect
│ │ ├── lambda4/
│ │ │ ├── lambda4.xgo
│ │ │ └── parser.expect
│ │ ├── listcompr/
│ │ │ ├── listcompr.xgo
│ │ │ └── parser.expect
│ │ ├── mapfunc/
│ │ │ ├── map.xgo
│ │ │ └── parser.expect
│ │ ├── matrix1/
│ │ │ ├── matrix.xgo
│ │ │ └── parser.expect
│ │ ├── matrix2/
│ │ │ ├── matrix.xgo
│ │ │ └── parser.expect
│ │ ├── mytest/
│ │ │ ├── mytest.xgo
│ │ │ └── parser.expect
│ │ ├── optparam/
│ │ │ ├── optparam.xgo
│ │ │ └── parser.expect
│ │ ├── overload1/
│ │ │ ├── overload.xgo
│ │ │ └── parser.expect
│ │ ├── overload2/
│ │ │ ├── overload2.xgo
│ │ │ └── parser.expect
│ │ ├── overloadop/
│ │ │ ├── op_overload.xgo
│ │ │ └── parser.expect
│ │ ├── printvariadic/
│ │ │ ├── parser.expect
│ │ │ └── printv.xgo
│ │ ├── pystr/
│ │ │ ├── parser.expect
│ │ │ └── pystr.xgo
│ │ ├── rangeexpr1/
│ │ │ ├── parser.expect
│ │ │ └── rangeexpr.xgo
│ │ ├── rangeexpr2/
│ │ │ ├── parser.expect
│ │ │ └── rangeexpr.xgo
│ │ ├── rangeexpr3/
│ │ │ ├── parser.expect
│ │ │ └── rangeexpr.xgo
│ │ ├── rational/
│ │ │ ├── parser.expect
│ │ │ └── rational.xgo
│ │ ├── selectdata/
│ │ │ ├── parser.expect
│ │ │ └── select.xgo
│ │ ├── slice1/
│ │ │ ├── parser.expect
│ │ │ └── slice.xgo
│ │ ├── slice2/
│ │ │ ├── parser.expect
│ │ │ └── slice2.xgo
│ │ ├── spxtest/
│ │ │ ├── foo.spx
│ │ │ └── parser.expect
│ │ ├── staticmthd1/
│ │ │ ├── parser.expect
│ │ │ └── static_method.xgo
│ │ ├── staticmthd2/
│ │ │ ├── a.gox
│ │ │ └── parser.expect
│ │ ├── stdtype/
│ │ │ ├── parser.expect
│ │ │ └── stdtype.xgo
│ │ ├── stringex1/
│ │ │ ├── parser.expect
│ │ │ └── string_lit.xgo
│ │ ├── stringex2/
│ │ │ ├── parser.expect
│ │ │ └── string_lit.xgo
│ │ ├── stringex3/
│ │ │ ├── parser.expect
│ │ │ └── string_lit.xgo
│ │ ├── tuplelit/
│ │ │ ├── parser.expect
│ │ │ └── tuplelit.xgo
│ │ ├── tupletype/
│ │ │ ├── parser.expect
│ │ │ └── tupletype.xgo
│ │ ├── typeof/
│ │ │ ├── parser.expect
│ │ │ └── typeof.xgo
│ │ ├── typeswitch/
│ │ │ ├── parser.expect
│ │ │ └── typeswitch.xgo
│ │ └── unit/
│ │ ├── parser.expect
│ │ └── step.xgo
│ ├── _testexpr/
│ │ └── lambda/
│ │ ├── in.xgo
│ │ └── out.expect
│ ├── fsx/
│ │ ├── fsys.go
│ │ └── memfs/
│ │ ├── fs.go
│ │ └── memfs.go
│ ├── interface.go
│ ├── parser.go
│ ├── parser_test.go
│ ├── parser_xgo.go
│ ├── parserdir_go118_test.go
│ ├── parserdir_test.go
│ └── parsertest/
│ └── parsertest.go
├── printer/
│ ├── _testdata/
│ │ ├── 02-Var-and-operator/
│ │ │ └── var_and_op.xgo
│ │ ├── 03-Import-go-package/
│ │ │ └── import.xgo
│ │ ├── 04-Func/
│ │ │ └── func.xgo
│ │ ├── 05-Closure/
│ │ │ └── closure.xgo
│ │ ├── 06-String-Map-Array-Slice/
│ │ │ └── datastruct.xgo
│ │ ├── 07-MapLit/
│ │ │ └── maplit.xgo
│ │ ├── 08-SliceLit/
│ │ │ └── slicelit.xgo
│ │ ├── 09-IfElse-SwitchCase/
│ │ │ └── flow.xgo
│ │ ├── 10-List-comprehension/
│ │ │ └── list_comprehens.xgo
│ │ ├── 11-Map-comprehension/
│ │ │ └── map_comprehens.xgo
│ │ ├── 12-Select-comprehension/
│ │ │ └── select.xgo
│ │ ├── 12-Select-comprehension2/
│ │ │ └── findscore.xgo
│ │ ├── 13-Exists-comprehension/
│ │ │ └── exists.xgo
│ │ ├── 14-Using-goplus-in-Go/
│ │ │ └── foo/
│ │ │ ├── foo.xgo
│ │ │ ├── foo_test.xgo
│ │ │ └── footest_test.xgo
│ │ ├── 15-ErrWrap/
│ │ │ └── err_wrap.xgo
│ │ ├── 16-Fib/
│ │ │ └── fib.xgo
│ │ ├── 17-Fibtc/
│ │ │ └── fibtc.xgo
│ │ ├── 18-Rational/
│ │ │ └── rational.xgo
│ │ ├── 21-Break-continue-goto/
│ │ │ └── flow.xgo
│ │ ├── 22-For-loop/
│ │ │ └── for.xgo
│ │ ├── 23-Defer/
│ │ │ └── defer.xgo
│ │ ├── 24-Goroutine/
│ │ │ └── goroutine.xgo
│ │ ├── 25-Struct/
│ │ │ └── struct.xgo
│ │ ├── 26-Method/
│ │ │ └── method.xgo
│ │ ├── 27-Func-Set/
│ │ │ └── func.xgo
│ │ ├── 28-Chan/
│ │ │ └── chan.xgo
│ │ ├── 29-CompareToNil/
│ │ │ └── ref.xgo
│ │ ├── 30-Recover/
│ │ │ └── recover.xgo
│ │ ├── 31-Builtin-Typecast/
│ │ │ └── builtin_and_typecast.xgo
│ │ ├── 32-Import-gop-package/
│ │ │ └── import_gop_pkg.xgo
│ │ ├── 33-Interface/
│ │ │ └── shape.xgo
│ │ ├── 34-Type-assert/
│ │ │ └── type_assert.xgo
│ │ ├── 35-Chan-select/
│ │ │ └── select.xgo
│ │ ├── 36-Auto-Property/
│ │ │ └── autoprop.xgo
│ │ ├── 37-Cmdline/
│ │ │ └── cmdline.xgo
│ │ ├── 38-Overload-operator/
│ │ │ └── overload_op.xgo
│ │ ├── 39-Lambda-expression/
│ │ │ └── lambda.xgo
│ │ ├── 40-Deduce-struct-type/
│ │ │ └── deduce.xgo
│ │ ├── 41-UDT-RangeForEach/
│ │ │ └── udt_range.xgo
│ │ ├── 42-UDT-RangeIterator/
│ │ │ └── udt_range_iter.xgo
│ │ └── 43-RangeExpr/
│ │ └── rangeexpr.xgo
│ ├── bugfix_test.go
│ ├── nodes.go
│ ├── printer.go
│ ├── printer_test.go
│ └── xgo_test.go
├── scanner/
│ ├── gop.go
│ └── scanner.go
├── test/
│ └── classfile.go
├── token/
│ ├── internal/
│ │ └── tokenutil/
│ │ ├── lines_go118.go
│ │ ├── lines_go120.go
│ │ ├── lines_go121.go
│ │ └── lines_test.go
│ ├── token.go
│ ├── token_test.go
│ └── types.go
├── tool/
│ ├── _gendeps.go
│ ├── build_install_run.go
│ ├── gengo.go
│ ├── imp.go
│ ├── load.go
│ ├── outline.go
│ └── tidy.go
├── tpl/
│ ├── README.md
│ ├── ast/
│ │ └── ast.go
│ ├── cl/
│ │ └── compile.go
│ ├── matcher/
│ │ └── match.go
│ ├── parser/
│ │ ├── _testdata/
│ │ │ ├── adjoin/
│ │ │ │ ├── in.xgo
│ │ │ │ └── out.expect
│ │ │ ├── pseudo/
│ │ │ │ ├── in.xgo
│ │ │ │ └── out.expect
│ │ │ ├── simple1/
│ │ │ │ ├── in.xgo
│ │ │ │ └── out.expect
│ │ │ └── simple2/
│ │ │ ├── in.xgo
│ │ │ └── out.expect
│ │ ├── parser.go
│ │ ├── parser_test.go
│ │ └── parsertest/
│ │ └── parsertest.go
│ ├── scanner/
│ │ ├── _testdata/
│ │ │ ├── cstr/
│ │ │ │ ├── go.expect
│ │ │ │ ├── gop.expect
│ │ │ │ ├── in.xgo
│ │ │ │ └── tpl.expect
│ │ │ ├── num/
│ │ │ │ ├── go.expect
│ │ │ │ ├── gop.expect
│ │ │ │ ├── in.xgo
│ │ │ │ └── tpl.expect
│ │ │ ├── pow/
│ │ │ │ ├── go.expect
│ │ │ │ ├── gop.expect
│ │ │ │ ├── in.xgo
│ │ │ │ └── tpl.expect
│ │ │ ├── rat/
│ │ │ │ ├── go.expect
│ │ │ │ ├── gop.expect
│ │ │ │ ├── in.xgo
│ │ │ │ └── tpl.expect
│ │ │ └── unit/
│ │ │ ├── go.expect
│ │ │ ├── gop.expect
│ │ │ ├── in.xgo
│ │ │ └── tpl.expect
│ │ ├── error.go
│ │ ├── scandir_test.go
│ │ ├── scanner.go
│ │ ├── scanner_test.go
│ │ └── scannertest/
│ │ └── scannertest.go
│ ├── token/
│ │ ├── token.go
│ │ ├── token_test.go
│ │ └── types.go
│ ├── tpl.go
│ ├── types/
│ │ └── types.go
│ └── variant/
│ ├── builtin/
│ │ └── builtin.go
│ ├── delay/
│ │ └── delay.go
│ ├── math/
│ │ └── math.go
│ ├── module.go
│ ├── time/
│ │ └── time.go
│ └── variant.go
└── x/
├── build/
│ ├── _testdata/
│ │ ├── hello/
│ │ │ ├── hello.expect
│ │ │ └── main.xgo
│ │ ├── multi/
│ │ │ ├── Rect.gox
│ │ │ ├── main.xgo
│ │ │ └── multi.expect
│ │ └── pkg/
│ │ ├── pkg.expect
│ │ └── pkg.xgo
│ ├── build.go
│ └── build_test.go
├── fakenet/
│ └── conn.go
├── format/
│ ├── README.md
│ ├── _testdata/
│ │ ├── collection/
│ │ │ ├── format.expect
│ │ │ └── index.xgo
│ │ ├── gopsyntax/
│ │ │ ├── format.expect
│ │ │ └── index.xgo
│ │ └── syntax/
│ │ ├── format.expect
│ │ └── index.xgo
│ ├── format.go
│ ├── gopstyle.go
│ ├── gopstyle_test.go
│ ├── gopstyledir_test.go
│ └── stmt_expr_or_type.go
├── fsnotify/
│ └── fsnotify.go
├── gocmd/
│ ├── build_install.go
│ ├── gocmd.go
│ └── run.go
├── jsonrpc2/
│ ├── conn.go
│ ├── frame.go
│ ├── internal/
│ │ └── stack/
│ │ ├── parse.go
│ │ ├── process.go
│ │ ├── stack.go
│ │ └── stacktest/
│ │ └── stacktest.go
│ ├── jsonrpc2.go
│ ├── jsonrpc2test/
│ │ ├── cases/
│ │ │ └── testcase.go
│ │ ├── jsonrpc2_test.go
│ │ ├── pipe.go
│ │ └── pipe_test.go
│ ├── messages.go
│ ├── serve.go
│ ├── stdio/
│ │ ├── server.go
│ │ └── stdio.go
│ └── wire.go
├── langserver/
│ ├── client.go
│ ├── serve_dial.go
│ └── server.go
├── typesutil/
│ ├── api.go
│ ├── builtin_test.go
│ ├── check.go
│ ├── check_test.go
│ ├── code_string.go
│ ├── codes.go
│ ├── eval.go
│ ├── exprstring.go
│ ├── exprstring_test.go
│ ├── gopinfo.go
│ ├── info_test.go
│ ├── internal/
│ │ └── typesutil/
│ │ └── types.go
│ └── typeparams/
│ └── typeparams.go
├── watcher/
│ ├── changes.go
│ └── watch.go
├── xgoenv/
│ └── env.go
└── xgoprojs/
├── proj.go
└── proj_test.go
Showing preview only (343K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (4458 symbols across 326 files)
FILE: ast/ast.go
type Expr (line 48) | type Expr interface
type Stmt (line 54) | type Stmt interface
type Decl (line 60) | type Decl interface
type Field (line 83) | type Field struct
method Pos (line 93) | func (f *Field) Pos() token.Pos {
method End (line 101) | func (f *Field) End() token.Pos {
type FieldList (line 112) | type FieldList struct
method Pos (line 119) | func (f *FieldList) Pos() token.Pos {
method End (line 132) | func (f *FieldList) End() token.Pos {
method NumFields (line 145) | func (f *FieldList) NumFields() int {
type BadExpr (line 165) | type BadExpr struct
method Pos (line 366) | func (x *BadExpr) Pos() token.Pos { return x.From }
method End (line 442) | func (x *BadExpr) End() token.Pos { return x.To }
method exprNode (line 530) | func (*BadExpr) exprNode() {}
type Ident (line 170) | type Ident struct
method Pos (line 369) | func (x *Ident) Pos() token.Pos { return x.NamePos }
method End (line 445) | func (x *Ident) End() token.Pos {
method Implicit (line 453) | func (x *Ident) Implicit() bool {
method exprNode (line 531) | func (*Ident) exprNode() {}
method IsExported (line 570) | func (x *Ident) IsExported() bool { return token.IsExported(x.Name) }
method String (line 572) | func (x *Ident) String() string {
type Ellipsis (line 178) | type Ellipsis struct
method Pos (line 372) | func (x *Ellipsis) Pos() token.Pos { return x.Ellipsis }
method End (line 459) | func (x *Ellipsis) End() token.Pos {
method exprNode (line 532) | func (*Ellipsis) exprNode() {}
type FuncLit (line 184) | type FuncLit struct
method Pos (line 375) | func (x *FuncLit) Pos() token.Pos { return x.Type.Pos() }
method End (line 467) | func (x *FuncLit) End() token.Pos { return x.Body.End() }
method exprNode (line 533) | func (*FuncLit) exprNode() {}
type CompositeLit (line 190) | type CompositeLit struct
method Pos (line 378) | func (x *CompositeLit) Pos() token.Pos {
method End (line 470) | func (x *CompositeLit) End() token.Pos { return x.Rbrace + 1 }
method exprNode (line 534) | func (*CompositeLit) exprNode() {}
type ParenExpr (line 199) | type ParenExpr struct
method Pos (line 386) | func (x *ParenExpr) Pos() token.Pos { return x.Lparen }
method End (line 473) | func (x *ParenExpr) End() token.Pos { return x.Rparen + 1 }
method exprNode (line 535) | func (*ParenExpr) exprNode() {}
type SelectorExpr (line 213) | type SelectorExpr struct
method Pos (line 389) | func (x *SelectorExpr) Pos() token.Pos { return x.X.Pos() }
method End (line 476) | func (x *SelectorExpr) End() token.Pos { return x.Sel.End() }
method exprNode (line 536) | func (*SelectorExpr) exprNode() {}
type IndexExpr (line 219) | type IndexExpr struct
method Pos (line 392) | func (x *IndexExpr) Pos() token.Pos { return x.X.Pos() }
method End (line 479) | func (x *IndexExpr) End() token.Pos { return x.Rbrack + 1 }
method exprNode (line 537) | func (*IndexExpr) exprNode() {}
type IndexListExpr (line 228) | type IndexListExpr struct
method Pos (line 395) | func (x *IndexListExpr) Pos() token.Pos { return x.X.Pos() }
method End (line 482) | func (x *IndexListExpr) End() token.Pos { return x.Rbrack + 1 }
method exprNode (line 538) | func (*IndexListExpr) exprNode() {}
type SliceExpr (line 236) | type SliceExpr struct
method Pos (line 398) | func (x *SliceExpr) Pos() token.Pos { return x.X.Pos() }
method End (line 485) | func (x *SliceExpr) End() token.Pos { return x.Rbrack + 1 }
method exprNode (line 539) | func (*SliceExpr) exprNode() {}
type TypeAssertExpr (line 248) | type TypeAssertExpr struct
method Pos (line 401) | func (x *TypeAssertExpr) Pos() token.Pos { return x.X.Pos() }
method End (line 488) | func (x *TypeAssertExpr) End() token.Pos { return x.Rparen + 1 }
method exprNode (line 540) | func (*TypeAssertExpr) exprNode() {}
type StarExpr (line 257) | type StarExpr struct
method Pos (line 404) | func (x *StarExpr) Pos() token.Pos { return x.Star }
method End (line 491) | func (x *StarExpr) End() token.Pos { return x.X.End() }
method exprNode (line 541) | func (*StarExpr) exprNode() {}
type UnaryExpr (line 264) | type UnaryExpr struct
method Pos (line 407) | func (x *UnaryExpr) Pos() token.Pos { return x.OpPos }
method End (line 494) | func (x *UnaryExpr) End() token.Pos { return x.X.End() }
method exprNode (line 542) | func (*UnaryExpr) exprNode() {}
type BinaryExpr (line 271) | type BinaryExpr struct
method Pos (line 410) | func (x *BinaryExpr) Pos() token.Pos { return x.X.Pos() }
method End (line 497) | func (x *BinaryExpr) End() token.Pos { return x.Y.End() }
method exprNode (line 543) | func (*BinaryExpr) exprNode() {}
type KeyValueExpr (line 280) | type KeyValueExpr struct
method Pos (line 413) | func (x *KeyValueExpr) Pos() token.Pos { return x.Key.Pos() }
method End (line 500) | func (x *KeyValueExpr) End() token.Pos { return x.Value.End() }
method exprNode (line 544) | func (*KeyValueExpr) exprNode() {}
type ChanDir (line 289) | type ChanDir
constant SEND (line 293) | SEND ChanDir = 1 << iota
constant RECV (line 295) | RECV
type ArrayType (line 303) | type ArrayType struct
method Pos (line 416) | func (x *ArrayType) Pos() token.Pos { return x.Lbrack }
method End (line 503) | func (x *ArrayType) End() token.Pos { return x.Elt.End() }
method exprNode (line 546) | func (*ArrayType) exprNode() {}
type StructType (line 310) | type StructType struct
method Pos (line 419) | func (x *StructType) Pos() token.Pos { return x.Struct }
method End (line 506) | func (x *StructType) End() token.Pos { return x.Fields.End() }
method exprNode (line 547) | func (*StructType) exprNode() {}
type FuncType (line 319) | type FuncType struct
method Pos (line 422) | func (x *FuncType) Pos() token.Pos {
method End (line 509) | func (x *FuncType) End() token.Pos {
method exprNode (line 548) | func (*FuncType) exprNode() {}
type InterfaceType (line 327) | type InterfaceType struct
method Pos (line 430) | func (x *InterfaceType) Pos() token.Pos { return x.Interface }
method End (line 517) | func (x *InterfaceType) End() token.Pos { return x.Methods.End() }
method exprNode (line 549) | func (*InterfaceType) exprNode() {}
type MapType (line 334) | type MapType struct
method Pos (line 433) | func (x *MapType) Pos() token.Pos { return x.Map }
method End (line 520) | func (x *MapType) End() token.Pos { return x.Value.End() }
method exprNode (line 550) | func (*MapType) exprNode() {}
type ChanType (line 341) | type ChanType struct
method Pos (line 436) | func (x *ChanType) Pos() token.Pos { return x.Begin }
method End (line 523) | func (x *ChanType) End() token.Pos { return x.Value.End() }
method exprNode (line 551) | func (*ChanType) exprNode() {}
type TupleType (line 356) | type TupleType struct
method Pos (line 439) | func (x *TupleType) Pos() token.Pos { return x.Lparen }
method End (line 526) | func (x *TupleType) End() token.Pos { return x.Rparen + 1 }
method exprNode (line 552) | func (*TupleType) exprNode() {}
function NewIdent (line 559) | func NewIdent(name string) *Ident { return &Ident{token.NoPos, name, nil} }
function NewIdentEx (line 562) | func NewIdentEx(pos token.Pos, name string, kind ObjKind) *Ident {
function IsExported (line 567) | func IsExported(name string) bool { return token.IsExported(name) }
type BadStmt (line 589) | type BadStmt struct
method Pos (line 743) | func (s *BadStmt) Pos() token.Pos { return s.From }
method End (line 806) | func (s *BadStmt) End() token.Pos { return s.To }
method stmtNode (line 907) | func (*BadStmt) stmtNode() {}
type DeclStmt (line 594) | type DeclStmt struct
method Pos (line 746) | func (s *DeclStmt) Pos() token.Pos { return s.Decl.Pos() }
method End (line 809) | func (s *DeclStmt) End() token.Pos { return s.Decl.End() }
method stmtNode (line 908) | func (*DeclStmt) stmtNode() {}
type EmptyStmt (line 602) | type EmptyStmt struct
method Pos (line 749) | func (s *EmptyStmt) Pos() token.Pos { return s.Semicolon }
method End (line 812) | func (s *EmptyStmt) End() token.Pos {
method stmtNode (line 909) | func (*EmptyStmt) stmtNode() {}
type LabeledStmt (line 608) | type LabeledStmt struct
method Pos (line 752) | func (s *LabeledStmt) Pos() token.Pos { return s.Label.Pos() }
method End (line 820) | func (s *LabeledStmt) End() token.Pos { return s.Stmt.End() }
method stmtNode (line 910) | func (*LabeledStmt) stmtNode() {}
type ExprStmt (line 617) | type ExprStmt struct
method Pos (line 755) | func (s *ExprStmt) Pos() token.Pos { return s.X.Pos() }
method End (line 823) | func (s *ExprStmt) End() token.Pos { return s.X.End() }
method stmtNode (line 911) | func (*ExprStmt) stmtNode() {}
type IncDecStmt (line 622) | type IncDecStmt struct
method Pos (line 761) | func (s *IncDecStmt) Pos() token.Pos { return s.X.Pos() }
method End (line 826) | func (s *IncDecStmt) End() token.Pos {
method stmtNode (line 913) | func (*IncDecStmt) stmtNode() {}
type AssignStmt (line 631) | type AssignStmt struct
method Pos (line 764) | func (s *AssignStmt) Pos() token.Pos { return s.Lhs[0].Pos() }
method End (line 831) | func (s *AssignStmt) End() token.Pos { return s.Rhs[len(s.Rhs)-1].End() }
method stmtNode (line 914) | func (*AssignStmt) stmtNode() {}
type GoStmt (line 639) | type GoStmt struct
method Pos (line 767) | func (s *GoStmt) Pos() token.Pos { return s.Go }
method End (line 834) | func (s *GoStmt) End() token.Pos { return s.Call.End() }
method stmtNode (line 915) | func (*GoStmt) stmtNode() {}
type DeferStmt (line 645) | type DeferStmt struct
method Pos (line 770) | func (s *DeferStmt) Pos() token.Pos { return s.Defer }
method End (line 837) | func (s *DeferStmt) End() token.Pos { return s.Call.End() }
method stmtNode (line 916) | func (*DeferStmt) stmtNode() {}
type ReturnStmt (line 651) | type ReturnStmt struct
method Pos (line 773) | func (s *ReturnStmt) Pos() token.Pos { return s.Return }
method End (line 840) | func (s *ReturnStmt) End() token.Pos {
method stmtNode (line 917) | func (*ReturnStmt) stmtNode() {}
type BranchStmt (line 659) | type BranchStmt struct
method Pos (line 776) | func (s *BranchStmt) Pos() token.Pos { return s.TokPos }
method End (line 848) | func (s *BranchStmt) End() token.Pos {
method stmtNode (line 918) | func (*BranchStmt) stmtNode() {}
type BlockStmt (line 666) | type BlockStmt struct
method Pos (line 779) | func (s *BlockStmt) Pos() token.Pos { return s.Lbrace }
method End (line 856) | func (s *BlockStmt) End() token.Pos {
method stmtNode (line 919) | func (*BlockStmt) stmtNode() {}
type IfStmt (line 673) | type IfStmt struct
method Pos (line 782) | func (s *IfStmt) Pos() token.Pos { return s.If }
method End (line 867) | func (s *IfStmt) End() token.Pos {
method stmtNode (line 920) | func (*IfStmt) stmtNode() {}
type CaseClause (line 682) | type CaseClause struct
method Pos (line 785) | func (s *CaseClause) Pos() token.Pos { return s.Case }
method End (line 875) | func (s *CaseClause) End() token.Pos {
method stmtNode (line 921) | func (*CaseClause) stmtNode() {}
type SwitchStmt (line 690) | type SwitchStmt struct
method Pos (line 788) | func (s *SwitchStmt) Pos() token.Pos { return s.Switch }
method End (line 883) | func (s *SwitchStmt) End() token.Pos { return s.Body.End() }
method stmtNode (line 922) | func (*SwitchStmt) stmtNode() {}
type TypeSwitchStmt (line 698) | type TypeSwitchStmt struct
method Pos (line 791) | func (s *TypeSwitchStmt) Pos() token.Pos { return s.Switch }
method End (line 886) | func (s *TypeSwitchStmt) End() token.Pos { return s.Body.End() }
method stmtNode (line 923) | func (*TypeSwitchStmt) stmtNode() {}
type CommClause (line 706) | type CommClause struct
method Pos (line 794) | func (s *CommClause) Pos() token.Pos { return s.Case }
method End (line 889) | func (s *CommClause) End() token.Pos {
method stmtNode (line 924) | func (*CommClause) stmtNode() {}
type SelectStmt (line 714) | type SelectStmt struct
method Pos (line 797) | func (s *SelectStmt) Pos() token.Pos { return s.Select }
method End (line 897) | func (s *SelectStmt) End() token.Pos { return s.Body.End() }
method stmtNode (line 925) | func (*SelectStmt) stmtNode() {}
type ForStmt (line 720) | type ForStmt struct
method Pos (line 800) | func (s *ForStmt) Pos() token.Pos { return s.For }
method End (line 900) | func (s *ForStmt) End() token.Pos { return s.Body.End() }
method stmtNode (line 926) | func (*ForStmt) stmtNode() {}
type RangeStmt (line 729) | type RangeStmt struct
method Pos (line 803) | func (s *RangeStmt) Pos() token.Pos { return s.For }
method End (line 903) | func (s *RangeStmt) End() token.Pos { return s.Body.End() }
method stmtNode (line 927) | func (*RangeStmt) stmtNode() {}
method Pos (line 758) | func (s *SendStmt) Pos() token.Pos { return s.Chan.Pos() }
method stmtNode (line 912) | func (*SendStmt) stmtNode() {}
type Spec (line 936) | type Spec interface
type ImportSpec (line 942) | type ImportSpec struct
method Pos (line 976) | func (s *ImportSpec) Pos() token.Pos {
method End (line 995) | func (s *ImportSpec) End() token.Pos {
method specNode (line 1018) | func (*ImportSpec) specNode() {}
type ValueSpec (line 953) | type ValueSpec struct
method Pos (line 984) | func (s *ValueSpec) Pos() token.Pos {
method End (line 1003) | func (s *ValueSpec) End() token.Pos {
method specNode (line 1019) | func (*ValueSpec) specNode() {}
type TypeSpec (line 963) | type TypeSpec struct
method Pos (line 992) | func (s *TypeSpec) Pos() token.Pos { return s.Name.Pos() }
method End (line 1014) | func (s *TypeSpec) End() token.Pos { return s.Type.End() }
method specNode (line 1020) | func (*TypeSpec) specNode() {}
type BadDecl (line 1028) | type BadDecl struct
method Pos (line 1069) | func (d *BadDecl) Pos() token.Pos { return d.From }
method End (line 1078) | func (d *BadDecl) End() token.Pos { return d.To }
method declNode (line 1098) | func (*BadDecl) declNode() {}
type GenDecl (line 1043) | type GenDecl struct
method Pos (line 1072) | func (d *GenDecl) Pos() token.Pos { return d.TokPos }
method End (line 1081) | func (d *GenDecl) End() token.Pos {
method declNode (line 1099) | func (*GenDecl) declNode() {}
type FuncDecl (line 1053) | type FuncDecl struct
method Pos (line 1075) | func (d *FuncDecl) Pos() token.Pos { return d.Type.Pos() }
method End (line 1089) | func (d *FuncDecl) End() token.Pos {
method declNode (line 1100) | func (*FuncDecl) declNode() {}
type Package (line 1106) | type Package struct
method Pos (line 1114) | func (p *Package) Pos() token.Pos { return token.NoPos }
method End (line 1117) | func (p *Package) End() token.Pos { return token.NoPos }
FILE: ast/ast_xgo.go
type OverloadFuncDecl (line 35) | type OverloadFuncDecl struct
method Pos (line 49) | func (p *OverloadFuncDecl) Pos() token.Pos {
method End (line 54) | func (p *OverloadFuncDecl) End() token.Pos {
method declNode (line 58) | func (*OverloadFuncDecl) declNode() {}
type CallExpr (line 65) | type CallExpr struct
method Pos (line 76) | func (x *CallExpr) Pos() token.Pos { return x.Fun.Pos() }
method End (line 79) | func (x *CallExpr) End() token.Pos {
method exprNode (line 86) | func (*CallExpr) exprNode() {}
method IsCommand (line 89) | func (x *CallExpr) IsCommand() bool {
type KwargExpr (line 94) | type KwargExpr struct
method Pos (line 99) | func (p *KwargExpr) Pos() token.Pos {
method End (line 103) | func (p *KwargExpr) End() token.Pos {
method exprNode (line 107) | func (p *KwargExpr) exprNode() {}
type DomainTextLit (line 118) | type DomainTextLit struct
method Pos (line 133) | func (x *DomainTextLit) Pos() token.Pos { return x.Domain.NamePos }
method End (line 136) | func (x *DomainTextLit) End() token.Pos { return token.Pos(int(x.Value...
method exprNode (line 138) | func (*DomainTextLit) exprNode() {}
type DomainTextLitEx (line 126) | type DomainTextLitEx struct
type BasicLit (line 143) | type BasicLit struct
method Pos (line 167) | func (x *BasicLit) Pos() token.Pos { return x.ValuePos }
method End (line 170) | func (x *BasicLit) End() token.Pos { return token.Pos(int(x.ValuePos) ...
method exprNode (line 172) | func (*BasicLit) exprNode() {}
type StringLitEx (line 150) | type StringLitEx struct
function NextPartPos (line 156) | func NextPartPos(pos token.Pos, part any) (nextPos token.Pos) {
type NumberUnitLit (line 177) | type NumberUnitLit struct
method exprNode (line 184) | func (*NumberUnitLit) exprNode() {}
method Pos (line 186) | func (x *NumberUnitLit) Pos() token.Pos {
method End (line 190) | func (x *NumberUnitLit) End() token.Pos {
type EnvExpr (line 197) | type EnvExpr struct
method Pos (line 205) | func (p *EnvExpr) Pos() token.Pos {
method End (line 210) | func (p *EnvExpr) End() token.Pos {
method HasBrace (line 218) | func (p *EnvExpr) HasBrace() bool {
method exprNode (line 222) | func (*EnvExpr) exprNode() {}
type AnySelectorExpr (line 232) | type AnySelectorExpr struct
method Pos (line 239) | func (p *AnySelectorExpr) Pos() token.Pos {
method End (line 244) | func (p *AnySelectorExpr) End() token.Pos {
method exprNode (line 248) | func (*AnySelectorExpr) exprNode() {}
type CondExpr (line 257) | type CondExpr struct
method Pos (line 264) | func (p *CondExpr) Pos() token.Pos {
method End (line 269) | func (p *CondExpr) End() token.Pos {
method exprNode (line 273) | func (*CondExpr) exprNode() {}
type SliceLit (line 278) | type SliceLit struct
method Pos (line 286) | func (p *SliceLit) Pos() token.Pos {
method End (line 291) | func (p *SliceLit) End() token.Pos {
method exprNode (line 295) | func (*SliceLit) exprNode() {}
type TupleLit (line 300) | type TupleLit struct
method Pos (line 308) | func (p *TupleLit) Pos() token.Pos {
method End (line 313) | func (p *TupleLit) End() token.Pos {
method exprNode (line 317) | func (*TupleLit) exprNode() {}
type MatrixLit (line 322) | type MatrixLit struct
method Pos (line 330) | func (p *MatrixLit) Pos() token.Pos {
method End (line 335) | func (p *MatrixLit) End() token.Pos {
method exprNode (line 339) | func (*MatrixLit) exprNode() {}
type ElemEllipsis (line 344) | type ElemEllipsis struct
method Pos (line 350) | func (p *ElemEllipsis) Pos() token.Pos {
method End (line 355) | func (p *ElemEllipsis) End() token.Pos {
method exprNode (line 359) | func (*ElemEllipsis) exprNode() {}
type ErrWrapExpr (line 364) | type ErrWrapExpr struct
method Pos (line 372) | func (p *ErrWrapExpr) Pos() token.Pos {
method End (line 377) | func (p *ErrWrapExpr) End() token.Pos {
method exprNode (line 384) | func (*ErrWrapExpr) exprNode() {}
type LambdaExpr (line 398) | type LambdaExpr struct
method Pos (line 422) | func (p *LambdaExpr) Pos() token.Pos {
method End (line 427) | func (p *LambdaExpr) End() token.Pos {
method exprNode (line 444) | func (*LambdaExpr) exprNode() {}
type LambdaExpr2 (line 413) | type LambdaExpr2 struct
method Pos (line 432) | func (p *LambdaExpr2) Pos() token.Pos {
method End (line 437) | func (p *LambdaExpr2) End() token.Pos {
method exprNode (line 445) | func (*LambdaExpr2) exprNode() {}
type RangeExpr (line 450) | type RangeExpr struct
method Pos (line 459) | func (p *RangeExpr) Pos() token.Pos {
method End (line 467) | func (p *RangeExpr) End() token.Pos {
method exprNode (line 480) | func (*RangeExpr) exprNode() {}
type ForPhrase (line 485) | type ForPhrase struct
method Pos (line 496) | func (p *ForPhrase) Pos() token.Pos { return p.For }
method End (line 499) | func (p *ForPhrase) End() token.Pos {
method exprNode (line 506) | func (p *ForPhrase) exprNode() {}
type ComprehensionExpr (line 514) | type ComprehensionExpr struct
method Pos (line 523) | func (p *ComprehensionExpr) Pos() token.Pos {
method End (line 528) | func (p *ComprehensionExpr) End() token.Pos {
method exprNode (line 532) | func (*ComprehensionExpr) exprNode() {}
type ForPhraseStmt (line 537) | type ForPhraseStmt struct
method Pos (line 543) | func (p *ForPhraseStmt) Pos() token.Pos {
method End (line 548) | func (p *ForPhraseStmt) End() token.Pos {
method stmtNode (line 552) | func (*ForPhraseStmt) stmtNode() {}
type SendStmt (line 557) | type SendStmt struct
method End (line 565) | func (s *SendStmt) End() token.Pos {
type File (line 593) | type File struct
method HasShadowEntry (line 610) | func (f *File) HasShadowEntry() bool {
method HasPkgDecl (line 615) | func (f *File) HasPkgDecl() bool {
method ClassFieldsDecl (line 620) | func (f *File) ClassFieldsDecl() *GenDecl {
method Pos (line 636) | func (f *File) Pos() token.Pos {
method End (line 645) | func (f *File) End() token.Pos {
FILE: ast/commentmap.go
type byPos (line 27) | type byPos
method Len (line 29) | func (a byPos) Len() int { return len(a) }
method Less (line 30) | func (a byPos) Less(i, j int) bool { return a[i].Pos() < a[j].Pos() }
method Swap (line 31) | func (a byPos) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
function sortComments (line 34) | func sortComments(list []*CommentGroup) {
type CommentMap (line 46) | type CommentMap
method addComment (line 48) | func (cmap CommentMap) addComment(n Node, c *CommentGroup) {
method Update (line 241) | func (cmap CommentMap) Update(old, new Node) Node {
method Filter (line 252) | func (cmap CommentMap) Filter(node Node) CommentMap {
method Comments (line 265) | func (cmap CommentMap) Comments() []*CommentGroup {
method String (line 310) | func (cmap CommentMap) String() string {
function nodeList (line 59) | func nodeList(n Node) []Node {
type commentListReader (line 79) | type commentListReader struct
method eol (line 87) | func (r *commentListReader) eol() bool {
method next (line 91) | func (r *commentListReader) next() {
type nodeStack (line 102) | type nodeStack
method push (line 106) | func (s *nodeStack) push(n Node) {
method pop (line 114) | func (s *nodeStack) pop(pos token.Pos) (top Node) {
function NewCommentMap (line 139) | func NewCommentMap(fset *token.FileSet, node Node, comments []*CommentGr...
function summary (line 274) | func summary(list []*CommentGroup) string {
FILE: ast/filter.go
function exportFilter (line 29) | func exportFilter(name string) bool {
function FileExports (line 40) | func FileExports(src *File) bool {
function PackageExports (line 50) | func PackageExports(pkg *Package) bool {
type Filter (line 58) | type Filter
function filterIdentList (line 60) | func filterIdentList(list []*Ident, f Filter) []*Ident {
function fieldName (line 74) | func fieldName(x Expr) *Ident {
function filterFieldList (line 88) | func filterFieldList(fields *FieldList, filter Filter, export bool) (rem...
function filterCompositeLit (line 123) | func filterCompositeLit(lit *CompositeLit, filter Filter, export bool) {
function filterExprList (line 131) | func filterExprList(list []Expr, filter Filter, export bool) []Expr {
function filterParamList (line 151) | func filterParamList(fields *FieldList, filter Filter, export bool) bool {
function filterType (line 164) | func filterType(typ Expr, f Filter, export bool) bool {
function filterSpec (line 201) | func filterSpec(spec Spec, f Filter, export bool) bool {
function filterSpecList (line 231) | func filterSpecList(list []Spec, f Filter, export bool) []Spec {
function FilterDecl (line 248) | func FilterDecl(decl Decl, f Filter) bool {
function filterDecl (line 252) | func filterDecl(decl Decl, f Filter, export bool) bool {
function FilterFile (line 272) | func FilterFile(src *File, f Filter) bool {
function filterFile (line 276) | func filterFile(src *File, f Filter, export bool) bool {
function FilterPackage (line 298) | func FilterPackage(pkg *Package, f Filter) bool {
function filterPackage (line 302) | func filterPackage(pkg *Package, f Filter, export bool) bool {
type MergeMode (line 316) | type MergeMode
constant FilterFuncDuplicates (line 320) | FilterFuncDuplicates MergeMode = 1 << iota
constant FilterUnassociatedComments (line 323) | FilterUnassociatedComments
constant FilterImportDuplicates (line 325) | FilterImportDuplicates
function nameOf (line 331) | func nameOf(f *FuncDecl) string {
function MergePackageFiles (line 354) | func MergePackageFiles(pkg *Package, mode MergeMode) *File {
FILE: ast/fromgo/gopast.go
function gopExpr (line 33) | func gopExpr(val ast.Expr) gopast.Expr {
function gopExprs (line 169) | func gopExprs(vals []ast.Expr) []gopast.Expr {
function gopFuncType (line 183) | func gopFuncType(v *ast.FuncType) *gopast.FuncType {
function gopType (line 192) | func gopType(v ast.Expr) gopast.Expr {
function gopBasicLit (line 196) | func gopBasicLit(v *ast.BasicLit) *gopast.BasicLit {
function gopIdent (line 207) | func gopIdent(v *ast.Ident) *gopast.Ident {
function CheckIdent (line 220) | func CheckIdent(v *gopast.Ident) (id *ast.Ident, ok bool) {
function gopIdents (line 227) | func gopIdents(names []*ast.Ident) []*gopast.Ident {
function gopField (line 237) | func gopField(v *ast.Field) *gopast.Field {
function gopFieldList (line 245) | func gopFieldList(v *ast.FieldList) *gopast.FieldList {
function gopFuncDecl (line 256) | func gopFuncDecl(v *ast.FuncDecl) *gopast.FuncDecl {
function gopImportSpec (line 268) | func gopImportSpec(spec *ast.ImportSpec) *gopast.ImportSpec {
function gopTypeSpec (line 276) | func gopTypeSpec(spec *ast.TypeSpec) *gopast.TypeSpec {
function gopValueSpec (line 285) | func gopValueSpec(spec *ast.ValueSpec) *gopast.ValueSpec {
function gopGenDecl (line 293) | func gopGenDecl(v *ast.GenDecl) *gopast.GenDecl {
function gopDecl (line 319) | func gopDecl(decl ast.Decl) gopast.Decl {
function gopDecls (line 330) | func gopDecls(decls []ast.Decl) []gopast.Decl {
constant KeepFuncBody (line 341) | KeepFuncBody = 1 << iota
constant KeepCgo (line 342) | KeepCgo
function ASTFile (line 346) | func ASTFile(f *ast.File, mode int) *gopast.File {
FILE: ast/fromgo/gopast_test.go
function testAST (line 30) | func testAST(t *testing.T, from, to string) {
function test (line 48) | func test(t *testing.T, src string) {
function testPanic (line 52) | func testPanic(t *testing.T, panicMsg string, doPanic func()) {
function TestErrASTFile (line 65) | func TestErrASTFile(t *testing.T) {
function TestErrDecl (line 74) | func TestErrDecl(t *testing.T) {
function TestErrExpr (line 85) | func TestErrExpr(t *testing.T) {
function TestBasic (line 91) | func TestBasic(t *testing.T) {
function TestMethod (line 121) | func TestMethod(t *testing.T) {
function TestCheckIdent (line 130) | func TestCheckIdent(t *testing.T) {
FILE: ast/fromgo/typeparams/typeparams_go117.go
function unsupported (line 11) | func unsupported() {
type IndexListExpr (line 17) | type IndexListExpr struct
method Pos (line 25) | func (*IndexListExpr) Pos() token.Pos { unsupported(); return token.No...
method End (line 26) | func (*IndexListExpr) End() token.Pos { unsupported(); return token.No...
function ForFuncType (line 30) | func ForFuncType(*ast.FuncType) *ast.FieldList {
function ForTypeSpec (line 36) | func ForTypeSpec(*ast.TypeSpec) *ast.FieldList {
FILE: ast/fromgo/typeparams/typeparams_go118.go
function ForFuncType (line 12) | func ForFuncType(n *ast.FuncType) *ast.FieldList {
function ForTypeSpec (line 20) | func ForTypeSpec(n *ast.TypeSpec) *ast.FieldList {
FILE: ast/fromgo/typeparams_test.go
function TestIndexListExpr (line 8) | func TestIndexListExpr(t *testing.T) {
FILE: ast/gopq/dom.go
type astPackages (line 26) | type astPackages
method Pos (line 28) | func (p astPackages) Pos() token.Pos { return token.NoPos }
method End (line 29) | func (p astPackages) End() token.Pos { return token.NoPos }
method ForEach (line 31) | func (p astPackages) ForEach(filter func(node Node) error) error {
method Obj (line 41) | func (p astPackages) Obj() any {
type astPackage (line 47) | type astPackage struct
method ForEach (line 51) | func (p astPackage) ForEach(filter func(node Node) error) error {
method Obj (line 61) | func (p astPackage) Obj() any {
type astFile (line 67) | type astFile struct
method ForEach (line 71) | func (p astFile) ForEach(filter func(node Node) error) error {
method Obj (line 81) | func (p astFile) Obj() any {
type astDecl (line 87) | type astDecl struct
method ForEach (line 91) | func (p *astDecl) ForEach(filter func(node Node) error) error {
method Obj (line 103) | func (p *astDecl) Obj() any {
type astSpec (line 109) | type astSpec struct
method ForEach (line 113) | func (p *astSpec) ForEach(filter func(node Node) error) error {
method Obj (line 117) | func (p *astSpec) Obj() any {
function visitStmt (line 123) | func visitStmt(stmt ast.Stmt, filter func(node Node) error) error {
type astStmt (line 130) | type astStmt struct
method ForEach (line 134) | func (p *astStmt) ForEach(filter func(node Node) error) error {
method Obj (line 158) | func (p *astStmt) Obj() any {
type astExpr (line 164) | type astExpr struct
method ForEach (line 168) | func (p *astExpr) ForEach(filter func(node Node) error) error {
method Obj (line 172) | func (p *astExpr) Obj() any {
FILE: ast/gopq/gopq.go
constant GopPackage (line 33) | GopPackage = true
type Node (line 51) | type Node interface
type NodeEnum (line 58) | type NodeEnum interface
type NodeSet (line 63) | type NodeSet struct
method Ok (line 131) | func (p NodeSet) Ok() bool {
method FuncDecl__0 (line 138) | func (p NodeSet) FuncDecl__0() NodeSet {
method FuncDecl__1 (line 149) | func (p NodeSet) FuncDecl__1(name string) NodeSet {
method GenDecl__0 (line 161) | func (p NodeSet) GenDecl__0(tok token.Token) NodeSet {
method TypeSpec (line 173) | func (p NodeSet) TypeSpec() NodeSet {
method ValueSpec (line 184) | func (p NodeSet) ValueSpec() NodeSet {
method ImportSpec (line 195) | func (p NodeSet) ImportSpec() NodeSet {
method ExprStmt (line 206) | func (p NodeSet) ExprStmt() NodeSet {
method AssignStmt (line 217) | func (p NodeSet) AssignStmt() NodeSet {
method CallExpr__0 (line 228) | func (p NodeSet) CallExpr__0() NodeSet {
method CallExpr__1 (line 239) | func (p NodeSet) CallExpr__1(name string) NodeSet {
method CompositeLit__0 (line 251) | func (p NodeSet) CompositeLit__0() NodeSet {
method CompositeLit__1 (line 262) | func (p NodeSet) CompositeLit__1(name string) NodeSet {
method Gop_Enum (line 275) | func (p NodeSet) Gop_Enum(callback func(node NodeSet)) {
method ForEach (line 285) | func (p NodeSet) ForEach(callback func(node NodeSet)) {
method One (line 304) | func (p NodeSet) One() NodeSet {
method Cache (line 361) | func (p NodeSet) Cache() NodeSet {
method Any (line 394) | func (p NodeSet) Any() (ret NodeSet) {
method Child (line 414) | func (p NodeSet) Child() NodeSet {
method Body (line 440) | func (p NodeSet) Body() NodeSet {
method X (line 474) | func (p NodeSet) X() NodeSet {
method Fun (line 501) | func (p NodeSet) Fun() NodeSet {
method Arg (line 540) | func (p NodeSet) Arg(i int) NodeSet {
method Varg (line 548) | func (p NodeSet) Varg(i int) NodeSet {
method Elt__0 (line 584) | func (p NodeSet) Elt__0(i int) NodeSet {
method Elt__1 (line 592) | func (p NodeSet) Elt__1() NodeSet {
method Elt__2 (line 622) | func (p NodeSet) Elt__2(name string) NodeSet {
method Rhs (line 650) | func (p NodeSet) Rhs(i int) NodeSet {
method Match (line 674) | func (p NodeSet) Match(match func(node Node) bool) (ret NodeSet) {
method Name (line 684) | func (p NodeSet) Name() []string {
method ToString (line 689) | func (p NodeSet) ToString(str func(node Node) string) (items []string) {
method Collect (line 701) | func (p NodeSet) Collect() (items []Node, err error) {
method CollectOne__1 (line 714) | func (p NodeSet) CollectOne__1(exactly bool) (item Node, err error) {
method CollectOne__0 (line 738) | func (p NodeSet) CollectOne__0() (item Node, err error) {
function FromFile (line 69) | func FromFile(fset *token.FileSet, filename string, src any, mode parser...
function FromFSFile (line 78) | func FromFSFile(
function FromDir (line 98) | func FromDir(
function FromFSDir (line 119) | func FromFSDir(
type oneNode (line 291) | type oneNode struct
method ForEach (line 295) | func (p *oneNode) ForEach(filter func(node Node) error) error {
method Cached (line 299) | func (p *oneNode) Cached() int {
function One__0 (line 316) | func One__0(node Node) NodeSet {
function One__1 (line 321) | func One__1(f *ast.File) NodeSet {
function One__2 (line 326) | func One__2(pkg *ast.Package) NodeSet {
type fixNodes (line 332) | type fixNodes struct
method ForEach (line 336) | func (p *fixNodes) ForEach(filter func(node Node) error) error {
method Cached (line 345) | func (p *fixNodes) Cached() int {
function Nodes (line 350) | func Nodes(nodes ...Node) NodeSet {
type cached (line 356) | type cached interface
type anyNodes (line 374) | type anyNodes struct
method ForEach (line 378) | func (p *anyNodes) ForEach(filter func(node Node) error) error {
function anyForEach (line 384) | func anyForEach(p Node, filter func(node Node) error) error {
type childNodes (line 403) | type childNodes struct
method ForEach (line 407) | func (p *childNodes) ForEach(filter func(node Node) error) error {
type bodyNodes (line 423) | type bodyNodes struct
method ForEach (line 427) | func (p *bodyNodes) ForEach(filter func(node Node) error) error {
type xNodes (line 449) | type xNodes struct
method ForEach (line 453) | func (p *xNodes) ForEach(filter func(node Node) error) error {
type funNodes (line 483) | type funNodes struct
method ForEach (line 487) | func (p *funNodes) ForEach(filter func(node Node) error) error {
type argNodes (line 510) | type argNodes struct
method ForEach (line 516) | func (p *argNodes) ForEach(filter func(node Node) error) error {
type ieltNodes (line 557) | type ieltNodes struct
method ForEach (line 562) | func (p *ieltNodes) ForEach(filter func(node Node) error) error {
type eltNodes (line 601) | type eltNodes struct
method ForEach (line 606) | func (p *eltNodes) ForEach(filter func(node Node) error) error {
type rhsNodes (line 631) | type rhsNodes struct
method ForEach (line 636) | func (p *rhsNodes) ForEach(filter func(node Node) error) error {
type matchedNodes (line 659) | type matchedNodes struct
method ForEach (line 664) | func (p *matchedNodes) ForEach(filter func(node Node) error) error {
FILE: ast/gopq/helper.go
method Funcs (line 29) | func (p NodeSet) Funcs() NodeSet {
method UnquotedString__1 (line 35) | func (p NodeSet) UnquotedString__1(exactly bool) (ret string, err error) {
method UnquotedString__0 (line 46) | func (p NodeSet) UnquotedString__0() (ret string, err error) {
method UnquotedStringElts__1 (line 52) | func (p NodeSet) UnquotedStringElts__1(exactly bool) (ret []string, err ...
method UnquotedStringElts__0 (line 73) | func (p NodeSet) UnquotedStringElts__0() (ret []string, err error) {
method Positions__1 (line 79) | func (p NodeSet) Positions__1(exactly bool) (ret []token.Pos, err error) {
method Positions__0 (line 93) | func (p NodeSet) Positions__0() (ret []token.Pos, err error) {
method EltLen__1 (line 99) | func (p NodeSet) EltLen__1(exactly bool) (ret int, err error) {
method EltLen__0 (line 110) | func (p NodeSet) EltLen__0() (ret int, err error) {
method Ident__1 (line 116) | func (p NodeSet) Ident__1(exactly bool) (ret string, err error) {
method Ident__0 (line 127) | func (p NodeSet) Ident__0() (ret string, err error) {
function getElt (line 133) | func getElt(elts []ast.Expr, name string) (ast.Expr, bool) {
function NameOf (line 147) | func NameOf(node Node) string {
function getName (line 151) | func getName(v any, useEmpty bool) string {
function CodeOf (line 174) | func CodeOf(fset *token.FileSet, f *ast.File, start, end token.Pos) stri...
FILE: ast/goptest/gopq.go
constant GopPackage (line 27) | GopPackage = "github.com/goplus/xgo/ast/gopq"
function New (line 33) | func New(script string) (gopq.NodeSet, error) {
FILE: ast/import.go
function SortImports (line 28) | func SortImports(fset *token.FileSet, f *File) {
function lineAt (line 68) | func lineAt(fset *token.FileSet, pos token.Pos) int {
function importPath (line 72) | func importPath(s Spec) string {
function importName (line 80) | func importName(s Spec) string {
function importComment (line 88) | func importComment(s Spec) string {
function collapse (line 97) | func collapse(prev, next Spec) bool {
type posSpan (line 104) | type posSpan struct
type cgPos (line 109) | type cgPos struct
function sortSpecs (line 114) | func sortSpecs(fset *token.FileSet, f *File, specs []Spec) []Spec {
FILE: ast/mod/deps.go
type Deps (line 32) | type Deps struct
method Load (line 36) | func (p Deps) Load(pkg *ast.Package, withXgoStd bool) {
method LoadGoFile (line 45) | func (p Deps) LoadGoFile(f *goast.File) {
method LoadFile (line 59) | func (p Deps) LoadFile(f *ast.File, withXgoStd bool) {
method xgoPkgPath (line 70) | func (p Deps) xgoPkgPath(s string, withXgoStd bool) {
FILE: ast/print.go
type FieldFilter (line 31) | type FieldFilter
function NotNilFilter (line 35) | func NotNilFilter(_ string, v reflect.Value) bool {
function Fprint (line 52) | func Fprint(w io.Writer, fset *token.FileSet, x any, f FieldFilter) error {
function fprint (line 56) | func fprint(w io.Writer, fset *token.FileSet, x any, f FieldFilter) (err...
function Print (line 86) | func Print(fset *token.FileSet, x any) error {
type printer (line 90) | type printer struct
method Write (line 102) | func (p *printer) Write(data []byte) (n int, err error) {
method printf (line 141) | func (p *printer) printf(format string, args ...any) {
method print (line 156) | func (p *printer) print(x reflect.Value) {
type localError (line 136) | type localError struct
FILE: ast/scope.go
type Scope (line 31) | type Scope struct
method Lookup (line 45) | func (s *Scope) Lookup(name string) *Object {
method Insert (line 53) | func (s *Scope) Insert(obj *Object) (alt *Object) {
method String (line 61) | func (s *Scope) String() string {
function NewScope (line 37) | func NewScope(outer *Scope) *Scope {
type Object (line 85) | type Object struct
method Pos (line 101) | func (obj *Object) Pos() token.Pos {
function NewObj (line 94) | func NewObj(kind ObjKind, name string) *Object {
type ObjKind (line 146) | type ObjKind
method String (line 176) | func (kind ObjKind) String() string { return objKindStrings[kind] }
constant Bad (line 150) | Bad ObjKind = iota
constant Pkg (line 151) | Pkg
constant Con (line 152) | Con
constant Typ (line 153) | Typ
constant Var (line 154) | Var
constant Fun (line 155) | Fun
constant Lbl (line 156) | Lbl
constant implicitBase (line 157) | implicitBase
constant ImplicitPkg (line 159) | ImplicitPkg = ObjKind(implicitBase)
constant ImplicitFun (line 160) | ImplicitFun = ObjKind(implicitBase + 1)
FILE: ast/togo/goast.go
function goExpr (line 31) | func goExpr(val gopast.Expr) ast.Expr {
function goExprs (line 160) | func goExprs(vals []gopast.Expr) []ast.Expr {
function goFuncType (line 174) | func goFuncType(v *gopast.FuncType) *ast.FuncType {
function goType (line 182) | func goType(v gopast.Expr) ast.Expr {
function goBasicLit (line 186) | func goBasicLit(v *gopast.BasicLit) *ast.BasicLit {
function goIdent (line 197) | func goIdent(v *gopast.Ident) *ast.Ident {
function goIdents (line 207) | func goIdents(names []*gopast.Ident) []*ast.Ident {
function goField (line 217) | func goField(v *gopast.Field) *ast.Field {
function goFieldList (line 225) | func goFieldList(v *gopast.FieldList) *ast.FieldList {
function goFuncDecl (line 236) | func goFuncDecl(v *gopast.FuncDecl) *ast.FuncDecl {
function goImportSpec (line 247) | func goImportSpec(spec *gopast.ImportSpec) *ast.ImportSpec {
function goTypeSpec (line 255) | func goTypeSpec(spec *gopast.TypeSpec) *ast.TypeSpec {
function goValueSpec (line 263) | func goValueSpec(spec *gopast.ValueSpec) *ast.ValueSpec {
function goGenDecl (line 271) | func goGenDecl(v *gopast.GenDecl) *ast.GenDecl {
function goDecl (line 296) | func goDecl(decl gopast.Decl) ast.Decl {
function goDecls (line 307) | func goDecls(decls []gopast.Decl) []ast.Decl {
constant KeepFuncBody (line 318) | KeepFuncBody = 1 << iota
function ASTFile (line 321) | func ASTFile(f *gopast.File, mode int) *ast.File {
FILE: ast/togo/goast_test.go
function testAST (line 29) | func testAST(t *testing.T, from, to string) {
function test (line 47) | func test(t *testing.T, src string) {
function testPanic (line 51) | func testPanic(t *testing.T, panicMsg string, doPanic func()) {
function TestErrASTFile (line 64) | func TestErrASTFile(t *testing.T) {
function TestErrDecl (line 70) | func TestErrDecl(t *testing.T) {
function TestErrExpr (line 81) | func TestErrExpr(t *testing.T) {
function TestBasic (line 87) | func TestBasic(t *testing.T) {
FILE: ast/walk.go
type Visitor (line 26) | type Visitor interface
function walkList (line 30) | func walkList[N Node](v Visitor, list []N) {
function Walk (line 44) | func Walk(v Visitor, node Node) {
type inspector (line 483) | type inspector
method Visit (line 485) | func (f inspector) Visit(node Node) Visitor {
function Inspect (line 496) | func Inspect(node Node, f func(Node) bool) {
FILE: cl/_testc/hello/out.go
function main (line 5) | func main() {
FILE: cl/_testgop/append1/out.go
type foo (line 5) | type foo struct
function main (line 9) | func main() {
FILE: cl/_testgop/append2/out.go
function main (line 5) | func main() {
FILE: cl/_testgop/autoref-2484/out.go
type Person (line 5) | type Person struct
type Point (line 9) | type Point struct
function processPerson (line 14) | func processPerson(p *Person) {
function processPoint (line 17) | func processPoint(p *Point) {
function processSlice (line 20) | func processSlice(s *[]int) {
function processMap (line 23) | func processMap(m *map[string]int) {
function processArray (line 26) | func processArray(a *[3]int) {
function main (line 30) | func main() {
FILE: cl/_testgop/builtin/out.go
function main (line 9) | func main() {
FILE: cl/_testgop/domaintext-html/out.go
function main (line 8) | func main() {
FILE: cl/_testgop/domaintext-huh/out.go
function main (line 5) | func main() {
FILE: cl/_testgop/domaintext-json/out.go
function main (line 9) | func main() {
FILE: cl/_testgop/domaintext-md/out.go
function main (line 8) | func main() {
FILE: cl/_testgop/domaintext-regexp/out.go
function main (line 8) | func main() {
FILE: cl/_testgop/domaintext-tpl/out.go
function main (line 5) | func main() {
FILE: cl/_testgop/domaintpl/out.go
function main (line 5) | func main() {
FILE: cl/_testgop/dql1/out.go
function main (line 8) | func main() {
FILE: cl/_testgop/dql2/out.go
function main (line 9) | func main() {
FILE: cl/_testgop/dql3/out.go
function main (line 8) | func main() {
FILE: cl/_testgop/dql4/out.go
function main (line 10) | func main() {
FILE: cl/_testgop/dql5/out.go
function main (line 9) | func main() {
FILE: cl/_testgop/dql6/out.go
function main (line 11) | func main() {
FILE: cl/_testgop/dql7/out.go
function main (line 9) | func main() {
FILE: cl/_testgop/enumlines-rdr/out.go
function main (line 11) | func main() {
FILE: cl/_testgop/enumlines-stdin/out.go
function main (line 9) | func main() {
FILE: cl/_testgop/errwrap1/out.go
function F (line 5) | func F() (a int8, b int16, err error) {
function F2 (line 9) | func F2() (err error) {
function main (line 23) | func main() {
FILE: cl/_testgop/errwrap2/out.go
function F (line 5) | func F() (a int8, b int16, err error) {
function F2 (line 9) | func F2() (err error) {
function main (line 27) | func main() {
FILE: cl/_testgop/errwrap3/out.go
constant XGoo_Bar (line 8) | XGoo_Bar = "BarOne,BarTwo"
function BarOne (line 10) | func BarOne() int {
function BarTwo (line 13) | func BarTwo() (int, error) {
function main (line 16) | func main() {
FILE: cl/_testgop/fatal/out.go
function main (line 9) | func main() {
FILE: cl/_testgop/for-in/out.go
function main (line 8) | func main() {
FILE: cl/_testgop/for-range/out.go
function foo (line 5) | func foo(yield func() bool) {
function bar (line 8) | func bar(yield func(v string) bool) {
function weekdays (line 11) | func weekdays(yield func(k string, v int) bool) {
function main (line 14) | func main() {
FILE: cl/_testgop/implicit-cast-2439/out.go
type BasePtr (line 3) | type BasePtr struct
type Base (line 5) | type Base struct
type T (line 8) | type T struct
function Walk (line 12) | func Walk(p *Base) {
function WalkPtr (line 14) | func WalkPtr(p *BasePtr) {
function f (line 16) | func f() *T {
function main (line 19) | func main() {
FILE: cl/_testgop/kwargs1/out.go
type Options (line 3) | type Options struct
function PlaySound (line 8) | func PlaySound(path string, options *Options) {
function main (line 10) | func main() {
FILE: cl/_testgop/kwargs2/out.go
type Options (line 3) | type Options struct
function PlaySound (line 8) | func PlaySound(path string, options Options) {
function main (line 10) | func main() {
FILE: cl/_testgop/kwargs3/out.go
type Options (line 3) | type Options
function PlaySound (line 5) | func PlaySound(options Options, paths ...string) {
function main (line 7) | func main() {
FILE: cl/_testgop/kwargs4/out.go
function PlaySound (line 5) | func PlaySound(path string, options *testutil.Options) {
function main (line 7) | func main() {
FILE: cl/_testgop/list-compr1/out.go
function main (line 3) | func main() {
FILE: cl/_testgop/list-compr2/out.go
function main (line 5) | func main() {
FILE: cl/_testgop/map-compr-cond1/out.go
function main (line 3) | func main() {
FILE: cl/_testgop/map-compr-cond2/out.go
function main (line 3) | func main() {
FILE: cl/_testgop/map-compr1/out.go
function main (line 3) | func main() {
FILE: cl/_testgop/map-field-access1/out.go
function main (line 5) | func main() {
FILE: cl/_testgop/map-field-access2/out.go
function main (line 7) | func main() {
FILE: cl/_testgop/optparam/out.go
type Server (line 5) | type Server struct
method handle (line 20) | func (s *Server) handle(req string, __xgo_optional_opts int) {
function basic (line 8) | func basic(a int, __xgo_optional_b int) {
function multiple (line 11) | func multiple(name string, __xgo_optional_age int, __xgo_optional_active...
function allOptional (line 14) | func allOptional(__xgo_optional_x int, __xgo_optional_y string) {
function withVariadic (line 17) | func withVariadic(__xgo_optional_a int, b ...string) {
function main (line 23) | func main() {
FILE: cl/_testgop/optparam2/out.go
function returnValue (line 5) | func returnValue(__xgo_optional_x int) int {
function useInExpression (line 8) | func useInExpression(__xgo_optional_a int, __xgo_optional_b int) int {
function simpleNested (line 12) | func simpleNested(__xgo_optional_outer int) {
function main (line 18) | func main() {
FILE: cl/_testgop/rangeexpr/out.go
function main (line 8) | func main() {
FILE: cl/_testgop/repeatuntil/out.go
function RepeatUntil (line 5) | func RepeatUntil(cond func() bool, body func()) {
function main (line 10) | func main() {
FILE: cl/_testgop/select-compr-twovalue1/out.go
function main (line 3) | func main() {
FILE: cl/_testgop/select-compr-twovalue2/out.go
function foo (line 3) | func foo() (int, bool) {
FILE: cl/_testgop/select-compr1/out.go
function main (line 3) | func main() {
FILE: cl/_testgop/structtag/out.go
type Start (line 3) | type Start struct
FILE: cl/_testgop/tuplelit/out.go
type T (line 5) | type T struct
function dump (line 12) | func dump(a struct {
function demo (line 22) | func demo(a int16, b float32) {
function main (line 25) | func main() {
FILE: cl/_testgop/tupletype1/out.go
type Empty (line 10) | type Empty struct
type Pair (line 13) | type Pair struct
type Triple (line 17) | type Triple struct
type Point (line 23) | type Point struct
type Person (line 27) | type Person struct
type Point3D (line 32) | type Point3D struct
type Mixed (line 37) | type Mixed struct
type WithArray (line 43) | type WithArray struct
type WithPointers (line 48) | type WithPointers struct
type WithFunc (line 53) | type WithFunc struct
type WithChan (line 58) | type WithChan struct
type WithMap (line 63) | type WithMap struct
type WithStruct (line 68) | type WithStruct struct
type WithInterface (line 77) | type WithInterface struct
type WithParen (line 84) | type WithParen struct
type WithQualified (line 89) | type WithQualified struct
type MixedArray (line 94) | type MixedArray struct
type SingleNamed (line 99) | type SingleNamed
function main (line 117) | func main() {
FILE: cl/_testgop/tupletype2/out.go
type Point (line 5) | type Point struct
type Int (line 9) | type Int
function main (line 11) | func main() {
FILE: cl/_testgop/unit/out.go
function Wait (line 8) | func Wait(time.Duration) {
function Step (line 10) | func Step(unit.Distance) {
function main (line 12) | func main() {
FILE: cl/_testpy/hello/out.go
function main (line 8) | func main() {
FILE: cl/_testpy/pycall/out.go
function main (line 9) | func main() {
FILE: cl/_testspx/basic/out.go
type Game (line 5) | type Game struct
method onInit (line 13) | func (this *Game) onInit() {
method MainEntry (line 18) | func (this *Game) MainEntry() {
method Main (line 21) | func (this *Game) Main() {
type Kai (line 8) | type Kai struct
method onMsg (line 24) | func (this *Kai) onMsg(msg string) {
method Main (line 30) | func (this *Kai) Main() {
function main (line 32) | func main() {
FILE: cl/_testspx/clsinit1/out.go
type Rect (line 3) | type Rect struct
method XGo_Init (line 11) | func (this *Rect) XGo_Init() *Rect {
FILE: cl/_testspx/clsinit2/out.go
type Rect (line 5) | type Rect struct
method Main (line 12) | func (this *Rect) Main() {
method XGo_Init (line 16) | func (this *Rect) XGo_Init() *Rect {
function main (line 21) | func main() {
FILE: cl/_testspx/execgsh/out.go
type demo (line 8) | type demo struct
method MainEntry (line 13) | func (this *demo) MainEntry() {
method Main (line 20) | func (this *demo) Main() {
method XGo_Init (line 23) | func (this *demo) XGo_Init() *demo {
function main (line 27) | func main() {
FILE: cl/_testspx/gshself/out.go
type demo (line 8) | type demo struct
method MainEntry (line 12) | func (this *demo) MainEntry() {
method Main (line 16) | func (this *demo) Main() {
function main (line 19) | func main() {
FILE: cl/_testspx/init/out.go
type _init (line 5) | type _init struct
method Main (line 16) | func (this *_init) Main() {
type MyGame (line 9) | type MyGame struct
method Main (line 13) | func (this *MyGame) Main() {
function main (line 18) | func main() {
FILE: cl/_testspx/multiworks/out.go
type foo (line 5) | type foo struct
method Main (line 29) | func (this *foo) Main(_xgo_arg0 *mcp.Tool) string {
type Tool_hello (line 9) | type Tool_hello struct
method Main (line 33) | func (this *Tool_hello) Main(_xgo_arg0 string) int {
type Game (line 13) | type Game struct
method MainEntry (line 18) | func (this *Game) MainEntry() {
method Main (line 21) | func (this *Game) Main() {
function main (line 37) | func main() {
FILE: cl/_testspx/newobj/out.go
type Kai (line 8) | type Kai struct
method Main (line 26) | func (this *Kai) Main(_xgo_arg0 string) {
method Classfname (line 29) | func (this *Kai) Classfname() string {
method Classclone (line 32) | func (this *Kai) Classclone() spx3.Handler {
type Game (line 12) | type Game struct
method MainEntry (line 16) | func (this *Game) MainEntry() {
method Main (line 22) | func (this *Game) Main() {
function main (line 36) | func main() {
FILE: cl/_testspx/nogame/out.go
type bar (line 5) | type bar struct
method Main (line 16) | func (this *bar) Main() {
type MyGame (line 9) | type MyGame struct
method Main (line 13) | func (this *MyGame) Main() {
function main (line 18) | func main() {
FILE: cl/_testspx/singlework/out.go
type Kai (line 9) | type Kai struct
method Main (line 25) | func (this *Kai) Main(_xgo_arg0 string) {
method Classfname (line 29) | func (this *Kai) Classfname() string {
method Classclone (line 32) | func (this *Kai) Classclone() spx3.Handler {
type Game (line 13) | type Game struct
method MainEntry (line 18) | func (this *Game) MainEntry() {
method Main (line 21) | func (this *Game) Main() {
function main (line 36) | func main() {
FILE: cl/_testspx/xgoinit_dup/out.go
type Spr (line 8) | type Spr struct
method Main (line 30) | func (this *Spr) Main(_xgo_arg0 string) {
method Classfname (line 34) | func (this *Spr) Classfname() string {
method Classclone (line 37) | func (this *Spr) Classclone() spx3.Handler {
type Game (line 12) | type Game struct
method MainEntry (line 18) | func (this *Game) MainEntry() {
method Main (line 22) | func (this *Game) Main() {
method XGo_Init (line 26) | func (this *Game) XGo_Init() *Game {
function main (line 41) | func main() {
FILE: cl/builtin.go
function initMathBig (line 28) | func initMathBig(_ *gogen.Package, conf *gogen.Config, big gogen.PkgRef) {
function initBuiltinFns (line 34) | func initBuiltinFns(builtin *types.Package, scope *types.Scope, pkg goge...
function initBuiltin (line 41) | func initBuiltin(_ *gogen.Package, builtin *types.Package, os, fmt, ng, ...
constant osxPkgPath (line 81) | osxPkgPath = "github.com/qiniu/x/osx"
method newBuiltinDefault (line 84) | func (ctx *pkgCtx) newBuiltinDefault(pkg *gogen.Package, conf *gogen.Con...
FILE: cl/builtin_test.go
function getGoxConf (line 36) | func getGoxConf() *gogen.Config {
function TestEmbeddedFieldCast (line 42) | func TestEmbeddedFieldCast(t *testing.T) {
function TestNonClosure (line 48) | func TestNonClosure(t *testing.T) {
function TestLoadExpr (line 55) | func TestLoadExpr(t *testing.T) {
function TestProjFile (line 62) | func TestProjFile(t *testing.T) {
function TestSpriteOf (line 69) | func TestSpriteOf(t *testing.T) {
function TestGetGameClass (line 76) | func TestGetGameClass(t *testing.T) {
function TestSimplifyPkgPath (line 95) | func TestSimplifyPkgPath(t *testing.T) {
function TestCompileLambdaExpr (line 104) | func TestCompileLambdaExpr(t *testing.T) {
function TestCompileLambda1 (line 118) | func TestCompileLambda1(t *testing.T) {
function TestCompileLambda2 (line 136) | func TestCompileLambda2(t *testing.T) {
function TestCompileExpr (line 154) | func TestCompileExpr(t *testing.T) {
function TestCompileStmt (line 166) | func TestCompileStmt(t *testing.T) {
function TestTryXGoExec (line 179) | func TestTryXGoExec(t *testing.T) {
function TestCompileFuncAlias (line 186) | func TestCompileFuncAlias(t *testing.T) {
function TestErrStringLit (line 201) | func TestErrStringLit(t *testing.T) {
function TestErrPreloadFile (line 215) | func TestErrPreloadFile(t *testing.T) {
function TestErrParseTypeEmbedName (line 231) | func TestErrParseTypeEmbedName(t *testing.T) {
function TestGmxCheckProjs (line 240) | func TestGmxCheckProjs(t *testing.T) {
function TestGmxCheckProjs2 (line 251) | func TestGmxCheckProjs2(t *testing.T) {
function TestNodeInterp (line 262) | func TestNodeInterp(t *testing.T) {
function TestMarkAutogen (line 275) | func TestMarkAutogen(t *testing.T) {
function TestClassNameAndExt (line 288) | func TestClassNameAndExt(t *testing.T) {
function TestFileClassType (line 299) | func TestFileClassType(t *testing.T) {
function TestErrMultiStarRecv (line 377) | func TestErrMultiStarRecv(t *testing.T) {
function TestErrAssign (line 386) | func TestErrAssign(t *testing.T) {
function TestErrPanicToRecv (line 404) | func TestErrPanicToRecv(t *testing.T) {
function TestCompileErrWrapExpr (line 427) | func TestCompileErrWrapExpr(t *testing.T) {
function TestToString (line 438) | func TestToString(t *testing.T) {
function TestGetTypeName (line 447) | func TestGetTypeName(t *testing.T) {
function TestHandleRecover (line 459) | func TestHandleRecover(t *testing.T) {
function TestCheckCommandWithoutArgs (line 467) | func TestCheckCommandWithoutArgs(t *testing.T) {
function TestClRangeStmt (line 477) | func TestClRangeStmt(t *testing.T) {
function TestGetStringConst (line 494) | func TestGetStringConst(t *testing.T) {
function TestSpxRef (line 501) | func TestSpxRef(t *testing.T) {
function isError (line 513) | func isError(e any, msg string) bool {
function TestGmxProject (line 525) | func TestGmxProject(t *testing.T) {
function TestSpxLookup (line 565) | func TestSpxLookup(t *testing.T) {
function lookupClass (line 574) | func lookupClass(ext string) (c *modfile.Project, ok bool) {
function lookupClassErr (line 585) | func lookupClassErr(ext string) (c *modfile.Project, ok bool) {
function TestGetGoFile (line 596) | func TestGetGoFile(t *testing.T) {
function TestErrNewType (line 614) | func TestErrNewType(t *testing.T) {
function TestErrCompileBasicLit (line 624) | func TestErrCompileBasicLit(t *testing.T) {
function testPanic (line 631) | func testPanic(t *testing.T, panicMsg string, doPanic func()) {
function TestClassFileEnd (line 644) | func TestClassFileEnd(t *testing.T) {
FILE: cl/c.go
constant pathLibc (line 26) | pathLibc = "github.com/goplus/lib/c"
constant pathLibpy (line 27) | pathLibpy = "github.com/goplus/lib/py"
constant pathLibcpp (line 28) | pathLibcpp = "github.com/goplus/lib/cpp"
function simplifyXgoPackage (line 31) | func simplifyXgoPackage(pkgPath string) string {
function simplifyPkgPath (line 38) | func simplifyPkgPath(pkgPath string) string {
FILE: cl/classfile.go
type gmxClass (line 39) | type gmxClass struct
method getName (line 47) | func (p *gmxClass) getName(ctx *pkgCtx) string {
type spxObj (line 55) | type spxObj struct
function spriteByProto (line 65) | func spriteByProto(sprites []*spxObj, proto string) *spxObj {
type gmxProject (line 74) | type gmxProject struct
method embed (line 90) | func (p *gmxProject) embed(chk func(name string) bool, flds []*types.V...
method getGameClass (line 158) | func (p *gmxProject) getGameClass(ctx *pkgCtx) string {
method hasMain (line 179) | func (p *gmxProject) hasMain() bool {
method getScheds (line 187) | func (p *gmxProject) getScheds(cb *gogen.CodeBuilder) []goast.Stmt {
type spriteFeat (line 105) | type spriteFeat
constant spriteClassfname (line 108) | spriteClassfname spriteFeat = 1 << iota
constant spriteClassclone (line 109) | spriteClassclone
constant spriteEmbedded (line 111) | spriteEmbedded spriteFeat = 0x80
function spriteFeature (line 114) | func spriteFeature(elt types.Type, sp *spxObj) {
function spriteFeatures (line 128) | func spriteFeatures(game gogen.Ref, sprites []*spxObj) {
function isTestClass (line 174) | func isTestClass(pkg gogen.PkgRef) bool {
function ClassNameAndExt (line 208) | func ClassNameAndExt(file string) (name, clsfile, ext string) {
function GetFileClassType (line 222) | func GetFileClassType(file *ast.File, filename string, lookupClass func(...
function isGoxTestFile (line 247) | func isGoxTestFile(ext string) bool {
function loadClass (line 251) | func loadClass(ctx *pkgCtx, pkg *gogen.Package, file string, f *ast.File...
function spName (line 341) | func spName(sp *spxObj, name string) string {
function getSpxObj (line 351) | func getSpxObj(p *gmxProject, ext string) *spxObj {
function spxLookup (line 360) | func spxLookup(pkgImps []gogen.PkgRef, name string) gogen.Ref {
function spxTryRef (line 369) | func spxTryRef(spx gogen.PkgRef, typ string) (obj types.Object, isPtr bo...
function spxRef (line 377) | func spxRef(spx gogen.PkgRef, typ string) (obj gogen.Ref, isPtr bool) {
function getStringConst (line 385) | func getStringConst(spx gogen.PkgRef, name string) string {
function setBodyHandler (line 394) | func setBodyHandler(ctx *blockCtx) {
constant casePrefix (line 409) | casePrefix = "case"
function testNameSuffix (line 412) | func testNameSuffix(testType string) string {
function gmxTestFunc (line 419) | func gmxTestFunc(pkg *gogen.Package, testType string, isProj bool) {
function genTestFunc (line 428) | func genTestFunc(pkg *gogen.Package, name, testType, param, paramType st...
function gmxCheckProjs (line 440) | func gmxCheckProjs(pkg *gogen.Package, ctx *pkgCtx) (*gmxProject, bool) {
function gmxProjMain (line 470) | func gmxProjMain(pkg *gogen.Package, parent *pkgCtx, proj *gmxProject) {
function genWorkClasses (line 580) | func genWorkClasses(
function genMainFunc (line 615) | func genMainFunc(pkg *gogen.Package, gameClass string) {
function findMethod (line 627) | func findMethod(o types.Object, name string) *types.Func {
function findMethodByType (line 634) | func findMethodByType(typ types.Type, name string) *types.Func {
function makeMainSig (line 646) | func makeMainSig(recv *types.Var, f *types.Func) *types.Signature {
function genClassfname (line 662) | func genClassfname(ctx *blockCtx, c *gmxClass) {
function genClassclone (line 671) | func genClassclone(ctx *blockCtx, classclone *types.Signature) {
function astEmptyEntrypoint (line 684) | func astEmptyEntrypoint(f *ast.File) {
function getEntrypoint (line 709) | func getEntrypoint(f *ast.File) string {
function inMainPkg (line 722) | func inMainPkg(f *ast.File) bool {
FILE: cl/cltest/cltest.go
function init (line 49) | func init() {
function LookupClass (line 68) | func LookupClass(ext string) (c *modfile.Project, ok bool) {
function Named (line 123) | func Named(t *testing.T, name string, gopcode, expected string) {
function Do (line 129) | func Do(t *testing.T, gopcode, expected string) {
function DoWithFname (line 133) | func DoWithFname(t *testing.T, gopcode, expected string, fname string) {
function DoExt (line 138) | func DoExt(t *testing.T, conf *cl.Config, pkgname, gopcode, expected str...
function Mixed (line 143) | func Mixed(t *testing.T, pkgname, gocode, gopcode, expected string, outl...
function DoFS (line 152) | func DoFS(
function FromDir (line 189) | func FromDir(t *testing.T, sel, relDir string) {
function testFrom (line 210) | func testFrom(t *testing.T, pkgDir, sel string) {
FILE: cl/cltest/error_msg.go
function Error (line 30) | func Error(t *testing.T, msg, src string) {
function ErrorEx (line 34) | func ErrorEx(t *testing.T, pkgname, filename, msg, src string) {
function ErrorAst (line 54) | func ErrorAst(t *testing.T, pkgname, filename, msg, src string) {
FILE: cl/cltest/recorder.go
type gopRecorder (line 25) | type gopRecorder struct
method Type (line 45) | func (info gopRecorder) Type(e ast.Expr, tv types.TypeAndValue) {
method Instantiate (line 60) | func (info gopRecorder) Instantiate(id *ast.Ident, inst types.Instance) {
method Def (line 72) | func (info gopRecorder) Def(id *ast.Ident, obj types.Object) {
method Use (line 80) | func (info gopRecorder) Use(id *ast.Ident, obj types.Object) {
method Implicit (line 91) | func (info gopRecorder) Implicit(node ast.Node, obj types.Object) {
method Select (line 96) | func (info gopRecorder) Select(e *ast.SelectorExpr, sel *types.Selecti...
method Scope (line 122) | func (info gopRecorder) Scope(n ast.Node, scope *types.Scope) {
FILE: cl/cltest/spx.go
function spxParserConf (line 37) | func spxParserConf() parser.Config {
function Spx (line 50) | func Spx(t *testing.T, gmx, spxcode, expected string) {
function SpxEx (line 54) | func SpxEx(t *testing.T, gmx, spxcode, expected, gmxfile, spxfile string) {
function SpxEx2 (line 58) | func SpxEx2(t *testing.T, gmx, spxcode, expected, gmxfile, spxfile, resu...
function SpxWithConf (line 62) | func SpxWithConf(t *testing.T, name string, conf *cl.Config, gmx, spxcod...
function SpxTest (line 72) | func SpxTest(t *testing.T, fs fsx.FileSystem, dir string, parseConf pars...
function SpxErrorFS (line 101) | func SpxErrorFS(t *testing.T, msg string, fs parser.FileSystem) {
function SpxErrorEx (line 121) | func SpxErrorEx(t *testing.T, msg, gmx, spxcode, gmxfile, spxfile string) {
function SpxFromDir (line 142) | func SpxFromDir(t *testing.T, sel, relDir string) {
function testSpxFrom (line 163) | func testSpxFrom(t *testing.T, pkgDir, sel string) {
FILE: cl/compile.go
type dbgFlags (line 39) | type dbgFlags
constant DbgFlagLoad (line 42) | DbgFlagLoad dbgFlags = 1 << iota
constant DbgFlagLookup (line 43) | DbgFlagLookup
constant FlagNoMarkAutogen (line 44) | FlagNoMarkAutogen
constant DbgFlagAll (line 45) | DbgFlagAll = DbgFlagLoad | DbgFlagLookup
function SetDisableRecover (line 58) | func SetDisableRecover(disableRecover bool) {
function SetDebug (line 62) | func SetDebug(flags dbgFlags) {
type Recorder (line 71) | type Recorder interface
type Config (line 176) | type Config struct
type nodeInterp (line 210) | type nodeInterp struct
method Position (line 216) | func (p *nodeInterp) Position(start token.Pos) (pos token.Position) {
method Caller (line 222) | func (p *nodeInterp) Caller(node ast.Node) string {
method LoadExpr (line 229) | func (p *nodeInterp) LoadExpr(node ast.Node) string {
method ProjFile (line 240) | func (p *nodeInterp) ProjFile() *ast.File {
type loader (line 249) | type loader interface
type baseLoader (line 254) | type baseLoader struct
method load (line 276) | func (p *baseLoader) load() {
method pos (line 280) | func (p *baseLoader) pos() token.Pos {
function initLoader (line 259) | func initLoader(ctx *pkgCtx, syms map[string]loader, start, end token.Po...
type typeLoader (line 284) | type typeLoader struct
method pos (line 311) | func (p *typeLoader) pos() token.Pos {
method load (line 315) | func (p *typeLoader) load() {
function getTypeLoader (line 290) | func getTypeLoader(ctx *pkgCtx, syms map[string]loader, start, end token...
function doNewType (line 321) | func doNewType(ld *typeLoader) {
function doInitType (line 328) | func doInitType(ld *typeLoader) {
function doInitMethods (line 335) | func doInitMethods(ld *typeLoader) {
type pkgCtx (line 344) | type pkgCtx struct
method newCodeError (line 424) | func (p *pkgCtx) newCodeError(pos, end token.Pos, msg string) error {
method newCodeErrorf (line 428) | func (p *pkgCtx) newCodeErrorf(pos, end token.Pos, format string, args...
method handleErrorf (line 432) | func (p *pkgCtx) handleErrorf(pos, end token.Pos, format string, args ...
method handleErr (line 436) | func (p *pkgCtx) handleErr(err error) {
method loadNamed (line 440) | func (p *pkgCtx) loadNamed(at *gogen.Package, t *types.Named) {
method complete (line 447) | func (p *pkgCtx) complete() error {
method loadType (line 451) | func (p *pkgCtx) loadType(name string) {
method loadSymbol (line 459) | func (p *pkgCtx) loadSymbol(name string) bool {
method handleRecover (line 479) | func (p *pkgCtx) handleRecover(e any, src ast.Node) {
method recoverErr (line 484) | func (p *pkgCtx) recoverErr(e any, src ast.Node) error {
method lookupClassNode (line 498) | func (p *pkgCtx) lookupClassNode(name string) ast.Node {
type pkgImp (line 365) | type pkgImp struct
type blockCtx (line 370) | type blockCtx struct
method cstr (line 395) | func (p *blockCtx) cstr() gogen.Ref {
method pystr (line 402) | func (p *blockCtx) pystr() gogen.Ref {
method recorder (line 409) | func (p *blockCtx) recorder() *goxRecorder {
method findImport (line 416) | func (p *blockCtx) findImport(name string) (pi pkgImp, ok bool) {
function embeddedFieldCast (line 510) | func embeddedFieldCast(o *types.Struct, tn *types.Named, pv *gogen.Eleme...
function implicitCast (line 552) | func implicitCast(pkg *gogen.Package, V, T types.Type, pv *gogen.Element...
constant defaultGoFile (line 568) | defaultGoFile = ""
constant skippingGoFile (line 569) | skippingGoFile = "_skip"
constant testingGoFile (line 570) | testingGoFile = "_test"
function NewPackage (line 574) | func NewPackage(pkgPath string, pkg *ast.Package, conf *Config) (p *goge...
function isOverloadFunc (line 735) | func isOverloadFunc(name string) bool {
function initXGoPkg (line 740) | func initXGoPkg(ctx *pkgCtx, pkg *gogen.Package, gopSyms map[string]bool) {
function loadFile (line 761) | func loadFile(ctx *pkgCtx, f *ast.File) {
function genGoFile (line 797) | func genGoFile(file string, goxTestFile bool) string {
function preloadXGoFile (line 804) | func preloadXGoFile(p *gogen.Package, ctx *blockCtx, file string, f *ast...
function parseTypeEmbedName (line 1003) | func parseTypeEmbedName(typ ast.Expr) *ast.Ident {
function preloadFile (line 1017) | func preloadFile(p *gogen.Package, ctx *blockCtx, f *ast.File, goFile st...
function checkOverloadMethodRecvType (line 1343) | func checkOverloadMethodRecvType(ot *ast.Ident, recv ast.Expr) (*ast.Ide...
constant indexTable (line 1356) | indexTable = "0123456789abcdefghijklmnopqrstuvwxyz"
function overloadFuncName (line 1359) | func overloadFuncName(name string, idx int) string {
function overloadName (line 1363) | func overloadName(recv *ast.Ident, name string, isOp bool) (string, erro...
function staticMethod (line 1382) | func staticMethod(tname, name string) string {
function stringLit (line 1390) | func stringLit(val string) *ast.BasicLit {
function newType (line 1394) | func newType(pkg *types.Package, pos token.Pos, name string) *types.Named {
function aliasType (line 1402) | func aliasType(ctx *blockCtx, pkg *types.Package, pos token.Pos, name st...
function loadFunc (line 1423) | func loadFunc(ctx *blockCtx, recv *types.Var, name string, d *ast.FuncDe...
function shouldCallXGoInit (line 1548) | func shouldCallXGoInit(recv *types.Var) bool {
function loadFuncBody (line 1556) | func loadFuncBody(ctx *blockCtx, fn *gogen.Func, body *ast.BlockStmt, si...
function loadImport (line 1588) | func loadImport(ctx *blockCtx, spec *ast.ImportSpec) {
function loadConstSpecs (line 1632) | func loadConstSpecs(ctx *blockCtx, cdecl *gogen.ConstDefs, specs []ast.S...
function loadConsts (line 1639) | func loadConsts(ctx *blockCtx, cdecl *gogen.ConstDefs, v *ast.ValueSpec,...
function loadVars (line 1667) | func loadVars(ctx *blockCtx, v *ast.ValueSpec, doc *ast.CommentGroup, gl...
function makeInitExpr (line 1688) | func makeInitExpr(ctx *blockCtx, v *ast.ValueSpec, typ types.Type, names...
function defNames (line 1722) | func defNames(ctx *blockCtx, names []*ast.Ident, scope *types.Scope) {
function makeNames (line 1735) | func makeNames(vals []*ast.Ident) []string {
function removeNames (line 1743) | func removeNames(syms map[string]loader, names []*ast.Ident) {
function setNamesLoader (line 1749) | func setNamesLoader(ctx *pkgCtx, syms map[string]loader, names []*ast.Id...
FILE: cl/compile_spx_test.go
function gopSpxTest (line 27) | func gopSpxTest(t *testing.T, gmx, spxcode, expected string) {
function gopSpxTestEx (line 31) | func gopSpxTestEx(t *testing.T, gmx, spxcode, expected, gmxfile, spxfile...
function gopSpxTestEx2 (line 35) | func gopSpxTestEx2(t *testing.T, gmx, spxcode, expected, gmxfile, spxfil...
function gopSpxTestExConf (line 39) | func gopSpxTestExConf(t *testing.T, name string, conf *cl.Config, gmx, s...
function gopSpxErrorTestEx (line 43) | func gopSpxErrorTestEx(t *testing.T, msg, gmx, spxcode, gmxfile, spxfile...
function gopSpxErrorTestMap (line 47) | func gopSpxErrorTestMap(t *testing.T, msg string, dirs map[string][]stri...
function TestSpxError (line 51) | func TestSpxError(t *testing.T) {
function TestSpxBasic (line 140) | func TestSpxBasic(t *testing.T) {
function TestEnvOp (line 194) | func TestEnvOp(t *testing.T) {
function TestSpxXGoEnv (line 226) | func TestSpxXGoEnv(t *testing.T) {
function TestSpxXGoExec (line 259) | func TestSpxXGoExec(t *testing.T) {
function TestSpxMethod (line 300) | func TestSpxMethod(t *testing.T) {
function TestSpxVar (line 355) | func TestSpxVar(t *testing.T) {
function TestSpxRun (line 414) | func TestSpxRun(t *testing.T) {
function TestSpx2 (line 460) | func TestSpx2(t *testing.T) {
function TestSpxMainEntry (line 497) | func TestSpxMainEntry(t *testing.T) {
function TestSpxGoxBasic (line 603) | func TestSpxGoxBasic(t *testing.T) {
function TestSpxClone (line 651) | func TestSpxClone(t *testing.T) {
function TestSpxErrorEnv (line 725) | func TestSpxErrorEnv(t *testing.T) {
function TestSpxErrorSel (line 731) | func TestSpxErrorSel(t *testing.T) {
function TestSpxMethodSel (line 739) | func TestSpxMethodSel(t *testing.T) {
function TestSpxPkgOverload (line 773) | func TestSpxPkgOverload(t *testing.T) {
function TestSpxSelection (line 812) | func TestSpxSelection(t *testing.T) {
function TestSpxOverload (line 876) | func TestSpxOverload(t *testing.T) {
function TestTestClassFile (line 985) | func TestTestClassFile(t *testing.T) {
function TestTestClassFile2 (line 1026) | func TestTestClassFile2(t *testing.T) {
function TestGoxNoFunc (line 1051) | func TestGoxNoFunc(t *testing.T) {
function TestGoxOverload (line 1064) | func TestGoxOverload(t *testing.T) {
function TestClassFileGox (line 1100) | func TestClassFileGox(t *testing.T) {
function TestClassFileMember (line 1193) | func TestClassFileMember(t *testing.T) {
FILE: cl/compile_test.go
constant gopRootDir (line 30) | gopRootDir = ".."
function init (line 37) | func init() {
function gopClNamedTest (line 50) | func gopClNamedTest(t *testing.T, name string, gopcode, expected string) {
function gopClTest (line 54) | func gopClTest(t *testing.T, gopcode, expected string) {
function gopClTestFile (line 58) | func gopClTestFile(t *testing.T, gopcode, expected string, fname string) {
function gopClTestEx (line 62) | func gopClTestEx(t *testing.T, conf *cl.Config, pkgname, gopcode, expect...
function gopMixedClTest (line 66) | func gopMixedClTest(t *testing.T, pkgname, gocode, gopcode, expected str...
function TestTypeDoc (line 70) | func TestTypeDoc(t *testing.T) {
function TestUnsafe (line 82) | func TestUnsafe(t *testing.T) {
function Test_CastSlice_Issue1240 (line 100) | func Test_CastSlice_Issue1240(t *testing.T) {
function TestUnderscoreRedeclared_Issue1197 (line 126) | func TestUnderscoreRedeclared_Issue1197(t *testing.T) {
function TestInterfaceBugNilUnderlying_Issue1198 (line 139) | func TestInterfaceBugNilUnderlying_Issue1198(t *testing.T) {
function TestInterfaceBugNilUnderlying_Issue1196 (line 183) | func TestInterfaceBugNilUnderlying_Issue1196(t *testing.T) {
function TestMyIntInc_Issue1195 (line 229) | func TestMyIntInc_Issue1195(t *testing.T) {
function TestAutoPropMixedName_Issue1194 (line 246) | func TestAutoPropMixedName_Issue1194(t *testing.T) {
function TestShiftUntypedInt_Issue1193 (line 282) | func TestShiftUntypedInt_Issue1193(t *testing.T) {
function TestInitFunc (line 294) | func TestInitFunc(t *testing.T) {
function TestSlogan (line 308) | func TestSlogan(t *testing.T) {
function TestAssignPrintln (line 326) | func TestAssignPrintln(t *testing.T) {
function TestRedefineBuiltin (line 341) | func TestRedefineBuiltin(t *testing.T) {
function TestTypeConvIssue804 (line 364) | func TestTypeConvIssue804(t *testing.T) {
function TestUntypedFloatIssue798 (line 385) | func TestUntypedFloatIssue798(t *testing.T) {
function TestInterfaceIssue795 (line 407) | func TestInterfaceIssue795(t *testing.T) {
function TestChanRecvIssue789 (line 440) | func TestChanRecvIssue789(t *testing.T) {
function TestNamedChanCloseIssue790 (line 455) | func TestNamedChanCloseIssue790(t *testing.T) {
function TestUntypedFloatIssue793 (line 472) | func TestUntypedFloatIssue793(t *testing.T) {
function TestUntypedFloatIssue788 (line 481) | func TestUntypedFloatIssue788(t *testing.T) {
function TestSwitchCompositeLitIssue801 (line 494) | func TestSwitchCompositeLitIssue801(t *testing.T) {
function TestConstIssue800 (line 519) | func TestConstIssue800(t *testing.T) {
function TestConstIssue805 (line 534) | func TestConstIssue805(t *testing.T) {
function TestUntypedNilIssue806 (line 565) | func TestUntypedNilIssue806(t *testing.T) {
function TestSwitchIssue807 (line 581) | func TestSwitchIssue807(t *testing.T) {
function TestUntypedComplexIssue799 (line 596) | func TestUntypedComplexIssue799(t *testing.T) {
function TestUnderscoreConstAndVar (line 615) | func TestUnderscoreConstAndVar(t *testing.T) {
function TestUnderscoreFuncAndMethod (line 652) | func TestUnderscoreFuncAndMethod(t *testing.T) {
function TestErrWrapIssue772 (line 683) | func TestErrWrapIssue772(t *testing.T) {
function TestErrWrapIssue778 (line 719) | func TestErrWrapIssue778(t *testing.T) {
function TestIssue774 (line 750) | func TestIssue774(t *testing.T) {
function TestBlockStmt (line 842) | func TestBlockStmt(t *testing.T) {
function TestConstTypeConvIssue792 (line 877) | func TestConstTypeConvIssue792(t *testing.T) {
function TestVarInitTwoValueIssue791 (line 888) | func TestVarInitTwoValueIssue791(t *testing.T) {
function TestVarAfterMain (line 901) | func TestVarAfterMain(t *testing.T) {
function TestVarAfterMain2 (line 944) | func TestVarAfterMain2(t *testing.T) {
function TestVarInMain (line 965) | func TestVarInMain(t *testing.T) {
function TestSelect (line 985) | func TestSelect(t *testing.T) {
function TestTypeSwitch (line 1015) | func TestTypeSwitch(t *testing.T) {
function TestTypeSwitch2 (line 1048) | func TestTypeSwitch2(t *testing.T) {
function TestTypeAssert (line 1073) | func TestTypeAssert(t *testing.T) {
function TestInterface (line 1089) | func TestInterface(t *testing.T) {
function TestInterfaceEmbedded (line 1111) | func TestInterfaceEmbedded(t *testing.T) {
function TestInterfaceExample (line 1131) | func TestInterfaceExample(t *testing.T) {
function TestEmbeddField (line 1206) | func TestEmbeddField(t *testing.T) {
function TestAutoProperty (line 1221) | func TestAutoProperty(t *testing.T) {
function TestSimplifyAutoProperty (line 1255) | func TestSimplifyAutoProperty(t *testing.T) {
function TestErrWrapBasic (line 1289) | func TestErrWrapBasic(t *testing.T) {
function TestErrWrapDefVal (line 1331) | func TestErrWrapDefVal(t *testing.T) {
function TestErrWrapPanic (line 1362) | func TestErrWrapPanic(t *testing.T) {
function TestErrWrapCommand (line 1384) | func TestErrWrapCommand(t *testing.T) {
function TestErrWrapCall (line 1412) | func TestErrWrapCall(t *testing.T) {
function TestMakeAndNew (line 1440) | func TestMakeAndNew(t *testing.T) {
function TestVarDecl (line 1453) | func TestVarDecl(t *testing.T) {
function TestUint128Add (line 1464) | func TestUint128Add(t *testing.T) {
function TestInt128Add (line 1477) | func TestInt128Add(t *testing.T) {
function TestBigIntAdd (line 1490) | func TestBigIntAdd(t *testing.T) {
function TestBigIntLit (line 1503) | func TestBigIntLit(t *testing.T) {
function TestUint128Lit (line 1517) | func TestUint128Lit(t *testing.T) {
function TestInt128Lit (line 1528) | func TestInt128Lit(t *testing.T) {
function TestBigRatLit (line 1539) | func TestBigRatLit(t *testing.T) {
function TestBigRatLitAdd (line 1553) | func TestBigRatLitAdd(t *testing.T) {
function TestBigRatAdd (line 1567) | func TestBigRatAdd(t *testing.T) {
function TestTypeConv (line 1586) | func TestTypeConv(t *testing.T) {
function TestStar (line 1604) | func TestStar(t *testing.T) {
function TestLHS (line 1615) | func TestLHS(t *testing.T) {
function TestSend (line 1641) | func TestSend(t *testing.T) {
function TestIncDec (line 1655) | func TestIncDec(t *testing.T) {
function TestAssignOp (line 1669) | func TestAssignOp(t *testing.T) {
function TestBigIntAssignOp (line 1683) | func TestBigIntAssignOp(t *testing.T) {
function TestBigIntAssignOp2 (line 1699) | func TestBigIntAssignOp2(t *testing.T) {
function TestBigIntAssignOp3 (line 1717) | func TestBigIntAssignOp3(t *testing.T) {
function TestCompositeLit (line 1735) | func TestCompositeLit(t *testing.T) {
function TestCompositeLit2 (line 1752) | func TestCompositeLit2(t *testing.T) {
function TestCompositeLit3 (line 1794) | func TestCompositeLit3(t *testing.T) {
function TestCompositeLit4 (line 1830) | func TestCompositeLit4(t *testing.T) {
function TestCompositeLit5 (line 1851) | func TestCompositeLit5(t *testing.T) {
function TestSliceLit (line 1867) | func TestSliceLit(t *testing.T) {
function TestChan (line 1895) | func TestChan(t *testing.T) {
function TestKeyValModeLit (line 1912) | func TestKeyValModeLit(t *testing.T) {
function TestStructLit (line 1925) | func TestStructLit(t *testing.T) {
function TestStructType (line 1957) | func TestStructType(t *testing.T) {
function TestDeferGo (line 1991) | func TestDeferGo(t *testing.T) {
function TestFor (line 2006) | func TestFor(t *testing.T) {
function TestRangeStmt (line 2031) | func TestRangeStmt(t *testing.T) {
function TestRangeStmtUDT (line 2079) | func TestRangeStmtUDT(t *testing.T) {
function TestForPhraseUDT (line 2107) | func TestForPhraseUDT(t *testing.T) {
function TestForPhraseUDT2 (line 2135) | func TestForPhraseUDT2(t *testing.T) {
function TestForPhraseUDT3 (line 2182) | func TestForPhraseUDT3(t *testing.T) {
function TestForPhraseUDT4 (line 2211) | func TestForPhraseUDT4(t *testing.T) {
function TestForPhrase (line 2281) | func TestForPhrase(t *testing.T) {
function TestExistsComprehension (line 2310) | func TestExistsComprehension(t *testing.T) {
function TestSliceGet (line 2328) | func TestSliceGet(t *testing.T) {
function TestIndexGetTwoValue (line 2347) | func TestIndexGetTwoValue(t *testing.T) {
function TestIndexGet (line 2362) | func TestIndexGet(t *testing.T) {
function TestIndexRef (line 2375) | func TestIndexRef(t *testing.T) {
function TestIndexArrayPtrIssue784 (line 2388) | func TestIndexArrayPtrIssue784(t *testing.T) {
function TestMemberVal (line 2405) | func TestMemberVal(t *testing.T) {
function TestNamedPtrMemberIssue786 (line 2424) | func TestNamedPtrMemberIssue786(t *testing.T) {
function TestMember (line 2450) | func TestMember(t *testing.T) {
function TestElem (line 2480) | func TestElem(t *testing.T) {
function TestNamedPtrIssue797 (line 2496) | func TestNamedPtrIssue797(t *testing.T) {
function TestMethod (line 2513) | func TestMethod(t *testing.T) {
function TestCmdlineNoEOL (line 2539) | func TestCmdlineNoEOL(t *testing.T) {
function TestImport (line 2550) | func TestImport(t *testing.T) {
function TestDotImport (line 2565) | func TestDotImport(t *testing.T) {
function TestLocalImport (line 2577) | func TestLocalImport(t *testing.T) {
function TestImportUnused (line 2589) | func TestImportUnused(t *testing.T) {
function TestImportForceUsed (line 2600) | func TestImportForceUsed(t *testing.T) {
function TestAnonymousImport (line 2613) | func TestAnonymousImport(t *testing.T) {
function TestVarAndConst (line 2627) | func TestVarAndConst(t *testing.T) {
function TestDeclStmt (line 2645) | func TestDeclStmt(t *testing.T) {
function TestIf (line 2670) | func TestIf(t *testing.T) {
function TestSwitch (line 2698) | func TestSwitch(t *testing.T) {
function TestSwitchFallthrough (line 2749) | func TestSwitchFallthrough(t *testing.T) {
function TestBranchStmt (line 2781) | func TestBranchStmt(t *testing.T) {
function TestReturn (line 2812) | func TestReturn(t *testing.T) {
function TestReturnExpr (line 2832) | func TestReturnExpr(t *testing.T) {
function TestClosure (line 2850) | func TestClosure(t *testing.T) {
function TestFunc (line 2868) | func TestFunc(t *testing.T) {
function TestLambdaExpr (line 2882) | func TestLambdaExpr(t *testing.T) {
function TestLambdaExpr2 (line 2987) | func TestLambdaExpr2(t *testing.T) {
function TestLambdaExpr3 (line 3115) | func TestLambdaExpr3(t *testing.T) {
function TestUnnamedMainFunc (line 3148) | func TestUnnamedMainFunc(t *testing.T) {
function TestFuncAsParam (line 3157) | func TestFuncAsParam(t *testing.T) {
function TestFuncAsParam2 (line 3178) | func TestFuncAsParam2(t *testing.T) {
function TestFuncCall (line 3225) | func TestFuncCall(t *testing.T) {
function TestFuncCallEllipsis (line 3238) | func TestFuncCallEllipsis(t *testing.T) {
function TestFuncCallCodeOrder (line 3258) | func TestFuncCallCodeOrder(t *testing.T) {
function TestInterfaceMethods (line 3281) | func TestInterfaceMethods(t *testing.T) {
function TestAssignUnderscore (line 3299) | func TestAssignUnderscore(t *testing.T) {
function TestOperator (line 3313) | func TestOperator(t *testing.T) {
function removeAutogenFiles (line 3334) | func removeAutogenFiles() {
function TestImportGopPkg (line 3340) | func TestImportGopPkg(t *testing.T) {
function TestCallDep (line 3363) | func TestCallDep(t *testing.T) {
function TestGoFuncInstr (line 3427) | func TestGoFuncInstr(t *testing.T) {
function TestGoTypeInstr (line 3443) | func TestGoTypeInstr(t *testing.T) {
function TestNoEntrypoint (line 3456) | func TestNoEntrypoint(t *testing.T) {
function TestParentExpr (line 3478) | func TestParentExpr(t *testing.T) {
function TestCommandStyle (line 3488) | func TestCommandStyle(t *testing.T) {
function TestTypeLoader (line 3503) | func TestTypeLoader(t *testing.T) {
function TestCallPrintln (line 3529) | func TestCallPrintln(t *testing.T) {
function TestAnyAlias (line 3552) | func TestAnyAlias(t *testing.T) {
function TestMainEntry (line 3568) | func TestMainEntry(t *testing.T) {
function TestCommandNotExpr (line 3607) | func TestCommandNotExpr(t *testing.T) {
function TestCommentLine (line 3644) | func TestCommentLine(t *testing.T) {
function TestCommentLineRoot (line 3694) | func TestCommentLineRoot(t *testing.T) {
function TestRangeScope (line 3749) | func TestRangeScope(t *testing.T) {
function TestSelectScope (line 3772) | func TestSelectScope(t *testing.T) {
function TestCommentVar (line 3805) | func TestCommentVar(t *testing.T) {
function TestForPhraseScope (line 3874) | func TestForPhraseScope(t *testing.T) {
function TestAddress (line 3919) | func TestAddress(t *testing.T) {
function TestSliceLitAssign (line 3973) | func TestSliceLitAssign(t *testing.T) {
function TestSliceLitReturn (line 3993) | func TestSliceLitReturn(t *testing.T) {
function TestCompositeLitAssign (line 4014) | func TestCompositeLitAssign(t *testing.T) {
function TestCompositeLitStruct (line 4044) | func TestCompositeLitStruct(t *testing.T) {
function TestCompositeLitEx (line 4075) | func TestCompositeLitEx(t *testing.T) {
function TestCommentFunc (line 4102) | func TestCommentFunc(t *testing.T) {
FILE: cl/compile_testdir_test.go
function TestTestspx (line 25) | func TestTestspx(t *testing.T) {
function TestTestgop (line 29) | func TestTestgop(t *testing.T) {
function TestTestc (line 33) | func TestTestc(t *testing.T) {
function TestTestpy (line 37) | func TestTestpy(t *testing.T) {
FILE: cl/compile_xgo_test.go
function TestArrowOp (line 24) | func TestArrowOp(t *testing.T) {
function TestMapLit (line 52) | func TestMapLit(t *testing.T) {
function TestMayBuiltinDelete (line 67) | func TestMayBuiltinDelete(t *testing.T) {
function TestVargCommand (line 88) | func TestVargCommand(t *testing.T) {
function TestCommandInPkg (line 112) | func TestCommandInPkg(t *testing.T) {
function TestFuncAlias (line 128) | func TestFuncAlias(t *testing.T) {
function TestOverloadOp (line 145) | func TestOverloadOp(t *testing.T) {
function TestOverloadOp2 (line 210) | func TestOverloadOp2(t *testing.T) {
function TestOverloadMethod (line 267) | func TestOverloadMethod(t *testing.T) {
function TestOverloadFunc (line 314) | func TestOverloadFunc(t *testing.T) {
function TestOverloadFunc2 (line 344) | func TestOverloadFunc2(t *testing.T) {
function TestOverloadFunc3 (line 380) | func TestOverloadFunc3(t *testing.T) {
function TestOverload (line 420) | func TestOverload(t *testing.T) {
function TestMixedOverload (line 534) | func TestMixedOverload(t *testing.T) {
function TestMixedOverloadOp (line 726) | func TestMixedOverloadOp(t *testing.T) {
function TestMixedVector3 (line 767) | func TestMixedVector3(t *testing.T) {
function TestMixedInterfaceOverload (line 834) | func TestMixedInterfaceOverload(t *testing.T) {
function TestMixedOverloadCommand (line 905) | func TestMixedOverloadCommand(t *testing.T) {
function TestOverloadNamed (line 935) | func TestOverloadNamed(t *testing.T) {
function TestMixedOverloadNamed (line 957) | func TestMixedOverloadNamed(t *testing.T) {
function TestStringLitBasic (line 998) | func TestStringLitBasic(t *testing.T) {
function TestStringLitVar (line 1009) | func TestStringLitVar(t *testing.T) {
function TestFileOpen (line 1027) | func TestFileOpen(t *testing.T) {
function TestMixedGo (line 1062) | func TestMixedGo(t *testing.T) {
function TestTypeAsParamsFunc (line 1127) | func TestTypeAsParamsFunc(t *testing.T) {
function TestYaptest (line 1182) | func TestYaptest(t *testing.T) {
function testRangeExpr (line 1209) | func testRangeExpr(t *testing.T, codeTpl, expect string) {
function TestRangeExpr (line 1219) | func TestRangeExpr(t *testing.T) {
function TestRangeExpr2 (line 1248) | func TestRangeExpr2(t *testing.T) {
function TestRangeExpr3 (line 1264) | func TestRangeExpr3(t *testing.T) {
function TestRangeExpr4 (line 1280) | func TestRangeExpr4(t *testing.T) {
function TestRangeExpr5 (line 1296) | func TestRangeExpr5(t *testing.T) {
function TestRangeExpr6 (line 1312) | func TestRangeExpr6(t *testing.T) {
function testRangeExpr8 (line 1328) | func testRangeExpr8(t *testing.T, codeTpl, expect string) {
function TestRangeExpr8 (line 1334) | func TestRangeExpr8(t *testing.T) {
function TestRangeExpr9 (line 1378) | func TestRangeExpr9(t *testing.T) {
function TestRangeExpr10 (line 1424) | func TestRangeExpr10(t *testing.T) {
function Test_RangeExpressionIf_Issue1243 (line 1441) | func Test_RangeExpressionIf_Issue1243(t *testing.T) {
function TestStaticMethod (line 1459) | func TestStaticMethod(t *testing.T) {
function TestOverlodOptions (line 1488) | func TestOverlodOptions(t *testing.T) {
function TestEmbedField (line 1515) | func TestEmbedField(t *testing.T) {
function TestOverloadUntyped (line 1548) | func TestOverloadUntyped(t *testing.T) {
function TestOverloadUntyped2 (line 1582) | func TestOverloadUntyped2(t *testing.T) {
function TestSliceType (line 1607) | func TestSliceType(t *testing.T) {
function TestMapLitType (line 1624) | func TestMapLitType(t *testing.T) {
FILE: cl/error_msg_test.go
function codeErrorTest (line 28) | func codeErrorTest(t *testing.T, msg, src string) {
function codeErrorTestEx (line 32) | func codeErrorTestEx(t *testing.T, pkgname, filename, msg, src string) {
function codeErrorTestAst (line 36) | func codeErrorTestAst(t *testing.T, pkgname, filename, msg, src string) {
function TestErrTplLit (line 40) | func TestErrTplLit(t *testing.T) {
function TestErrSendStmt (line 46) | func TestErrSendStmt(t *testing.T) {
function TestErrVargCommand (line 53) | func TestErrVargCommand(t *testing.T) {
function TestErrUnsafe (line 75) | func TestErrUnsafe(t *testing.T) {
function TestErrLambdaExpr (line 81) | func TestErrLambdaExpr(t *testing.T) {
function TestErrErrWrap (line 182) | func TestErrErrWrap(t *testing.T) {
function TestErrVar (line 190) | func TestErrVar(t *testing.T) {
function TestErrImport (line 271) | func TestErrImport(t *testing.T) {
function TestErrConst (line 308) | func TestErrConst(t *testing.T) {
function TestErrNewVar (line 323) | func TestErrNewVar(t *testing.T) {
function TestErrDefineVar (line 331) | func TestErrDefineVar(t *testing.T) {
function TestErrAssignMismatchT (line 339) | func TestErrAssignMismatchT(t *testing.T) {
function TestErrAssign (line 363) | func TestErrAssign(t *testing.T) {
function TestErrReturn (line 382) | func TestErrReturn(t *testing.T) {
function TestErrForRange (line 446) | func TestErrForRange(t *testing.T) {
function TestErrInitFunc (line 456) | func TestErrInitFunc(t *testing.T) {
function TestErrRecv (line 464) | func TestErrRecv(t *testing.T) {
function TestErrEnvOp (line 490) | func TestErrEnvOp(t *testing.T) {
function TestErrStringLit (line 499) | func TestErrStringLit(t *testing.T) {
function TestErrStructLit (line 505) | func TestErrStructLit(t *testing.T) {
function TestErrArray (line 527) | func TestErrArray(t *testing.T) {
function TestErrArrayLit (line 535) | func TestErrArrayLit(t *testing.T) {
function TestErrSliceLit (line 574) | func TestErrSliceLit(t *testing.T) {
function TestErrMapLit (line 595) | func TestErrMapLit(t *testing.T) {
function TestErrSlice (line 621) | func TestErrSlice(t *testing.T) {
function TestErrIndex (line 643) | func TestErrIndex(t *testing.T) {
function TestErrIndexRef (line 658) | func TestErrIndexRef(t *testing.T) {
function TestErrStar (line 667) | func TestErrStar(t *testing.T) {
function TestErrCondExpr (line 682) | func TestErrCondExpr(t *testing.T) {
function TestErrMember (line 693) | func TestErrMember(t *testing.T) {
function TestErrMemberRef (line 722) | func TestErrMemberRef(t *testing.T) {
function TestErrLabel (line 753) | func TestErrLabel(t *testing.T) {
function TestErrBranchStmt (line 773) | func TestErrBranchStmt(t *testing.T) {
function TestErrNoEntrypoint (line 781) | func TestErrNoEntrypoint(t *testing.T) {
function TestErrTypeRedefine (line 809) | func TestErrTypeRedefine(t *testing.T) {
function TestErrSwitchDuplicate (line 827) | func TestErrSwitchDuplicate(t *testing.T) {
function TestErrTypeSwitchDuplicate (line 908) | func TestErrTypeSwitchDuplicate(t *testing.T) {
function TestErrAutoProperty (line 940) | func TestErrAutoProperty(t *testing.T) {
function TestFiledsNameRedecl (line 948) | func TestFiledsNameRedecl(t *testing.T) {
function TestErrImportPkg (line 967) | func TestErrImportPkg(t *testing.T) {
function TestErrClassFileGopx (line 991) | func TestErrClassFileGopx(t *testing.T) {
function TestErrVarInFunc (line 1005) | func TestErrVarInFunc(t *testing.T) {
function TestErrInt128 (line 1020) | func TestErrInt128(t *testing.T) {
function TestErrUint128 (line 1036) | func TestErrUint128(t *testing.T) {
function TestErrCompileFunc (line 1055) | func TestErrCompileFunc(t *testing.T) {
function TestToTypeError (line 1061) | func TestToTypeError(t *testing.T) {
function TestCompileExprError (line 1068) | func TestCompileExprError(t *testing.T) {
function TestOverloadFuncDecl (line 1082) | func TestOverloadFuncDecl(t *testing.T) {
function TestCompositeLitError (line 1125) | func TestCompositeLitError(t *testing.T) {
FILE: cl/expr.go
constant clIdentCanAutoCall (line 62) | clIdentCanAutoCall = 1 << iota
constant clIdentAllowBuiltin (line 63) | clIdentAllowBuiltin
constant clIdentLHS (line 64) | clIdentLHS
constant clIdentSelectorExpr (line 65) | clIdentSelectorExpr
constant clIdentGoto (line 66) | clIdentGoto
constant clCommandWithoutArgs (line 67) | clCommandWithoutArgs
constant clCommandIdent (line 68) | clCommandIdent
constant clIdentInStringLitEx (line 69) | clIdentInStringLitEx
constant clInCallExpr (line 70) | clInCallExpr
constant objNormal (line 74) | objNormal = iota
constant objPkgRef (line 75) | objPkgRef
constant objXGoExecOrEnv (line 76) | objXGoExecOrEnv
constant objXGoEnv (line 78) | objXGoEnv = objXGoExecOrEnv
constant objXGoExec (line 79) | objXGoExec = objXGoExecOrEnv
function compileIdent (line 82) | func compileIdent(ctx *blockCtx, lhs int, ident *ast.Ident, flags int) (...
function compileEnvExpr (line 215) | func compileEnvExpr(ctx *blockCtx, lhs int, v *ast.EnvExpr) {
function classRecv (line 238) | func classRecv(cb *gogen.CodeBuilder) *types.Var {
function xgoOp (line 246) | func xgoOp(cb *gogen.CodeBuilder, recv *types.Var, op1, op2 string, src ...
function isBuiltin (line 257) | func isBuiltin(o types.Object) bool {
function compileMember (line 264) | func compileMember(ctx *blockCtx, lhs int, v ast.Node, name string, flag...
function compileExprLHS (line 278) | func compileExprLHS(ctx *blockCtx, expr ast.Expr) {
function identOrSelectorFlags (line 296) | func identOrSelectorFlags(inFlags []int) (flags int, cmdNoArgs bool) {
function callCmdNoArgs (line 312) | func callCmdNoArgs(ctx *blockCtx, src ast.Node, panicErr bool) (err erro...
function compileExpr (line 325) | func compileExpr(ctx *blockCtx, lhs int, expr ast.Expr, inFlags ...int) {
function compileExprOrNone (line 423) | func compileExprOrNone(ctx *blockCtx, expr ast.Expr) {
function compileUnaryExpr (line 431) | func compileUnaryExpr(ctx *blockCtx, lhs int, v *ast.UnaryExpr) {
function compileBinaryExpr (line 436) | func compileBinaryExpr(ctx *blockCtx, v *ast.BinaryExpr) {
function compileIndexExprLHS (line 442) | func compileIndexExprLHS(ctx *blockCtx, v *ast.IndexExpr) {
function compileStarExprLHS (line 448) | func compileStarExprLHS(ctx *blockCtx, v *ast.StarExpr) { // *x = ...
function compileStarExpr (line 453) | func compileStarExpr(ctx *blockCtx, v *ast.StarExpr) { // ... = *x
function compileTypeAssertExpr (line 458) | func compileTypeAssertExpr(ctx *blockCtx, lhs int, v *ast.TypeAssertExpr) {
function compileIndexExpr (line 467) | func compileIndexExpr(ctx *blockCtx, lhs int, v *ast.IndexExpr, inFlags ...
function compileIndexListExpr (line 473) | func compileIndexListExpr(ctx *blockCtx, lhs int, v *ast.IndexListExpr, ...
function compileSliceExpr (line 482) | func compileSliceExpr(ctx *blockCtx, v *ast.SliceExpr) { // x[i:j:k]
function compileSelectorExprLHS (line 492) | func compileSelectorExprLHS(ctx *blockCtx, v *ast.SelectorExpr) {
function compileCondExpr (line 505) | func compileCondExpr(ctx *blockCtx, v *ast.CondExpr) {
function newNodeSeqParam (line 559) | func newNodeSeqParam(pkgTypes *types.Package, nodeType types.Type) *type...
function compileAnySelectorExpr (line 566) | func compileAnySelectorExpr(ctx *blockCtx, lhs int, v *ast.AnySelectorEx...
function checkAnyOrMap (line 584) | func checkAnyOrMap(cb *gogen.CodeBuilder) *gogen.Element {
function convMapToNodeSet (line 598) | func convMapToNodeSet(cb *gogen.CodeBuilder) {
function compileSelectorExpr (line 608) | func compileSelectorExpr(ctx *blockCtx, lhs int, v *ast.SelectorExpr, fl...
function compileAttr (line 653) | func compileAttr(cb *gogen.CodeBuilder, lhs int, name string, v ast.Node...
function unquote (line 667) | func unquote(name string) string {
function compileFuncAlias (line 674) | func compileFuncAlias(ctx *blockCtx, lhs int, scope *types.Scope, x *ast...
function pkgRef (line 689) | func pkgRef(at gogen.PkgRef, name string) (o types.Object, alias bool) {
function lookupPkgRef (line 701) | func lookupPkgRef(ctx *blockCtx, pkg gogen.PkgRef, x *ast.Ident, pkgKind...
function compilePkgRef (line 721) | func compilePkgRef(ctx *blockCtx, lhs int, at gogen.PkgRef, x *ast.Ident...
function identVal (line 735) | func identVal(ctx *blockCtx, lhs int, x *ast.Ident, flags int, v types.O...
type fnType (line 754) | type fnType struct
method arg (line 766) | func (p *fnType) arg(i int, ellipsis bool) types.Type {
method init (line 780) | func (p *fnType) init(base int, t *types.Signature, typeAsParams bool) {
method initTypeType (line 791) | func (p *fnType) initTypeType(t *gogen.TypeType) {
method unpackTupleLit (line 797) | func (p *fnType) unpackTupleLit(cb *gogen.CodeBuilder) bool {
method load (line 801) | func (p *fnType) load(fnt types.Type) {
method initFuncs (line 822) | func (p *fnType) initFuncs(base int, funcs []types.Object, typeAsParam...
function compileCallExpr (line 837) | func compileCallExpr(ctx *blockCtx, lhs int, v *ast.CallExpr, inFlags in...
constant msgNoKwargsOVF (line 922) | msgNoKwargsOVF = "keyword arguments are not supported for a func...
constant msgNoEnoughArgToKwargs (line 923) | msgNoEnoughArgToKwargs = "not enough arguments for function call with ke...
constant msgUnexpectedKwargs (line 924) | msgUnexpectedKwargs = "keyword arguments can only be used for struct ...
function inThisPkg (line 927) | func inThisPkg(ctx *blockCtx, t types.Type) bool {
function mergeKwargs (line 936) | func mergeKwargs(ctx *blockCtx, v *ast.CallExpr, t types.Type) ast.Expr {
function mergeStringMapKwargs (line 952) | func mergeStringMapKwargs(kwargs []*ast.KwargExpr) ast.Expr {
function mergeStructKwargs (line 968) | func mergeStructKwargs(kwargs []*ast.KwargExpr, u *types.Struct, inPkg b...
function getFldName (line 984) | func getFldName(name *ast.Ident, u *types.Struct, inPkg bool) *ast.Ident {
function toBasicLit (line 1004) | func toBasicLit(fn *ast.Ident) *ast.BasicLit {
function builtinOrXGoExec (line 1010) | func builtinOrXGoExec(ctx *blockCtx, lhs int, ifn *ast.Ident, v *ast.Cal...
function tryXGoExec (line 1026) | func tryXGoExec(cb *gogen.CodeBuilder, ifn *ast.Ident) bool {
function fnCall (line 1037) | func fnCall(ctx *blockCtx, lhs int, v *ast.CallExpr, flags gogen.InstrFl...
function compileCallArgs (line 1044) | func compileCallArgs(ctx *blockCtx, lhs int, pfn *gogen.Element, fn *fnT...
type clLambaFlag (line 1175) | type clLambaFlag
constant clLambaAssign (line 1178) | clLambaAssign clLambaFlag = "assignment"
constant clLambaField (line 1179) | clLambaField clLambaFlag = "field value"
constant clLambaArgument (line 1180) | clLambaArgument clLambaFlag = "argument"
function checkLambdaFuncType (line 1184) | func checkLambdaFuncType(ctx *blockCtx, lambda ast.Expr, ftyp types.Type...
function sigParamLen (line 1206) | func sigParamLen(typ types.Type) int {
function nonClosure (line 1218) | func nonClosure(typ types.Type) bool {
function compileLambda (line 1234) | func compileLambda(ctx *blockCtx, lambda ast.Expr, sig *types.Signature) {
function makeLambdaParams (line 1247) | func makeLambdaParams(ctx *blockCtx, pos, end token.Pos, lhs []*ast.Iden...
function makeLambdaResults (line 1276) | func makeLambdaResults(pkg *gogen.Package, out *types.Tuple) *types.Tuple {
function compileLambdaExpr (line 1288) | func compileLambdaExpr(ctx *blockCtx, v *ast.LambdaExpr, sig *types.Sign...
function compileLambdaExpr2 (line 1309) | func compileLambdaExpr2(ctx *blockCtx, v *ast.LambdaExpr2, sig *types.Si...
function compileFuncLit (line 1331) | func compileFuncLit(ctx *blockCtx, v *ast.FuncLit) {
function compileNumberUnitLit (line 1345) | func compileNumberUnitLit(ctx *blockCtx, v *ast.NumberUnitLit, expected ...
function compileBasicLit (line 1351) | func compileBasicLit(ctx *blockCtx, v *ast.BasicLit) {
function invalidVal (line 1380) | func invalidVal(cb *gogen.CodeBuilder) {
function basicLit (line 1384) | func basicLit(cb *gogen.CodeBuilder, v *ast.BasicLit) {
constant stringutilPkgPath (line 1389) | stringutilPkgPath = "github.com/qiniu/x/stringutil"
function compileStringLitEx (line 1392) | func compileStringLitEx(ctx *blockCtx, cb *gogen.CodeBuilder, lit *ast.B...
constant tplPkgPath (line 1437) | tplPkgPath = "github.com/goplus/xgo/tpl"
constant encodingPkgPrefix (line 1438) | encodingPkgPrefix = "github.com/goplus/xgo/encoding/"
function compileDomainTextLit (line 1448) | func compileDomainTextLit(ctx *blockCtx, v *ast.DomainTextLit) {
function lambdaRetFunc (line 1506) | func lambdaRetFunc(expr *ast.LambdaExpr2) *ast.LambdaExpr2 {
function sigRetFunc (line 1514) | func sigRetFunc(pkg *gogen.Package, isList bool) *types.Signature {
function anyParam (line 1525) | func anyParam(pkg *gogen.Package) *types.Var {
function anySliceParam (line 1529) | func anySliceParam(pkg *gogen.Package) *types.Var {
constant compositeLitVal (line 1534) | compositeLitVal = 0
constant compositeLitKeyVal (line 1535) | compositeLitKeyVal = 1
function checkCompositeLitElts (line 1538) | func checkCompositeLitElts(elts []ast.Expr) (kind int) {
function compileCompositeLitElts (line 1547) | func compileCompositeLitElts(ctx *blockCtx, elts []ast.Expr, kind int, e...
function compileCompositeLitElt (line 1572) | func compileCompositeLitElt(ctx *blockCtx, e ast.Expr, typ types.Type, f...
function unparen (line 1592) | func unparen(x ast.Expr) ast.Expr {
function compileStructLit (line 1599) | func compileStructLit(ctx *blockCtx, elts []ast.Expr, t *types.Struct, t...
function compileStructLitInKeyVal (line 1613) | func compileStructLitInKeyVal(ctx *blockCtx, elts []ast.Expr, t *types.S...
type kvType (line 1637) | type kvType struct
method required (line 1643) | func (p *kvType) required() *kvType {
method Key (line 1658) | func (p *kvType) Key() types.Type {
method Elem (line 1662) | func (p *kvType) Elem() types.Type {
function getUnderlying (line 1666) | func getUnderlying(ctx *blockCtx, typ types.Type) types.Type {
function compileCompositeLit (line 1677) | func compileCompositeLit(ctx *blockCtx, v *ast.CompositeLit, expected ty...
function compileCompositeLitEx (line 1684) | func compileCompositeLitEx(ctx *blockCtx, v *ast.CompositeLit, expected ...
function compileMapLitEx (line 1758) | func compileMapLitEx(ctx *blockCtx, typ types.Type, n int, v *ast.Compos...
function isMapOrStruct (line 1768) | func isMapOrStruct(tu types.Type) bool {
function compileSliceLit (line 1778) | func compileSliceLit(ctx *blockCtx, v *ast.SliceLit, typ types.Type, noP...
function compileTupleLit (line 1798) | func compileTupleLit(ctx *blockCtx, v *ast.TupleLit, typ types.Type, noP...
function compileRangeExpr (line 1814) | func compileRangeExpr(ctx *blockCtx, v *ast.RangeExpr) {
constant comprehensionInvalid (line 1832) | comprehensionInvalid = iota
constant comprehensionList (line 1833) | comprehensionList
constant comprehensionMap (line 1834) | comprehensionMap
constant comprehensionSelect (line 1835) | comprehensionSelect
function comprehensionKind (line 1838) | func comprehensionKind(v *ast.ComprehensionExpr) int {
function compileComprehensionExpr (line 1855) | func compileComprehensionExpr(ctx *blockCtx, lhs int, v *ast.Comprehensi...
constant errorPkgPath (line 1950) | errorPkgPath = "github.com/qiniu/x/errors"
function compileErrWrapExpr (line 1957) | func compileErrWrapExpr(ctx *blockCtx, lhs int, v *ast.ErrWrapExpr, inFl...
function sprintAst (line 2044) | func sprintAst(fset *token.FileSet, x ast.Node) string {
FILE: cl/func_type_and_var.go
function toRecv (line 34) | func toRecv(ctx *blockCtx, recv *ast.FieldList) *types.Var {
function getRecvTypeName (line 59) | func getRecvTypeName(ctx *pkgCtx, recv *ast.FieldList, handleErr bool) (...
function toResults (line 71) | func toResults(ctx *blockCtx, in *ast.FieldList) *types.Tuple {
function toParams (line 84) | func toParams(ctx *blockCtx, flds []*ast.Field) (typ *types.Tuple, varia...
function toParam (line 97) | func toParam(ctx *blockCtx, fld *ast.Field, args []*gogen.Param) []*goge...
function toType (line 116) | func toType(ctx *blockCtx, typ ast.Expr) (t types.Type) {
function toChanType (line 201) | func toChanType(ctx *blockCtx, v *ast.ChanType) *types.Chan {
function toExternalType (line 205) | func toExternalType(ctx *blockCtx, v *ast.SelectorExpr) types.Type {
function toIdentType (line 236) | func toIdentType(ctx *blockCtx, ident *ast.Ident) (ret types.Type) {
function lookupType (line 271) | func lookupType(ctx *blockCtx, name string) (types.Object, types.Object) {
type fieldKind (line 293) | type fieldKind
constant fieldKindUser (line 296) | fieldKindUser fieldKind = iota
constant fieldKindClass (line 297) | fieldKindClass
type fieldElem (line 300) | type fieldElem struct
type checkRedecl (line 306) | type checkRedecl struct
method chkRedecl (line 314) | func (p *checkRedecl) chkRedecl(ctx *blockCtx, name string, pos, end t...
function newCheckRedecl (line 310) | func newCheckRedecl() *checkRedecl {
function toTupleType (line 344) | func toTupleType(ctx *blockCtx, v *ast.TupleType) types.Type {
function toStructType (line 392) | func toStructType(ctx *blockCtx, v *ast.StructType) *types.Struct {
function toFieldTag (line 448) | func toFieldTag(v *ast.BasicLit) string {
function noTagKey (line 463) | func noTagKey(data string) bool {
function getTypeName (line 471) | func getTypeName(typ types.Type) string {
function toMapType (line 485) | func toMapType(ctx *blockCtx, v *ast.MapType) *types.Map {
function toArrayType (line 491) | func toArrayType(ctx *blockCtx, v *ast.ArrayType) types.Type {
function toInt64 (line 502) | func toInt64(ctx *blockCtx, e ast.Expr, emsg string) int64 {
function toInterfaceType (line 519) | func toInterfaceType(ctx *blockCtx, v *ast.InterfaceType) types.Type {
function instantiate (line 549) | func instantiate(ctx *blockCtx, exprX ast.Expr, indices ...ast.Expr) typ...
function toIndexType (line 567) | func toIndexType(ctx *blockCtx, v *ast.IndexExpr) types.Type {
function toIndexListType (line 571) | func toIndexListType(ctx *blockCtx, v *ast.IndexListExpr) types.Type {
function toString (line 577) | func toString(l *ast.BasicLit) string {
FILE: cl/internal/dql/dql.go
constant XGoPackage (line 6) | XGoPackage = true
type Node (line 9) | type Node struct
type NodeSet (line 12) | type NodeSet struct
method XGo_Enum (line 25) | func (p NodeSet) XGo_Enum() iter.Seq[NodeSet] {
method XGo_Any (line 30) | func (p NodeSet) XGo_Any(name string) NodeSet {
method XGo_Select (line 34) | func (p NodeSet) XGo_Select(name string) NodeSet {
method XGo_Child (line 39) | func (p NodeSet) XGo_Child() NodeSet {
method XGo_first (line 44) | func (p NodeSet) XGo_first() (*Node, error) {
method XGo_Elem (line 49) | func (p NodeSet) XGo_Elem(name string) NodeSet {
method XGo_Attr__0 (line 53) | func (p NodeSet) XGo_Attr__0(name string) int {
method XGo_Attr__1 (line 57) | func (p NodeSet) XGo_Attr__1(name string) (int, error) {
function New (line 15) | func New() NodeSet {
function NodeSet_Cast (line 20) | func NodeSet_Cast(func(yield func(*Node) bool)) NodeSet {
type NodeSet2 (line 61) | type NodeSet2 struct
method XGo_first (line 72) | func (p NodeSet2) XGo_first() *Node {
method XGo_Enum (line 76) | func (p NodeSet2) XGo_Enum() iter.Seq[NodeSet2] {
method XGo_Elem (line 80) | func (p NodeSet2) XGo_Elem(name string) NodeSet2 {
method XGo_Attr (line 84) | func (p NodeSet2) XGo_Attr(name string) int {
function New2 (line 64) | func New2() NodeSet2 {
function NodeSet2_Cast (line 68) | func NodeSet2_Cast(func(yield func(*Node) bool)) NodeSet2 {
FILE: cl/internal/huh/huh.go
type Form (line 5) | type Form
method Run (line 7) | func (f Form) Run() {
function New (line 10) | func New(string, string, int) Form {
FILE: cl/internal/llgo-hello/hello.go
function Main (line 5) | func Main() {
FILE: cl/internal/mcp/classfile.go
constant GopPackage (line 4) | GopPackage = true
type Game (line 7) | type Game struct
method initGame (line 14) | func (p *Game) initGame() {}
method Server (line 16) | func (p *Game) Server(name string) {}
function New (line 10) | func New() *Game {
type Tool (line 18) | type Tool struct
method Main (line 21) | func (p *Tool) Main(name string) int {
type Prompt (line 25) | type Prompt struct
method Main (line 28) | func (p *Prompt) Main(*Tool) string {
type Resource (line 32) | type Resource struct
method Main (line 35) | func (p *Resource) Main() {
type ToolProto (line 38) | type ToolProto interface
type PromptProto (line 42) | type PromptProto interface
type ResourceProto (line 46) | type ResourceProto interface
function Gopt_Game_Main (line 50) | func Gopt_Game_Main(game interface{ initGame() }, resources []ResourcePr...
FILE: cl/internal/overload/bar/bar.go
constant GopPackage (line 3) | GopPackage = true
type basetype (line 7) | type basetype interface
type Var__0 (line 11) | type Var__0 struct
method Value (line 15) | func (p *Var__0[T]) Value() T {
type Var__1 (line 19) | type Var__1 struct
method Value (line 23) | func (p *Var__1[T]) Value() T {
function XGox_Var_Cast__0 (line 27) | func XGox_Var_Cast__0[T basetype]() *Var__0[T] {
function XGox_Var_Cast__1 (line 31) | func XGox_Var_Cast__1[T map[string]any]() *Var__1[T] {
type Player (line 35) | type Player struct
function XGot_Player_XGox_OnCmd__0 (line 38) | func XGot_Player_XGox_OnCmd__0[T any](p *Player, handler func(cmd T) err...
function XGot_Player_XGox_OnCmd__1 (line 43) | func XGot_Player_XGox_OnCmd__1[T1 ~int, T2 any](p *Player, n T1, handler...
FILE: cl/internal/overload/foo/foo.go
constant GopPackage (line 3) | GopPackage = true
type Mesher (line 5) | type Mesher interface
type N (line 9) | type N struct
method OnKey__0 (line 12) | func (m *N) OnKey__0(a string, fn func()) {
method OnKey__1 (line 15) | func (m *N) OnKey__1(a string, fn func(key string)) {
method OnKey__2 (line 18) | func (m *N) OnKey__2(a []string, fn func()) {
method OnKey__3 (line 21) | func (m *N) OnKey__3(a []string, fn func(key string)) {
method OnKey__4 (line 24) | func (m *N) OnKey__4(a []Mesher, fn func()) {
method OnKey__5 (line 27) | func (m *N) OnKey__5(a []Mesher, fn func(key Mesher)) {
method OnKey__6 (line 30) | func (m *N) OnKey__6(a []string, b []string, fn func(key string)) {
method OnKey__7 (line 33) | func (m *N) OnKey__7(a []string, b []Mesher, fn func(key string)) {
method OnKey__8 (line 36) | func (m *N) OnKey__8(x int, y int) {
function OnKey__0 (line 39) | func OnKey__0(a string, fn func()) {
function OnKey__1 (line 42) | func OnKey__1(a string, fn func(key string)) {
function OnKey__2 (line 45) | func OnKey__2(a []string, fn func()) {
function OnKey__3 (line 48) | func OnKey__3(a []string, fn func(key string)) {
function OnKey__4 (line 51) | func OnKey__4(a []Mesher, fn func()) {
function OnKey__5 (line 54) | func OnKey__5(a []Mesher, fn func(key Mesher)) {
function OnKey__6 (line 57) | func OnKey__6(a []string, b []string, fn func(key string)) {
function OnKey__7 (line 60) | func OnKey__7(a []string, b []Mesher, fn func(key string)) {
function OnKey__8 (line 63) | func OnKey__8(x int, y int) {
function Test__0 (line 66) | func Test__0() {
function Test__1 (line 69) | func Test__1[N any](n N) {
function Test__2 (line 72) | func Test__2[N1, N2 any](n1 N1, n2 N2) {
FILE: cl/internal/spx/game.go
constant GopPackage (line 20) | GopPackage = "github.com/goplus/xgo/cl/internal/spx/pkg"
constant Gop_sched (line 21) | Gop_sched = "Sched,SchedNow"
type Sound (line 24) | type Sound
type MyGame (line 26) | type MyGame struct
method Ls (line 32) | func (p *MyGame) Ls(n int) {}
method Capout (line 34) | func (p *MyGame) Capout(doSth func()) (string, error) {
method Gop_Env (line 38) | func (p *MyGame) Gop_Env(name string) int {
method Gop_Exec (line 42) | func (p *MyGame) Gop_Exec(name string, args ...any) {
method InitGameApp (line 45) | func (p *MyGame) InitGameApp(args ...string) {
method Broadcast__0 (line 48) | func (p *MyGame) Broadcast__0(msg string) {
method Broadcast__1 (line 51) | func (p *MyGame) Broadcast__1(msg string, wait bool) {
method Broadcast__2 (line 54) | func (p *MyGame) Broadcast__2(msg string, data any, wait bool) {
method Play (line 57) | func (p *MyGame) Play(media string, wait ...bool) {
method sendMessage (line 60) | func (p *MyGame) sendMessage(data any) {
method SendMessage (line 63) | func (p *MyGame) SendMessage(data any) {
function Gopt_MyGame_Main (line 29) | func Gopt_MyGame_Main(game any) {
function Gopt_MyGame_Run (line 67) | func Gopt_MyGame_Run(game any, resource string) error {
function Sched (line 71) | func Sched() {
function SchedNow (line 74) | func SchedNow() {
function Rand__0 (line 77) | func Rand__0(int) int {
function Rand__1 (line 81) | func Rand__1(float64) float64 {
FILE: cl/internal/spx/pkg/pkg.go
constant GopPackage (line 4) | GopPackage = true
type Vector (line 7) | type Vector struct
method Add__0 (line 16) | func (v *Vector) Add__0(x int, y int) {
method Add__1 (line 21) | func (v *Vector) Add__1(o *Vector) {
method Self (line 25) | func (v *Vector) Self() *Vector {
function NewVector (line 12) | func NewVector(x, y int) *Vector {
FILE: cl/internal/spx/sprite.go
type Sprite (line 23) | type Sprite struct
method SetCostume (line 36) | func (p *Sprite) SetCostume(costume any) {
method Say (line 39) | func (p *Sprite) Say(msg string, secs ...float64) {
method Position (line 42) | func (p *Sprite) Position() *pkg.Vector {
type Entry (line 28) | type Entry struct
method Vector (line 32) | func (p *Entry) Vector() *pkg.Vector {
type Mesher (line 46) | type Mesher interface
function Gopt_Sprite_Clone__0 (line 50) | func Gopt_Sprite_Clone__0(sprite any) {
function Gopt_Sprite_Clone__1 (line 53) | func Gopt_Sprite_Clone__1(sprite any, data any) {
function Gopt_Sprite_OnKey__0 (line 56) | func Gopt_Sprite_OnKey__0(sprite any, a string, fn func()) {
function Gopt_Sprite_OnKey__1 (line 59) | func Gopt_Sprite_OnKey__1(sprite any, a string, fn func(key string)) {
function Gopt_Sprite_OnKey__2 (line 62) | func Gopt_Sprite_OnKey__2(sprite any, a []string, fn func()) {
function Gopt_Sprite_OnKey__3 (line 65) | func Gopt_Sprite_OnKey__3(sprite any, a []string, fn func(key string)) {
function Gopt_Sprite_OnKey__4 (line 68) | func Gopt_Sprite_OnKey__4(sprite any, a []Mesher, fn func()) {
function Gopt_Sprite_OnKey__5 (line 71) | func Gopt_Sprite_OnKey__5(sprite any, a []Mesher, fn func(key Mesher)) {
function Gopt_Sprite_OnKey__6 (line 74) | func Gopt_Sprite_OnKey__6(sprite any, a []string, b []string, fn func(ke...
function Gopt_Sprite_OnKey__7 (line 77) | func Gopt_Sprite_OnKey__7(sprite any, a []string, b []Mesher, fn func(ke...
function Gopt_Sprite_OnKey__8 (line 80) | func Gopt_Sprite_OnKey__8(sprite any, x int, y int) {
function Gopt_Sprite_OnKey2 (line 83) | func Gopt_Sprite_OnKey2(sprite any, a string, fn func(key string)) {
FILE: cl/internal/spx2/spx2.go
constant Gop_sched (line 20) | Gop_sched = "Sched"
constant Gop_work (line 21) | Gop_work = "Sprite"
type Game (line 24) | type Game struct
method Main (line 27) | func (p *Game) Main() {
type Sprite (line 30) | type Sprite struct
function Sched (line 33) | func Sched() {
FILE: cl/internal/spx3/jwt/jwt.go
function Token (line 19) | func Token(v string) string {
FILE: cl/internal/spx3/spx3.go
constant GopPackage (line 20) | GopPackage = true
type Game (line 23) | type Game struct
method initGame (line 30) | func (p *Game) initGame() {}
method Run (line 32) | func (p *Game) Run() {}
function New (line 26) | func New() *Game {
type Sprite (line 34) | type Sprite struct
method Name (line 37) | func (p *Sprite) Name() string {
method Main (line 41) | func (p *Sprite) Main(name string) {}
type Handler (line 43) | type Handler interface
function Gopt_Game_Main (line 49) | func Gopt_Game_Main(game interface{ initGame() }, workers ...Handler) {
FILE: cl/internal/spx4/game.go
constant GopPackage (line 20) | GopPackage = "github.com/goplus/xgo/cl/internal/spx/pkg"
constant Gop_sched (line 21) | Gop_sched = "Sched,SchedNow"
type Sound (line 24) | type Sound
type MyGame (line 26) | type MyGame struct
method Ls (line 32) | func (p *MyGame) Ls(n int) {}
method Capout (line 34) | func (p *MyGame) Capout(doSth func()) (string, error) {
method Gop_Env (line 38) | func (p *MyGame) Gop_Env(name string) int {
method Gop_Exec (line 42) | func (p *MyGame) Gop_Exec(name string, args ...any) {
method InitGameApp (line 45) | func (p *MyGame) InitGameApp(args ...string) {
method Broadcast__0 (line 48) | func (p *MyGame) Broadcast__0(msg string) {
method Broadcast__1 (line 51) | func (p *MyGame) Broadcast__1(msg string, wait bool) {
method Broadcast__2 (line 54) | func (p *MyGame) Broadcast__2(msg string, data any, wait bool) {
method BackdropName (line 57) | func (p *MyGame) BackdropName() string {
method Play (line 61) | func (p *MyGame) Play(media string, wait ...bool) {
method sendMessage (line 64) | func (p *MyGame) sendMessage(data any) {
method SendMessage (line 67) | func (p *MyGame) SendMessage(data any) {
function Gopt_MyGame_Main (line 29) | func Gopt_MyGame_Main(game any, sprites ...Sprite) {
function Gopt_MyGame_Run (line 71) | func Gopt_MyGame_Run(game any, resource string) error {
function Sched (line 75) | func Sched() {
function SchedNow (line 78) | func SchedNow() {
function Rand__0 (line 81) | func Rand__0(int) int {
function Rand__1 (line 85) | func Rand__1(float64) float64 {
FILE: cl/internal/spx4/pkg/pkg.go
constant GopPackage (line 4) | GopPackage = true
type Vector (line 7) | type Vector struct
method Add__0 (line 16) | func (v *Vector) Add__0(x int, y int) {
method Add__1 (line 21) | func (v *Vector) Add__1(o *Vector) {
method Self (line 25) | func (v *Vector) Self() *Vector {
function NewVector (line 12) | func NewVector(x, y int) *Vector {
FILE: cl/internal/spx4/sprite.go
type Sprite (line 23) | type Sprite struct
method SetCostume (line 36) | func (p *Sprite) SetCostume(costume any) {
method Say (line 39) | func (p *Sprite) Say(msg string, secs ...float64) {
method Position (line 42) | func (p *Sprite) Position() *pkg.Vector {
type Entry (line 28) | type Entry struct
method Vector (line 32) | func (p *Entry) Vector() *pkg.Vector {
type Mesher (line 46) | type Mesher interface
function Gopt_Sprite_Clone__0 (line 50) | func Gopt_Sprite_Clone__0(sprite any) {
function Gopt_Sprite_Clone__1 (line 53) | func Gopt_Sprite_Clone__1(sprite any, data any) {
function Gopt_Sprite_OnKey__0 (line 56) | func Gopt_Sprite_OnKey__0(sprite any, a string, fn func()) {
function Gopt_Sprite_OnKey__1 (line 59) | func Gopt_Sprite_OnKey__1(sprite any, a string, fn func(key string)) {
function Gopt_Sprite_OnKey__2 (line 62) | func Gopt_Sprite_OnKey__2(sprite any, a []string, fn func()) {
function Gopt_Sprite_OnKey__3 (line 65) | func Gopt_Sprite_OnKey__3(sprite any, a []string, fn func(key string)) {
function Gopt_Sprite_OnKey__4 (line 68) | func Gopt_Sprite_OnKey__4(sprite any, a []Mesher, fn func()) {
function Gopt_Sprite_OnKey__5 (line 71) | func Gopt_Sprite_OnKey__5(sprite any, a []Mesher, fn func(key Mesher)) {
function Gopt_Sprite_OnKey__6 (line 74) | func Gopt_Sprite_OnKey__6(sprite any, a []string, b []string, fn func(ke...
function Gopt_Sprite_OnKey__7 (line 77) | func Gopt_Sprite_OnKey__7(sprite any, a []string, b []Mesher, fn func(ke...
function Gopt_Sprite_OnKey__8 (line 80) | func Gopt_Sprite_OnKey__8(sprite any, x int, y int) {
function Gopt_Sprite_OnKey2 (line 83) | func Gopt_Sprite_OnKey2(sprite any, a string, fn func(key string)) {
FILE: cl/internal/test/case.go
type CaseT (line 26) | type CaseT interface
type TestingT (line 126) | type TestingT struct
method Errorln (line 136) | func (p TestingT) Errorln(args ...any) {
method Run (line 146) | func (p TestingT) Run(name string, doSth func()) bool {
function NewT (line 131) | func NewT(t *testing.T) TestingT {
FILE: cl/internal/test/match.go
constant GopPackage (line 20) | GopPackage = true
type basetype (line 23) | type basetype interface
type Case (line 27) | type Case struct
constant XGoo_Gopt_Case_Match (line 32) | XGoo_Gopt_Case_Match = "Gopt_Case_MatchTBase,Gopt_Case_MatchAny"
function Gopt_Case_MatchTBase (line 35) | func Gopt_Case_MatchTBase[T basetype](t CaseT, got, expected T, name ......
function Gopt_Case_MatchAny (line 38) | func Gopt_Case_MatchAny(t CaseT, got, expected any, name ...string) {
FILE: cl/internal/testutil/testutil.go
type Options (line 19) | type Options struct
FILE: cl/internal/typesutil/api.go
type OperandMode (line 28) | type OperandMode
type TypeAndValue (line 32) | type TypeAndValue struct
function NewTypeAndValueForType (line 38) | func NewTypeAndValueForType(typ types.Type) (ret types.TypeAndValue) {
function NewTypeAndValueForValue (line 48) | func NewTypeAndValueForValue(typ types.Type, val constant.Value, mode Op...
function NewTypeAndValueForCallResult (line 62) | func NewTypeAndValueForCallResult(typ types.Type, val constant.Value) (r...
function NewTypeAndValueForObject (line 80) | func NewTypeAndValueForObject(obj types.Object) (ret types.TypeAndValue) {
FILE: cl/internal/typesutil/api_test.go
function TestTypeAndValue (line 27) | func TestTypeAndValue(t *testing.T) {
FILE: cl/internal/typesutil/mode.go
constant Invalid (line 23) | Invalid OperandMode = iota
constant NoValue (line 24) | NoValue
constant Builtin (line 25) | Builtin
constant TypExpr (line 26) | TypExpr
constant Constant (line 27) | Constant
constant Variable (line 28) | Variable
constant MapIndex (line 29) | MapIndex
constant Value (line 30) | Value
constant CommaOK (line 31) | CommaOK
constant CommaErr (line 32) | CommaErr
constant CgoFunc (line 33) | CgoFunc
FILE: cl/internal/typesutil/mode_go123.go
constant Invalid (line 23) | Invalid OperandMode = iota
constant NoValue (line 24) | NoValue
constant Builtin (line 25) | Builtin
constant TypExpr (line 26) | TypExpr
constant Constant (line 27) | Constant
constant Variable (line 28) | Variable
constant MapIndex (line 29) | MapIndex
constant Value (line 30) | Value
constant NilValue (line 31) | NilValue
constant CommaOK (line 32) | CommaOK
constant CommaErr (line 33) | CommaErr
constant CgoFunc (line 34) | CgoFunc
FILE: cl/internal/unit/unit.go
type Distance (line 5) | type Distance
constant XGou_Distance (line 7) | XGou_Distance = "mm=1,cm=10,dm=100,m=1000"
FILE: cl/outline/outline.go
type Config (line 35) | type Config struct
type Package (line 47) | type Package struct
method Pkg (line 69) | func (p Package) Pkg() *types.Package {
method Valid (line 73) | func (p Package) Valid() bool {
method Outline (line 213) | func (p Package) Outline(withUnexported ...bool) (ret *All) {
function NewPackage (line 53) | func NewPackage(pkgPath string, pkg *ast.Package, conf *Config) (_ Packa...
type All (line 79) | type All struct
method checkAlias (line 97) | func (p *All) checkAlias(aliasr *typeutil.Map, t types.Type, withBasic...
method markUsed (line 108) | func (p *All) markUsed(named *TypeName) {
method checkUsed (line 124) | func (p *All) checkUsed(typ types.Type) {
method checkUsedMethod (line 164) | func (p *All) checkUsedMethod(fn *types.Func) {
method checkUsedSig (line 170) | func (p *All) checkUsedSig(sig *types.Signature) {
method checkUsedTuple (line 175) | func (p *All) checkUsedTuple(t *types.Tuple) {
method getNamed (line 181) | func (p *All) getNamed(t *types.TypeName) *TypeName {
method initNamed (line 188) | func (p *All) initNamed(aliasr *typeutil.Map, objs []types.Object) {
method lookupNamed (line 201) | func (p *All) lookupNamed(pkg *types.Package, name string) (_ *TypeNam...
method sigKind (line 294) | func (p *All) sigKind(aliasr *typeutil.Map, sig *types.Signature) (sig...
method checkLocal (line 310) | func (p *All) checkLocal(aliasr *typeutil.Map, first types.Type, withB...
function setAlias (line 89) | func setAlias(aliasr *typeutil.Map, t types.Type, named *TypeName) {
type sigKindType (line 286) | type sigKindType
constant sigNormal (line 289) | sigNormal sigKindType = iota
constant sigCreator (line 290) | sigCreator
constant sigHelper (line 291) | sigHelper
function indirect (line 321) | func indirect(typ types.Type) types.Type {
type Const (line 330) | type Const struct
method Obj (line 334) | func (p Const) Obj() types.Object {
method Doc (line 338) | func (p Const) Doc() string {
type Var (line 342) | type Var struct
method Obj (line 346) | func (p Var) Obj() types.Object {
method Doc (line 350) | func (p Var) Doc() string {
type Func (line 354) | type Func struct
method Obj (line 359) | func (p Func) Obj() types.Object {
method Doc (line 363) | func (p Func) Doc() string {
function CheckOverload (line 367) | func CheckOverload(obj types.Object) (name string, fn *types.Func, ok bo...
constant goptPrefix (line 375) | goptPrefix = "Gopt_"
function isGoptFunc (line 378) | func isGoptFunc(name string) bool {
function isOverloadFunc (line 382) | func isOverloadFunc(name string) bool {
function checkGoptFunc (line 387) | func checkGoptFunc(name string) (string, bool) {
function checkOverloadFunc (line 397) | func checkOverloadFunc(name string) (string, bool) {
type TypeName (line 406) | type TypeName struct
method IsUsed (line 415) | func (p *TypeName) IsUsed() bool {
method ObjWith (line 419) | func (p *TypeName) ObjWith(all bool) *types.TypeName {
method Obj (line 427) | func (p *TypeName) Obj() types.Object {
method Doc (line 431) | func (p *TypeName) Doc() string {
method Type (line 435) | func (p *TypeName) Type() Type {
function hideUnexported (line 439) | func hideUnexported(o *types.TypeName) *types.TypeName {
function typeHideUnexported (line 462) | func typeHideUnexported(typ types.Type) (ret types.Type, ok bool) {
type tyUnexpImp (line 490) | type tyUnexpImp struct
method String (line 492) | func (p tyUnexpImp) String() string { return "..." }
method Underlying (line 493) | func (p tyUnexpImp) Underlying() types.Type { return p }
type Type (line 501) | type Type struct
method CheckNamed (line 505) | func (p Type) CheckNamed(pkg Package) (_ Named, ok bool) {
type Named (line 515) | type Named struct
method Methods (line 520) | func (p Named) Methods() []Func {
FILE: cl/recorder.go
type goxRecorder (line 30) | type goxRecorder struct
method ReferUse (line 45) | func (p *goxRecorder) ReferUse(ident *ast.Ident, name string) {
method ReferDef (line 50) | func (p *goxRecorder) ReferDef(ident *ast.Ident, node ast.Node) {
method Complete (line 55) | func (p *goxRecorder) Complete(scope *types.Scope) {
method Member (line 113) | func (p *goxRecorder) Member(id ast.Node, obj types.Object) {
method Call (line 135) | func (p *goxRecorder) Call(id ast.Node, obj types.Object) {
method checkExprByValue (line 154) | func (rec *goxRecorder) checkExprByValue(v ast.Expr) bool {
method Type (line 170) | func (rec *goxRecorder) Type(expr ast.Expr, tv types.TypeAndValue) {
method instantiate (line 175) | func (rec *goxRecorder) instantiate(expr ast.Expr, _, typ types.Type) {
method recordTypeValue (line 195) | func (rec *goxRecorder) recordTypeValue(ctx *blockCtx, expr ast.Expr, ...
method indexExpr (line 201) | func (rec *goxRecorder) indexExpr(ctx *blockCtx, expr *ast.IndexExpr) {
method unaryExpr (line 224) | func (rec *goxRecorder) unaryExpr(ctx *blockCtx, expr *ast.UnaryExpr) {
method recordCallExpr (line 233) | func (rec *goxRecorder) recordCallExpr(ctx *blockCtx, v *ast.CallExpr,...
method recordCompositeLit (line 241) | func (rec *goxRecorder) recordCompositeLit(v *ast.CompositeLit, typ ty...
method recordFuncLit (line 246) | func (rec *goxRecorder) recordFuncLit(v *ast.FuncLit, typ types.Type) {
method recordType (line 251) | func (rec *goxRecorder) recordType(typ ast.Expr, t types.Type) {
method recordIdent (line 255) | func (rec *goxRecorder) recordIdent(ident *ast.Ident, obj types.Object) {
method recordExpr (line 260) | func (rec *goxRecorder) recordExpr(ctx *blockCtx, expr ast.Expr, _ boo...
function newRecorder (line 37) | func newRecorder(rec Recorder) *goxRecorder {
FILE: cl/run_test.go
function init (line 26) | func init() {
function check (line 35) | func check(err error) {
function checkWith (line 41) | func checkWith(err error, stdout, stderr io.Writer) {
function fatalWith (line 47) | func fatalWith(err error, stdout, stderr io.Writer) {
type iBytes (line 54) | type iBytes interface
function getBytes (line 58) | func getBytes(stdout, stderr io.Writer) (o iBytes, ok bool) {
function goRun (line 66) | func goRun(_ *testing.T, code []byte) string {
function genGo (line 83) | func genGo(t *testing.T, conf *cl.Config, gopcode string) []byte {
function testRun (line 105) | func testRun(t *testing.T, gopcode, expected string) {
function testRunType (line 113) | func testRunType(t *testing.T, typ, gopcodeT, expected string) {
constant testType_inc_code (line 121) | testType_inc_code, testType_inc_ret = `
constant testType_dec_code (line 131) | testType_dec_code, testType_dec_ret = `
constant testType_init_code (line 139) | testType_init_code, testType_init_ret = `
constant testType_twoval_code (line 150) | testType_twoval_code, testType_twoval_ret = `
constant testType_cast_code (line 162) | testType_cast_code, testType_cast_ret = `
constant testType_printf_code (line 168) | testType_printf_code, testType_printf_ret = `
constant testTypescanf_code (line 175) | testTypescanf_code, testType_scanf_ret = `
constant testType_com_code (line 188) | testType_com_code, testType_com_ret = testType_inc_code + testType_init_...
constant testType_fixint_code (line 190) | testType_fixint_code, testType_fixint_ret = testTypescanf_code + testTyp...
function TestUint128_run (line 194) | func TestUint128_run(t *testing.T) {
function TestInt128_run (line 198) | func TestInt128_run(t *testing.T) {
function TestBigint_run (line 202) | func TestBigint_run(t *testing.T) {
FILE: cl/stmt.go
function fileLineFile (line 34) | func fileLineFile(relBaseDir, absFile string) string {
function relFile (line 41) | func relFile(dir string, absFile string) string {
function commentStmt (line 48) | func commentStmt(ctx *blockCtx, stmt ast.Stmt) {
function commentStmtEx (line 54) | func commentStmtEx(cb *gogen.CodeBuilder, ctx *pkgCtx, stmt ast.Stmt) {
function checkStmtDoc (line 74) | func checkStmtDoc(stmt ast.Stmt) *ast.CommentGroup {
function commentFunc (line 83) | func commentFunc(ctx *blockCtx, fn *gogen.Func, decl *ast.FuncDecl) {
function compileStmts (line 110) | func compileStmts(ctx *blockCtx, body []ast.Stmt) {
function compileStmt (line 122) | func compileStmt(ctx *blockCtx, stmt ast.Stmt) {
function checkCommandWithoutArgs (line 185) | func checkCommandWithoutArgs(x ast.Expr) int {
function compileReturnStmt (line 197) | func compileReturnStmt(ctx *blockCtx, expr *ast.ReturnStmt) {
function compileIncDecStmt (line 245) | func compileIncDecStmt(ctx *blockCtx, expr *ast.IncDecStmt) {
function isAppendable (line 254) | func isAppendable(x ast.Expr) bool {
function compileSendStmt (line 265) | func compileSendStmt(ctx *blockCtx, expr *ast.SendStmt) {
function compileAssignStmt (line 300) | func compileAssignStmt(ctx *blockCtx, expr *ast.AssignStmt) {
function compileRangeStmt (line 396) | func compileRangeStmt(ctx *blockCtx, v *ast.RangeStmt) {
function compileForPhraseStmt (line 470) | func compileForPhraseStmt(ctx *blockCtx, v *ast.ForPhraseStmt) {
function toForStmt (line 528) | func toForStmt(forPos token.Pos, value ast.Expr, body *ast.BlockStmt, re...
function compileForStmt (line 627) | func compileForStmt(ctx *blockCtx, v *ast.ForStmt) {
function compileIfStmt (line 668) | func compileIfStmt(ctx *blockCtx, v *ast.IfStmt) {
function compileTypeSwitchStmt (line 715) | func compileTypeSwitchStmt(ctx *blockCtx, v *ast.TypeSwitchStmt) {
function compileSwitchStmt (line 816) | func compileSwitchStmt(ctx *blockCtx, v *ast.SwitchStmt) {
function hasFallthrough (line 896) | func hasFallthrough(body []ast.Stmt) ([]ast.Stmt, bool) {
function compileSelectStmt (line 923) | func compileSelectStmt(ctx *blockCtx, v *ast.SelectStmt) {
function compileBranchStmt (line 955) | func compileBranchStmt(ctx *blockCtx, v *ast.BranchStmt) {
function getLabel (line 980) | func getLabel(ctx *blockCtx, label *ast.Ident) *gogen.Label {
function compileLabeledStmt (line 990) | func compileLabeledStmt(ctx *blockCtx, v *ast.LabeledStmt) {
function compileGoStmt (line 996) | func compileGoStmt(ctx *blockCtx, v *ast.GoStmt) {
function compileDeferStmt (line 1001) | func compileDeferStmt(ctx *blockCtx, v *ast.DeferStmt) {
function compileDeclStmt (line 1006) | func compileDeclStmt(ctx *blockCtx, expr *ast.DeclStmt) {
function compileType (line 1028) | func compileType(ctx *blockCtx, t *ast.TypeSpec) {
type valueMap (line 1041) | type valueMap
type valueType (line 1042) | type valueType struct
function goVal (line 1049) | func goVal(val constant.Value) any {
FILE: cl/typeparams.go
function toTermList (line 26) | func toTermList(ctx *blockCtx, expr ast.Expr) []*types.Term {
function toBinaryExprType (line 46) | func toBinaryExprType(ctx *blockCtx, v *ast.BinaryExpr) types.Type {
function toUnaryExprType (line 50) | func toUnaryExprType(ctx *blockCtx, v *ast.UnaryExpr) types.Type {
function toTypeParams (line 54) | func toTypeParams(ctx *blockCtx, params *ast.FieldList) []*types.TypePar...
function recvTypeParams (line 61) | func recvTypeParams(ctx *blockCtx, typ ast.Expr, named *types.Named) (tp...
function toFuncType (line 104) | func toFuncType(ctx *blockCtx, typ *ast.FuncType, recv *types.Var, d *as...
type typeParamLookup (line 129) | type typeParamLookup struct
method Lookup (line 133) | func (p *typeParamLookup) Lookup(name string) *types.TypeParam {
function initType (line 143) | func initType(ctx *blockCtx, named *types.Named, spec *ast.TypeSpec) {
function getRecvType (line 169) | func getRecvType(expr ast.Expr) (typ ast.Expr, ptr bool, ok bool) {
function collectTypeParams (line 197) | func collectTypeParams(ctx *blockCtx, list *ast.FieldList) []*types.Type...
function declareTypeParams (line 241) | func declareTypeParams(ctx *blockCtx, tparams []*types.TypeParam, names ...
function isTypeParam (line 258) | func isTypeParam(t types.Type) bool {
function isSpecificSliceType (line 263) | func isSpecificSliceType(ctx *blockCtx, typ types.Type) bool {
function boundTypeParam (line 280) | func boundTypeParam(ctx *blockCtx, x ast.Expr) types.Type {
function namedIsTypeParams (line 303) | func namedIsTypeParams(ctx *blockCtx, t *types.Named) bool {
FILE: cl/typeparams_test.go
function TestTypeParams (line 31) | func TestTypeParams(t *testing.T) {
function TestTypeParamsFunc (line 53) | func TestTypeParamsFunc(t *testing.T) {
function TestTypeParamsType (line 138) | func TestTypeParamsType(t *testing.T) {
function TestTypeParamsComparable (line 206) | func TestTypeParamsComparable(t *testing.T) {
function mixedErrorTest (line 237) | func mixedErrorTest(t *testing.T, msg, gocode, gopcode string) {
function mixedErrorTestEx (line 241) | func mixedErrorTestEx(t *testing.T, pkgname, msg, gocode, gopcode string) {
function TestTypeParamsErrorInstantiate (line 261) | func TestTypeParamsErrorInstantiate(t *testing.T) {
function TestTypeParamsErrorMatch (line 293) | func TestTypeParamsErrorMatch(t *testing.T) {
function TestTypeParamsErrInferFunc (line 316) | func TestTypeParamsErrInferFunc(t *testing.T) {
function TestTypeParamsErrArgumentsParameters1 (line 328) | func TestTypeParamsErrArgumentsParameters1(t *testing.T) {
function TestTypeParamsErrArgumentsParameters2 (line 341) | func TestTypeParamsErrArgumentsParameters2(t *testing.T) {
function TestTypeParamsErrArgumentsParameters3 (line 354) | func TestTypeParamsErrArgumentsParameters3(t *testing.T) {
function TestTypeParamsErrCallArguments1 (line 366) | func TestTypeParamsErrCallArguments1(t *testing.T) {
function TestTypeParamsErrCallArguments2 (line 380) | func TestTypeParamsErrCallArguments2(t *testing.T) {
function TestTypeParamsErrCallArguments3 (line 394) | func TestTypeParamsErrCallArguments3(t *testing.T) {
function TestTypeParamsErrCallVariadicArguments1 (line 410) | func TestTypeParamsErrCallVariadicArguments1(t *testing.T) {
function TestTypeParamsErrCallVariadicArguments2 (line 428) | func TestTypeParamsErrCallVariadicArguments2(t *testing.T) {
function TestTypeParamsRecvTypeError1 (line 444) | func TestTypeParamsRecvTypeError1(t *testing.T) {
function TestTypeParamsRecvTypeError2 (line 458) | func TestTypeParamsRecvTypeError2(t *testing.T) {
function TestTypeParamsRecvTypeError3 (line 472) | func TestTypeParamsRecvTypeError3(t *testing.T) {
function TestGenericTypeWithoutInst1 (line 487) | func TestGenericTypeWithoutInst1(t *testing.T) {
function TestGenericTypeWithoutInst2 (line 502) | func TestGenericTypeWithoutInst2(t *testing.T) {
function TestGenericTypeWithoutInst3 (line 519) | func TestGenericTypeWithoutInst3(t *testing.T) {
function TestGenericTypeWithoutInst4 (line 536) | func TestGenericTypeWithoutInst4(t *testing.T) {
function TestGenericTypeWithoutInst5 (line 553) | func TestGenericTypeWithoutInst5(t *testing.T) {
function TestGenericTypeWithoutInst6 (line 566) | func TestGenericTypeWithoutInst6(t *testing.T) {
function TestGenericTypeWithoutInst7 (line 579) | func TestGenericTypeWithoutInst7(t *testing.T) {
function TestGenericTypeWithoutInst8 (line 594) | func TestGenericTypeWithoutInst8(t *testing.T) {
function TestGenericTypeCompositeLit (line 608) | func TestGenericTypeCompositeLit(t *testing.T) {
function TestInferFuncLambda (line 643) | func TestInferFuncLambda(t *testing.T) {
function TestInferOverloadFuncLambda (line 673) | func TestInferOverloadFuncLambda(t *testing.T) {
function TestGenericFuncAlias (line 714) | func TestGenericFuncAlias(t *testing.T) {
function TestGoptLambdaFunc (line 737) | func TestGoptLambdaFunc(t *testing.T) {
function TestGoptLambdaError (line 778) | func TestGoptLambdaError(t *testing.T) {
function TestAliasTypeparams (line 814) | func TestAliasTypeparams(t *testing.T) {
FILE: cmd/chore/goptestgo/goptestgo.go
function fileIsDirty (line 35) | func fileIsDirty(srcMod time.Time, destFile string) bool {
function runGoFile (line 43) | func runGoFile(dir, file, fname string) {
function gopTestRunGo (line 93) | func gopTestRunGo(dir string) {
function main (line 126) | func main() {
FILE: cmd/hdq/xgo_autogen.go
constant _ (line 23) | _ = true
type Cmd_fetch (line 25) | type Cmd_fetch struct
method Main (line 49) | func (this *Cmd_fetch) Main(_xgo_arg0 string) {
method Classfname (line 135) | func (this *Cmd_fetch) Classfname() string {
type Cmd_list (line 29) | type Cmd_list struct
method Main (line 139) | func (this *Cmd_list) Main(_xgo_arg0 string) {
method Classfname (line 155) | func (this *Cmd_list) Classfname() string {
type App (line 33) | type App struct
method MainEntry (line 37) | func (this *App) MainEntry() {
method Main (line 43) | func (this *App) Main() {
function main (line 158) | func main() {
FILE: cmd/internal/base/base.go
type Command (line 31) | type Command struct
method LongName (line 60) | func (c *Command) LongName() string {
method Name (line 72) | func (c *Command) Name() string {
method Usage (line 81) | func (c *Command) Usage(w io.Writer) {
method Runnable (line 95) | func (c *Command) Runnable() bool {
function Main (line 108) | func Main(c *Command, app string, args []string) {
FILE: cmd/internal/base/pass.go
type stringValue (line 9) | type stringValue struct
method String (line 14) | func (p *stringValue) String() string {
method Set (line 18) | func (p *stringValue) Set(v string) error {
type boolValue (line 23) | type boolValue struct
method String (line 28) | func (p *boolValue) String() string {
method Set (line 32) | func (p *boolValue) Set(v string) error {
method IsBoolFlag (line 37) | func (p *boolValue) IsBoolFlag() bool {
type PassArgs (line 41) | type PassArgs struct
method Tags (line 46) | func (p *PassArgs) Tags() string {
method Var (line 55) | func (p *PassArgs) Var(names ...string) {
method Bool (line 61) | func (p *PassArgs) Bool(names ...string) {
function NewPassArgs (line 67) | func NewPassArgs(flag *flag.FlagSet) *PassArgs {
function PassBuildFlags (line 72) | func PassBuildFlags(cmd *Command) *PassArgs {
FILE: cmd/internal/bug/bug.go
function init (line 45) | func init() {
function runCmd (line 49) | func runCmd(_ *base.Command, args []string) {
constant bugHeader (line 70) | bugHeader = `<!-- Please answer these questions before submitting your i...
constant bugFooter (line 73) | bugFooter = `### What did you do?
function printXgoVersion (line 91) | func printXgoVersion(w io.Writer) {
function printEnvDetails (line 100) | func printEnvDetails(w io.Writer) {
function printXgoEnv (line 111) | func printXgoEnv(w io.Writer) {
function printXgoDetails (line 122) | func printXgoDetails(w io.Writer) {
function printOSDetails (line 128) | func printOSDetails(w io.Writer) {
function printCDetails (line 149) | func printCDetails(w io.Writer) {
function printCmdOut (line 163) | func printCmdOut(w io.Writer, prefix, path string, args ...string) {
function firstLine (line 173) | func firstLine(buf []byte) []byte {
function printGlibcVersion (line 183) | func printGlibcVersion(w io.Writer) {
function commands (line 226) | func commands() [][]string {
function open (line 252) | func open(url string) bool {
function appearsSuccessful (line 265) | func appearsSuccessful(cmd *exec.Cmd, timeout time.Duration) bool {
FILE: cmd/internal/build/build.go
function init (line 47) | func init() {
function runCmd (line 51) | func runCmd(cmd *base.Command, args []string) {
function build (line 95) | func build(proj xgoprojs.Proj, conf *tool.Config, build *gocmd.BuildConf...
FILE: cmd/internal/clean/clean.go
constant autoGenFileSuffix (line 30) | autoGenFileSuffix = "_autogen.go"
constant autoGenGopTestFile (line 31) | autoGenGopTestFile = "gop_autogen_test.go"
constant autoGen2GopTestFile (line 32) | autoGen2GopTestFile = "gop_autogen2_test.go"
constant autoGenXgoTestFile (line 33) | autoGenXgoTestFile = "xgo_autogen_test.go"
constant autoGen2XgoTestFile (line 34) | autoGen2XgoTestFile = "xgo_autogen2_test.go"
function cleanAGFiles (line 39) | func cleanAGFiles(dir string, execAct bool) {
function removeGopDir (line 81) | func removeGopDir(dir string, execAct bool) {
function init (line 116) | func init() {
function runCmd (line 120) | func runCmd(_ *base.Command, args []string) {
FILE: cmd/internal/doc/doc.go
function init (line 52) | func init() {
function runCmd (line 56) | func runCmd(cmd *base.Command, args []string) {
function outlinePkg (line 83) | func outlinePkg(proj xgoprojs.Proj, conf *tool.Config) {
constant indent (line 107) | indent = " "
constant ln (line 108) | ln = "\n"
function outlineDoc (line 111) | func outlineDoc(out *outline.All, all, withDoc bool) {
type object (line 168) | type object interface
function printObject (line 173) | func printObject(pkg *types.Package, o object, withDoc bool) {
function printDoc (line 180) | func printDoc(o object) {
function printFuncsForType (line 188) | func printFuncsForType(pkg *types.Package, fns []outline.Func, withDoc b...
function objectString (line 198) | func objectString(pkg *types.Package, obj types.Object) string {
function constShortString (line 205) | func constShortString(obj *types.Const) string {
function qualifier (line 209) | func qualifier(pkg *types.Package) types.Qualifier {
FILE: cmd/internal/env/env.go
function init (line 46) | func init() {
function runCmd (line 50) | func runCmd(_ *base.Command, args []string) {
function outputEnvVars (line 85) | func outputEnvVars(gopEnv map[string]any, vars []string, outputJson bool) {
FILE: cmd/internal/gengo/go.go
function init (line 50) | func init() {
function runCmd (line 54) | func runCmd(cmd *base.Command, args []string) {
function errorNum (line 109) | func errorNum(err error) int {
FILE: cmd/internal/gopfmt/fmt.go
function init (line 54) | func init() {
function gopfmt (line 65) | func gopfmt(path string, class, smart, mvgo bool) (err error) {
function writeFileWithBackup (line 111) | func writeFileWithBackup(path string, target []byte) (err error) {
type walker (line 130) | type walker struct
method walk (line 138) | func (w *walker) walk(path string, d fs.DirEntry, err error) error {
function newWalker (line 134) | func newWalker() *walker {
function report (line 193) | func report(err error) {
function runCmd (line 198) | func runCmd(cmd *base.Command, args []string) {
FILE: cmd/internal/gopget/get.go
function init (line 44) | func init() {
function runCmd (line 48) | func runCmd(cmd *base.Command, args []string) {
function get (line 62) | func get(pkgPath string) {
function check (line 89) | func check(err error) {
FILE: cmd/internal/help/help.go
function Help (line 35) | func Help(w io.Writer, args []string) {
type errWriter (line 78) | type errWriter struct
method Write (line 83) | func (w *errWriter) Write(b []byte) (int, error) {
function tmpl (line 92) | func tmpl(w io.Writer, text string, data any) {
function capitalize (line 110) | func capitalize(s string) string {
function PrintUsage (line 119) | func PrintUsage(w io.Writer, cmd *base.Command) {
FILE: cmd/internal/install/install.go
function init (line 46) | func init() {
function runCmd (line 50) | func runCmd(cmd *base.Command, args []string) {
function install (line 87) | func install(proj xgoprojs.Proj, conf *tool.Config, install *gocmd.Insta...
FILE: cmd/internal/mod/download.go
function init (line 30) | func init() {
FILE: cmd/internal/mod/init.go
function init (line 43) | func init() {
function runInit (line 47) | func runInit(cmd *base.Command, args []string) {
function goMainVer (line 80) | func goMainVer() string {
function llgoLibVer (line 91) | func llgoLibVer() string {
FILE: cmd/internal/mod/mod.go
function check (line 37) | func check(err error) {
function fatal (line 43) | func fatal(msg any) {
FILE: cmd/internal/mod/tidy.go
function init (line 34) | func init() {
function runTidy (line 38) | func runTidy(cmd *base.Command, args []string) {
FILE: cmd/internal/run/run.go
function init (line 49) | func init() {
function runCmd (line 53) | func runCmd(cmd *base.Command, args []string) {
function run (line 97) | func run(proj xgoprojs.Proj, args []string, chDir bool, conf *tool.Confi...
FILE: cmd/internal/serve/serve.go
function init (line 41) | func init() {
function runCmd (line 45) | func runCmd(cmd *base.Command, args []string) {
FILE: cmd/internal/test/test.go
function init (line 45) | func init() {
function runCmd (line 49) | func runCmd(cmd *base.Command, args []string) {
function test (line 85) | func test(proj xgoprojs.Proj, conf *tool.Config, test *gocmd.TestConfig) {
FILE: cmd/internal/test/testflag.go
type boolFlag (line 7) | type boolFlag interface
function PassTestFlags (line 11) | func PassTestFlags(cmd *base.Command) *base.PassArgs {
FILE: cmd/internal/version/ver.go
function init (line 40) | func init() {
function runCmd (line 44) | func runCmd(cmd *base.Command, args []string) {
FILE: cmd/internal/watch/watch.go
function init (line 44) | func init() {
function runCmd (line 48) | func runCmd(cmd *base.Command, args []string) {
FILE: cmd/make.go
function checkPathExist (line 36) | func checkPathExist(path string, isDir bool) bool {
function trimRight (line 45) | func trimRight(s string) string {
type Path (line 50) | type Path struct
method checkExists (line 55) | func (p *Path) checkExists(rootDir string) bool {
function getXgoRoot (line 60) | func getXgoRoot() string {
constant inWindows (line 88) | inWindows = (runtime.GOOS == "windows")
function init (line 91) | func init() {
type ExecCmdError (line 99) | type ExecCmdError struct
method Error (line 104) | func (p *ExecCmdError) Error() string {
type iGitRemote (line 111) | type iGitRemote interface
type gitRemoteImpl (line 119) | type gitRemoteImpl struct
method CheckRemoteUrl (line 123) | func (p *gitRemoteImpl) CheckRemoteUrl() {
method CreateBranchFrom (line 129) | func (p *gitRemoteImpl) CreateBranchFrom(branch, remote string) (err e...
method PushCommits (line 139) | func (p *gitRemoteImpl) PushCommits(remote, branch string) error {
method DeleteBranch (line 144) | func (p *gitRemoteImpl) DeleteBranch(branch string) error {
type gitRemoteNone (line 120) | type gitRemoteNone struct
method CheckRemoteUrl (line 149) | func (p *gitRemoteNone) CheckRemoteUrl() ...
method CreateBranchFrom (line 150) | func (p *gitRemoteNone) CreateBranchFrom(branch, remote string) (err e...
method PushCommits (line 151) | func (p *gitRemoteNone) PushCommits(remote, branch string) error ...
method DeleteBranch (line 152) | func (p *gitRemoteNone) DeleteBranch(branch string) error ...
function execCommand (line 158) | func execCommand(command string, arg ...string) (string, error) {
function getTagRev (line 171) | func getTagRev(tag string) string {
function getGitRemoteUrl (line 184) | func getGitRemoteUrl(name string) string {
function getGitBranch (line 192) | func getGitBranch() string {
function gitTag (line 200) | func gitTag(tag string) error {
function gitTagAndPushTo (line 205) | func gitTagAndPushTo(tag string, remote, branch string) error {
function gitAdd (line 215) | func gitAdd(file string) error {
function gitCommit (line 220) | func gitCommit(msg string) error {
function gitCheckoutBranch (line 230) | func gitCheckoutBranch(branch string) error {
function isGitRepo (line 235) | func isGitRepo() bool {
function getBuildDateTime (line 243) | func getBuildDateTime() string {
function getBuildVer (line 248) | func getBuildVer() string {
function getGopBuildFlags (line 262) | func getGopBuildFlags() string {
function detectGopBinPath (line 276) | func detectGopBinPath() string {
function detectGoBinPath (line 280) | func detectGoBinPath() string {
function linkGoplusToLocalBin (line 299) | func linkGoplusToLocalBin() string {
function buildGoplusTools (line 339) | func buildGoplusTools(useGoProxy bool) {
function showHelpPostInstall (line 372) | func showHelpPostInstall(installPath string) {
function install (line 383) | func install() {
function runTestcases (line 393) | func runTestcases() {
function clean (line 413) | func clean() {
function cleanGopRunCache (line 437) | func cleanGopRunCache() {
function uninstall (line 451) | func uninstall() {
function isInChinaWindows (line 457) | func isInChinaWindows() bool {
function isInChina (line 468) | func isInChina() bool {
function findXgoVersion (line 485) | func findXgoVersion() string {
function releaseNewVersion (line 503) | func releaseNewVersion(tag string) {
function runRegtests (line 555) | func runRegtests() {
function main (line 572) | func main() {
FILE: cmd/make_test.go
constant inWindows (line 18) | inWindows = (runtime.GOOS == "windows")
function checkPathExist (line 28) | func checkPathExist(path string, isDir bool) bool {
function trimRight (line 37) | func trimRight(s string) string {
function execCommand (line 41) | func execCommand(command string, arg ...string) (string, error) {
function getBranch (line 55) | func getBranch() string {
function detectGoBinPath (line 63) | func detectGoBinPath() string {
function init (line 80) | func init() {
function cleanGopRunCacheFiles (line 95) | func cleanGopRunCacheFiles(t *testing.T) {
function TestAllScript (line 107) | func TestAllScript(t *testing.T) {
function TestTagFlagInGitRepo (line 136) | func TestTagFlagInGitRepo(t *testing.T) {
function TestTagFlagInNonGitRepo (line 249) | func TestTagFlagInNonGitRepo(t *testing.T) {
function TestInstallInNonGitRepo (line 276) | func TestInstallInNonGitRepo(t *testing.T) {
function TestHandleMultiFlags (line 331) | func TestHandleMultiFlags(t *testing.T) {
FILE: cmd/xgo/xgo_autogen.go
constant _ (line 29) | _ = true
type Cmd_bug (line 31) | type Cmd_bug struct
method Main (line 137) | func (this *Cmd_bug) Main(_xgo_arg0 string) {
method Classfname (line 151) | func (this *Cmd_bug) Classfname() string {
type Cmd_build (line 35) | type Cmd_build struct
method Main (line 155) | func (this *Cmd_build) Main(_xgo_arg0 string) {
method Classfname (line 169) | func (this *Cmd_build) Classfname() string {
type Cmd_clean (line 39) | type Cmd_clean struct
method Main (line 173) | func (this *Cmd_clean) Main(_xgo_arg0 string) {
method Classfname (line 187) | func (this *Cmd_clean) Classfname() string {
type Cmd_doc (line 43) | type Cmd_doc struct
method Main (line 191) | func (this *Cmd_doc) Main(_xgo_arg0 string) {
method Classfname (line 205) | func (this *Cmd_doc) Classfname() string {
type Cmd_env (line 47) | type Cmd_env struct
method Main (line 209) | func (this *Cmd_env) Main(_xgo_arg0 string) {
method Classfname (line 223) | func (this *Cmd_env) Classfname() string {
type Cmd_fmt (line 51) | type Cmd_fmt struct
method Main (line 227) | func (this *Cmd_fmt) Main(_xgo_arg0 string) {
method Classfname (line 241) | func (this *Cmd_fmt) Classfname() string {
type Cmd_get (line 55) | type Cmd_get struct
method Main (line 245) | func (this *Cmd_get) Main(_xgo_arg0 string) {
method Classfname (line 259) | func (this *Cmd_get) Classfname() string {
type Cmd_go (line 59) | type Cmd_go struct
method Main (line 263) | func (this *Cmd_go) Main(_xgo_arg0 string) {
method Classfname (line 277) | func (this *Cmd_go) Classfname() string {
type Cmd_install (line 63) | type Cmd_install struct
method Main (line 281) | func (this *Cmd_install) Main(_xgo_arg0 string) {
method Classfname (line 295) | func (this *Cmd_install) Classfname() string {
type App (line 67) | type App struct
method MainEntry (line 107) | func (this *App) MainEntry() {
method Main (line 115) | func (this *App) Main() {
type Cmd_mod (line 70) | type Cmd_mod struct
method Main (line 299) | func (this *Cmd_mod) Main(_xgo_arg0 string) {
method Classfname (line 311) | func (this *Cmd_mod) Classfname() string {
type Cmd_mod_download (line 74) | type Cmd_mod_download struct
method Main (line 315) | func (this *Cmd_mod_download) Main(_xgo_arg0 string) {
method Classfname (line 336) | func (this *Cmd_mod_download) Classfname() string {
type Cmd_mod_init (line 78) | type Cmd_mod_init struct
method Main (line 340) | func (this *Cmd_mod_init) Main(_xgo_arg0 string) {
method Classfname (line 361) | func (this *Cmd_mod_init) Classfname() string {
type Cmd_mod_tidy (line 82) | type Cmd_mod_tidy struct
method Main (line 365) | func (this *Cmd_mod_tidy) Main(_xgo_arg0 string) {
method Classfname (line 379) | func (this *Cmd_mod_tidy) Classfname() string {
type Cmd_run (line 86) | type Cmd_run struct
method Main (line 383) | func (this *Cmd_run) Main(_xgo_arg0 string) {
method Classfname (line 397) | func (this *Cmd_run) Classfname() string {
type Cmd_serve (line 90) | type Cmd_serve struct
method Main (line 401) | func (this *Cmd_serve) Main(_xgo_arg0 string) {
method Classfname (line 415) | func (this *Cmd_serve) Classfname() string {
type Cmd_test (line 94) | type Cmd_test struct
method Main (line 419) | func (this *Cmd_test) Main(_xgo_arg0 string) {
method Classfname (line 433) | func (this *Cmd_test) Classfname() string {
type Cmd_version (line 98) | type Cmd_version struct
method Main (line 437) | func (this *Cmd_version) Main(_xgo_arg0 string) {
method Classfname (line 449) | func (this *Cmd_version) Classfname() string {
type Cmd_watch (line 102) | type Cmd_watch struct
method Main (line 453) | func (this *Cmd_watch) Main(_xgo_arg0 string) {
method Classfname (line 467) | func (this *Cmd_watch) Classfname() string {
function main (line 470) | func main() {
FILE: demo/fullspec/mixgo-complex/bar.go
type ift (line 9) | type ift interface
type impl (line 15) | type impl struct
function Bar (line 19) | func Bar(t *testing.T) int {
FILE: demo/fullspec/mixgo-complex/xgo_autogen.go
constant _ (line 11) | _ = true
type ift2 (line 13) | type ift2 interface
type T (line 19) | type T struct
method Close (line 23) | func (T) Close() (err error) {
method g (line 30) | func (t T) g() {
method f (line 33) | func (t T) f(a int) (b string) {
function Foo (line 40) | func Foo(i *impl) string {
function foo (line 51) | func foo(a int, b int) string {
function main (line 56) | func main() {
FILE: demo/mixgo/a.go
function p (line 5) | func p(a any) {
FILE: demo/mixgo/xgo_autogen.go
constant _ (line 7) | _ = true
function sayMix (line 9) | func sayMix() {
function main (line 14) | func main() {
FILE: demo/typeasparamsfunc/col.go
function XGox_Col (line 8) | func XGox_Col[T any](name string) {
FILE: demo/typeasparamsmethod/col.go
type basetype (line 8) | type basetype interface
type Table (line 12) | type Table struct
function XGot_Table_XGox_Col__0 (line 15) | func XGot_Table_XGox_Col__0[T basetype](p *Table, name string) {
function XGot_Table_XGox_Col__1 (line 19) | func XGot_Table_XGox_Col__1[Array any](p *Table, name string) {
FILE: demo/typeparamscast/foo.go
type basetype (line 5) | type basetype interface
type Var__0 (line 9) | type Var__0 struct
type Var__1 (line 13) | type Var__1 struct
function XGox_Var_Cast__0 (line 17) | func XGox_Var_Cast__0[T basetype]() *Var__0[T] {
function XGox_Var_Cast__1 (line 21) | func XGox_Var_Cast__1[T map[string]any]() *Var__1[T] {
FILE: demo/xgo-sample/cpkag/b/ab.go
function Ab (line 3) | func Ab() {
FILE: doc/_testdata/gopoFn/in.go
constant GopPackage (line 3) | GopPackage = true
constant Gopo_Add (line 5) | Gopo_Add = "AddInt,,AddString"
function Add__1 (line 8) | func Add__1(a, b float64) float64 {
function AddInt (line 13) | func AddInt(a, b int) int {
function AddString (line 18) | func AddString(a, b string) string {
FILE: doc/_testdata/gopoMethod/in.go
constant GopPackage (line 3) | GopPackage = true
constant Gopo__T__Gop_Add (line 5) | Gopo__T__Gop_Add = ".AddInt,AddString"
type T (line 7) | type T
method AddInt (line 10) | func (p T) AddInt(b int) *T {
function AddString (line 15) | func AddString(this *T, b string) *T {
FILE: doc/_testdata/overloadFn/in.go
constant GopPackage (line 3) | GopPackage = true
function Bar__0 (line 6) | func Bar__0() {
FILE: doc/_testdata/overloadMethod/in.go
constant GopPackage (line 3) | GopPackage = true
type T (line 5) | type T
method Bar__0 (line 8) | func (p *T) Bar__0() {
method Bar__1 (line 12) | func (t T) Bar__1() {
FILE: doc/_testdata/xgoOverloadFn/in.go
constant XGoPackage (line 3) | XGoPackage = true
function Bar__0 (line 6) | func Bar__0() {
FILE: doc/_testdata/xgoOverloadMethod/in.go
constant XGoPackage (line 3) | XGoPackage = true
type T (line 5) | type T
method Bar__0 (line 8) | func (p *T) Bar__0() {
method Bar__1 (line 12) | func (t T) Bar__1() {
FILE: doc/z_gop.go
constant goptPrefix (line 25) | goptPrefix = "Gopt_"
constant gopoPrefix (line 26) | gopoPrefix = "Gopo_"
constant gopxPrefix (line 27) | gopxPrefix = "Gopx_"
constant gopPackage (line 28) | gopPackage = "GopPackage"
constant xgoPackage (line 29) | xgoPackage = "XGoPackage"
function isXGoPackage (line 32) | func isXGoPackage(in *doc.Package) bool {
function isGopoConst (line 43) | func isGopoConst(name string) bool {
function hasGopoConst (line 47) | func hasGopoConst(in *doc.Value) bool {
function isOverload (line 56) | func isOverload(name string) bool {
function checkTypeMethod (line 65) | func checkTypeMethod(name string) mthd {
FILE: doc/z_test.go
function TestToIndex (line 33) | func TestToIndex(t *testing.T) {
function TestCheckTypeMethod (line 45) | func TestCheckTypeMethod(t *testing.T) {
function TestIsXGoPackage (line 54) | func TestIsXGoPackage(t *testing.T) {
function TestDocRecv (line 60) | func TestDocRecv(t *testing.T) {
function printVal (line 66) | func printVal(parts []string, format string, val any) []string {
function printFuncDecl (line 70) | func printFuncDecl(parts []string, fset *token.FileSet, decl *ast.FuncDe...
function printFunc (line 78) | func printFunc(parts []string, fset *token.FileSet, format string, fn *d...
function printFuncs (line 88) | func printFuncs(parts []string, fset *token.FileSet, fns []*doc.Func) []...
function printType (line 95) | func printType(parts []string, fset *token.FileSet, typ *doc.Type) []str...
function printTypes (line 106) | func printTypes(parts []string, fset *token.FileSet, types []*doc.Type) ...
function printPkg (line 113) | func printPkg(fset *token.FileSet, in *doc.Package) string {
function testPkg (line 120) | func testPkg(t *testing.T, filename string, src any, expected string) {
function testFromDir (line 137) | func testFromDir(t *testing.T, sel, relDir string) {
function TestFromTestdata (line 163) | func TestFromTestdata(t *testing.T) {
FILE: doc/z_transform.go
type mthd (line 28) | type mthd struct
type omthd (line 33) | type omthd struct
type typExtra (line 38) | type typExtra struct
type transformCtx (line 44) | type transformCtx struct
method finish (line 50) | func (p *transformCtx) finish(in *doc.Package) {
method mergeFuncs (line 61) | func (p *transformCtx) mergeFuncs(a, b []*doc.Func) []*doc.Func {
function newCtx (line 77) | func newCtx(in *doc.Package) *transformCtx {
function newIdent (line 90) | func newIdent(name string, in *ast.Ident) *ast.Ident {
function newFuncDecl (line 96) | func newFuncDecl(name string, in *ast.FuncDecl) *ast.FuncDecl {
function newMethodDecl (line 102) | func newMethodDecl(name string, in *ast.FuncDecl) *ast.FuncDecl {
function docRecv (line 116) | func docRecv(recv *ast.Field) (_ string, ok bool) {
function newMethod (line 128) | func newMethod(name string, in *doc.Func) *doc.Func {
function newFunc (line 139) | func newFunc(name string, in *doc.Func) *doc.Func {
function setOrder (line 147) | func setOrder(ctx *transformCtx, in *doc.Func, order int) *doc.Func {
function buildFunc (line 152) | func buildFunc(ctx *transformCtx, overload omthd, in *doc.Func) {
function toIndex (line 162) | func toIndex(c byte) int {
function transformFunc (line 172) | func transformFunc(ctx *transformCtx, t *doc.Type, in *doc.Func, method ...
function transformFuncs (line 191) | func transformFuncs(ctx *transformCtx, t *doc.Type, in []*doc.Func, meth...
function transformTypes (line 197) | func transformTypes(ctx *transformCtx, in []*doc.Type) {
function transformGopo (line 204) | func transformGopo(ctx *transformCtx, name, val string) {
function transformConstSpec (line 221) | func transformConstSpec(ctx *transformCtx, vspec *ast.ValueSpec) {
function transformConst (line 234) | func transformConst(ctx *transformCtx, in *doc.Value) {
function transformConsts (line 243) | func transformConsts(ctx *transformCtx, in []*doc.Value) {
function Transform (line 250) | func Transform(in *doc.Package) *doc.Package {
FILE: dql/dql.go
constant XGoPackage (line 26) | XGoPackage = true
function NopIter (line 37) | func NopIter[T any](yield func(T) bool) {}
function First (line 43) | func First[T any, Seq ~func(func(T) bool)](seq Seq) (ret T, err error) {
function Single (line 55) | func Single[T any, Seq ~func(func(T) bool)](seq Seq) (ret T, err error) {
function Collect (line 71) | func Collect[T any, Seq ~func(func(T) bool)](seq Seq) []T {
function Int (line 84) | func Int(text string) (int, error) {
FILE: dql/fetcher/fetch.go
function convert (line 35) | func convert(conv reflect.Value, input, source any) any {
function URL (line 48) | func URL(fetchType string, input any) (string, error) {
function Do (line 58) | func Do(fetchType string, input any) (any, error) {
function From (line 69) | func From(fetchType string, input, source any) (any, error) {
type fetchInfo (line 79) | type fetchInfo struct
function Register (line 91) | func Register(fetchType string, conv Conv, urlOf func(input any) string) {
function List (line 97) | func List() []string {
FILE: dql/fetcher/github.com/issueTask/xgo_autogen.go
constant XGoPackage (line 11) | XGoPackage = "github.com/goplus/xgo/dql/html"
constant _ (line 12) | _ = true
type Task (line 14) | type Task struct
type Result (line 19) | type Result struct
function New (line 25) | func New(input interface{}, doc html.NodeSet) Result {
function URL (line 67) | func URL(input interface{}) string {
function init (line 79) | func init() {
FILE: dql/fetcher/github.com/repoList/xgo_autogen.go
constant XGoPackage (line 11) | XGoPackage = "github.com/goplus/xgo/dql/html"
constant _ (line 12) | _ = true
type Repo (line 14) | type Repo struct
type Result (line 23) | type Result struct
function newRepo (line 29) | func newRepo(node html.NodeSet) Repo {
function New (line 159) | func New(input interface{}, doc html.NodeSet) Result {
function URL (line 243) | func URL(input interface{}) string {
function init (line 248) | func init() {
FILE: dql/fetcher/hrefs/xgo_autogen.go
constant XGoPackage (line 10) | XGoPackage = "github.com/goplus/xgo/dql/html"
constant _ (line 11) | _ = true
type Result (line 13) | type Result struct
function New (line 19) | func New(input interface{}, doc html.NodeSet) Result {
function URL (line 43) | func URL(input interface{}) string {
function init (line 48) | func init() {
FILE: dql/fetcher/pkg.go.dev/importedBy/xgo_autogen.go
constant XGoPackage (line 13) | XGoPackage = "github.com/goplus/xgo/dql/html"
constant _ (line 14) | _ = true
type Result (line 16) | type Result struct
function New (line 23) | func New(input interface{}, doc html.NodeSet) Result {
function URL (line 104) | func URL(input interface{}) string {
function init (line 109) | func init() {
FILE: dql/fetcher/pytorch.org/fndoc/xgo_autogen.go
constant XGoPackage (line 11) | XGoPackage = "github.com/goplus/xgo/dql/html"
constant _ (line 12) | _ = true
constant spaces (line 13) | spaces = " \t\r\n¶"
type Result (line 15) | type Result struct
function New (line 25) | func New(input interface{}, doc html.NodeSet) Result {
function URL (line 77) | func URL(input interface{}) string {
function init (line 82) | func init() {
FILE: dql/fs/fs.go
type Node (line 33) | type Node struct
method Name (line 47) | func (p *Node) Name() (string, error) {
method IsDir (line 55) | func (p *Node) IsDir() (bool, error) {
method info (line 62) | func (p *Node) info() (fs.FileInfo, error) {
method Size (line 73) | func (p *Node) Size() (int64, error) {
method Type (line 83) | func (p *Node) Type() (fs.FileMode, error) {
method Mode (line 91) | func (p *Node) Mode() (fs.FileMode, error) {
method ModTime (line 100) | func (p *Node) ModTime() (time.Time, error) {
method Sys (line 109) | func (p *Node) Sys() (any, error) {
type NodeSet (line 121) | type NodeSet struct
method XGo_Enum (line 213) | func (p NodeSet) XGo_Enum() iter.Seq[NodeSet] {
method Dir (line 226) | func (p NodeSet) Dir() NodeSet {
method File (line 242) | func (p NodeSet) File() NodeSet {
method XGo_Child (line 257) | func (p NodeSet) XGo_Child() NodeSet {
method XGo_Any (line 329) | func (p NodeSet) XGo_Any(name string) NodeSet {
method Match (line 387) | func (p NodeSet) Match(pattern string) NodeSet {
method OnError (line 414) | func (p NodeSet) OnError(onErr func(error) bool) NodeSet {
method All (line 437) | func (p NodeSet) All() NodeSet {
method One (line 447) | func (p NodeSet) One() NodeSet {
method Single (line 461) | func (p NodeSet) Single() NodeSet {
method Ok (line 475) | func (p NodeSet) Ok() bool {
method XGo_first (line 481) | func (p NodeSet) XGo_first() (ret *Node, err error) {
method First (line 490) | func (p NodeSet) First() (*Node, error) {
method Collect (line 498) | func (p NodeSet) Collect() ([]*Node, error) {
method Path (line 514) | func (p NodeSet) Path() (name string, err error) {
method Name (line 523) | func (p NodeSet) Name() (name string, err error) {
method IsDir (line 532) | func (p NodeSet) IsDir() (is bool, err error) {
method Size (line 541) | func (p NodeSet) Size() (size int64, err error) {
method Mode (line 550) | func (p NodeSet) Mode() (mode fs.FileMode, err error) {
method ModTime (line 559) | func (p NodeSet) ModTime() (modTime time.Time, err error) {
function Root (line 128) | func Root(root fs.FS, doc *Node) NodeSet {
function Nodes (line 138) | func Nodes(root fs.FS, nodes ...*Node) NodeSet {
function Dir (line 152) | func Dir(dir string) NodeSet {
function New (line 158) | func New(root fs.FS) NodeSet {
type rootDirEntry (line 175) | type rootDirEntry struct
method Name (line 178) | func (p rootDirEntry) Name() string {
method Size (line 182) | func (p rootDirEntry) Size() int64 {
method Type (line 186) | func (p rootDirEntry) Type() fs.FileMode {
method Mode (line 190) | func (p rootDirEntry) Mode() fs.FileMode {
method Info (line 194) | func (p rootDirEntry) Info() (fs.FileInfo, error) {
method ModTime (line 198) | func (p rootDirEntry) ModTime() time.Time {
method IsDir (line 202) | func (p rootDirEntry) IsDir() bool {
method Sys (line 206) | func (p rootDirEntry) Sys() any {
function filterDir (line 273) | func filterDir(de fs.DirEntry) bool {
function filterFile (line 277) | func filterFile(de fs.DirEntry) bool {
function yieldChildNodes (line 282) | func yieldChildNodes(base fs.FS, node *Node, filter filterType, yield fu...
constant kindAny (line 316) | kindAny = iota
constant kindFile (line 317) | kindFile
constant kindDir (line 318) | kindDir
function yieldAnyNodes (line 355) | func yieldAnyNodes(kind int, base fs.FS, node *Node, yield func(*Node) b...
FILE: dql/golang/golang.go
constant XGoPackage (line 34) | XGoPackage = "github.com/goplus/xgo/dql/reflects"
type NodeSet (line 43) | type NodeSet struct
method XGo_Enum (line 153) | func (p NodeSet) XGo_Enum() iter.Seq[NodeSet] {
method XGo_Select (line 167) | func (p NodeSet) XGo_Select(name string) NodeSet {
method XGo_Elem (line 176) | func (p NodeSet) XGo_Elem(name string) NodeSet {
method XGo_Child (line 183) | func (p NodeSet) XGo_Child() NodeSet {
method XGo_Any (line 195) | func (p NodeSet) XGo_Any(name string) NodeSet {
method All (line 206) | func (p NodeSet) All() NodeSet {
method One (line 214) | func (p NodeSet) One() NodeSet {
method Single (line 223) | func (p NodeSet) Single() NodeSet {
method Ok (line 232) | func (p NodeSet) Ok() bool {
method XGo_Attr__0 (line 240) | func (p NodeSet) XGo_Attr__0(name string) any {
method XGo_Attr__1 (line 249) | func (p NodeSet) XGo_Attr__1(name string) (val any, err error) {
method Class (line 269) | func (p NodeSet) Class() string {
function NodeSet_Cast (line 48) | func NodeSet_Cast(seq iter.Seq[Node]) NodeSet {
function Root (line 55) | func Root(doc Node) NodeSet {
function Nodes (line 62) | func Nodes(nodes ...Node) NodeSet {
function New (line 69) | func New(f *ast.File) NodeSet {
type Config (line 76) | type Config struct
constant defaultMode (line 82) | defaultMode = parser.ParseComments
function parse (line 86) | func parse(uri string, src any, conf ...Config) (f *ast.File, err error) {
function From (line 105) | func From(uri string, src any, conf ...Config) NodeSet {
function Source (line 125) | func Source(r any, conf ...Config) (ret NodeSet) {
FILE: dql/golang/parse.go
type File (line 27) | type File struct
method XGo_Elem (line 47) | func (f *File) XGo_Elem(name string) NodeSet {
method XGo_Child (line 53) | func (f *File) XGo_Child() NodeSet {
method XGo_Any (line 63) | func (f *File) XGo_Any(name string) NodeSet {
function ParseFile (line 34) | func ParseFile(filename string, src any, conf ...Config) (f *File, err e...
FILE: dql/html/html.go
constant XGoPackage (line 32) | XGoPackage = true
type NodeSet (line 38) | type NodeSet struct
method XGo_Enum (line 122) | func (p NodeSet) XGo_Enum() iter.Seq[NodeSet] {
method XGo_Select (line 136) | func (p NodeSet) XGo_Select(name string) NodeSet {
method XGo_Elem (line 160) | func (p NodeSet) XGo_Elem(name string) NodeSet {
method XGo_Child (line 186) | func (p NodeSet) XGo_Child() NodeSet {
method XGo_Any (line 216) | func (p NodeSet) XGo_Any(name string) NodeSet {
method All (line 264) | func (p NodeSet) All() NodeSet {
method One (line 274) | func (p NodeSet) One() NodeSet {
method Single (line 288) | func (p NodeSet) Single() NodeSet {
method ParentN (line 300) | func (p NodeSet) ParentN(n int) NodeSet {
method Parent (line 330) | func (p NodeSet) Parent() NodeSet {
method PrevSibling (line 347) | func (p NodeSet) PrevSibling() NodeSet {
method NextSibling (line 364) | func (p NodeSet) NextSibling() NodeSet {
method FirstElementChild (line 382) | func (p NodeSet) FirstElementChild() NodeSet {
method TextNode (line 401) | func (p NodeSet) TextNode() NodeSet {
method Dump (line 428) | func (p NodeSet) Dump() NodeSet {
method Ok (line 448) | func (p NodeSet) Ok() bool {
method XGo_first (line 454) | func (p NodeSet) XGo_first() (ret *Node, err error) {
method First (line 463) | func (p NodeSet) First() (*Node, error) {
method Collect (line 471) | func (p NodeSet) Collect() ([]*Node, error) {
method Name (line 481) | func (p NodeSet) Name() string {
method Value__0 (line 492) | func (p NodeSet) Value__0() string {
method Value__1 (line 498) | func (p NodeSet) Value__1() (val string, err error) {
method HasAttr (line 508) | func (p NodeSet) HasAttr(name string) bool {
method XGo_Attr__0 (line 520) | func (p NodeSet) XGo_Attr__0(name string) string {
method XGo_Attr__1 (line 529) | func (p NodeSet) XGo_Attr__1(name string) (val string, err error) {
function NodeSet_Cast (line 44) | func NodeSet_Cast(seq iter.Seq[*Node]) NodeSet {
function Root (line 49) | func Root(doc *Node) NodeSet {
function Nodes (line 63) | func Nodes(nodes ...*Node) NodeSet {
function New (line 78) | func New(r io.Reader) NodeSet {
function Source (line 94) | func Source(r any) (ret NodeSet) {
function selectNode (line 150) | func selectNode(node *Node, name string, yield func(*Node) bool) bool {
function yieldNode (line 174) | func yieldNode(n *Node, name string, yield func(*Node) bool) bool {
function yieldChildNodes (line 200) | func yieldChildNodes(n *Node, yield func(*Node) bool) bool {
function yieldAnyNodes (line 232) | func yieldAnyNodes(n *Node, name string, yield func(*Node) bool) bool {
function yieldParentN (line 313) | func yieldParentN(node *Node, n int, yield func(*Node) bool) bool {
function yieldNodeType (line 414) | func yieldNodeType(node *Node, typ html.NodeType, yield func(*Node) bool...
FILE: dql/html/html_test.go
function TestTextOf (line 27) | func TestTextOf(t *testing.T) {
constant codeBody (line 63) | codeBody = `<div data-v-9ebd45a1="" class="code-body">
type commentRemover (line 80) | type commentRemover struct
method Filter (line 84) | func (f commentRemover) Filter(node *html.Node) bool {
function TestTextFilter (line 96) | func TestTextFilter(t *testing.T) {
FILE: dql/html/node.go
type Node (line 30) | type Node struct
method XGo_Elem (line 53) | func (n *Node) XGo_Elem(name string) NodeSet {
method XGo_Child (line 59) | func (n *Node) XGo_Child() NodeSet {
method XGo_Any (line 69) | func (n *Node) XGo_Any(name string) NodeSet {
method Dump (line 74) | func (n *Node) Dump() NodeSet {
method Name (line 82) | func (n *Node) Name() string {
method Value (line 90) | func (n *Node) Value() string {
method HasAttr (line 95) | func (n *Node) HasAttr(name string) bool {
method XGo_Attr__0 (line 108) | func (n *Node) XGo_Attr__0(name string) string {
method XGo_Attr__1 (line 117) | func (n *Node) XGo_Attr__1(name string) (string, error) {
function Parse (line 36) | func Parse(r io.Reader) (n *Node, err error) {
function toNode (line 44) | func toNode(n *html.Node) *Node {
FILE: dql/html/text.go
type NodeFilter (line 28) | type NodeFilter interface
type noFilter (line 38) | type noFilter struct
method Filter (line 40) | func (f noFilter) Filter(*html.Node) bool { return true }
method TextNodeData (line 41) | func (f noFilter) TextNodeData(node *html.Node) string {
function textOf (line 46) | func textOf[F NodeFilter](node *html.Node, outer bool, f F) string {
type textPrinter (line 54) | type textPrinter struct
function isSpace (line 61) | func isSpace(c byte) bool {
method printCollapsed (line 65) | func (p *textPrinter[F]) printCollapsed(v string) {
method printVerbatim (line 94) | func (p *textPrinter[F]) printVerbatim(v string) {
method printNode (line 103) | func (p *textPrinter[F]) printNode(node *html.Node, outer, verbatim bool) {
method Text__0 (line 138) | func (p NodeSet) Text__0() string {
method Text__1 (line 145) | func (p NodeSet) Text__1() (val string, err error) {
function Text (line 164) | func Text[F NodeFilter](ns NodeSet, outer bool, f F) (val string, err er...
method Int (line 174) | func (p NodeSet) Int() (int, error) {
FILE: dql/json/json.go
constant XGoPackage (line 30) | XGoPackage = "github.com/goplus/xgo/dql/maps"
function New (line 42) | func New(r io.Reader) NodeSet {
function Source (line 61) | func Source(r any) (ret NodeSet) {
FILE: dql/maps/maps.go
constant XGoPackage (line 26) | XGoPackage = true
type NodeSet (line 32) | type NodeSet struct
method XGo_Enum (line 105) | func (p NodeSet) XGo_Enum() iter.Seq[NodeSet] {
method XGo_Select (line 119) | func (p NodeSet) XGo_Select(name string) NodeSet {
method XGo_Elem (line 138) | func (p NodeSet) XGo_Elem(name string) NodeSet {
method XGo_Child (line 162) | func (p NodeSet) XGo_Child() NodeSet {
method XGo_Any (line 200) | func (p NodeSet) XGo_Any(name string) NodeSet {
method XGo_all (line 253) | func (p NodeSet) XGo_all() NodeSet {
method XGo_one (line 263) | func (p NodeSet) XGo_one() NodeSet {
method XGo_single (line 277) | func (p NodeSet) XGo_single() NodeSet {
method XGo_ok (line 291) | func (p NodeSet) XGo_ok() bool {
method XGo_first (line 296) | func (p NodeSet) XGo_first() (Node, error) {
method XGo_name__0 (line 305) | func (p NodeSet) XGo_name__0() string {
method XGo_name__1 (line 312) | func (p NodeSet) XGo_name__1() (ret string, err error) {
method XGo_value__0 (line 322) | func (p NodeSet) XGo_value__0() any {
method XGo_value__1 (line 329) | func (p NodeSet) XGo_value__1() (ret any, err error) {
method XGo_hasAttr (line 339) | func (p NodeSet) XGo_hasAttr(name string) bool {
method XGo_Attr__0 (line 351) | func (p NodeSet) XGo_Attr__0(name string) any {
method XGo_Attr__1 (line 360) | func (p NodeSet) XGo_Attr__1(name string) (val any, err error) {
function NodeSet_Cast (line 38) | func NodeSet_Cast(seq iter.Seq[Node]) NodeSet {
function Root (line 43) | func Root(doc Node) NodeSet {
function Nodes (line 52) | func Nodes(nodes ...Node) NodeSet {
function New (line 67) | func New(doc any) NodeSet {
function Source (line 87) | func Source(r any) (ret NodeSet) {
function yieldElem (line 152) | func yieldElem(node Node, name string, yield func(Node) bool) bool {
function yieldChildNodes (line 176) | func yieldChildNodes(node Node, yield func(Node) bool) bool {
function yieldAnyNodes (line 215) | func yieldAnyNodes(name string, node Node, yield func(Node) bool) bool {
function yieldAnyNode (line 240) | func yieldAnyNode(name, k string, v any, yield func(Node) bool) bool {
FILE: dql/maps/node.go
type Node (line 26) | type Node struct
method XGo_Elem (line 34) | func (n Node) XGo_Elem(name string) (ret Node) {
method XGo_Child (line 45) | func (n Node) XGo_Child() NodeSet {
method XGo_Any (line 55) | func (n Node) XGo_Any(name string) NodeSet {
method XGo_hasAttr (line 62) | func (n Node) XGo_hasAttr(name string) bool {
method XGo_Attr__0 (line 75) | func (n Node) XGo_Attr__0(name string) any {
method XGo_Attr__1 (line 84) | func (n Node) XGo_Attr__1(name string) (any, error) {
FILE: dql/reflects/node.go
function capitalize (line 26) | func capitalize(name string) string {
function uncapitalize (line 36) | func uncapitalize(name string) string {
function allowAnyMethod (line 45) | func allowAnyMethod(obj reflect.Value, name string) bool {
function lookup (line 53) | func lookup(obj reflect.Value, name string, allowMthd func(reflect.Value...
function deref (line 77) | func deref(v reflect.Value) (reflect.Kind, reflect.Value) {
type Node (line 93) | type Node struct
method XGo_Elem (line 101) | func (n Node) XGo_Elem(name string) (ret Node) {
method XGo_ElemEx (line 109) | func (n Node) XGo_ElemEx(name string, allowMthd func(reflect.Value, st...
method XGo_Child (line 118) | func (n Node) XGo_Child() NodeSet {
method XGo_Any (line 128) | func (n Node) XGo_Any(name string) NodeSet {
method XGo_hasAttr (line 135) | func (n Node) XGo_hasAttr(name string) bool {
method XGo_Attr__0 (line 143) | func (n Node) XGo_Attr__0(name string) any {
method XGo_Attr__1 (line 152) | func (n Node) XGo_Attr__1(name string) (any, error) {
method XGo_AttrEx (line 161) | func (n Node) XGo_AttrEx(name string, allowMthd func(reflect.Value, st...
FILE: dql/reflects/reflects.go
constant XGoPackage (line 27) | XGoPackage = true
type NodeSet (line 33) | type NodeSet struct
method XGo_Enum (line 96) | func (p NodeSet) XGo_Enum() iter.Seq[NodeSet] {
method XGo_Select (line 110) | func (p NodeSet) XGo_Select(name string) NodeSet {
method XGo_Elem (line 129) | func (p NodeSet) XGo_Elem(name string) NodeSet {
method XGo_ElemEx (line 137) | func (p NodeSet) XGo_ElemEx(name string, allowMthd func(reflect.Value,...
method XGo_Child (line 205) | func (p NodeSet) XGo_Child() NodeSet {
method XGo_Any (line 224) | func (p NodeSet) XGo_Any(name string) NodeSet {
method XGo_all (line 242) | func (p NodeSet) XGo_all() NodeSet {
method XGo_one (line 252) | func (p NodeSet) XGo_one() NodeSet {
method XGo_single (line 266) | func (p NodeSet) XGo_single() NodeSet {
method XGo_ok (line 280) | func (p NodeSet) XGo_ok() bool {
method XGo_first (line 285) | func (p NodeSet) XGo_first() (Node, error) {
method XGo_name__0 (line 294) | func (p NodeSet) XGo_name__0() string {
method XGo_name__1 (line 301) | func (p NodeSet) XGo_name__1() (ret string, err error) {
method XGo_value__0 (line 311) | func (p NodeSet) XGo_value__0() any {
method XGo_value__1 (line 318) | func (p NodeSet) XGo_value__1() (ret any, err error) {
method XGo_class (line 327) | func (p NodeSet) XGo_class() (class string) {
method XGo_hasAttr (line 341) | func (p NodeSet) XGo_hasAttr(name string) bool {
method XGo_Attr__0 (line 353) | func (p NodeSet) XGo_Attr__0(name string) any {
method XGo_Attr__1 (line 362) | func (p NodeSet) XGo_Attr__1(name string) (any, error) {
method XGo_AttrEx (line 371) | func (p NodeSet) XGo_AttrEx(name string, allowMthd func(reflect.Value,...
function NodeSet_Cast (line 39) | func NodeSet_Cast(seq iter.Seq[Node]) NodeSet {
function Root (line 44) | func Root(doc Node) NodeSet {
function Nodes (line 53) | func Nodes(nodes ...Node) NodeSet {
function New (line 66) | func New(doc reflect.Value) NodeSet {
function Source (line 80) | func Source(r any) (ret NodeSet) {
function yieldElem (line 151) | func yieldElem(node Node, name string, allowMthd func(reflect.Value, str...
function yieldChildNodes (line 158) | func yieldChildNodes(node reflect.Value, yield func(Node) bool) bool {
function yieldAnyNodes (line 193) | func yieldAnyNodes(name string, node Node, yield func(Node) bool) bool {
FILE: dql/xgo/parse.go
type File (line 28) | type File struct
method XGo_Elem (line 48) | func (f *File) XGo_Elem(name string) NodeSet {
method XGo_Child (line 54) | func (f *File) XGo_Child() NodeSet {
method XGo_Any (line 64) | func (f *File) XGo_Any(name string) NodeSet {
function ParseFile (line 35) | func ParseFile(filename string, src any, conf ...Config) (f *File, err e...
FILE: dql/xgo/xgo.go
constant XGoPackage (line 34) | XGoPackage = "github.com/goplus/xgo/dql/reflects"
type NodeSet (line 43) | type NodeSet struct
method XGo_Enum (line 153) | func (p NodeSet) XGo_Enum() iter.Seq[NodeSet] {
method XGo_Select (line 167) | func (p NodeSet) XGo_Select(name string) NodeSet {
method XGo_Elem (line 176) | func (p NodeSet) XGo_Elem(name string) NodeSet {
method XGo_Child (line 183) | func (p NodeSet) XGo_Child() NodeSet {
method XGo_Any (line 195) | func (p NodeSet) XGo_Any(name string) NodeSet {
method All (line 206) | func (p NodeSet) All() NodeSet {
method One (line 214) | func (p NodeSet) One() NodeSet {
method Single (line 223) | func (p NodeSet) Single() NodeSet {
method Ok (line 232) | func (p NodeSet) Ok() bool {
method XGo_Attr__0 (line 240) | func (p NodeSet) XGo_Attr__0(name string) any {
method XGo_Attr__1 (line 249) | func (p NodeSet) XGo_Attr__1(name string) (val any, err error) {
method Class (line 269) | func (p NodeSet) Class() string {
function NodeSet_Cast (line 48) | func NodeSet_Cast(seq iter.Seq[Node]) NodeSet {
function Root (line 55) | func Root(doc Node) NodeSet {
function Nodes (line 62) | func Nodes(nodes ...Node) NodeSet {
function New (line 69) | func New(f *ast.File) NodeSet {
type Config (line 76) | type Config struct
constant defaultMode (line 82) | defaultMode = parser.ParseComments
function parse (line 86) | func parse(uri string, src any, conf ...Config) (f *ast.File, err error) {
function From (line 105) | func From(uri string, src any, conf ...Config) NodeSet {
function Source (line 125) | func Source(r any, conf ...Config) (ret NodeSet) {
FILE: dql/xml/node.go
type Node (line 44) | type Node struct
method UnmarshalXML (line 58) | func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er...
method XGo_Elem (line 95) | func (n *Node) XGo_Elem(name string) NodeSet {
method XGo_Child (line 101) | func (n *Node) XGo_Child() NodeSet {
method XGo_Any (line 111) | func (n *Node) XGo_Any(name string) NodeSet {
method XGo_dump (line 116) | func (n *Node) XGo_dump() NodeSet {
method XGo_hasAttr (line 123) | func (n *Node) XGo_hasAttr(name string) bool {
method XGo_Attr__0 (line 136) | func (n *Node) XGo_Attr__0(name string) string {
method XGo_Attr__1 (line 145) | func (n *Node) XGo_Attr__1(name string) (string, error) {
function Parse (line 51) | func Parse(r io.Reader) (doc *Node, err error) {
FILE: dql/xml/text.go
method XGo_text__0 (line 29) | func (p NodeSet) XGo_text__0() string {
method XGo_text__1 (line 36) | func (p NodeSet) XGo_text__1() (val string, err error) {
method XGo_int (line 51) | func (p NodeSet) XGo_int() (int, error) {
FILE: dql/xml/xml.go
constant XGoPackage (line 31) | XGoPackage = true
type NodeSet (line 37) | type NodeSet struct
method XGo_Enum (line 118) | func (p NodeSet) XGo_Enum() iter.Seq[NodeSet] {
method XGo_Select (line 132) | func (p NodeSet) XGo_Select(name string) NodeSet {
method XGo_Elem (line 156) | func (p NodeSet) XGo_Elem(name string) NodeSet {
method XGo_Child (line 184) | func (p NodeSet) XGo_Child() NodeSet {
method XGo_Any (line 215) | func (p NodeSet) XGo_Any(name string) NodeSet {
method XGo_all (line 251) | func (p NodeSet) XGo_all() NodeSet {
method XGo_one (line 261) | func (p NodeSet) XGo_one() NodeSet {
method XGo_single (line 275) | func (p NodeSet) XGo_single() NodeSet {
method XGo_dump (line 289) | func (p NodeSet) XGo_dump() NodeSet {
method XGo_ok (line 302) | func (p NodeSet) XGo_ok() bool {
method XGo_first (line 307) | func (p NodeSet) XGo_first() (*Node, error) {
method XGo_hasAttr (line 316) | func (p NodeSet) XGo_hasAttr(name string) bool {
method XGo_Attr__0 (line 328) | func (p NodeSet) XGo_Attr__0(name string) string {
method XGo_Attr__1 (line 337) | func (p NodeSet) XGo_Attr__1(name string) (val string, err error) {
function NodeSet_Cast (line 43) | func NodeSet_Cast(seq iter.Seq[*Node]) NodeSet {
function Root (line 48) | func Root(doc *Node) NodeSet {
function Nodes (line 57) | func Nodes(nodes ...*Node) NodeSet {
function New (line 72) | func New(r io.Reader) NodeSet {
function Source (line 92) | func Source(r any) (ret NodeSet) {
function selectNode (line 146) | func selectNode(node *Node, name string, yield func(*Node) bool) bool {
function yieldNode (line 170) | func yieldNode(n *Node, name string, yield func(*Node) bool) bool {
function yieldChildNodes (line 198) | func yieldChildNodes(n *Node, yield func(*Node) bool) bool {
function yieldAnyNodes (line 230) | func yieldAnyNodes(n *Node, name string, yield func(*Node) bool) bool {
FILE: dql/yaml/yaml.go
constant XGoPackage (line 30) | XGoPackage = "github.com/goplus/xgo/dql/maps"
function New (line 42) | func New(r io.Reader, opts ...yaml.DecodeOption) NodeSet {
function Source (line 61) | func Source(r any, opts ...yaml.DecodeOption) (ret NodeSet) {
FILE: encoding/csv/csv.go
function New (line 29) | func New(text string) (records Object, err error) {
FILE: encoding/fs/fs.go
function New (line 24) | func New(dir string) fs.NodeSet {
FILE: encoding/golang/golang.go
constant XGoPackage (line 27) | XGoPackage = "github.com/goplus/xgo/dql/golang"
function New (line 35) | func New(text string, mode ...parser.Mode) (f Object, err error) {
FILE: encoding/html/html.go
constant XGoPackage (line 26) | XGoPackage = "github.com/goplus/xgo/dql/html"
function New (line 33) | func New(text string) (ret Object, err error) {
FILE: encoding/json/json.go
function New (line 29) | func New(text string) (ret Object, err error) {
FILE: encoding/regexp/regexp.go
function New (line 27) | func New(text string) (Object, error) {
FILE: encoding/regexposix/regexp.go
function New (line 27) | func New(text string) (Object, error) {
FILE: encoding/xgo/xgo.go
constant XGoPackage (line 27) | XGoPackage = "github.com/goplus/xgo/dql/xgo"
function New (line 35) | func New(text string, mode ...parser.Mode) (f Object, err error) {
FILE: encoding/xml/xml.go
constant XGoPackage (line 26) | XGoPackage = "github.com/goplus/xgo/dql/xml"
function New (line 33) | func New(text string) (ret Object, err error) {
FILE: encoding/yaml/yaml.go
function New (line 30) | func New(text string, opts ...yaml.DecodeOption) (ret Object, err error) {
FILE: env/build.go
function BuildDate (line 26) | func BuildDate() string {
FILE: env/goenv.go
function HOME (line 25) | func HOME() string {
FILE: env/gop_nonwindows.go
function isXgoCmd (line 22) | func isXgoCmd(fname string) bool {
FILE: env/path.go
function XGOROOT (line 33) | func XGOROOT() string {
constant envXGOROOT (line 42) | envXGOROOT = "XGOROOT"
function findXgoRoot (line 45) | func findXgoRoot() (string, error) {
function executableRealPath (line 85) | func executableRealPath() (path string, err error) {
function isFileExists (line 96) | func isFileExists(path string) bool {
function isDirExists (line 101) | func isDirExists(path string) bool {
function isValidXgoRoot (line 106) | func isValidXgoRoot(path string) bool {
FILE: env/path_test.go
function findGoModFile (line 27) | func findGoModFile(dir string) (modfile string, noCacheFile bool, err er...
function makeTestDir (line 48) | func makeTestDir(t *testing.T) (root string, src string, xgoRoot string) {
function makeValidXgoRoot (line 57) | func makeValidXgoRoot(root string) {
function writeDummyFile (line 64) | func writeDummyFile(path string) {
function cleanup (line 68) | func cleanup() {
function TestBasic (line 74) | func TestBasic(t *testing.T) {
function TestFindGoModFileInGoModDir (line 82) | func TestFindGoModFileInGoModDir(t *testing.T) {
function TestFindGoModFileInGopRoot (line 122) | func TestFindGoModFileInGopRoot(t *testing.T) {
FILE: env/sys_others.go
constant envHOME (line 23) | envHOME = "HOME"
FILE: env/sys_plan9.go
constant envHOME (line 20) | envHOME = "home"
FILE: env/sys_windows.go
constant envHOME (line 22) | envHOME = "USERPROFILE"
function isXgoCmd (line 25) | func isXgoCmd(fname string) bool {
FILE: env/version.go
function init (line 34) | func init() {
function initEnv (line 38) | func initEnv() {
function initEnvByXgo (line 44) | func initEnvByXgo() {
function Installed (line 65) | func Installed() bool {
function Version (line 77) | func Version() string {
function MainVersion (line 97) | func MainVersion() string {
FILE: env/version_test.go
function TestPanic (line 26) | func TestPanic(t *testing.T) {
function TestEnv (line 39) | func TestEnv(t *testing.T) {
function TestMainVersion (line 65) | func TestMainVersion(t *testing.T) {
FILE: format/format.go
constant parserMode (line 41) | parserMode = parser.ParseComments
function Node (line 53) | func Node(dst io.Writer, fset *token.FileSet, node any) error {
function Source (line 103) | func Source(src []byte, class bool, filename ...string) ([]byte, error) {
function hasUnsortedImports (line 123) | func hasUnsortedImports(file *ast.File) bool {
FILE: format/formatutil/format_gop.go
function RearrangeFuncs (line 26) | func RearrangeFuncs(src []byte, filename ...string) ([]byte, error) {
function codeOf (
Condensed preview — 844 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,884K chars).
[
{
"path": ".gitattributes",
"chars": 114,
"preview": "*.expect text eol=lf\n*.golden text eol=lf\n\n*.xgo text eol=lf\n*.gop text eol=lf\n*.go text eol=lf\n*.gox text eol=lf\n"
},
{
"path": ".github/ISSUE_TEMPLATE/bug-report.yml",
"chars": 1237,
"preview": "name: Bug Report\ndescription: Create a report to help us improve\n\nbody:\n - type: markdown\n attributes:\n value: "
},
{
"path": ".github/ISSUE_TEMPLATE/config.yml",
"chars": 112,
"preview": "contact_links:\n - name: Visit the XGo website\n url: https://xgo.dev\n about: Much help can be found there\n"
},
{
"path": ".github/ISSUE_TEMPLATE/enhancement.yml",
"chars": 876,
"preview": "name: Feature request\ndescription: Propose a change to XGo\n\nbody:\n - type: markdown\n attributes:\n value: |\n "
},
{
"path": ".github/codecov.yml",
"chars": 750,
"preview": "coverage:\n ignore:\n - \"builtin\"\n - \"ast\"\n - \"test\"\n - \"scanner\"\n - \"format\"\n - \"demo\"\n - \"demo/uni"
},
{
"path": ".github/dependabot.yml",
"chars": 642,
"preview": "# To get started with Dependabot version updates, you'll need to specify which\n# package ecosystems to update and where "
},
{
"path": ".github/workflows/check_goreleaser_config.py",
"chars": 1642,
"preview": "import os\nimport subprocess\nimport yaml\n\nfiles = [f for f in os.listdir('.') if not f.startswith(\n \".\") and f not in "
},
{
"path": ".github/workflows/go.yml",
"chars": 1629,
"preview": "name: XGo CI\n\non:\n push:\n branches:\n - \"*\"\n pull_request:\n branches:\n - \"*\"\n\njobs:\n Check:\n runs-on: u"
},
{
"path": ".github/workflows/release-build.yml",
"chars": 2320,
"preview": "name: Release Build\n\non:\n push:\n tags:\n - \"v*\"\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - uses"
},
{
"path": ".github/xgopilot.yml",
"chars": 35,
"preview": "claude:\n model: \"claude-4.6-opus\"\n"
},
{
"path": ".gitignore",
"chars": 684,
"preview": "# Compiled Object files, Static and Dynamic libs (Shared Objects)\n*.o\n*.a\n*.so\n*.txt\n*.cache\n.DS_Store\ntest.db\ngo.json\nx"
},
{
"path": ".goreleaser.yaml",
"chars": 9570,
"preview": "version: 2\n\nenv:\n - DOCKER_IMAGE_REPO={{ envOrDefault \"DOCKER_IMAGE_REPO\" \"xgo\" }}\n\ndist: .dist\n\nbefore:\n hooks:\n -"
},
{
"path": "CLAUDE.md",
"chars": 6241,
"preview": "# XGo Project AI Assistant Guide\n\n## Project Overview\n\n**XGo** is the first AI-native programming language that integrat"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 5217,
"preview": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nWe as members, contributors, and leaders pledge to make participa"
},
{
"path": "Dockerfile",
"chars": 576,
"preview": "ARG BASE_IMAGE=golang:1.24-bookworm\n\nFROM $BASE_IMAGE AS build\n\nARG TARGETPLATFORM\nARG USE_GORELEASER_ARTIFACTS=0\n\nWORKD"
},
{
"path": "LICENSE",
"chars": 11347,
"preview": "Apache License\n Version 2.0, January 2004\n http://www.apache.org/licens"
},
{
"path": "Makefile",
"chars": 1723,
"preview": "NAME := gop\nRELEASE_VERSION := `git describe --tags`\nBUILD_ROOT_DIR := build-dir\n\n.PHONY: clean all\nall: build\n\nclean:\n\t"
},
{
"path": "README.md",
"chars": 15636,
"preview": "<div align=\"center\">\n<p></p>\n<p>\n <img width=\"80\" src=\"https://xgo.dev/favicon.svg\">\n</p>\n<h1>The XGo Programming Lan"
},
{
"path": "all.bash",
"chars": 702,
"preview": "#! /usr/bin/env bash\n\n#\n# Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n#\n# Licensed under the Apac"
},
{
"path": "all.bat",
"chars": 51,
"preview": "go run cmd/make.go --install --regtest --autoproxy\n"
},
{
"path": "ast/ast.go",
"chars": 37282,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/ast_xgo.go",
"chars": 19836,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/commentmap.go",
"chars": 9223,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/filter.go",
"chars": 14270,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/fromgo/gopast.go",
"chars": 8455,
"preview": "/*\n * Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/fromgo/gopast_test.go",
"chars": 2904,
"preview": "/*\n * Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/fromgo/typeparams/typeparams_go117.go",
"chars": 985,
"preview": "//go:build !go1.18\n// +build !go1.18\n\npackage typeparams\n\nimport (\n\t\"go/ast\"\n\t\"go/token\"\n)\n\nfunc unsupported() {\n\tpanic("
},
{
"path": "ast/fromgo/typeparams/typeparams_go118.go",
"chars": 450,
"preview": "//go:build go1.18\n// +build go1.18\n\npackage typeparams\n\nimport \"go/ast\"\n\n// IndexListExpr is an alias for ast.IndexListE"
},
{
"path": "ast/fromgo/typeparams_test.go",
"chars": 216,
"preview": "//go:build go1.18\n// +build go1.18\n\npackage fromgo\n\nimport \"testing\"\n\nfunc TestIndexListExpr(t *testing.T) {\n\ttest(t, `p"
},
{
"path": "ast/gopq/dom.go",
"chars": 3798,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/gopq/gopq.go",
"chars": 17424,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/gopq/helper.go",
"chars": 4757,
"preview": "/*\n * Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/goptest/gopq.go",
"chars": 1219,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/import.go",
"chars": 6301,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/mod/deps.go",
"chars": 2099,
"preview": "/*\n * Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/print.go",
"chars": 6465,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/resolve.go",
"chars": 5889,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/scope.go",
"chars": 4630,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/togo/goast.go",
"chars": 7428,
"preview": "/*\n * Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/togo/goast_test.go",
"chars": 2438,
"preview": "/*\n * Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "ast/walk.go",
"chars": 8354,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "builtin/doc.xgo",
"chars": 20788,
"preview": "package builtin\n\nimport (\n\t\"github.com/qiniu/x/osx\"\n\t\"io\"\n\t\"os\"\n\t\"reflect\"\n)\n\n// Echo formats using the default formats "
},
{
"path": "cl/_testc/hello/in.xgo",
"chars": 40,
"preview": "import \"c\"\n\nc.Printf c\"Hello, world!\\n\"\n"
},
{
"path": "cl/_testc/hello/out.go",
"chars": 100,
"preview": "package main\n\nimport \"github.com/goplus/lib/c\"\n\nfunc main() {\n\tc.Printf(c.Str(\"Hello, world!\\n\"))\n}\n"
},
{
"path": "cl/_testgop/_matrix/in.xgo",
"chars": 27,
"preview": "echo [\n\t1, 2, 3\n\t4, 5, 6\n]\n"
},
{
"path": "cl/_testgop/append1/in.xgo",
"chars": 131,
"preview": "type foo struct {\n\ta []int\n}\n\na := [1, 2, 3]\na <- 4\necho a\n\nf := foo{a: [1, 2, 3]}\nf.a <- 4\necho f\n\nf2 := [2]chan int{}\n"
},
{
"path": "cl/_testgop/append1/out.go",
"chars": 229,
"preview": "package main\n\nimport \"fmt\"\n\ntype foo struct {\n\ta []int\n}\n\nfunc main() {\n\ta := []int{1, 2, 3}\n\ta = append(a, 4)\n\tfmt.Prin"
},
{
"path": "cl/_testgop/append2/in.xgo",
"chars": 62,
"preview": "a := [1, 2, 3]\na <- 4, 5\necho a\n\nb := [7, 8]\na <- b...\necho a\n"
},
{
"path": "cl/_testgop/append2/out.go",
"chars": 157,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ta := []int{1, 2, 3}\n\ta = append(a, 4, 5)\n\tfmt.Println(a)\n\tb := []int{7, 8}\n\ta"
},
{
"path": "cl/_testgop/autoref-2484/in.xgo",
"chars": 700,
"preview": "type Person struct {\n\tName string\n\tAge int\n}\n\ntype Point struct {\n\tX, Y int\n}\n\nfunc processPerson(p *Person) {\n\tprintln"
},
{
"path": "cl/_testgop/autoref-2484/out.go",
"chars": 739,
"preview": "package main\n\nimport \"fmt\"\n\ntype Person struct {\n\tName string\n\tAge int\n}\ntype Point struct {\n\tX int\n\tY int\n}\n\nfunc proc"
},
{
"path": "cl/_testgop/builtin/in.xgo",
"chars": 152,
"preview": "a := [\"hello\", \"world\", \"123\"]\necho a.capitalize\necho contains(\"param-required required\", \"required\")\necho contains(\"par"
},
{
"path": "cl/_testgop/builtin/out.go",
"chars": 339,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/qiniu/x/stringslice\"\n\t\"github.com/qiniu/x/stringutil\"\n)\n\nfunc main() {\n\ta := "
},
{
"path": "cl/_testgop/domaintext-html/in.xgo",
"chars": 52,
"preview": "echo html`<html><body><h1>hello</h1></body></html>`\n"
},
{
"path": "cl/_testgop/domaintext-html/out.go",
"chars": 155,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/encoding/html\"\n)\n\nfunc main() {\n\tfmt.Println(html.New(`<html><body"
},
{
"path": "cl/_testgop/domaintext-huh/in.xgo",
"chars": 106,
"preview": "import \"github.com/goplus/xgo/cl/internal/huh\"\n\nform := huh`> \"1\", 2\n<form id=\"test\">\n</form>\n`\n\nform.run\n"
},
{
"path": "cl/_testgop/domaintext-huh/out.go",
"chars": 148,
"preview": "package main\n\nimport \"github.com/goplus/xgo/cl/internal/huh\"\n\nfunc main() {\n\tform := huh.New(\"<form id=\\\"test\\\">\\n</form"
},
{
"path": "cl/_testgop/domaintext-json/in.xgo",
"chars": 49,
"preview": "echo json`{\"a\":1, \"b\":2}`\necho yaml`\na: 1\nb: c\n`\n"
},
{
"path": "cl/_testgop/domaintext-json/out.go",
"chars": 206,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/encoding/json\"\n\t\"github.com/goplus/xgo/encoding/yaml\"\n)\n\nfunc main"
},
{
"path": "cl/_testgop/domaintext-md/go.mod",
"chars": 122,
"preview": "module example\n\ngo 1.22\n\nrequire github.com/xushiwei/markdown v0.1.0\n\nrequire github.com/yuin/goldmark v1.7.8 // indirec"
},
{
"path": "cl/_testgop/domaintext-md/go.sum",
"chars": 342,
"preview": "github.com/xushiwei/markdown v0.1.0 h1:Vjw4MVcwSEJge9ObA/3C1lrmNYX60nJwuVKdLYrf0+o=\ngithub.com/xushiwei/markdown v0.1.0/"
},
{
"path": "cl/_testgop/domaintext-md/in.xgo",
"chars": 118,
"preview": "import (\n \"os\"\n\n \"github.com/xushiwei/markdown\"\n)\n\nmd := markdown`\n# Title\n\nHello world\n`\n\nmd.convert os.Stdout\n"
},
{
"path": "cl/_testgop/domaintext-md/out.go",
"chars": 149,
"preview": "package main\n\nimport (\n\t\"github.com/xushiwei/markdown\"\n\t\"os\"\n)\n\nfunc main() {\n\tmd := markdown.New(`\n# Title\n\nHello world"
},
{
"path": "cl/_testgop/domaintext-regexp/in.xgo",
"chars": 78,
"preview": "re, err := regexp`^[a-z]+\\[[0-9]+\\]$`\necho re.matchString(\"adam[23]\")\n_ = err\n"
},
{
"path": "cl/_testgop/domaintext-regexp/out.go",
"chars": 185,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/encoding/regexp\"\n)\n\nfunc main() {\n\tre, err := regexp.New(`^[a-z]+\\"
},
{
"path": "cl/_testgop/domaintext-tpl/in.xgo",
"chars": 73,
"preview": "cl, err := tpl`expr = INT % (\"+\" | \"-\")`\ncl.parseExpr \"1+2\", nil\n_ = err\n"
},
{
"path": "cl/_testgop/domaintext-tpl/out.go",
"chars": 195,
"preview": "package main\n\nimport \"github.com/goplus/xgo/tpl\"\n\nfunc main() {\n\tcl, err := tpl.NewEx(`expr = INT % (\"+\" | \"-\")`, \"cl/_t"
},
{
"path": "cl/_testgop/domaintpl/in.xgo",
"chars": 932,
"preview": "tpl`\nfile = stmts => {\n\treturn self\n}\n\nstmts = *(stmt \";\") => {\n\treturn [n.([]any)[0] for n in self]\n}\n\nstmt = varStmt |"
},
{
"path": "cl/_testgop/domaintpl/out.go",
"chars": 1306,
"preview": "package main\n\nimport \"github.com/goplus/xgo/tpl\"\n\nfunc main() {\n\ttpl.NewEx(`\nfile = stmts => {\n\treturn self\n}\n\nstmts = *"
},
{
"path": "cl/_testgop/dql1/in.xgo",
"chars": 162,
"preview": "import \"github.com/goplus/xgo/cl/internal/dql\"\n\ndoc := dql.new\necho doc.foo.**.users.*.$age\necho doc.\"foo-name\".**.\"elem"
},
{
"path": "cl/_testgop/dql1/out.go",
"chars": 337,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/cl/internal/dql\"\n)\n\nfunc main() {\n\tdoc := dql.New()\n\tfmt.Println(d"
},
{
"path": "cl/_testgop/dql2/in.xgo",
"chars": 115,
"preview": "import \"github.com/goplus/xgo/cl/internal/dql\"\n\ndoc := dql.new\nname := doc.users@($age?:100 < 18).$name!\necho name\n"
},
{
"path": "cl/_testgop/dql2/out.go",
"chars": 904,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/cl/internal/dql\"\n\t\"github.com/qiniu/x/errors\"\n)\n\nfunc main() {\n\tdo"
},
{
"path": "cl/_testgop/dql3/in.xgo",
"chars": 94,
"preview": "import \"github.com/goplus/xgo/cl/internal/dql\"\n\ndoc := dql.new\necho doc.*@users@`users`.$name\n"
},
{
"path": "cl/_testgop/dql3/out.go",
"chars": 198,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/cl/internal/dql\"\n)\n\nfunc main() {\n\tdoc := dql.New()\n\tfmt.Println(d"
},
{
"path": "cl/_testgop/dql4/in.xgo",
"chars": 417,
"preview": "doc := xml`<doc><animals>\n\t<animal class=\"gopher\">Line 1</animal>\n\t<animal class=\"armadillo\">Line 2</animal>\n\t<animal cl"
},
{
"path": "cl/_testgop/dql4/out.go",
"chars": 1518,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\txml1 \"github.com/goplus/xgo/dql/xml\"\n\t\"github.com/goplus/xgo/encoding/xml\"\n\t\"github.com/q"
},
{
"path": "cl/_testgop/dql5/in.xgo",
"chars": 185,
"preview": "doc := html`<html><body>\n<p>Links:</p>\n<ul>\n\t<li><a href=\"foo\">Foo</a>\n\t<li><a href=\"/bar/baz\">BarBaz</a>\n</ul>\n</body><"
},
{
"path": "cl/_testgop/dql5/out.go",
"chars": 733,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/encoding/html\"\n\t\"github.com/qiniu/x/errors\"\n)\n\nfunc main() {\n\tdoc "
},
{
"path": "cl/_testgop/dql6/in.xgo",
"chars": 223,
"preview": "doc := golang`package main\n\nvar (\n\ta, b string\n\tc int\n)\n\nfunc add(a, b int) int {\n\treturn a + b\n}\n\nfunc mul(a, b floa"
},
{
"path": "cl/_testgop/dql6/out.go",
"chars": 1159,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\tgolang1 \"github.com/goplus/xgo/dql/golang\"\n\t\"github.com/goplus/xgo/dql/reflects\"\n\t\"github"
},
{
"path": "cl/_testgop/dql7/in.xgo",
"chars": 412,
"preview": "doc := json`{\n\t\"animals\": [\n\t\t{\"class\": \"gopher\", \"at\": \"Line 1\"},\n\t\t{\"class\": \"armadillo\", \"at\": \"Line 2\"},\n\t\t{\"class\":"
},
{
"path": "cl/_testgop/dql7/out.go",
"chars": 1602,
"preview": "package main\n\nimport (\n\t\"github.com/goplus/xgo/dql/maps\"\n\t\"github.com/goplus/xgo/encoding/json\"\n\t\"github.com/qiniu/x/err"
},
{
"path": "cl/_testgop/enumlines-rdr/in.xgo",
"chars": 69,
"preview": "import \"io\"\n\nvar r io.Reader\n\nfor line in lines(r) {\n\tprintln line\n}\n"
},
{
"path": "cl/_testgop/enumlines-rdr/out.go",
"chars": 248,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/qiniu/x/osx\"\n\t\"io\"\n)\n\nvar r io.Reader\n\nfunc main() {\n\tfor _xgo_it := osx.Line"
},
{
"path": "cl/_testgop/enumlines-stdin/in.xgo",
"chars": 52,
"preview": "import \"os\"\n\nfor line <- os.Stdin {\n\tprintln line\n}\n"
},
{
"path": "cl/_testgop/enumlines-stdin/out.go",
"chars": 231,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/qiniu/x/osx\"\n\t\"os\"\n)\n\nfunc main() {\n\tfor _xgo_it := osx.EnumLines(os.Stdin); "
},
{
"path": "cl/_testgop/errwrap1/in.xgo",
"chars": 126,
"preview": "func F() (a int8, b int16, err error) {\n\ta = 1\n\treturn\n}\n\nfunc F2() (err error) {\n\tc, d := F()!\n\t_ = c\n\t_ = d\n\treturn\n}\n"
},
{
"path": "cl/_testgop/errwrap1/out.go",
"chars": 439,
"preview": "package main\n\nimport \"github.com/qiniu/x/errors\"\n\nfunc F() (a int8, b int16, err error) {\n\ta = 1\n\treturn\n}\nfunc F2() (er"
},
{
"path": "cl/_testgop/errwrap2/in.xgo",
"chars": 126,
"preview": "func F() (a int8, b int16, err error) {\n\ta = 1\n\treturn\n}\n\nfunc F2() (err error) {\n\tc, d := F()?\n\t_ = c\n\t_ = d\n\treturn\n}\n"
},
{
"path": "cl/_testgop/errwrap2/out.go",
"chars": 481,
"preview": "package main\n\nimport \"github.com/qiniu/x/errors\"\n\nfunc F() (a int8, b int16, err error) {\n\ta = 1\n\treturn\n}\nfunc F2() (er"
},
{
"path": "cl/_testgop/errwrap3/in.xgo",
"chars": 122,
"preview": "func BarOne() int {\n\treturn 0\n}\n\nfunc BarTwo() (int, error) {\n\treturn 0, nil\n}\n\nfunc Bar = (\n\tBarOne\n\tBarTwo\n)\n\necho bar"
},
{
"path": "cl/_testgop/errwrap3/out.go",
"chars": 436,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/qiniu/x/errors\"\n)\n\nconst XGoo_Bar = \"BarOne,BarTwo\"\n\nfunc BarOne() int {\n\tret"
},
{
"path": "cl/_testgop/fatal/in.xgo",
"chars": 137,
"preview": "import \"os\"\n\nf, err := os.open(\"hello.txt\")\nif err != nil {\n errorln \"[WARN] an error\"\n fatal \"open file failed: $"
},
{
"path": "cl/_testgop/fatal/out.go",
"chars": 269,
"preview": "package main\n\nimport (\n\t\"github.com/qiniu/x/osx\"\n\t\"github.com/qiniu/x/stringutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tf, err := os.O"
},
{
"path": "cl/_testgop/for-in/in.xgo",
"chars": 103,
"preview": "import \"github.com/goplus/xgo/cl/internal/dql\"\n\ndoc := dql.new\nfor user in doc.users {\n echo user\n}\n"
},
{
"path": "cl/_testgop/for-in/out.go",
"chars": 185,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/cl/internal/dql\"\n)\n\nfunc main() {\n\tdoc := dql.New()\n\tfor user := r"
},
{
"path": "cl/_testgop/for-range/in.xgo",
"chars": 282,
"preview": "func foo(yield func() bool) {\n\tyield()\n}\n\nfunc bar(yield func(v string) bool) {\n\tyield(\"World\")\n}\n\nfunc weekdays(yield f"
},
{
"path": "cl/_testgop/for-range/out.go",
"chars": 345,
"preview": "package main\n\nimport \"fmt\"\n\nfunc foo(yield func() bool) {\n\tyield()\n}\nfunc bar(yield func(v string) bool) {\n\tyield(\"World"
},
{
"path": "cl/_testgop/implicit-cast-2439/in.xgo",
"chars": 194,
"preview": "type BasePtr struct {\n}\n\ntype Base struct {\n *BasePtr\n}\n\nfunc Walk(p *Base) {}\nfunc WalkPtr(p *BasePtr) {}\n\ntype T st"
},
{
"path": "cl/_testgop/implicit-cast-2439/out.go",
"chars": 233,
"preview": "package main\n\ntype BasePtr struct {\n}\ntype Base struct {\n\t*BasePtr\n}\ntype T struct {\n\tBase\n}\n\nfunc Walk(p *Base) {\n}\nfun"
},
{
"path": "cl/_testgop/kwargs1/in.xgo",
"chars": 183,
"preview": "type Options struct {\n Loop bool\n async bool\n}\n\nfunc PlaySound(path string, options *Options) {\n}\n\nplaySound \"1.m"
},
{
"path": "cl/_testgop/kwargs1/out.go",
"chars": 227,
"preview": "package main\n\ntype Options struct {\n\tLoop bool\n\tasync bool\n}\n\nfunc PlaySound(path string, options *Options) {\n}\nfunc ma"
},
{
"path": "cl/_testgop/kwargs2/in.xgo",
"chars": 182,
"preview": "type Options struct {\n Loop bool\n async bool\n}\n\nfunc PlaySound(path string, options Options) {\n}\n\nplaySound \"1.mp"
},
{
"path": "cl/_testgop/kwargs2/out.go",
"chars": 224,
"preview": "package main\n\ntype Options struct {\n\tLoop bool\n\tasync bool\n}\n\nfunc PlaySound(path string, options Options) {\n}\nfunc mai"
},
{
"path": "cl/_testgop/kwargs3/in.xgo",
"chars": 172,
"preview": "type Options map[string]bool\n\nfunc PlaySound(options Options, paths ...string) {\n}\n\nplaySound \"1.mp3\", \"foo.wav\", loop ="
},
{
"path": "cl/_testgop/kwargs3/out.go",
"chars": 226,
"preview": "package main\n\ntype Options map[string]bool\n\nfunc PlaySound(options Options, paths ...string) {\n}\nfunc main() {\n\tPlaySoun"
},
{
"path": "cl/_testgop/kwargs4/in.xgo",
"chars": 190,
"preview": "import \"github.com/goplus/xgo/cl/internal/testutil\"\n\nfunc PlaySound(path string, options *testutil.Options) {\n}\n\nplaySou"
},
{
"path": "cl/_testgop/kwargs4/out.go",
"chars": 258,
"preview": "package main\n\nimport \"github.com/goplus/xgo/cl/internal/testutil\"\n\nfunc PlaySound(path string, options *testutil.Options"
},
{
"path": "cl/_testgop/list-compr1/in.xgo",
"chars": 39,
"preview": "a := [1, 3.4, 5]\nb := [x*x for x <- a]\n"
},
{
"path": "cl/_testgop/list-compr1/out.go",
"chars": 171,
"preview": "package main\n\nfunc main() {\n\ta := []float64{1, 3.4, 5}\n\tb := func() (_xgo_ret []float64) {\n\t\tfor _, x := range a {\n\t\t\t_x"
},
{
"path": "cl/_testgop/list-compr2/in.xgo",
"chars": 99,
"preview": "arr := [1, 2, 3, 4.1, 5, 6]\nx := [[a, b] for a <- arr, a < b for b <- arr, b > 2]\nprintln(\"x:\", x)\n"
},
{
"path": "cl/_testgop/list-compr2/out.go",
"chars": 313,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tarr := []float64{1, 2, 3, 4.1, 5, 6}\n\tx := func() (_xgo_ret [][]float64) {\n\t\t"
},
{
"path": "cl/_testgop/map-compr-cond1/in.xgo",
"chars": 73,
"preview": "z := {v: k for k, v <- {\"Hello\": 1, \"Hi\": 3, \"xsw\": 5, \"XGo\": 7}, v > 3}\n"
},
{
"path": "cl/_testgop/map-compr-cond1/out.go",
"chars": 236,
"preview": "package main\n\nfunc main() {\n\tz := func() (_xgo_ret map[int]string) {\n\t\t_xgo_ret = map[int]string{}\n\t\tfor k, v := range m"
},
{
"path": "cl/_testgop/map-compr-cond2/in.xgo",
"chars": 81,
"preview": "z := {t: k for k, v <- {\"Hello\": 1, \"Hi\": 3, \"xsw\": 5, \"XGo\": 7}, t := v; t > 3}\n"
},
{
"path": "cl/_testgop/map-compr-cond2/out.go",
"chars": 244,
"preview": "package main\n\nfunc main() {\n\tz := func() (_xgo_ret map[int]string) {\n\t\t_xgo_ret = map[int]string{}\n\t\tfor k, v := range m"
},
{
"path": "cl/_testgop/map-compr1/in.xgo",
"chars": 51,
"preview": "y := {x: i for i, x <- [\"1\", \"3\", \"5\", \"7\", \"11\"]}\n"
},
{
"path": "cl/_testgop/map-compr1/out.go",
"chars": 195,
"preview": "package main\n\nfunc main() {\n\ty := func() (_xgo_ret map[string]int) {\n\t\t_xgo_ret = map[string]int{}\n\t\tfor i, x := range ["
},
{
"path": "cl/_testgop/map-field-access1/in.xgo",
"chars": 116,
"preview": "v := map[string]map[string]any{\"a\": {\"b\": 1}}\nc, ok := v[\"b\"][\"c\"].(int)\necho c, ok\n\nc, ok = v.b.c.(int)\necho c, ok\n"
},
{
"path": "cl/_testgop/map-field-access1/out.go",
"chars": 216,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tv := map[string]map[string]interface{}{\"a\": map[string]interface{}{\"b\": 1}}\n\t"
},
{
"path": "cl/_testgop/map-field-access2/in.xgo",
"chars": 76,
"preview": "var v any\n\nc, ok := v[\"b\"][\"c\"].(int)\necho c, ok\n\nd, ok := v.b.c\necho d, ok\n"
},
{
"path": "cl/_testgop/map-field-access2/out.go",
"chars": 329,
"preview": "package main\n\nimport \"fmt\"\n\nvar v interface{}\n\nfunc main() {\n\t_autoGo_1, _ := v.(map[string]any)\n\t_autoGo_2, _ := _autoG"
},
{
"path": "cl/_testgop/optparam/in.xgo",
"chars": 469,
"preview": "func basic(a int, b int?) {\n\tprintln a, b\n}\n\nfunc multiple(name string, age int?, active bool?) {\n\tprintln name, age, ac"
},
{
"path": "cl/_testgop/optparam/out.go",
"chars": 748,
"preview": "package main\n\nimport \"fmt\"\n\ntype Server struct {\n}\n\nfunc basic(a int, __xgo_optional_b int) {\n\tfmt.Println(a, __xgo_opti"
},
{
"path": "cl/_testgop/optparam2/in.xgo",
"chars": 254,
"preview": "func returnValue(x int?) int {\n\treturn x\n}\n\nfunc useInExpression(a int?, b int?) int {\n\tresult := a + b\n\treturn result *"
},
{
"path": "cl/_testgop/optparam2/out.go",
"chars": 422,
"preview": "package main\n\nimport \"fmt\"\n\nfunc returnValue(__xgo_optional_x int) int {\n\treturn __xgo_optional_x\n}\nfunc useInExpression"
},
{
"path": "cl/_testgop/rangeexpr/in.xgo",
"chars": 27,
"preview": "println [x for x <- 0:3:1]\n"
},
{
"path": "cl/_testgop/rangeexpr/out.go",
"chars": 309,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/qiniu/x/xgo\"\n)\n\nfunc main() {\n\tfmt.Println(func() (_xgo_ret []int) {\n\t\tfor _x"
},
{
"path": "cl/_testgop/repeatuntil/in.xgo",
"chars": 193,
"preview": "func RepeatUntil(cond func() bool, body func()) {\n for !cond() {\n body()\n }\n}\n\nx := 0\nrepeatUntil x >= 3, ="
},
{
"path": "cl/_testgop/repeatuntil/out.go",
"chars": 273,
"preview": "package main\n\nimport \"fmt\"\n\nfunc RepeatUntil(cond func() bool, body func()) {\n\tfor !cond() {\n\t\tbody()\n\t}\n}\nfunc main() {"
},
{
"path": "cl/_testgop/select-compr-twovalue1/in.xgo",
"chars": 62,
"preview": "y, ok := {i for i, x <- [\"1\", \"3\", \"5\", \"7\", \"11\"], x == \"5\"}\n"
},
{
"path": "cl/_testgop/select-compr-twovalue1/out.go",
"chars": 194,
"preview": "package main\n\nfunc main() {\n\ty, ok := func() (_xgo_ret int, _xgo_ok bool) {\n\t\tfor i, x := range []string{\"1\", \"3\", \"5\", "
},
{
"path": "cl/_testgop/select-compr-twovalue2/in.xgo",
"chars": 88,
"preview": "func foo() (int, bool) {\n\treturn {i for i, x <- [\"1\", \"3\", \"5\", \"7\", \"11\"], x == \"5\"}\n}\n"
},
{
"path": "cl/_testgop/select-compr-twovalue2/out.go",
"chars": 203,
"preview": "package main\n\nfunc foo() (int, bool) {\n\treturn func() (_xgo_ret int, _xgo_ok bool) {\n\t\tfor i, x := range []string{\"1\", \""
},
{
"path": "cl/_testgop/select-compr1/in.xgo",
"chars": 58,
"preview": "y := {i for i, x <- [\"1\", \"3\", \"5\", \"7\", \"11\"], x == \"5\"}\n"
},
{
"path": "cl/_testgop/select-compr1/out.go",
"chars": 170,
"preview": "package main\n\nfunc main() {\n\ty := func() (_xgo_ret int) {\n\t\tfor i, x := range []string{\"1\", \"3\", \"5\", \"7\", \"11\"} {\n\t\t\tif"
},
{
"path": "cl/_testgop/structtag/in.xgo",
"chars": 59,
"preview": "type Start struct {\n\t_ \"Start recording meeting minutes\"\n}\n"
},
{
"path": "cl/_testgop/structtag/out.go",
"chars": 89,
"preview": "package main\n\ntype Start struct {\n\t_ struct {\n\t} `_:\"Start recording meeting minutes\"`\n}\n"
},
{
"path": "cl/_testgop/tuplelit/in.xgo",
"chars": 333,
"preview": "type T struct {\n\tx (int16, float32)\n}\n\nfunc dump(a (int16, float32), _ ...bool) {\n\tt := T{\n\t\tx: (1, 3.14),\n\t}\n\techo a, t"
},
{
"path": "cl/_testgop/tuplelit/out.go",
"chars": 687,
"preview": "package main\n\nimport \"fmt\"\n\ntype T struct {\n\tx struct {\n\t\tX_0 int16\n\t\tX_1 float32\n\t}\n}\n\nfunc dump(a struct {\n\tX_0 int16\n"
},
{
"path": "cl/_testgop/tupletype1/in.xgo",
"chars": 1659,
"preview": "import \"io\"\n\n// Empty tuple\ntype Empty ()\n\n// Anonymous tuple types\ntype Pair (int, string)\n\ntype Triple (int, string, b"
},
{
"path": "cl/_testgop/tupletype1/out.go",
"chars": 2057,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/qiniu/x/stringutil\"\n\t\"io\"\n\t\"strconv\"\n)\n// Empty tuple\ntype Empty struct {\n}\n/"
},
{
"path": "cl/_testgop/tupletype2/in.xgo",
"chars": 173,
"preview": "type Point (x, y int)\ntype Int (x int)\n\npt := Point{x: 2, y: 3}\necho pt.x, pt.y\necho Int(100)\n\npt2 := Point(100, 200)\nec"
},
{
"path": "cl/_testgop/tupletype2/out.go",
"chars": 289,
"preview": "package main\n\nimport \"fmt\"\n\ntype Point struct {\n\tX_0 int\n\tX_1 int\n}\ntype Int int\n\nfunc main() {\n\tpt := Point{X_0: 2, X_1"
},
{
"path": "cl/_testgop/unit/in.xgo",
"chars": 153,
"preview": "import (\n \"time\"\n\n \"github.com/goplus/xgo/cl/internal/unit\"\n)\n\nfunc Wait(time.Duration) {}\nfunc Step(unit.Distance"
},
{
"path": "cl/_testgop/unit/out.go",
"chars": 192,
"preview": "package main\n\nimport (\n\t\"github.com/goplus/xgo/cl/internal/unit\"\n\t\"time\"\n)\n\nfunc Wait(time.Duration) {\n}\nfunc Step(unit."
},
{
"path": "cl/_testpy/_matrix/in.xgo",
"chars": 202,
"preview": "import (\n\t\"py/numpy\"\n\t\"py/std\"\n)\n\na := [\n\t[1.0, 2.0, 3.0],\n\t[4.0, 5.0, 6.0],\n\t[7.0, 8.0, 9.0],\n]\nb := [\n\t[9.0, 8.0, 7.0]"
},
{
"path": "cl/_testpy/hello/in.xgo",
"chars": 50,
"preview": "import (\n\t\"py/std\"\n)\n\nstd.print py\"Hello, World!\"\n"
},
{
"path": "cl/_testpy/hello/out.go",
"chars": 138,
"preview": "package main\n\nimport (\n\t\"github.com/goplus/lib/py\"\n\t\"github.com/goplus/lib/py/std\"\n)\n\nfunc main() {\n\tstd.Print(py.Str(\"H"
},
{
"path": "cl/_testpy/pycall/in.xgo",
"chars": 100,
"preview": "import (\n\t\"c\"\n\t\"py\"\n\t\"py/math\"\n)\n\nx := math.sqrt(py.float(2))\nc.printf c\"sqrt(2) = %f\\n\", x.float64\n"
},
{
"path": "cl/_testpy/pycall/out.go",
"chars": 207,
"preview": "package main\n\nimport (\n\t\"github.com/goplus/lib/c\"\n\t\"github.com/goplus/lib/py\"\n\t\"github.com/goplus/lib/py/math\"\n)\n\nfunc m"
},
{
"path": "cl/_testspx/basic/Game.tgmx",
"chars": 41,
"preview": "func onInit() {\n\tfor {\n\t}\n}\n\ninitGameApp\n"
},
{
"path": "cl/_testspx/basic/Kai.tspx",
"chars": 48,
"preview": "func onMsg(msg string) {\n\tfor {\n\t\tsay \"Hi\"\n\t}\n}\n"
},
{
"path": "cl/_testspx/basic/out.go",
"chars": 447,
"preview": "package main\n\nimport \"github.com/goplus/xgo/cl/internal/spx\"\n\ntype Game struct {\n\t*spx.MyGame\n}\ntype Kai struct {\n\tspx.S"
},
{
"path": "cl/_testspx/clsinit1/Rect.gox",
"chars": 78,
"preview": "var (\n w, h = 10, 20\n line = 3\n color int\n border float64 = 1.2\n)\n"
},
{
"path": "cl/_testspx/clsinit1/out.go",
"chars": 211,
"preview": "package main\n\ntype Rect struct {\n\tw int\n\th int\n\tline int\n\tcolor int\n\tborder float64\n}\n\nfunc (this *Rect) XG"
},
{
"path": "cl/_testspx/clsinit2/Rect.gox",
"chars": 77,
"preview": "var (\n w, h = 10, 20\n color int\n border float64 = 1.2\n)\n\necho *this\n"
},
{
"path": "cl/_testspx/clsinit2/out.go",
"chars": 298,
"preview": "package main\n\nimport \"fmt\"\n\ntype Rect struct {\n\tw int\n\th int\n\tcolor int\n\tborder float64\n}\n\nfunc (this *Rect) "
},
{
"path": "cl/_testspx/execgsh/demo.gsh",
"chars": 82,
"preview": "var (\n score = 100\n)\n\necho score\nxgo \"run\", \"./foo\"\nexec \"ls $HOME\"\nls ${HOME}\n"
},
{
"path": "cl/_testspx/execgsh/out.go",
"chars": 442,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/qiniu/x/gsh\"\n)\n\ntype demo struct {\n\tgsh.App\n\tscore int\n}\n\nfunc (this *demo) M"
},
{
"path": "cl/_testspx/gshself/demo.gsh",
"chars": 79,
"preview": "import \"github.com/goplus/xgo/cl/internal/dql\"\n\nself := dql.Node{}\n\nls ${HOME}\n"
},
{
"path": "cl/_testspx/gshself/out.go",
"chars": 309,
"preview": "package main\n\nimport (\n\t\"github.com/goplus/xgo/cl/internal/dql\"\n\t\"github.com/qiniu/x/gsh\"\n)\n\ntype demo struct {\n\tgsh.App"
},
{
"path": "cl/_testspx/init/init.tspx",
"chars": 0,
"preview": ""
},
{
"path": "cl/_testspx/init/out.go",
"chars": 267,
"preview": "package main\n\nimport \"github.com/goplus/xgo/cl/internal/spx\"\n\ntype _init struct {\n\tspx.Sprite\n\t*MyGame\n}\ntype MyGame str"
},
{
"path": "cl/_testspx/multiworks/foo_prompt.gox",
"chars": 12,
"preview": "return \"Hi\"\n"
},
{
"path": "cl/_testspx/multiworks/hello_tool.gox",
"chars": 10,
"preview": "return -1\n"
},
{
"path": "cl/_testspx/multiworks/main_mcp.gox",
"chars": 16,
"preview": "server \"protos\"\n"
},
{
"path": "cl/_testspx/multiworks/out.go",
"chars": 724,
"preview": "package main\n\nimport \"github.com/goplus/xgo/cl/internal/mcp\"\n\ntype foo struct {\n\tmcp.Prompt\n\t*Game\n}\ntype Tool_hello str"
},
{
"path": "cl/_testspx/newobj/Kai_spx.gox",
"chars": 0,
"preview": ""
},
{
"path": "cl/_testspx/newobj/main_spx.gox",
"chars": 44,
"preview": "a := new\na.run\nb := new(Sprite)\necho b.name\n"
},
{
"path": "cl/_testspx/newobj/out.go",
"chars": 598,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/cl/internal/spx3\"\n)\n\ntype Kai struct {\n\tspx3.Sprite\n\t*Game\n}\ntype "
},
{
"path": "cl/_testspx/nogame/bar.tspx",
"chars": 0,
"preview": ""
},
{
"path": "cl/_testspx/nogame/out.go",
"chars": 263,
"preview": "package main\n\nimport \"github.com/goplus/xgo/cl/internal/spx\"\n\ntype bar struct {\n\tspx.Sprite\n\t*MyGame\n}\ntype MyGame struc"
},
{
"path": "cl/_testspx/singlework/Kai_spx.gox",
"chars": 21,
"preview": "echo jwt.token(\"Hi\")\n"
},
{
"path": "cl/_testspx/singlework/main_spx.gox",
"chars": 22,
"preview": "var (\n\tKai Kai\n)\n\nrun\n"
},
{
"path": "cl/_testspx/singlework/out.go",
"chars": 623,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/cl/internal/spx3\"\n\t\"github.com/goplus/xgo/cl/internal/spx3/jwt\"\n)\n"
},
{
"path": "cl/_testspx/xgoinit_dup/Spr_spx.gox",
"chars": 26,
"preview": "echo \"sprite main called\"\n"
},
{
"path": "cl/_testspx/xgoinit_dup/main_spx.gox",
"chars": 35,
"preview": "var (\n\tscore = 100\n\tSpr Spr\n)\n\nrun\n"
},
{
"path": "cl/_testspx/xgoinit_dup/out.go",
"chars": 682,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/goplus/xgo/cl/internal/spx3\"\n)\n\ntype Spr struct {\n\tspx3.Sprite\n\t*Game\n}\ntype "
},
{
"path": "cl/builtin.go",
"chars": 5015,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/builtin_test.go",
"chars": 16703,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/c.go",
"chars": 1580,
"preview": "/*\n * Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/classfile.go",
"chars": 18823,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/cltest/cltest.go",
"chars": 7024,
"preview": "/*\n * Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/cltest/error_msg.go",
"chars": 1966,
"preview": "/*\n * Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/cltest/recorder.go",
"chars": 4698,
"preview": "/*\n * Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/cltest/spx.go",
"chars": 4821,
"preview": "/*\n * Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/compile.go",
"chars": 45184,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/compile_spx_test.go",
"chars": 19985,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/compile_test.go",
"chars": 60096,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/compile_testdir_test.go",
"chars": 1000,
"preview": "/*\n * Copyright (c) 2022 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/compile_xgo_test.go",
"chars": 24185,
"preview": "/*\n * Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/error_msg_test.go",
"chars": 24928,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/expr.go",
"chars": 52946,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/func_type_and_var.go",
"chars": 14965,
"preview": "/*\n * Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.\n *\n * Licensed under the Apache License, Versio"
},
{
"path": "cl/internal/.gitignore",
"chars": 51,
"preview": ".gop/\n.xgo/\ngo.mod\ngop_autogen*.go\nxgo_autogen*.go\n"
},
{
"path": "cl/internal/dql/dql.go",
"chars": 1610,
"preview": "package dql\n\nimport \"iter\"\n\nconst (\n\tXGoPackage = true\n)\n\ntype Node struct {\n}\n\ntype NodeSet struct {\n}\n\nfunc New() Node"
},
{
"path": "cl/internal/gop-in-go/foo/foo.xgo",
"chars": 95,
"preview": "package foo\n\nfunc ReverseMap(m map[string]int) map[int]string {\n\treturn {v: k for k, v <- m}\n}\n"
},
{
"path": "cl/internal/gop-in-go/foo/foo_test.xgo",
"chars": 180,
"preview": "package foo\n\nimport (\n\t\"testing\"\n)\n\nfunc TestReverseMap(t *testing.T) {\n\tout := ReverseMap({\"a\": 1})\n\tif len(out) != 1 |"
}
]
// ... and 644 more files (download for full content)
About this extraction
This page contains the full source code of the goplus/xgo GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 844 files (2.5 MB), approximately 701.0k tokens, and a symbol index with 4458 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.