aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2018-10-23 11:05:09 -0400
committerAlan Donovan <adonovan@google.com>2018-10-23 11:05:09 -0400
commite3deafefac22db7bfd4877d37614fe5db4b03881 (patch)
treee3de93e8b63abffb95767055fb392714cc8cc8a1 /internal
parentce5c2fa1ad6a8fa4beb4eacdbd3bf9997162d144 (diff)
downloadstarlark-go-e3deafefac22db7bfd4877d37614fe5db4b03881.tar.gz
rename skylark -> starlark
Change-Id: Iebd0e040ff674b2f9da39bf5242c8afaa7f4ddc8
Diffstat (limited to 'internal')
-rw-r--r--internal/compile/codegen_test.go6
-rw-r--r--internal/compile/compile.go20
-rw-r--r--internal/compile/compile_test.go28
-rw-r--r--internal/compile/serial.go6
4 files changed, 30 insertions, 30 deletions
diff --git a/internal/compile/codegen_test.go b/internal/compile/codegen_test.go
index 6539946..359d3bb 100644
--- a/internal/compile/codegen_test.go
+++ b/internal/compile/codegen_test.go
@@ -5,8 +5,8 @@ import (
"fmt"
"testing"
- "github.com/google/skylark/resolve"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/resolve"
+ "github.com/google/starlark/syntax"
)
// TestPlusFolding ensures that the compiler generates optimized code for
@@ -54,7 +54,7 @@ func TestPlusFolding(t *testing.T) {
`return`,
},
} {
- expr, err := syntax.ParseExpr("in.sky", test.src, 0)
+ expr, err := syntax.ParseExpr("in.star", test.src, 0)
if err != nil {
t.Errorf("#%d: %v", i, err)
continue
diff --git a/internal/compile/compile.go b/internal/compile/compile.go
index 6b69fd5..32c2307 100644
--- a/internal/compile/compile.go
+++ b/internal/compile/compile.go
@@ -1,5 +1,5 @@
-// The compile package defines the Skylark bytecode compiler.
-// It is an internal package of the Skylark interpreter and is not directly accessible to clients.
+// The compile package defines the Starlark bytecode compiler.
+// It is an internal package of the Starlark interpreter and is not directly accessible to clients.
//
// The compiler generates byte code with optional uint32 operands for a
// virtual machine with the following components:
@@ -30,8 +30,8 @@ import (
"path/filepath"
"strconv"
- "github.com/google/skylark/resolve"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/resolve"
+ "github.com/google/starlark/syntax"
)
const debug = false // TODO(adonovan): use a bitmap of options; and regexp to match files
@@ -276,7 +276,7 @@ func (op Opcode) String() string {
return fmt.Sprintf("illegal op (%d)", op)
}
-// A Program is a Skylark file in executable form.
+// A Program is a Starlark file in executable form.
//
// Programs are serialized by the gobProgram function,
// which must be updated whenever this declaration is changed.
@@ -289,7 +289,7 @@ type Program struct {
Toplevel *Funcode // module initialization function
}
-// A Funcode is the code of a compiled Skylark function.
+// A Funcode is the code of a compiled Starlark function.
//
// Funcodes are serialized by the gobFunc function,
// which must be updated whenever this declaration is changed.
@@ -804,7 +804,7 @@ func (fcomp *fcomp) emit1(op Opcode, arg uint32) {
// On return, the current block is unset.
func (fcomp *fcomp) jump(b *block) {
if b == fcomp.block {
- panic("self-jump") // unreachable: Skylark has no arbitrary looping constructs
+ panic("self-jump") // unreachable: Starlark has no arbitrary looping constructs
}
fcomp.block.jmp = b
fcomp.block = nil
@@ -1530,16 +1530,16 @@ func (fcomp *fcomp) args(call *syntax.CallExpr) (op Opcode, arg uint32) {
p++
}
- // Python2, Python3, and Skylark-in-Java all permit named arguments
+ // Python2, Python3, and Starlark-in-Java all permit named arguments
// to appear both before and after a *args argument:
// f(1, 2, x=3, *[4], y=5, **dict(z=6))
//
// However all three implement different argument evaluation orders:
// Python2: 1 2 3 5 4 6 (*args and **kwargs evaluated last)
// Python3: 1 2 4 3 5 6 (positional args evaluated before named args)
- // Skylark-in-Java: 1 2 3 4 5 6 (lexical order)
+ // Starlark-in-Java: 1 2 3 4 5 6 (lexical order)
//
- // The Skylark-in-Java semantics are clean but hostile to a
+ // The Starlark-in-Java semantics are clean but hostile to a
// compiler-based implementation because they require that the
// compiler emit code for positional, named, *args, more named,
// and *kwargs arguments and provide the callee with a map of
diff --git a/internal/compile/compile_test.go b/internal/compile/compile_test.go
index a545817..dea51c8 100644
--- a/internal/compile/compile_test.go
+++ b/internal/compile/compile_test.go
@@ -5,15 +5,15 @@ import (
"strings"
"testing"
- "github.com/google/skylark"
+ "github.com/google/starlark"
)
// TestSerialization verifies that a serialized program can be loaded,
// deserialized, and executed.
func TestSerialization(t *testing.T) {
- predeclared := skylark.StringDict{
- "x": skylark.String("mur"),
- "n": skylark.MakeInt(2),
+ predeclared := starlark.StringDict{
+ "x": starlark.String("mur"),
+ "n": starlark.MakeInt(2),
}
const src = `
def mul(a, b):
@@ -21,7 +21,7 @@ def mul(a, b):
y = mul(x, n)
`
- _, oldProg, err := skylark.SourceProgram("mul.sky", src, predeclared.Has)
+ _, oldProg, err := starlark.SourceProgram("mul.star", src, predeclared.Has)
if err != nil {
t.Fatal(err)
}
@@ -31,31 +31,31 @@ y = mul(x, n)
t.Fatalf("oldProg.WriteTo: %v", err)
}
- newProg, err := skylark.CompiledProgram(buf)
+ newProg, err := starlark.CompiledProgram(buf)
if err != nil {
t.Fatalf("CompiledProgram: %v", err)
}
- thread := new(skylark.Thread)
+ thread := new(starlark.Thread)
globals, err := newProg.Init(thread, predeclared)
if err != nil {
t.Fatalf("newProg.Init: %v", err)
}
- if got, want := globals["y"], skylark.String("murmur"); got != want {
+ if got, want := globals["y"], starlark.String("murmur"); got != want {
t.Errorf("Value of global was %s, want %s", got, want)
t.Logf("globals: %v", globals)
}
// Verify stack frame.
- predeclared["n"] = skylark.None
+ predeclared["n"] = starlark.None
_, err = newProg.Init(thread, predeclared)
- evalErr, ok := err.(*skylark.EvalError)
+ evalErr, ok := err.(*starlark.EvalError)
if !ok {
t.Fatalf("newProg.Init call returned err %v, want *EvalError", err)
}
const want = `Traceback (most recent call last):
- mul.sky:5: in <toplevel>
- mul.sky:3: in mul
+ mul.star:5: in <toplevel>
+ mul.star:3: in mul
Error: unknown binary op: string * NoneType`
if got := evalErr.Backtrace(); got != want {
t.Fatalf("got <<%s>>, want <<%s>>", got, want)
@@ -63,8 +63,8 @@ Error: unknown binary op: string * NoneType`
}
func TestGarbage(t *testing.T) {
- const garbage = "This is not a compiled Skylark program."
- _, err := skylark.CompiledProgram(strings.NewReader(garbage))
+ const garbage = "This is not a compiled Starlark program."
+ _, err := starlark.CompiledProgram(strings.NewReader(garbage))
if err == nil {
t.Fatalf("CompiledProgram did not report an error when decoding garbage")
}
diff --git a/internal/compile/serial.go b/internal/compile/serial.go
index 706456f..4d2e01e 100644
--- a/internal/compile/serial.go
+++ b/internal/compile/serial.go
@@ -13,7 +13,7 @@ import (
"fmt"
"io"
- "github.com/google/skylark/syntax"
+ "github.com/google/starlark/syntax"
)
const magic = "!sky"
@@ -45,7 +45,7 @@ type gobIdent struct {
Line, Col int32 // the filename is gobProgram.Filename
}
-// Write writes a compiled Skylark program to out.
+// Write writes a compiled Starlark program to out.
func (prog *Program) Write(out io.Writer) error {
out.Write([]byte(magic))
@@ -94,7 +94,7 @@ func (prog *Program) Write(out io.Writer) error {
return gob.NewEncoder(out).Encode(gp)
}
-// ReadProgram reads a compiled Skylark program from in.
+// ReadProgram reads a compiled Starlark program from in.
func ReadProgram(in io.Reader) (*Program, error) {
magicBuf := []byte(magic)
n, err := in.Read(magicBuf)