Skip to content

Commit bcbebd5

Browse files
authored
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: https://github.com/segmentio/asm/blob/18af27c3ce38682a2545f2d95e5ef564dd312d6e/build/base64/decode_asm.go#L13-L14 https://github.com/phoreproject/bls/blob/a88a5ae26844d7293359422888d7c7f69f43c845/asm/asm.go#L6-L7
1 parent 4f7179b commit bcbebd5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

build/global.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ func Store(src reg.Register, dst gotypes.Component) { ctx.Store(src, dst) }
122122
// Dereference loads a pointer and returns its element type.
123123
func Dereference(ptr gotypes.Component) gotypes.Component { return ctx.Dereference(ptr) }
124124

125+
// Function starts building a new function with the given name.
126+
func Function(name string) { ctx.Function(name) }
127+
125128
// Doc sets documentation comment lines for the currently active function.
126129
func Doc(lines ...string) { ctx.Doc(lines...) }
127130

@@ -131,6 +134,9 @@ func Pragma(directive string, args ...string) { ctx.Pragma(directive, args...) }
131134
// Attributes sets function attributes for the currently active function.
132135
func Attributes(a attr.Attribute) { ctx.Attributes(a) }
133136

137+
// SignatureExpr parses the signature expression and sets it as the active function's signature.
138+
func SignatureExpr(expr string) { ctx.SignatureExpr(expr) }
139+
134140
// Implement starts building a function of the given name, whose type is
135141
// specified by a stub in the containing package.
136142
func Implement(name string) { ctx.Implement(name) }

0 commit comments

Comments
 (0)