github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/mm/gen.go (about)

     1  // +build ignore
     2  
     3  package main
     4  
     5  import (
     6  	"os"
     7  
     8  	"github.com/egonelbre/exp/mm"
     9  )
    10  
    11  func main() {
    12  	data, err := mm.Generate(mm.FallbackDef, map[string]*mm.Spec{
    13  		"Primary": mm.SpecFor(mm.Malloc{}),
    14  		"Fallback": &mm.Spec{
    15  			Type:      "*mm.Region",
    16  			Alignment: mm.PlatformAlignment,
    17  			Dealloc:   true,
    18  			Owns:      true,
    19  			Empty:     false,
    20  		},
    21  	})
    22  	if err != nil {
    23  		panic(err)
    24  	}
    25  
    26  	file, err := os.Create("xxx/fallback.go")
    27  	if err != nil {
    28  		panic(err)
    29  	}
    30  	defer file.Close()
    31  
    32  	file.WriteString("// DO NOT EDIT\n")
    33  	file.WriteString("// GENERATED CODE\n")
    34  	file.Write(data)
    35  }