|
14 | 14 |
|
15 | 15 | //go:build ignore
|
16 | 16 |
|
| 17 | +// Since our go.mod still has 'go 1.22', but we want to use go/types.Alias |
| 18 | +// to differentiate cue.Value from pkg.Schema, we enable it explicitly. |
| 19 | +// TODO(mvdan): this can be removed once we bump go.mod to 'go 1.23'; |
| 20 | +// at which point packages.NeedSyntax below can be removed as well |
| 21 | +// as we no longer need to force go/packages to typecheck with our GODEBUG setting. |
| 22 | +//go:debug gotypesalias=1 |
| 23 | + |
17 | 24 | // gen.go generates the pkg.go files inside the packages under the pkg directory.
|
18 | 25 | //
|
19 | 26 | // It takes the list of packages from the packages.txt.
|
@@ -106,7 +113,7 @@ func main() {
|
106 | 113 | packagesList = append(packagesList, path.Join(pkgParent, pkg))
|
107 | 114 | }
|
108 | 115 |
|
109 |
| - cfg := &packages.Config{Mode: packages.NeedName | packages.NeedFiles | packages.NeedTypes} |
| 116 | + cfg := &packages.Config{Mode: packages.NeedName | packages.NeedFiles | packages.NeedTypes | packages.NeedSyntax} |
110 | 117 | pkgs, err := packages.Load(cfg, packagesList...)
|
111 | 118 | if err != nil {
|
112 | 119 | fmt.Fprintf(os.Stderr, "load: %v\n", err)
|
@@ -365,31 +372,28 @@ func (g *generator) genFunc(fn *types.Func) {
|
365 | 372 | // TODO(mvdan): goKind and goToCUE still use a lot of strings; simplify.
|
366 | 373 |
|
367 | 374 | func (g *generator) goKind(typ types.Type) string {
|
368 |
| - if ptr, ok := typ.(*types.Pointer); ok { |
369 |
| - typ = ptr.Elem() |
370 |
| - } |
371 | 375 | switch str := types.TypeString(typ, nil); str {
|
372 |
| - case "math/big.Int": |
| 376 | + case "*math/big.Int": |
373 | 377 | return "bigInt"
|
374 |
| - case "math/big.Float": |
| 378 | + case "*math/big.Float": |
375 | 379 | return "bigFloat"
|
376 |
| - case "math/big.Rat": |
| 380 | + case "*math/big.Rat": |
377 | 381 | return "bigRat"
|
378 | 382 | case "cuelang.org/go/internal/core/adt.Bottom":
|
379 | 383 | return "error"
|
380 |
| - case "github.com/cockroachdb/apd/v3.Decimal": |
| 384 | + case "*cuelang.org/go/internal.Decimal": |
381 | 385 | return "decimal"
|
382 | 386 | case "cuelang.org/go/internal/pkg.List":
|
383 | 387 | return "cueList"
|
384 | 388 | case "cuelang.org/go/internal/pkg.Struct":
|
385 | 389 | return "struct"
|
386 |
| - case "cuelang.org/go/internal/pkg.Schema": |
387 |
| - g.nonConcrete = true |
388 |
| - return "schema" |
389 |
| - case "[]*github.com/cockroachdb/apd/v3.Decimal": |
| 390 | + case "[]*cuelang.org/go/internal.Decimal": |
390 | 391 | return "decimalList"
|
391 | 392 | case "cuelang.org/go/cue.Value":
|
392 | 393 | return "value"
|
| 394 | + case "cuelang.org/go/internal/pkg.Schema": |
| 395 | + g.nonConcrete = true |
| 396 | + return "schema" |
393 | 397 | case "cuelang.org/go/cue.List":
|
394 | 398 | return "list"
|
395 | 399 | case "[]string":
|
|
0 commit comments