Skip to content

Commit

Permalink
cmd/compile: use types.IdealFoo directly in predecl
Browse files Browse the repository at this point in the history
Instead of using untype(Ctype) to get corresponding untyped type.

Passes toolstash-check.

Change-Id: I311fe6c94b1f8eb2e1615101a379cd06dcab835b
Reviewed-on: https://go-review.googlesource.com/c/go/+/260698
Trust: Cuong Manh Le <[email protected]>
Run-TryBot: Cuong Manh Le <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Matthew Dempsky <[email protected]>
  • Loading branch information
cuonglm committed Oct 8, 2020
1 parent 542693e commit f3b58ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
38 changes: 7 additions & 31 deletions src/cmd/compile/internal/gc/bexport.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,30 +126,6 @@ const (
aliasTag
)

// untype returns the "pseudo" untyped type for a Ctype (import/export use only).
// (we can't use a pre-initialized array because we must be sure all types are
// set up)
func untype(ctype Ctype) *types.Type {
switch ctype {
case CTINT:
return types.Idealint
case CTRUNE:
return types.Idealrune
case CTFLT:
return types.Idealfloat
case CTCPLX:
return types.Idealcomplex
case CTSTR:
return types.Idealstring
case CTBOOL:
return types.Idealbool
case CTNIL:
return types.Types[TNIL]
}
Fatalf("exporter: unknown Ctype")
return nil
}

var predecl []*types.Type // initialized lazily

func predeclared() []*types.Type {
Expand Down Expand Up @@ -184,13 +160,13 @@ func predeclared() []*types.Type {
types.Errortype,

// untyped types
untype(CTBOOL),
untype(CTINT),
untype(CTRUNE),
untype(CTFLT),
untype(CTCPLX),
untype(CTSTR),
untype(CTNIL),
types.Idealbool,
types.Idealint,
types.Idealrune,
types.Idealfloat,
types.Idealcomplex,
types.Idealstring,
types.Types[TNIL],

// package unsafe
types.Types[TUNSAFEPTR],
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/gc/iexport.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@ func constTypeOf(typ *types.Type) Ctype {
}

func (w *exportWriter) value(typ *types.Type, v Val) {
if typ.IsUntyped() {
typ = untype(v.Ctype())
if vt := idealType(v.Ctype()); typ.IsUntyped() && typ != vt {
Fatalf("exporter: untyped type mismatch, have: %v, want: %v", typ, vt)
}
w.typ(typ)

Expand Down

0 comments on commit f3b58ed

Please sign in to comment.