linkGenMixin.go 4.63 KB
Newer Older
Eric Myhre's avatar
Eric Myhre committed
1 2 3 4 5
package mixins

import (
	"io"

6
	ld "gitlab.dms3.io/ld/go-ld-prime"
Eric Myhre's avatar
Eric Myhre committed
7 8 9 10 11 12 13 14
)

type LinkTraits struct {
	PkgName    string
	TypeName   string // see doc in kindTraitsGenerator
	TypeSymbol string // see doc in kindTraitsGenerator
}

15 16
func (LinkTraits) Kind() ld.Kind {
	return ld.Kind_Link
Eric Myhre's avatar
Eric Myhre committed
17
}
18
func (g LinkTraits) EmitNodeMethodKind(w io.Writer) {
Eric Myhre's avatar
Eric Myhre committed
19
	doTemplate(`
20 21
		func ({{ .TypeSymbol }}) Kind() ld.Kind {
			return ld.Kind_Link
Eric Myhre's avatar
Eric Myhre committed
22 23 24
		}
	`, w, g)
}
25
func (g LinkTraits) EmitNodeMethodLookupByString(w io.Writer) {
26
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodLookupByString(w)
Eric Myhre's avatar
Eric Myhre committed
27
}
28
func (g LinkTraits) EmitNodeMethodLookupByNode(w io.Writer) {
29
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodLookupByNode(w)
Eric Myhre's avatar
Eric Myhre committed
30
}
31
func (g LinkTraits) EmitNodeMethodLookupByIndex(w io.Writer) {
32
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodLookupByIndex(w)
Eric Myhre's avatar
Eric Myhre committed
33
}
34
func (g LinkTraits) EmitNodeMethodLookupBySegment(w io.Writer) {
35
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodLookupBySegment(w)
Eric Myhre's avatar
Eric Myhre committed
36 37
}
func (g LinkTraits) EmitNodeMethodMapIterator(w io.Writer) {
38
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodMapIterator(w)
Eric Myhre's avatar
Eric Myhre committed
39 40
}
func (g LinkTraits) EmitNodeMethodListIterator(w io.Writer) {
41
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodListIterator(w)
Eric Myhre's avatar
Eric Myhre committed
42 43
}
func (g LinkTraits) EmitNodeMethodLength(w io.Writer) {
44
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodLength(w)
Eric Myhre's avatar
Eric Myhre committed
45
}
46
func (g LinkTraits) EmitNodeMethodIsAbsent(w io.Writer) {
47
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodIsAbsent(w)
Eric Myhre's avatar
Eric Myhre committed
48 49
}
func (g LinkTraits) EmitNodeMethodIsNull(w io.Writer) {
50
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodIsNull(w)
Eric Myhre's avatar
Eric Myhre committed
51 52
}
func (g LinkTraits) EmitNodeMethodAsBool(w io.Writer) {
53
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodAsBool(w)
Eric Myhre's avatar
Eric Myhre committed
54 55
}
func (g LinkTraits) EmitNodeMethodAsInt(w io.Writer) {
56
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodAsInt(w)
Eric Myhre's avatar
Eric Myhre committed
57 58
}
func (g LinkTraits) EmitNodeMethodAsFloat(w io.Writer) {
59
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodAsFloat(w)
Eric Myhre's avatar
Eric Myhre committed
60 61
}
func (g LinkTraits) EmitNodeMethodAsString(w io.Writer) {
62
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodAsString(w)
Eric Myhre's avatar
Eric Myhre committed
63 64
}
func (g LinkTraits) EmitNodeMethodAsBytes(w io.Writer) {
65
	kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ld.Kind_Link}.emitNodeMethodAsBytes(w)
Eric Myhre's avatar
Eric Myhre committed
66 67 68 69 70 71 72 73
}

type LinkAssemblerTraits struct {
	PkgName       string
	TypeName      string // see doc in kindAssemblerTraitsGenerator
	AppliedPrefix string // see doc in kindAssemblerTraitsGenerator
}

74 75
func (LinkAssemblerTraits) Kind() ld.Kind {
	return ld.Kind_Link
Eric Myhre's avatar
Eric Myhre committed
76 77
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) {
78
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_Link}.emitNodeAssemblerMethodBeginMap(w)
Eric Myhre's avatar
Eric Myhre committed
79 80
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) {
81
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_Link}.emitNodeAssemblerMethodBeginList(w)
Eric Myhre's avatar
Eric Myhre committed
82 83
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
84
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_Link}.emitNodeAssemblerMethodAssignNull(w)
Eric Myhre's avatar
Eric Myhre committed
85 86
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) {
87
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_Link}.emitNodeAssemblerMethodAssignBool(w)
Eric Myhre's avatar
Eric Myhre committed
88 89
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) {
90
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_Link}.emitNodeAssemblerMethodAssignInt(w)
Eric Myhre's avatar
Eric Myhre committed
91 92
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) {
93
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_Link}.emitNodeAssemblerMethodAssignFloat(w)
Eric Myhre's avatar
Eric Myhre committed
94 95
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) {
96
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_Link}.emitNodeAssemblerMethodAssignString(w)
Eric Myhre's avatar
Eric Myhre committed
97 98
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) {
99
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_Link}.emitNodeAssemblerMethodAssignBytes(w)
Eric Myhre's avatar
Eric Myhre committed
100
}
101
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) {
102
	kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ld.Kind_Link}.emitNodeAssemblerMethodPrototype(w)
Eric Myhre's avatar
Eric Myhre committed
103
}