aboutsummaryrefslogtreecommitdiff
path: root/starlarkstruct
diff options
context:
space:
mode:
authoralandonovan <adonovan@google.com>2019-06-04 09:08:55 -0400
committerGitHub <noreply@github.com>2019-06-04 09:08:55 -0400
commit6ddc71c0ba77217b518c586dc8589d627c92ebfb (patch)
treecd9983e4142841e9869107c8132782758afa405c /starlarkstruct
parent30ae18b8564f6cd89b550b19dbdae92e0ec5b0a3 (diff)
downloadstarlark-go-6ddc71c0ba77217b518c586dc8589d627c92ebfb.tar.gz
resolve: move resolver types to resolver package (#211)
The job of the resolver is to compute a binding for each identifer, the local and free variables for each function, and the locals and globals for each module. As a space optimization and for convenience, this information is saved in the syntax tree rather than in a side table. We have a choice between declaring these resolver data structures in the syntax package or the resolve package. Putting them in the syntax package, as we did prior to this change, allowed each Identifier, File, DefStmt, and LambdaExpr to depend directly on the resolver types, even though those types didn't really belong there. This change moves these types to the resolver package where they belong. The dependencies on the types are broken by using an interface{} in each case. (The values are are all pointers, so this does not induce new allocation.) Also, this change eliminates syntax.Function, which was a false abstraction of DefStmt and LambdaExpr. The two syntax nodes are now fully concrete; it is in the resolver that their shared concept of Function belongs. This is a breaking API change, but it should affect very few clients and be trivial to fix.
Diffstat (limited to 'starlarkstruct')
-rw-r--r--starlarkstruct/struct_test.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/starlarkstruct/struct_test.go b/starlarkstruct/struct_test.go
index 81936a9..8e6a93d 100644
--- a/starlarkstruct/struct_test.go
+++ b/starlarkstruct/struct_test.go
@@ -9,8 +9,8 @@ import (
"path/filepath"
"testing"
- "go.starlark.net/starlark"
"go.starlark.net/resolve"
+ "go.starlark.net/starlark"
"go.starlark.net/starlarkstruct"
"go.starlark.net/starlarktest"
)
@@ -67,7 +67,7 @@ func (sym *symbol) Name() string { return sym.name }
func (sym *symbol) String() string { return sym.name }
func (sym *symbol) Type() string { return "symbol" }
func (sym *symbol) Freeze() {} // immutable
-func (sym *symbol) Truth() starlark.Bool { return starlark.True }
+func (sym *symbol) Truth() starlark.Bool { return starlark.True }
func (sym *symbol) Hash() (uint32, error) { return 0, fmt.Errorf("unhashable: %s", sym.Type()) }
func (sym *symbol) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {