intGenMixin.go 4.58 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 IntTraits struct {
	PkgName    string
	TypeName   string // see doc in kindTraitsGenerator
	TypeSymbol string // see doc in kindTraitsGenerator
}

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

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

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