Fix control flow graph for unary expressions
This commit is contained in:
15
_test/struct7.go
Normal file
15
_test/struct7.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
type Opt struct {
|
||||||
|
b bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type T struct {
|
||||||
|
i int
|
||||||
|
opt Opt
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
a := T{}
|
||||||
|
println(a.i, a.opt.b)
|
||||||
|
}
|
||||||
@@ -930,6 +930,7 @@ func (interp *Interpreter) Cfg(root *Node) []*Node {
|
|||||||
log.Println(n.index, "selector unresolved:", n.child[0].ident+"."+n.child[1].ident)
|
log.Println(n.index, "selector unresolved:", n.child[0].ident+"."+n.child[1].ident)
|
||||||
}
|
}
|
||||||
} else if fi := n.typ.fieldIndex(n.child[1].ident); fi >= 0 {
|
} else if fi := n.typ.fieldIndex(n.child[1].ident); fi >= 0 {
|
||||||
|
//log.Println(n.index, "selector field", fi)
|
||||||
// Resolve struct field index
|
// Resolve struct field index
|
||||||
if n.typ.cat == PtrT {
|
if n.typ.cat == PtrT {
|
||||||
n.run = getPtrIndex
|
n.run = getPtrIndex
|
||||||
@@ -986,6 +987,9 @@ func (interp *Interpreter) Cfg(root *Node) []*Node {
|
|||||||
}
|
}
|
||||||
n.typ = n.child[1].typ
|
n.typ = n.child[1].typ
|
||||||
|
|
||||||
|
case UnaryExpr:
|
||||||
|
wireChild(n)
|
||||||
|
|
||||||
case ValueSpec:
|
case ValueSpec:
|
||||||
l := len(n.child) - 1
|
l := len(n.child) - 1
|
||||||
if n.typ = n.child[l].typ; n.typ == nil {
|
if n.typ = n.child[l].typ; n.typ == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user