generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
array.go
33 lines (25 loc) 路 854 Bytes
/
array.go
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
package schema
import (
"google.golang.org/protobuf/proto"
schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema"
)
type Array struct {
Pos Position `parser:"" protobuf:"1,optional"`
Element Type `parser:"'[' @@ ']'" protobuf:"2"`
}
var _ Type = (*Array)(nil)
var _ Symbol = (*Array)(nil)
func (a *Array) Position() Position { return a.Pos }
func (a *Array) schemaChildren() []Node { return []Node{a.Element} }
func (a *Array) schemaType() {}
func (a *Array) schemaSymbol() {}
func (a *Array) String() string { return "[" + a.Element.String() + "]" }
func (a *Array) ToProto() proto.Message {
return &schemapb.Array{Element: typeToProto(a.Element)}
}
func arrayToSchema(s *schemapb.Array) *Array {
return &Array{
Pos: posFromProto(s.Pos),
Element: typeToSchema(s.Element),
}
}