Files
opencloud/vendor/github.com/open-policy-agent/opa/v1/ast/strings.go
dependabot[bot] 42987b038b build(deps): bump github.com/open-policy-agent/opa from 1.15.2 to 1.17.1
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 1.15.2 to 1.17.1.
- [Release notes](https://github.com/open-policy-agent/opa/releases)
- [Changelog](https://github.com/open-policy-agent/opa/blob/v1.17.1/CHANGELOG.md)
- [Commits](https://github.com/open-policy-agent/opa/compare/v1.15.2...v1.17.1)

---
updated-dependencies:
- dependency-name: github.com/open-policy-agent/opa
  dependency-version: 1.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-16 08:40:16 +00:00

59 lines
1.2 KiB
Go

// Copyright 2016 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.
package ast
import (
"reflect"
"strings"
)
// TypeName returns a human readable name for the AST element type.
func TypeName(x any) string {
if _, ok := x.(*lazyObj); ok {
return "object"
}
return strings.ToLower(reflect.Indirect(reflect.ValueOf(x)).Type().Name())
}
// ValueName returns a human readable name for the AST Value type.
// This is preferrable over calling TypeName when the argument is known to be
// a Value, as this doesn't require reflection (= heap allocations).
func ValueName(x Value) string {
switch x.(type) {
case String:
return "string"
case Boolean:
return "boolean"
case Number:
return "number"
case Null:
return "null"
case Var:
return "var"
case Object:
return "object"
case Set:
return "set"
case Ref:
return "ref"
case Call:
return "call"
case *Array:
return "array"
case *ArrayComprehension:
return "arraycomprehension"
case *ObjectComprehension:
return "objectcomprehension"
case *SetComprehension:
return "setcomprehension"
case *TemplateString:
return "templatestring"
case *Not:
return "not"
}
return TypeName(x)
}