Skip to content

Commit 163df86

Browse files
committed
simplify and remove dead code
1 parent 3d7e30e commit 163df86

File tree

4 files changed

+4
-29
lines changed

4 files changed

+4
-29
lines changed

checker/nature/nature.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ type Cache struct {
8888
structs map[reflect.Type]Nature
8989
}
9090

91-
type rTypeWithKey struct {
92-
t reflect.Type
93-
key string
94-
}
95-
9691
// NatureOf returns a Nature describing "i". If "i" is nil then it returns a
9792
// Nature describing the value "nil".
9893
func (c *Cache) NatureOf(i any) Nature {

checker/nature/utils.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package nature
22

33
import (
4-
"fmt"
54
"reflect"
65
)
76

@@ -46,23 +45,6 @@ func (s *structData) finished() bool {
4645
s.curChild == nil // no child in process of visiting
4746
}
4847

49-
func (s *structData) structDebug(prefix string) { // TODO: DEBUG
50-
if len(s.fields) == 0 {
51-
fmt.Printf("%s[%s]\n", prefix, s.rType)
52-
return
53-
}
54-
fmt.Printf("%s[%s] fields:\n", prefix, s.rType)
55-
prefix += " "
56-
for k, v := range s.fields {
57-
fmt.Printf("%s%s at index %v:", prefix, k, v.Index)
58-
if v.Nature.Kind == reflect.Struct {
59-
v.Nature.structDebug(prefix)
60-
} else {
61-
fmt.Printf("%s[%s]\n", prefix, v.Nature.Type)
62-
}
63-
}
64-
}
65-
6648
func (s *structData) structField(parentEmbed *structData, name string) (structField, bool) {
6749
if s.fields == nil {
6850
if s.numField > 0 {

compiler/compiler.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/expr-lang/expr/ast"
1111
"github.com/expr-lang/expr/builtin"
1212
"github.com/expr-lang/expr/checker"
13-
"github.com/expr-lang/expr/checker/nature"
1413
. "github.com/expr-lang/expr/checker/nature"
1514
"github.com/expr-lang/expr/conf"
1615
"github.com/expr-lang/expr/file"
@@ -41,7 +40,7 @@ func Compile(tree *parser.Tree, config *conf.Config) (program *Program, err erro
4140
if config != nil {
4241
c.ntCache = &c.config.NtCache
4342
} else {
44-
c.ntCache = new(nature.Cache)
43+
c.ntCache = new(Cache)
4544
}
4645

4746
c.compile(tree.Node)
@@ -82,7 +81,7 @@ func Compile(tree *parser.Tree, config *conf.Config) (program *Program, err erro
8281

8382
type compiler struct {
8483
config *conf.Config
85-
ntCache *nature.Cache
84+
ntCache *Cache
8685
locations []file.Location
8786
bytecode []Opcode
8887
variables int

parser/parser.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/expr-lang/expr/builtin"
1313
"github.com/expr-lang/expr/conf"
1414
"github.com/expr-lang/expr/file"
15-
"github.com/expr-lang/expr/parser/lexer"
1615
. "github.com/expr-lang/expr/parser/lexer"
1716
"github.com/expr-lang/expr/parser/operator"
1817
"github.com/expr-lang/expr/parser/utils"
@@ -49,7 +48,7 @@ var predicates = map[string]struct {
4948

5049
// Parser is a reusable parser. The zero value is ready for use.
5150
type Parser struct {
52-
lexer *lexer.Lexer
51+
lexer *Lexer
5352
current, stashed Token
5453
hasStash bool
5554
err *file.Error
@@ -60,7 +59,7 @@ type Parser struct {
6059

6160
func (p *Parser) Parse(input string, config *conf.Config) (*Tree, error) {
6261
if p.lexer == nil {
63-
p.lexer = lexer.New()
62+
p.lexer = New()
6463
}
6564
p.config = config
6665
source := file.NewSource(input)

0 commit comments

Comments
 (0)