File: README.md

package info (click to toggle)
golang-github-mmcloughlin-avo 0.0~git20200523.4439b6b-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,304 kB
  • sloc: xml: 71,029; asm: 13,138; sh: 179; makefile: 35
file content (33 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# ext

Demonstrates how to use external types in an `avo` function signature.

In this case, you will need to write the function stub yourself.

[embedmd]:# (stub.go /package/ $)
```go
package ext

import "github.com/mmcloughlin/avo/examples/ext/ext"

// StructFieldB returns field B.
func StructFieldB(e ext.Struct) byte
```

Then in place of the usual `TEXT` declaration we use `Implement` to state that we are beginning the definition of a function already declared in the package stub file.

[embedmd]:# (asm.go go /.*Package.*/ /RET.*/)
```go
	Package("github.com/mmcloughlin/avo/examples/ext")
	Implement("StructFieldB")
	b := Load(Param("e").Field("B"), GP8())
	Store(b, ReturnIndex(0))
	RET()
```

Finally, in this case the `go:generate` line is different since we do not need to generate the stub file.

[embedmd]:# (ext_test.go go /.*go:generate.*/)
```go
//go:generate go run asm.go -out ext.s
```