mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: remove isLiteral
It has duplicated logic with "n.isGoConst". Passes toolstash-check. Change-Id: I5bf871ef81c7188ca09dae29c7ff55b3a254d972 Reviewed-on: https://go-review.googlesource.com/c/go/+/265437 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
3f6b1a0d5e
commit
e3bb53a768
1 changed files with 3 additions and 8 deletions
|
|
@ -375,11 +375,6 @@ func readonlystaticname(t *types.Type) *Node {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func isLiteral(n *Node) bool {
|
|
||||||
// Treat nils as zeros rather than literals.
|
|
||||||
return n.Op == OLITERAL && n.Val().Ctype() != CTNIL
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *Node) isSimpleName() bool {
|
func (n *Node) isSimpleName() bool {
|
||||||
return n.Op == ONAME && n.Class() != PAUTOHEAP && n.Class() != PEXTERN
|
return n.Op == ONAME && n.Class() != PAUTOHEAP && n.Class() != PEXTERN
|
||||||
}
|
}
|
||||||
|
|
@ -404,7 +399,7 @@ const (
|
||||||
func getdyn(n *Node, top bool) initGenType {
|
func getdyn(n *Node, top bool) initGenType {
|
||||||
switch n.Op {
|
switch n.Op {
|
||||||
default:
|
default:
|
||||||
if isLiteral(n) {
|
if n.isGoConst() {
|
||||||
return initConst
|
return initConst
|
||||||
}
|
}
|
||||||
return initDynamic
|
return initDynamic
|
||||||
|
|
@ -559,7 +554,7 @@ func fixedlit(ctxt initContext, kind initKind, n *Node, var_ *Node, init *Nodes)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
islit := isLiteral(value)
|
islit := value.isGoConst()
|
||||||
if (kind == initKindStatic && !islit) || (kind == initKindDynamic && islit) {
|
if (kind == initKindStatic && !islit) || (kind == initKindDynamic && islit) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -732,7 +727,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if vstat != nil && isLiteral(value) { // already set by copy from static value
|
if vstat != nil && value.isGoConst() { // already set by copy from static value
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue