mirror of
https://github.com/google/go-jsonnet.git
synced 2025-08-08 07:17:12 +02:00
Eliminate the unnecessary ast.StdAst
The initially empty ast.StdAst was created to break the circular dependency. The generation of stdlib AST used to depend on the primary "jsonnet" package, which meant that "jsonnet" could not depend on it directly. Hence stdlib needed to be put in the ast package. Now dumpstdlibast no longer depends on Jsonnet, so we can get rid of this complication. All code using ast.StdAst should now use astgen.StdAst.
This commit is contained in:
parent
e6c74ca7a6
commit
c77f22c99f
@ -1,8 +0,0 @@
|
|||||||
package ast
|
|
||||||
|
|
||||||
// StdAst is the AST for the standard library.
|
|
||||||
//
|
|
||||||
// Its inital value is the Jsonnet null value, such that the standard library is not available
|
|
||||||
// during evaluation. Set this variable to point at a non-null AST node to make that tree available
|
|
||||||
// as the standard library.
|
|
||||||
var StdAst Node = &LiteralNull{}
|
|
@ -11,9 +11,6 @@ import (
|
|||||||
"github.com/google/go-jsonnet/ast"
|
"github.com/google/go-jsonnet/ast"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
ast.StdAst = StdAst
|
|
||||||
}
|
|
||||||
var p3Var = "$"
|
var p3Var = "$"
|
||||||
var p3 = &p3Var
|
var p3 = &p3Var
|
||||||
var p8Var = "object <anonymous>"
|
var p8Var = "object <anonymous>"
|
||||||
|
@ -6,8 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/google/go-jsonnet"
|
"github.com/google/go-jsonnet"
|
||||||
"github.com/google/go-jsonnet/ast"
|
|
||||||
"github.com/google/go-jsonnet/astgen"
|
|
||||||
|
|
||||||
// #cgo CXXFLAGS: -std=c++11 -Wall -I../cpp-jsonnet/include
|
// #cgo CXXFLAGS: -std=c++11 -Wall -I../cpp-jsonnet/include
|
||||||
// #include "internal.h"
|
// #include "internal.h"
|
||||||
@ -159,5 +157,4 @@ func jsonnet_tla_code(vmRef *C.struct_JsonnetVm, key, value *C.char) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ast.StdAst = astgen.StdAst
|
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,4 @@ import (
|
|||||||
"github.com/google/go-jsonnet/ast"
|
"github.com/google/go-jsonnet/ast"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
ast.StdAst = StdAst
|
|
||||||
}
|
|
||||||
`[1:]
|
`[1:]
|
||||||
|
@ -32,8 +32,6 @@ import (
|
|||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
|
|
||||||
"github.com/google/go-jsonnet"
|
"github.com/google/go-jsonnet"
|
||||||
"github.com/google/go-jsonnet/ast"
|
|
||||||
"github.com/google/go-jsonnet/astgen"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func nextArg(i *int, args []string) string {
|
func nextArg(i *int, args []string) string {
|
||||||
@ -473,7 +471,6 @@ func writeOutputFile(output string, outputFile string, createDirs bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ast.StdAst = astgen.StdAst
|
|
||||||
// https://blog.golang.org/profiling-go-programs
|
// https://blog.golang.org/profiling-go-programs
|
||||||
var cpuprofile = os.Getenv("JSONNET_CPU_PROFILE")
|
var cpuprofile = os.Getenv("JSONNET_CPU_PROFILE")
|
||||||
if cpuprofile != "" {
|
if cpuprofile != "" {
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/google/go-jsonnet/ast"
|
"github.com/google/go-jsonnet/ast"
|
||||||
|
"github.com/google/go-jsonnet/astgen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO(sbarzowski) use it as a pointer in most places b/c it can sometimes be shared
|
// TODO(sbarzowski) use it as a pointer in most places b/c it can sometimes be shared
|
||||||
@ -1119,7 +1120,7 @@ func evaluateStd(i *interpreter) (value, error) {
|
|||||||
)
|
)
|
||||||
evalLoc := ast.MakeLocationRangeMessage("During evaluation of std")
|
evalLoc := ast.MakeLocationRangeMessage("During evaluation of std")
|
||||||
evalTrace := TraceElement{loc: &evalLoc}
|
evalTrace := TraceElement{loc: &evalLoc}
|
||||||
node := ast.StdAst
|
node := astgen.StdAst
|
||||||
return i.EvalInCleanEnv(evalTrace, &beforeStdEnv, node, false)
|
return i.EvalInCleanEnv(evalTrace, &beforeStdEnv, node, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,15 +4,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/google/go-jsonnet/ast"
|
|
||||||
"github.com/google/go-jsonnet/astgen"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
ast.StdAst = astgen.StdAst
|
|
||||||
}
|
|
||||||
|
|
||||||
type errorFormattingTest struct {
|
type errorFormattingTest struct {
|
||||||
name string
|
name string
|
||||||
input string
|
input string
|
||||||
|
Loading…
Reference in New Issue
Block a user