}
}
- sym := TypeSymPrefix(".hash", t)
if base.Flag.LowerR != 0 {
- fmt.Printf("genhash %v %v %v\n", closure, sym, t)
+ fmt.Printf("genhash %v %v\n", closure, t)
}
+ fn := hashFunc(t)
+
+ // Build closure. It doesn't close over any variables, so
+ // it contains just the function pointer.
+ objw.SymPtr(closure, 0, fn.Linksym(), 0)
+ objw.Global(closure, int32(types.PtrSize), obj.DUPOK|obj.RODATA)
+
+ return closure
+}
+
+func hashFunc(t *types.Type) *ir.Func {
base.Pos = base.AutogeneratedPos // less confusing than end of input
typecheck.DeclContext = ir.PEXTERN
}
results := []*ir.Field{ir.NewField(base.Pos, nil, types.Types[types.TUINTPTR])}
+ sym := TypeSymPrefix(".hash", t)
fn := typecheck.DeclFunc(sym, nil, args, results)
np := ir.AsNode(fn.Type().Params().Field(0).Nname)
nh := ir.AsNode(fn.Type().Params().Field(1).Nname)
fn.SetNilCheckDisabled(true)
typecheck.Target.Decls = append(typecheck.Target.Decls, fn)
- // Build closure. It doesn't close over any variables, so
- // it contains just the function pointer.
- objw.SymPtr(closure, 0, fn.Linksym(), 0)
- objw.Global(closure, int32(types.PtrSize), obj.DUPOK|obj.RODATA)
-
- return closure
+ return fn
}
func runtimeHashFor(name string, t *types.Type) *ir.Name {
return n
}
-func hashfor(t *types.Type) ir.Node {
+// hashfor returns the function to compute the hash of a value of type t.
+func hashfor(t *types.Type) *ir.Name {
var sym *types.Sym
switch a, _ := types.AlgType(t); a {