mirror of
https://github.com/hanzoai/expr.git
synced 2026-09-24 16:58:58 +00:00
make ast.Node return *nature.Nature (#849)
This commit is contained in:
committed by
GitHub
parent
93c6e39251
commit
6b6df6494c
+3
-3
@@ -15,7 +15,7 @@ var (
|
||||
type Node interface {
|
||||
Location() file.Location
|
||||
SetLocation(file.Location)
|
||||
Nature() nature.Nature
|
||||
Nature() *nature.Nature
|
||||
SetNature(nature.Nature)
|
||||
Type() reflect.Type
|
||||
SetType(reflect.Type)
|
||||
@@ -47,8 +47,8 @@ func (n *base) SetLocation(loc file.Location) {
|
||||
}
|
||||
|
||||
// Nature returns the nature of the node.
|
||||
func (n *base) Nature() nature.Nature {
|
||||
return n.nature
|
||||
func (n *base) Nature() *nature.Nature {
|
||||
return &n.nature
|
||||
}
|
||||
|
||||
// SetNature sets the nature of the node.
|
||||
|
||||
+1
-2
@@ -635,8 +635,7 @@ func (v *Checker) callNode(node *ast.CallNode) Nature {
|
||||
// checker pass we should replace anyType on method node
|
||||
// with new correct function return type.
|
||||
if typ := node.Type(); typ != nil && typ != anyType {
|
||||
nt := node.Nature()
|
||||
return nt
|
||||
return *node.Nature()
|
||||
}
|
||||
|
||||
nt := v.visit(node.Callee)
|
||||
|
||||
+1
-2
@@ -15,8 +15,7 @@ func FieldIndex(c *Cache, env Nature, node ast.Node) (bool, []int, string) {
|
||||
return true, idx, n.Value
|
||||
}
|
||||
case *ast.MemberNode:
|
||||
base := n.Node.Nature()
|
||||
base = base.Deref(c)
|
||||
base := n.Node.Nature().Deref(c)
|
||||
if base.Kind == reflect.Struct {
|
||||
if prop, ok := n.Property.(*ast.StringNode); ok {
|
||||
if idx, ok := base.FieldIndex(c, prop.Value); ok {
|
||||
|
||||
@@ -1088,8 +1088,7 @@ func (c *compiler) BuiltinNode(node *ast.BuiltinNode) {
|
||||
for i, arg := range node.Arguments {
|
||||
c.compile(arg)
|
||||
argType := arg.Type()
|
||||
argNature := arg.Nature()
|
||||
if argType.Kind() == reflect.Ptr || argNature.IsUnknown(c.ntCache) {
|
||||
if argType.Kind() == reflect.Ptr || arg.Nature().IsUnknown(c.ntCache) {
|
||||
if f.Deref == nil {
|
||||
// By default, builtins expect arguments to be dereferenced.
|
||||
c.emit(OpDeref)
|
||||
|
||||
Reference in New Issue
Block a user