Skip to content

Commit 631ca07

Browse files
committed
dsl/types: add Struct type
1 parent 6f71591 commit 631ca07

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

dsl/types/ext.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ func AsSlice(x Type) *Slice { return nil }
1212
// Returns nil if type is not a pointer.
1313
func AsPointer(x Type) *Pointer { return nil }
1414

15+
// AsStruct is a type-assert like operation, x.(*Struct), but never panics.
16+
// Returns nil if type is not a struct.
17+
func AsStruct(x Type) *Struct { return nil }
18+
1519
// AsInterface is a type-assert like operation, x.(*Interface), but never panics.
1620
// Returns nil if type is not an interface.
1721
func AsInterface(x Type) *Interface { return nil }

dsl/types/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type (
2929

3030
// An Interface represents an interface type.
3131
Interface struct{}
32+
33+
// A struct represents a struct type.
34+
Struct struct{}
3235
)
3336

3437
// NewArray returns a new array type for the given element type and length.
@@ -53,3 +56,13 @@ func NewPointer(elem Type) *Pointer { return nil }
5356

5457
// Elem returns the element type for the given pointer.
5558
func (*Pointer) Elem() Type { return nil }
59+
60+
func (*Struct) NumFields() int { return 0 }
61+
62+
func (*Struct) Field(i int) *Var { return nil }
63+
64+
type Var struct{}
65+
66+
func (*Var) Embedded() bool { return false }
67+
68+
func (*Var) Type() Type { return nil }

0 commit comments

Comments
 (0)