// because Config contains private structs we can't use reflect.Value
// directly, instead we need to "unsafely" address the variable
188824
func unsafeValueOf(val reflect.Value) reflect.Value {
	uptr := unsafe.Pointer(val.UnsafeAddr())
	return reflect.NewAt(val.Type(), uptr).Elem()
}
75216
func reflectWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string) error {
	switch t.Kind() {
	case reflect.String:
		key.SetValue(field.String())
	case reflect.Bool:
		key.SetValue(fmt.Sprint(field.Bool()))
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		key.SetValue(fmt.Sprint(field.Int()))
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		key.SetValue(fmt.Sprint(field.Uint()))
	case reflect.Float32, reflect.Float64:
		key.SetValue(fmt.Sprint(field.Float()))
	case reflectTime:
		key.SetValue(fmt.Sprint(field.Interface().(time.Time).Format(time.RFC3339)))
	case reflect.Slice:
		return reflectSliceWithProperType(key, field, delim)
	default:
		return fmt.Errorf("unsupported type '%s'", t)
	}
	return nil
}
793239
func (r *Reflector) reflectStruct(definitions Definitions, t reflect.Type) *Type {
	st := &Type{
		Type:                 "object",
		Properties:           map[string]*Type{},
		AdditionalProperties: []byte("false"),
	}
	if r.AllowAdditionalProperties {
		st.AdditionalProperties = []byte("true")
	}
	definitions[t.Name()] = st
	r.reflectStructFields(st, definitions, t)

	return &Type{
		Version: Version,
		Ref:     "#/definitions/" + t.Name(),
	}
}
281313
func (s *Section) ReflectFrom(v interface{}) error {
	typ := reflect.TypeOf(v)
	val := reflect.ValueOf(v)
	if typ.Kind() == reflect.Ptr {
		typ = typ.Elem()
		val = val.Elem()
	} else {
		return errors.New("cannot reflect from non-pointer struct")
	}

	return s.reflectFrom(val)
}
566646
func configValueFromCLI(synthFilename, rawValue string, wantType cty.Type) (cty.Value, tfdiags.Diagnostics) {
	var diags tfdiags.Diagnostics

	switch {
	case wantType.IsPrimitiveType():
		// Primitive types are handled as conversions from string.
		val := cty.StringVal(rawValue)
		var err error
		val, err = convert.Convert(val, wantType)
		if err != nil {
			diags = diags.Append(tfdiags.Sourceless(
				tfdiags.Error,
				"Invalid backend configuration value",
				fmt.Sprintf("Invalid backend configuration argument %s: %s", synthFilename, err),
			))
			val = cty.DynamicVal // just so we return something valid-ish
		}
		return val, diags
	default:
		// Non-primitives are parsed as HCL expressions
		src := []byte(rawValue)
		expr, hclDiags := hclsyntax.ParseExpression(src, synthFilename, hcl.Pos{Line: 1, Column: 1})
		diags = diags.Append(hclDiags)
		if hclDiags.HasErrors() {
			return cty.DynamicVal, diags
		}
		val, hclDiags := expr.Value(nil)
		diags = diags.Append(hclDiags)
		if hclDiags.HasErrors() {
			val = cty.DynamicVal
		}
		return val, diags
	}
}
726811
func buildConstantStruct(c ConstantMap) (*ConstantStruct, error) {
	fields := make(map[string]ConstantValue, len(c))
	for _, pair := range c {
		s, isString := pair.Key.(ConstantString)
		if !isString {
			return nil, fmt.Errorf(
				"%v is not a string: all keys must be strings", pair.Key)
		}
		fields[string(s)] = pair.Value
	}
	return &ConstantStruct{Fields: fields}, nil
}
757843
func stringifyValue(w io.Writer, val reflect.Value) {
	if val.Kind() == reflect.Ptr && val.IsNil() {
		w.Write([]byte("<nil>"))
		return
	}
	v := reflect.Indirect(val)
	switch v.Kind() {
	case reflect.String:
		fmt.Fprintf(w, `"%s"`, v)
	case reflect.Slice:
		w.Write([]byte{'['})
		for i := 0; i < v.Len(); i++ {
			if i > 0 {
				w.Write([]byte{' '})
			}
			stringifyValue(w, v.Index(i))
		}
		w.Write([]byte{']'})
		return
	case reflect.Struct:
		if v.Type().Name() != "" {
			w.Write([]byte(v.Type().String()))
		}
		w.Write([]byte{'{'})
		var sep bool
		for i := 0; i < v.NumField(); i++ {
			fv := v.Field(i)
			if fv.Kind() == reflect.Ptr && fv.IsNil() {
				continue
			}
			if fv.Kind() == reflect.Slice && fv.IsNil() {
				continue
			}
			if sep {
				w.Write([]byte(", "))
			} else {
				sep = true
			}
			w.Write([]byte(v.Type().Field(i).Name))
			w.Write([]byte{':'})
			stringifyValue(w, fv)
		}
		w.Write([]byte{'}'})
	default:
		if v.CanInterface() {
			fmt.Fprint(w, v.Interface())
		}
	}
}
1082778
func ReflectValue(valueType string, value interface{}) (reflect.Value, error) {
	if strings.HasPrefix(valueType, "[]") {
		return reflectValues(valueType, value)
	}

	return reflectValue(valueType, value)
}
1249413
func reflectSliceWithProperType(key *Key, field reflect.Value, delim string) error {
	slice := field.Slice(0, field.Len())
	if field.Len() == 0 {
		return nil
	}

	var buf bytes.Buffer
	sliceOf := field.Type().Elem().Kind()
	for i := 0; i < field.Len(); i++ {
		switch sliceOf {
		case reflect.String:
			buf.WriteString(slice.Index(i).String())
		case reflect.Int, reflect.Int64:
			buf.WriteString(fmt.Sprint(slice.Index(i).Int()))
		case reflect.Uint, reflect.Uint64:
			buf.WriteString(fmt.Sprint(slice.Index(i).Uint()))
		case reflect.Float64:
			buf.WriteString(fmt.Sprint(slice.Index(i).Float()))
		case reflectTime:
			buf.WriteString(slice.Index(i).Interface().(time.Time).Format(time.RFC3339))
		default:
			return fmt.Errorf("unsupported type '[]%s'", sliceOf)
		}
		buf.WriteString(delim)
	}
	key.SetValue(buf.String()[:buf.Len()-1])
	return nil
}
1130565
func tryConcreteValue(v interface{}) Value {
	switch val := v.(type) {
	case Value:
		return val
	case int:
		return IntegerValue(val)
	case int64:
		return LongValue(val)
	case string:
		return StringValue(val)
	case []interface{}:
		return ListValue(val)
	case map[string]interface{}:
		return JsonValue(val)
	case map[interface{}]interface{}:
		return NewMapValue(val)
	case nil:
		return nullValue
	case []Value:
		return NewValueArray(val)
	case []byte:
		return BytesValue(val)
	case int8:
		return IntegerValue(int(val))
	case int16:
		return IntegerValue(int(val))
	case int32:
		return IntegerValue(int(val))
	case uint8: // byte supported here
		return IntegerValue(int(val))
	case uint16:
		return IntegerValue(int(val))
	case uint32:
		return IntegerValue(int(val))
	case float32:
		return FloatValue(float64(val))
	case float64:
		return FloatValue(val)
	case uint:
		// if it doesn't overflow int64, it is OK
		if int64(val) >= 0 {
			return LongValue(int64(val))
		}
	case MapIter:
		return NewMapperValue(val)
	case ListIter:
		return NewListerValue(val)
	case AerospikeBlob:
		return NewBlobValue(val)

	/*
		The following cases will try to avoid using reflection by matching against the
		internal generic types.
		If you have custom type aliases in your code, you can use the same aerospike types to cast your type into,
		to avoid hitting the generics.
	*/
	case []string:
		return NewListerValue(stringSlice(val))
	case []int:
		return NewListerValue(intSlice(val))
	case []int8:
		return NewListerValue(int8Slice(val))
	case []int16:
		return NewListerValue(int16Slice(val))
	case []int32:
		return NewListerValue(int32Slice(val))
	case []int64:
		return NewListerValue(int64Slice(val))
	case []uint16:
		return NewListerValue(uint16Slice(val))
	case []uint32:
		return NewListerValue(uint32Slice(val))
	case []uint64:
		return NewListerValue(uint64Slice(val))
	case []float32:
		return NewListerValue(float32Slice(val))
	case []float64:
		return NewListerValue(float64Slice(val))
	case map[string]string:
		return NewMapperValue(stringStringMap(val))
	case map[string]int:
		return NewMapperValue(stringIntMap(val))
	case map[string]int8:
		return NewMapperValue(stringInt8Map(val))
	case map[string]int16:
		return NewMapperValue(stringInt16Map(val))
	case map[string]int32:
		return NewMapperValue(stringInt32Map(val))
	case map[string]int64:
		return NewMapperValue(stringInt64Map(val))
	case map[string]uint16:
		return NewMapperValue(stringUint16Map(val))
	case map[string]uint32:
		return NewMapperValue(stringUint32Map(val))
	case map[string]float32:
		return NewMapperValue(stringFloat32Map(val))
	case map[string]float64:
		return NewMapperValue(stringFloat64Map(val))
	case map[int]string:
		return NewMapperValue(intStringMap(val))
	case map[int]int:
		return NewMapperValue(intIntMap(val))
	case map[int]int8:
		return NewMapperValue(intInt8Map(val))
	case map[int]int16:
		return NewMapperValue(intInt16Map(val))
	case map[int]int32:
		return NewMapperValue(intInt32Map(val))
	case map[int]int64:
		return NewMapperValue(intInt64Map(val))
	case map[int]uint16:
		return NewMapperValue(intUint16Map(val))
	case map[int]uint32:
		return NewMapperValue(intUint32Map(val))
	case map[int]float32:
		return NewMapperValue(intFloat32Map(val))
	case map[int]float64:
		return NewMapperValue(intFloat64Map(val))
	case map[int]interface{}:
		return NewMapperValue(intInterfaceMap(val))
	case map[int8]string:
		return NewMapperValue(int8StringMap(val))
	case map[int8]int:
		return NewMapperValue(int8IntMap(val))
	case map[int8]int8:
		return NewMapperValue(int8Int8Map(val))
	case map[int8]int16:
		return NewMapperValue(int8Int16Map(val))
	case map[int8]int32:
		return NewMapperValue(int8Int32Map(val))
	case map[int8]int64:
		return NewMapperValue(int8Int64Map(val))
	case map[int8]uint16:
		return NewMapperValue(int8Uint16Map(val))
	case map[int8]uint32:
		return NewMapperValue(int8Uint32Map(val))
	case map[int8]float32:
		return NewMapperValue(int8Float32Map(val))
	case map[int8]float64:
		return NewMapperValue(int8Float64Map(val))
	case map[int8]interface{}:
		return NewMapperValue(int8InterfaceMap(val))
	case map[int16]string:
		return NewMapperValue(int16StringMap(val))
	case map[int16]int:
		return NewMapperValue(int16IntMap(val))
	case map[int16]int8:
		return NewMapperValue(int16Int8Map(val))
	case map[int16]int16:
		return NewMapperValue(int16Int16Map(val))
	case map[int16]int32:
		return NewMapperValue(int16Int32Map(val))
	case map[int16]int64:
		return NewMapperValue(int16Int64Map(val))
	case map[int16]uint16:
		return NewMapperValue(int16Uint16Map(val))
	case map[int16]uint32:
		return NewMapperValue(int16Uint32Map(val))
	case map[int16]float32:
		return NewMapperValue(int16Float32Map(val))
	case map[int16]float64:
		return NewMapperValue(int16Float64Map(val))
	case map[int16]interface{}:
		return NewMapperValue(int16InterfaceMap(val))
	case map[int32]string:
		return NewMapperValue(int32StringMap(val))
	case map[int32]int:
		return NewMapperValue(int32IntMap(val))
	case map[int32]int8:
		return NewMapperValue(int32Int8Map(val))
	case map[int32]int16:
		return NewMapperValue(int32Int16Map(val))
	case map[int32]int32:
		return NewMapperValue(int32Int32Map(val))
	case map[int32]int64:
		return NewMapperValue(int32Int64Map(val))
	case map[int32]uint16:
		return NewMapperValue(int32Uint16Map(val))
	case map[int32]uint32:
		return NewMapperValue(int32Uint32Map(val))
	case map[int32]float32:
		return NewMapperValue(int32Float32Map(val))
	case map[int32]float64:
		return NewMapperValue(int32Float64Map(val))
	case map[int32]interface{}:
		return NewMapperValue(int32InterfaceMap(val))
	case map[int64]string:
		return NewMapperValue(int64StringMap(val))
	case map[int64]int:
		return NewMapperValue(int64IntMap(val))
	case map[int64]int8:
		return NewMapperValue(int64Int8Map(val))
	case map[int64]int16:
		return NewMapperValue(int64Int16Map(val))
	case map[int64]int32:
		return NewMapperValue(int64Int32Map(val))
	case map[int64]int64:
		return NewMapperValue(int64Int64Map(val))
	case map[int64]uint16:
		return NewMapperValue(int64Uint16Map(val))
	case map[int64]uint32:
		return NewMapperValue(int64Uint32Map(val))
	case map[int64]float32:
		return NewMapperValue(int64Float32Map(val))
	case map[int64]float64:
		return NewMapperValue(int64Float64Map(val))
	case map[int64]interface{}:
		return NewMapperValue(int64InterfaceMap(val))
	case map[uint16]string:
		return NewMapperValue(uint16StringMap(val))
	case map[uint16]int:
		return NewMapperValue(uint16IntMap(val))
	case map[uint16]int8:
		return NewMapperValue(uint16Int8Map(val))
	case map[uint16]int16:
		return NewMapperValue(uint16Int16Map(val))
	case map[uint16]int32:
		return NewMapperValue(uint16Int32Map(val))
	case map[uint16]int64:
		return NewMapperValue(uint16Int64Map(val))
	case map[uint16]uint16:
		return NewMapperValue(uint16Uint16Map(val))
	case map[uint16]uint32:
		return NewMapperValue(uint16Uint32Map(val))
	case map[uint16]float32:
		return NewMapperValue(uint16Float32Map(val))
	case map[uint16]float64:
		return NewMapperValue(uint16Float64Map(val))
	case map[uint16]interface{}:
		return NewMapperValue(uint16InterfaceMap(val))
	case map[uint32]string:
		return NewMapperValue(uint32StringMap(val))
	case map[uint32]int:
		return NewMapperValue(uint32IntMap(val))
	case map[uint32]int8:
		return NewMapperValue(uint32Int8Map(val))
	case map[uint32]int16:
		return NewMapperValue(uint32Int16Map(val))
	case map[uint32]int32:
		return NewMapperValue(uint32Int32Map(val))
	case map[uint32]int64:
		return NewMapperValue(uint32Int64Map(val))
	case map[uint32]uint16:
		return NewMapperValue(uint32Uint16Map(val))
	case map[uint32]uint32:
		return NewMapperValue(uint32Uint32Map(val))
	case map[uint32]float32:
		return NewMapperValue(uint32Float32Map(val))
	case map[uint32]float64:
		return NewMapperValue(uint32Float64Map(val))
	case map[uint32]interface{}:
		return NewMapperValue(uint32InterfaceMap(val))
	case map[float32]string:
		return NewMapperValue(float32StringMap(val))
	case map[float32]int:
		return NewMapperValue(float32IntMap(val))
	case map[float32]int8:
		return NewMapperValue(float32Int8Map(val))
	case map[float32]int16:
		return NewMapperValue(float32Int16Map(val))
	case map[float32]int32:
		return NewMapperValue(float32Int32Map(val))
	case map[float32]int64:
		return NewMapperValue(float32Int64Map(val))
	case map[float32]uint16:
		return NewMapperValue(float32Uint16Map(val))
	case map[float32]uint32:
		return NewMapperValue(float32Uint32Map(val))
	case map[float32]float32:
		return NewMapperValue(float32Float32Map(val))
	case map[float32]float64:
		return NewMapperValue(float32Float64Map(val))
	case map[float32]interface{}:
		return NewMapperValue(float32InterfaceMap(val))
	case map[float64]string:
		return NewMapperValue(float64StringMap(val))
	case map[float64]int:
		return NewMapperValue(float64IntMap(val))
	case map[float64]int8:
		return NewMapperValue(float64Int8Map(val))
	case map[float64]int16:
		return NewMapperValue(float64Int16Map(val))
	case map[float64]int32:
		return NewMapperValue(float64Int32Map(val))
	case map[float64]int64:
		return NewMapperValue(float64Int64Map(val))
	case map[float64]uint16:
		return NewMapperValue(float64Uint16Map(val))
	case map[float64]uint32:
		return NewMapperValue(float64Uint32Map(val))
	case map[float64]float32:
		return NewMapperValue(float64Float32Map(val))
	case map[float64]float64:
		return NewMapperValue(float64Float64Map(val))
	case map[float64]interface{}:
		return NewMapperValue(float64InterfaceMap(val))
	case map[string]uint64:
		return NewMapperValue(stringUint64Map(val))
	case map[int]uint64:
		return NewMapperValue(intUint64Map(val))
	case map[int8]uint64:
		return NewMapperValue(int8Uint64Map(val))
	case map[int16]uint64:
		return NewMapperValue(int16Uint64Map(val))
	case map[int32]uint64:
		return NewMapperValue(int32Uint64Map(val))
	case map[int64]uint64:
		return NewMapperValue(int64Uint64Map(val))
	case map[uint16]uint64:
		return NewMapperValue(uint16Uint64Map(val))
	case map[uint32]uint64:
		return NewMapperValue(uint32Uint64Map(val))
	case map[float32]uint64:
		return NewMapperValue(float32Uint64Map(val))
	case map[float64]uint64:
		return NewMapperValue(float64Uint64Map(val))
	case map[uint64]string:
		return NewMapperValue(uint64StringMap(val))
	case map[uint64]int:
		return NewMapperValue(uint64IntMap(val))
	case map[uint64]int8:
		return NewMapperValue(uint64Int8Map(val))
	case map[uint64]int16:
		return NewMapperValue(uint64Int16Map(val))
	case map[uint64]int32:
		return NewMapperValue(uint64Int32Map(val))
	case map[uint64]int64:
		return NewMapperValue(uint64Int64Map(val))
	case map[uint64]uint16:
		return NewMapperValue(uint64Uint16Map(val))
	case map[uint64]uint32:
		return NewMapperValue(uint64Uint32Map(val))
	case map[uint64]uint64:
		return NewMapperValue(uint64Uint64Map(val))
	case map[uint64]float32:
		return NewMapperValue(uint64Float32Map(val))
	case map[uint64]float64:
		return NewMapperValue(uint64Float64Map(val))
	case map[uint64]interface{}:
		return NewMapperValue(uint64InterfaceMap(val))
	}

	return nil
}
997983
func reflectValues(valueType string, value interface{}) (reflect.Value, error) {
	theType, ok := typesMap[valueType]
	if !ok {
		return reflect.Value{}, NewErrUnsupportedType(valueType)
	}

	// For NULL we return an empty slice
	if value == nil {
		return reflect.MakeSlice(theType, 0, 0), nil
	}

	var theValue reflect.Value

	// Booleans
	if theType.String() == "[]bool" {
		bools := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, bools.Len(), bools.Len())
		for i := 0; i < bools.Len(); i++ {
			boolValue, err := getBoolValue(strings.Split(theType.String(), "[]")[1], bools.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetBool(boolValue)
		}

		return theValue, nil
	}

	// Integers
	if strings.HasPrefix(theType.String(), "[]int") {
		ints := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, ints.Len(), ints.Len())
		for i := 0; i < ints.Len(); i++ {
			intValue, err := getIntValue(strings.Split(theType.String(), "[]")[1], ints.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetInt(intValue)
		}

		return theValue, nil
	}

	// Unsigned integers
	if strings.HasPrefix(theType.String(), "[]uint") {
		uints := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, uints.Len(), uints.Len())
		for i := 0; i < uints.Len(); i++ {
			uintValue, err := getUintValue(strings.Split(theType.String(), "[]")[1], uints.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetUint(uintValue)
		}

		return theValue, nil
	}

	// Floating point numbers
	if strings.HasPrefix(theType.String(), "[]float") {
		floats := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, floats.Len(), floats.Len())
		for i := 0; i < floats.Len(); i++ {
			floatValue, err := getFloatValue(strings.Split(theType.String(), "[]")[1], floats.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetFloat(floatValue)
		}

		return theValue, nil
	}

	// Strings
	if theType.String() == "[]string" {
		strs := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, strs.Len(), strs.Len())
		for i := 0; i < strs.Len(); i++ {
			strValue, err := getStringValue(strings.Split(theType.String(), "[]")[1], strs.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetString(strValue)
		}

		return theValue, nil
	}

	return reflect.Value{}, NewErrUnsupportedType(valueType)
}
689828
func (c *Config) GetValue(section, name string) string {
	c.ReadList()
	conf := c.ReadList()
	for _, v := range conf {
		for key, value := range v {
			if key == section {
				return value[name]
			}
		}
	}
	return "no value"
}
677198
func BuildBindVariables(in map[string]interface{}) (map[string]*querypb.BindVariable, error) {
	if len(in) == 0 {
		return nil, nil
	}

	out := make(map[string]*querypb.BindVariable, len(in))
	for k, v := range in {
		bv, err := BuildBindVariable(v)
		if err != nil {
			return nil, fmt.Errorf("%s: %v", k, err)
		}
		out[k] = bv
	}
	return out, nil
}
531036
func compileConstantValue(v ast.ConstantValue) ConstantValue {
	if v == nil {
		return nil
	}

	// TODO(abg): Support typedefs

	switch src := v.(type) {
	case ast.ConstantReference:
		return constantReference(src)
	case ast.ConstantMap:
		return compileConstantMap(src)
	case ast.ConstantList:
		return compileConstantList(src)
	case ast.ConstantBoolean:
		return ConstantBool(src)
	case ast.ConstantInteger:
		return ConstantInt(src)
	case ast.ConstantString:
		return ConstantString(src)
	case ast.ConstantDouble:
		return ConstantDouble(src)
	default:
		panic(fmt.Sprintf("unknown constant value of type %T: %v", src, src))
	}
}
1013726
func UpdateConfig(old, new *Config) {
	// Using reflection here is not necessary, but it's a good exercise.
	// For more information on reflections in Go, read "The Laws of Reflection"
	// http://golang.org/doc/articles/laws_of_reflection.html
	newVal := reflect.ValueOf(new).Elem()
	oldVal := reflect.ValueOf(old).Elem()

	// typeOfT := newVal.Type()
	for i := 0; i < newVal.NumField(); i++ {
		newField := newVal.Field(i)
		oldField := oldVal.Field(i)
		// log.Printf("%d: %s %s = %v\n", i,
		// typeOfT.Field(i).Name, newField.Type(), newField.Interface())
		switch newField.Kind() {
		case reflect.Interface:
			if fmt.Sprintf("%v", newField.Interface()) != "" {
				oldField.Set(newField)
			}
		case reflect.String:
			s := newField.String()
			if s != "" {
				oldField.SetString(s)
			}
		case reflect.Int:
			i := newField.Int()
			if i != 0 {
				oldField.SetInt(i)
			}
		}
	}

	old.Timeout = new.Timeout
	readTimeout = time.Duration(old.Timeout) * time.Second
}
821370
func BlockDataHashingStructureValue() *StandardConfigValue {
	return &StandardConfigValue{
		key: BlockDataHashingStructureKey,
		value: &cb.BlockDataHashingStructure{
			Width: defaultBlockDataHashingStructureWidth,
		},
	}
}
398522
func ConstantValue(g Generator, c compile.ConstantValue, t compile.TypeSpec) (string, error) {
	switch v := c.(type) {
	case compile.ConstantBool:
		return constantBool(g, v, t)
	case compile.ConstantDouble:
		return constantDouble(g, v, t)
	case compile.ConstantInt:
		return constantInt(g, v, t)
	case compile.ConstantList:
		return constantList(g, v, t)
	case compile.ConstantMap:
		return constantMap(g, v, t)
	case compile.ConstantSet:
		return constantSet(g, v, t)
	case compile.ConstantString:
		return strconv.Quote(string(v)), nil
	case *compile.ConstantStruct:
		return constantStruct(g, v, t)
	case compile.EnumItemReference:
		return enumItemReference(g, v, t)
	case compile.ConstReference:
		if canBeConstant(v.Target.Type) {
			return g.LookupConstantName(v.Target)
		}
		return ConstantValue(g, v.Target.Value, v.Target.Type)
	default:
		panic(fmt.Sprintf("Unknown constant value %v (%T)", c, c))
	}
}