// isBuiltin reports whether expr is a (possibly parenthesized)
// referenced to the specified built-in function.
-func (p *pkgWriter) isBuiltin(expr syntax.Expr, builtin string) bool {
+func (pw *pkgWriter) isBuiltin(expr syntax.Expr, builtin string) bool {
if name, ok := unparen(expr).(*syntax.Name); ok && name.Value == builtin {
- return p.typeAndValue(name).IsBuiltin()
+ return pw.typeAndValue(name).IsBuiltin()
}
return false
}
// terminates reports whether stmt terminates normal control flow
// (i.e., does not merely advance to the following statement).
-func (p *pkgWriter) terminates(stmt syntax.Stmt) bool {
+func (pw *pkgWriter) terminates(stmt syntax.Stmt) bool {
switch stmt := stmt.(type) {
case *syntax.BranchStmt:
if stmt.Tok == syntax.Goto {
return true
case *syntax.ExprStmt:
if call, ok := unparen(stmt.X).(*syntax.CallExpr); ok {
- if p.isBuiltin(call.Fun, "panic") {
+ if pw.isBuiltin(call.Fun, "panic") {
return true
}
}
// }
// unreachable
case *syntax.IfStmt:
- cond := p.staticBool(&stmt.Cond)
- return (cond < 0 || p.terminates(stmt.Then)) && (cond > 0 || p.terminates(stmt.Else))
+ cond := pw.staticBool(&stmt.Cond)
+ return (cond < 0 || pw.terminates(stmt.Then)) && (cond > 0 || pw.terminates(stmt.Else))
case *syntax.BlockStmt:
- return p.terminates(lastNonEmptyStmt(stmt.List))
+ return pw.terminates(lastNonEmptyStmt(stmt.List))
}
return false
// Sort returns a slice of the edges in the map, in a consistent
// order. The sort order is first based on the edge weight
// (higher-to-lower) and then by the node names to avoid flakiness.
-func (e EdgeMap) Sort() []*Edge {
- el := make(edgeList, 0, len(e))
- for _, w := range e {
+func (em EdgeMap) Sort() []*Edge {
+ el := make(edgeList, 0, len(em))
+ for _, w := range em {
el = append(el, w)
}
}
// Sum returns the total weight for a set of nodes.
-func (e EdgeMap) Sum() int64 {
+func (em EdgeMap) Sum() int64 {
var ret int64
- for _, edge := range e {
+ for _, edge := range em {
ret += edge.Weight
}
return ret
return fmt.Sprintf("0x%x.%d.%d", ls.Registers, ls.stackOffsetValue(), int32(ls.StackOffset)&1)
}
-func (loc liveSlot) absent() bool {
- return loc.Registers == 0 && !loc.onStack()
+func (ls liveSlot) absent() bool {
+ return ls.Registers == 0 && !ls.onStack()
}
// StackOffset encodes whether a value is on the stack and if so, where.
regValues *[]*Value // values assigned to registers accumulate here
}
-func (rc *registerCursor) String() string {
+func (c *registerCursor) String() string {
dest := "<none>"
- if rc.storeDest != nil {
- dest = rc.storeDest.String()
+ if c.storeDest != nil {
+ dest = c.storeDest.String()
}
regs := "<none>"
- if rc.regValues != nil {
+ if c.regValues != nil {
regs = ""
- for i, x := range *rc.regValues {
+ for i, x := range *c.regValues {
if i > 0 {
regs = regs + "; "
}
}
}
// not printing the config because that has not been useful
- return fmt.Sprintf("RCSR{storeDest=%v, regsLen=%d, nextSlice=%d, regValues=[%s]}", dest, rc.regsLen, rc.nextSlice, regs)
+ return fmt.Sprintf("RCSR{storeDest=%v, regsLen=%d, nextSlice=%d, regValues=[%s]}", dest, c.regsLen, c.nextSlice, regs)
}
// next effectively post-increments the register cursor; the receiver is advanced,