Commit ef62f641 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: use ONAME instead of OPACK in binary export format

This is addressing feedback given on golang.org/cl/23052;
we do it in a separate CL to separate the functional from
the rename change.

ONAME was not used in the export data, but it's the natural node op
where we used OPACK instead. Renamed.

Furthermore, OPACK and ONONAME nodes are replaced by the type checker
with ONAME nodes, so OPACK nodes cannot occur when exporting type-checked
code. Removed a special-case for OPACK nodes since they don't appear.

Change-Id: I78b01a1badbf60e9283eaadeca2578a65d28cbd2
Reviewed-on: https://go-review.googlesource.com/23053
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
parent aff48890
......@@ -1157,15 +1157,13 @@ func (p *exporter) expr(n *Node) {
// Special case: name used as local variable in export.
// _ becomes ~b%d internally; print as _ for export
if n.Sym != nil && n.Sym.Name[0] == '~' && n.Sym.Name[1] == 'b' {
// case 0: mapped to OPACK
p.op(OPACK)
p.op(ONAME)
p.string("_") // inlined and customized version of p.sym(n)
break
}
if n.Sym != nil && !isblank(n) && n.Name.Vargen > 0 {
// case 1: mapped to OPACK
p.op(OPACK)
p.op(ONAME)
p.sym(n)
break
}
......@@ -1174,20 +1172,18 @@ func (p *exporter) expr(n *Node) {
// but for export, this should be rendered as (*pkg.T).meth.
// These nodes have the special property that they are names with a left OTYPE and a right ONAME.
if n.Left != nil && n.Left.Op == OTYPE && n.Right != nil && n.Right.Op == ONAME {
// case 2: mapped to OXDOT
p.op(OXDOT)
p.expr(n.Left) // n.Left.Op == OTYPE
p.fieldSym(n.Right.Sym, true)
break
}
// case 3: mapped to OPACK
fallthrough
case OPACK, ONONAME:
p.op(OPACK)
p.op(ONAME)
p.sym(n)
// case OPACK, ONONAME:
// should have been resolved by typechecking - handled by default case
case OTYPE:
p.op(OTYPE)
if p.bool(n.Type == nil) {
......@@ -1400,10 +1396,7 @@ func (p *exporter) stmt(n *Node) {
p.expr(n.Right)
}
case OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
fallthrough
case OAS2:
case OAS2, OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
p.op(OAS2)
p.exprList(n.List)
p.exprList(n.Rlist)
......
......@@ -798,12 +798,12 @@ func (p *importer) node() *Node {
}
return n
// case ONAME, OPACK, ONONAME:
// unreachable - mapped to case OPACK below by exporter
case OPACK:
case ONAME:
return mkname(p.sym())
// case OPACK, ONONAME:
// unreachable - should have been resolved by typechecking
case OTYPE:
if p.bool() {
return mkname(p.sym())
......@@ -854,14 +854,7 @@ func (p *importer) node() *Node {
case OXDOT:
// see parser.new_dotname
obj := p.expr()
sel := p.fieldSym()
if obj.Op == OPACK {
s := restrictlookup(sel.Name, obj.Name.Pkg)
obj.Used = true
return oldname(s)
}
return NodSym(OXDOT, obj, sel)
return NodSym(OXDOT, p.expr(), p.fieldSym())
// case ODOTTYPE, ODOTTYPE2:
// unreachable - mapped to case ODOTTYPE below by exporter
......
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