Lines Matching full:reflect
11 "reflect"
31 value reflect.Value
35 func (s *state) push(name string, value reflect.Value) {
50 func (s *state) setVar(n int, value reflect.Value) {
55 func (s *state) varValue(name string) reflect.Value {
65 var zero reflect.Value
134 value := reflect.ValueOf(data)
174 func (s *state) walk(dot reflect.Value, node parse.Node) {
207 func (s *state) walkIfOrWith(typ parse.NodeType, dot reflect.Value, pipe *parse.PipeNode, list, elseList *parse.ListNode) {
227 func isTrue(val reflect.Value) (truth, ok bool) {
233 case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
235 case reflect.Bool:
237 case reflect.Complex64, reflect.Complex128:
239 case reflect.Chan, reflect.Func, reflect.Ptr, reflect.Interface:
241 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
243 case reflect.Float32, reflect.Float64:
245 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
247 case reflect.Struct:
255 func (s *state) walkRange(dot reflect.Value, r *parse.RangeNode) {
261 oneIteration := func(index, elem reflect.Value) {
274 case reflect.Array, reflect.Slice:
279 oneIteration(reflect.ValueOf(i), val.Index(i))
282 case reflect.Map:
290 case reflect.Chan:
300 oneIteration(reflect.ValueOf(i), elem)
306 case reflect.Invalid:
316 func (s *state) walkTemplate(dot reflect.Value, t *parse.TemplateNode) {
339 func (s *state) evalPipeline(dot reflect.Value, pipe *parse.PipeNode) (value reflect.Value) {
347 if value.Kind() == reflect.Interface && value.Type().NumMethod() == 0 {
348 value = reflect.ValueOf(value.Interface()) // lovely!
357 func (s *state) notAFunction(args []parse.Node, final reflect.Value) {
363 func (s *state) evalCommand(dot reflect.Value, cmd *parse.CommandNode, final reflect.Value) reflect.Value {
383 return reflect.ValueOf(word.True)
391 return reflect.ValueOf(word.Text)
401 func (s *state) idealConstant(constant *parse.NumberNode) reflect.Value {
408 return reflect.ValueOf(constant.Complex128) // incontrovertible.
410 return reflect.ValueOf(constant.Float64)
416 return reflect.ValueOf(n)
427 func (s *state) evalFieldNode(dot reflect.Value, field *parse.FieldNode, args []parse.Node, final reflect.Value) reflect.Value {
432 func (s *state) evalChainNode(dot reflect.Value, chain *parse.ChainNode, args []parse.Node, final reflect.Value) reflect.Value {
445 func (s *state) evalVariableNode(dot reflect.Value, variable *parse.VariableNode, args []parse.Node, final reflect.Value) reflect.Value {
459 func (s *state) evalFieldChain(dot, receiver reflect.Value, node parse.Node, ident []string, args []parse.Node, final reflect.Value) reflect.Value {
468 func (s *state) evalFunction(dot reflect.Value, node *parse.IdentifierNode, cmd parse.Node, args []parse.Node, final reflect.Value) reflect.Value {
481 func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node, args []parse.Node, final, receiver reflect.Value) reflect.Value {
490 if ptr.Kind() != reflect.Interface && ptr.CanAddr() {
503 case reflect.Struct:
517 case reflect.Map:
519 nameVal := reflect.ValueOf(fieldName)
530 result = reflect.Zero(receiver.Type().Elem())
543 errorType = reflect.TypeOf((*error)(nil)).Elem()
544 fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem()
550 func (s *state) evalCall(dot, fun reflect.Value, node parse.Node, name string, args []parse.Node, final reflect.Value) reflect.Value {
573 argv := make([]reflect.Value, numIn)
611 // canBeNil reports whether an untyped nil can be assigned to the type. See reflect.Zero.
612 func canBeNil(typ reflect.Type) bool {
614 case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
621 func (s *state) validateType(value reflect.Value, typ reflect.Type) reflect.Value {
625 return reflect.Zero(typ)
630 if value.Kind() == reflect.Interface && !value.IsNil() {
642 case value.Kind() == reflect.Ptr && value.Type().Elem().AssignableTo(typ):
647 case reflect.PtrTo(value.Type()).AssignableTo(typ) && value.CanAddr():
656 func (s *state) evalArg(dot reflect.Value, typ reflect.Type, n parse.Node) reflect.Value {
663 return reflect.Zero(typ)
678 case reflect.Bool:
680 case reflect.Complex64, reflect.Complex128:
682 case reflect.Float32, reflect.Float64:
684 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
686 case reflect.Interface:
690 case reflect.String:
692 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
699 func (s *state) evalBool(typ reflect.Type, n parse.Node) reflect.Value {
702 value := reflect.New(typ).Elem()
710 func (s *state) evalString(typ reflect.Type, n parse.Node) reflect.Value {
713 value := reflect.New(typ).Elem()
721 func (s *state) evalInteger(typ reflect.Type, n parse.Node) reflect.Value {
724 value := reflect.New(typ).Elem()
732 func (s *state) evalUnsignedInteger(typ reflect.Type, n parse.Node) reflect.Value {
735 value := reflect.New(typ).Elem()
743 func (s *state) evalFloat(typ reflect.Type, n parse.Node) reflect.Value {
746 value := reflect.New(typ).Elem()
754 func (s *state) evalComplex(typ reflect.Type, n parse.Node) reflect.Value {
756 value := reflect.New(typ).Elem()
764 func (s *state) evalEmptyInterface(dot reflect.Value, n parse.Node) reflect.Value {
768 return reflect.ValueOf(n.True)
781 return reflect.ValueOf(n.Text)
794 func indirect(v reflect.Value) (rv reflect.Value, isNil bool) {
795 for ; v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface; v = v.Elem() {
799 if v.Kind() == reflect.Interface && v.NumMethod() > 0 {
808 func (s *state) printValue(n parse.Node, v reflect.Value) {
819 func printableValue(v reflect.Value) (interface{}, bool) {
820 if v.Kind() == reflect.Ptr {
828 if v.CanAddr() && (reflect.PtrTo(v.Type()).Implements(errorType) || reflect.PtrTo(v.Type()).Implements(fmtStringerType)) {
832 case reflect.Chan, reflect.Func:
842 type rvs []reflect.Value
863 // sortKeys sorts (if it can) the slice of reflect.Values, which is a slice of map keys.
864 func sortKeys(v []reflect.Value) []reflect.Value {
869 case reflect.Float32, reflect.Float64:
871 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
873 case reflect.String:
875 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: