type Context … // NewContext initializes an empty build Context. func NewContext() *Context { … } // Package sets the package the generated file will belong to. Required to be able to reference types in the package. func (c *Context) Package(path string) { … } // Constraints sets build constraints for the file. func (c *Context) Constraints(t buildtags.ConstraintsConvertable) { … } // Constraint appends a constraint to the file's build constraints. func (c *Context) Constraint(t buildtags.ConstraintConvertable) { … } // ConstraintExpr appends a constraint to the file's build constraints. The // constraint to add is parsed from the given expression. The expression should // look the same as the content following "// +build " in regular build // constraint comments. func (c *Context) ConstraintExpr(expr string) { … } // Function starts building a new function with the given name. func (c *Context) Function(name string) { … } // Doc sets documentation comment lines for the currently active function. func (c *Context) Doc(lines ...string) { … } // Pragma adds a compiler directive to the currently active function. func (c *Context) Pragma(directive string, args ...string) { … } // Attributes sets function attributes for the currently active function. func (c *Context) Attributes(a attr.Attribute) { … } // Signature sets the signature for the currently active function. func (c *Context) Signature(s *gotypes.Signature) { … } // SignatureExpr parses the signature expression and sets it as the active function's signature. func (c *Context) SignatureExpr(expr string) { … } // Implement starts building a function of the given name, whose type is // specified by a stub in the containing package. func (c *Context) Implement(name string) { … } func (c *Context) types() *types.Package { … } // AllocLocal allocates size bytes in the stack of the currently active function. // Returns a reference to the base pointer for the newly allocated region. func (c *Context) AllocLocal(size int) operand.Mem { … } // Instruction adds an instruction to the active function. func (c *Context) Instruction(i *ir.Instruction) { … } // Label adds a label to the active function. func (c *Context) Label(name string) { … } // Comment adds comment lines to the active function. func (c *Context) Comment(lines ...string) { … } // Commentf adds a formtted comment line. func (c *Context) Commentf(format string, a ...any) { … } func (c *Context) activefunc() *ir.Function { … } // StaticGlobal adds a new static data section to the file and returns a pointer to it. func (c *Context) StaticGlobal(name string) operand.Mem { … } // DataAttributes sets the attributes on the current active global data section. func (c *Context) DataAttributes(a attr.Attribute) { … } // AddDatum adds constant v at offset to the current active global data section. func (c *Context) AddDatum(offset int, v operand.Constant) { … } // AppendDatum appends a constant to the current active global data section. func (c *Context) AppendDatum(v operand.Constant) { … } func (c *Context) activeglobal() *ir.Global { … } func (c *Context) adderror(err error) { … } func (c *Context) adderrormessage(msg string) { … } // Result returns the built file and any accumulated errors. func (c *Context) Result() (*ir.File, error) { … }