build: global Function() and SignatureExpr() (#215)

Exposes a few functions on Context that are not available globally. This
oversight suggests that #33 or #133 would be reasonable. `Signature()` is
currently excluded because it causes a conflict for users who have
dot-imported both `build` and `gotypes`. For example:

18af27c3ce/build/base64/decode_asm.go (L13-L14)
a88a5ae268/asm/asm.go (L6-L7)
This commit is contained in:
Michael McLoughlin
2021-10-30 15:05:19 -07:00
committed by GitHub
parent 4f7179b08e
commit bcbebd5674

View File

@@ -122,6 +122,9 @@ func Store(src reg.Register, dst gotypes.Component) { ctx.Store(src, dst) }
// Dereference loads a pointer and returns its element type. // Dereference loads a pointer and returns its element type.
func Dereference(ptr gotypes.Component) gotypes.Component { return ctx.Dereference(ptr) } func Dereference(ptr gotypes.Component) gotypes.Component { return ctx.Dereference(ptr) }
// Function starts building a new function with the given name.
func Function(name string) { ctx.Function(name) }
// Doc sets documentation comment lines for the currently active function. // Doc sets documentation comment lines for the currently active function.
func Doc(lines ...string) { ctx.Doc(lines...) } func Doc(lines ...string) { ctx.Doc(lines...) }
@@ -131,6 +134,9 @@ func Pragma(directive string, args ...string) { ctx.Pragma(directive, args...) }
// Attributes sets function attributes for the currently active function. // Attributes sets function attributes for the currently active function.
func Attributes(a attr.Attribute) { ctx.Attributes(a) } func Attributes(a attr.Attribute) { ctx.Attributes(a) }
// SignatureExpr parses the signature expression and sets it as the active function's signature.
func SignatureExpr(expr string) { ctx.SignatureExpr(expr) }
// Implement starts building a function of the given name, whose type is // Implement starts building a function of the given name, whose type is
// specified by a stub in the containing package. // specified by a stub in the containing package.
func Implement(name string) { ctx.Implement(name) } func Implement(name string) { ctx.Implement(name) }