pub struct Selection { /* private fields */ }
Expand description
A Selection describes a selector expression x.f. For the declarations:
type T struct{ x int; E } type E struct{} func (e E) m() {} var p *T
the following relations exist:
Selector Kind Recv Obj Type Index Indirect
p.x FieldVal T x int {0} true p.m MethodVal *T m func (e *T) m() {1, 0} true T.m MethodExpr T m func m(_ T) {1, 0} false
Implementations§
Source§impl Selection
impl Selection
pub fn new( kind: SelectionKind, recv: Option<TypeKey>, obj: ObjKey, indices: Vec<usize>, indirect: bool, objs: &TCObjects, ) -> Selection
pub fn init_type(&mut self, objs: &mut TCObjects)
pub fn kind(&self) -> &SelectionKind
pub fn recv(&self) -> Option<TypeKey>
pub fn obj(&self) -> ObjKey
pub fn id(&self) -> &String
Sourcepub fn indices(&self) -> &Vec<usize>
pub fn indices(&self) -> &Vec<usize>
indices describes the path from x to f in x.f. The last indices entry is the field or method indices of the type declaring f; either:
- the list of declared methods of a named type; or
- the list of methods of an interface type; or
- the list of fields of a struct type.
The earlier indices entries are the indices of the embedded fields implicitly traversed to get from (the type of) x to f, starting at embedding depth 0.
Sourcepub fn indirect(&self) -> &bool
pub fn indirect(&self) -> &bool
Indirect reports whether any pointer indirection was required to get from x to f in x.f.