Commit 53d43cb5 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile/internal/gc: introduce type for untyped constant kinds

Change-Id: Ia34b6dd099d07d5e1d4bffe775a20fa92705fdb0
Reviewed-on: https://go-review.googlesource.com/16335
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent cd7d7382
...@@ -963,7 +963,7 @@ var tagString = [...]string{ ...@@ -963,7 +963,7 @@ var tagString = [...]string{
// untype returns the "pseudo" untyped type for a Ctype (import/export use only). // untype returns the "pseudo" untyped type for a Ctype (import/export use only).
// (we can't use an pre-initialized array because we must be sure all types are // (we can't use an pre-initialized array because we must be sure all types are
// set up) // set up)
func untype(ctype int) *Type { func untype(ctype Ctype) *Type {
switch ctype { switch ctype {
case CTINT: case CTINT:
return idealint return idealint
......
This diff is collapsed.
...@@ -10,8 +10,6 @@ import ( ...@@ -10,8 +10,6 @@ import (
"cmd/internal/obj" "cmd/internal/obj"
) )
// avoid <ctype.h>
// The parser's maximum stack size. // The parser's maximum stack size.
// We have to use a #define macro here since yacc // We have to use a #define macro here since yacc
// or bison will check for its definition and use // or bison will check for its definition and use
...@@ -95,7 +93,7 @@ type Val struct { ...@@ -95,7 +93,7 @@ type Val struct {
type NilVal struct{} type NilVal struct{}
func (v Val) Ctype() int { func (v Val) Ctype() Ctype {
switch x := v.U.(type) { switch x := v.U.(type) {
default: default:
Fatalf("unexpected Ctype for %T", v.U) Fatalf("unexpected Ctype for %T", v.U)
...@@ -312,8 +310,11 @@ const ( ...@@ -312,8 +310,11 @@ const (
NTYPE NTYPE
) )
// Ctype describes the constant kind of an "ideal" (untyped) constant.
type Ctype int8
const ( const (
CTxxx = iota CTxxx Ctype = iota
CTINT CTINT
CTRUNE CTRUNE
......
...@@ -744,11 +744,11 @@ func exprcmp(c1, c2 *caseClause) int { ...@@ -744,11 +744,11 @@ func exprcmp(c1, c2 *caseClause) int {
n2 := c2.node.Left n2 := c2.node.Left
// sort by type (for switches on interface) // sort by type (for switches on interface)
ct := int(n1.Val().Ctype()) ct := n1.Val().Ctype()
if ct > int(n2.Val().Ctype()) { if ct > n2.Val().Ctype() {
return +1 return +1
} }
if ct < int(n2.Val().Ctype()) { if ct < n2.Val().Ctype() {
return -1 return -1
} }
if !Eqtype(n1.Type, n2.Type) { if !Eqtype(n1.Type, n2.Type) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment