Skip to content

Commit db1510d

Browse files
committed
move Cache to be argument instead of field
1 parent eafdb3c commit db1510d

9 files changed

Lines changed: 226 additions & 294 deletions

File tree

checker/checker.go

Lines changed: 144 additions & 145 deletions
Large diffs are not rendered by default.

checker/info.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ import (
1111
func FieldIndex(c *Cache, env Nature, node ast.Node) (bool, []int, string) {
1212
switch n := node.(type) {
1313
case *ast.IdentifierNode:
14-
if idx, ok := env.FieldIndex(n.Value); ok {
14+
if idx, ok := env.FieldIndex(c, n.Value); ok {
1515
return true, idx, n.Value
1616
}
1717
case *ast.MemberNode:
1818
base := n.Node.Nature()
19-
base.Bind(c) // AST doesn't cache nature info
20-
base = base.Deref()
19+
base = base.Deref(c)
2120
if base.Kind == reflect.Struct {
2221
if prop, ok := n.Property.(*ast.StringNode); ok {
23-
if idx, ok := base.FieldIndex(prop.Value); ok {
22+
if idx, ok := base.FieldIndex(c, prop.Value); ok {
2423
return true, idx, prop.Value
2524
}
2625
}
@@ -33,7 +32,7 @@ func MethodIndex(c *Cache, env Nature, node ast.Node) (bool, int, string) {
3332
switch n := node.(type) {
3433
case *ast.IdentifierNode:
3534
if env.Kind == reflect.Struct {
36-
if m, ok := env.Get(n.Value); ok && m.FuncData != nil {
35+
if m, ok := env.Get(c, n.Value); ok && m.FuncData != nil {
3736
return m.Method, m.MethodIndex, n.Value
3837
}
3938
}

0 commit comments

Comments
 (0)