update directory package structure

This commit is contained in:
Daniel Kang 2019-01-11 02:27:28 -08:00
parent d954348e75
commit 27438eea6f
126 changed files with 178 additions and 178 deletions

View file

@ -8,9 +8,9 @@ import (
"testing"
"github.com/d5/tengo/compiler"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
"github.com/d5/tengo/objects"
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
)
func NoError(t *testing.T, err error, msg ...interface{}) bool {

View file

@ -4,12 +4,12 @@ import (
"fmt"
"time"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/compiler"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/parser"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/objects"
"github.com/d5/tengo/parser"
"github.com/d5/tengo/source"
"github.com/d5/tengo/vm"
"github.com/d5/tengo/runtime"
)
func main() {
@ -156,11 +156,11 @@ func compileFile(file *ast.File) (time.Duration, *compiler.Bytecode, error) {
}
func runVM(bytecode *compiler.Bytecode) (time.Duration, objects.Object, error) {
globals := make([]*objects.Object, vm.GlobalsSize)
globals := make([]*objects.Object, runtime.GlobalsSize)
start := time.Now()
v := vm.NewVM(bytecode, globals)
v := runtime.NewVM(bytecode, globals)
if err := v.Run(); err != nil {
return time.Since(start), nil, err
}

View file

@ -7,12 +7,12 @@ import (
"os"
"os/user"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/compiler"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/parser"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/objects"
"github.com/d5/tengo/parser"
"github.com/d5/tengo/source"
"github.com/d5/tengo/vm"
"github.com/d5/tengo/runtime"
)
const (
@ -34,7 +34,7 @@ func startRepl(in io.Reader, out io.Writer) {
stdin := bufio.NewScanner(in)
fileSet := source.NewFileSet()
globals := make([]*objects.Object, vm.GlobalsSize)
globals := make([]*objects.Object, runtime.GlobalsSize)
symbolTable := compiler.NewSymbolTable()
for {
@ -61,7 +61,7 @@ func startRepl(in io.Reader, out io.Writer) {
continue
}
machine := vm.NewVM(c.Bytecode(), globals)
machine := runtime.NewVM(c.Bytecode(), globals)
if err != nil {
_, _ = fmt.Fprintf(out, "VM error:\n %s\n", err.Error())
continue

View file

@ -11,7 +11,7 @@ import (
"github.com/d5/tengo"
"github.com/d5/tengo/compiler"
"github.com/d5/tengo/vm"
"github.com/d5/tengo/runtime"
)
var (
@ -113,7 +113,7 @@ func doRun(data []byte, _, _ string) (err error) {
return
}
machine := vm.NewVM(bytecode, nil)
machine := runtime.NewVM(bytecode, nil)
err = machine.Run()
if err != nil {

View file

@ -3,7 +3,7 @@ package ast
import (
"strings"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/source"
)
type ArrayLit struct {

View file

@ -3,8 +3,8 @@ package ast
import (
"strings"
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
)
type AssignStmt struct {

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type BadExpr struct {
From source.Pos

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type BadStmt struct {
From source.Pos

View file

@ -1,8 +1,8 @@
package ast
import (
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
)
type BinaryExpr struct {

View file

@ -3,7 +3,7 @@ package ast
import (
"strings"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/source"
)
type BlockStmt struct {

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type BoolLit struct {
Value bool

View file

@ -1,8 +1,8 @@
package ast
import (
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
)
type BranchStmt struct {

View file

@ -3,7 +3,7 @@ package ast
import (
"strings"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/source"
)
type CallExpr struct {

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type CharLit struct {
Value rune

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type EmptyStmt struct {
Semicolon source.Pos

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type ExprStmt struct {
Expr Expr

View file

@ -3,7 +3,7 @@ package ast
import (
"strings"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/source"
)
type File struct {

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type FloatLit struct {
Value float64

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type ForInStmt struct {
ForPos source.Pos

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type ForStmt struct {
ForPos source.Pos

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type FuncLit struct {
Type *FuncType

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type FuncType struct {
FuncPos source.Pos

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type Ident struct {
Name string

View file

@ -3,7 +3,7 @@ package ast
import (
"strings"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/source"
)
type IdentList struct {

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type IfStmt struct {
IfPos source.Pos

View file

@ -1,8 +1,8 @@
package ast
import (
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
)
type IncDecStmt struct {

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type IndexExpr struct {
Expr Expr

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type IntLit struct {
Value int64

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type MapElementLit struct {
Key string

View file

@ -3,7 +3,7 @@ package ast
import (
"strings"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/source"
)
type MapLit struct {

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type Node interface {
Pos() source.Pos

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type ParenExpr struct {
Expr Expr

View file

@ -3,7 +3,7 @@ package ast
import (
"strings"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/source"
)
type ReturnStmt struct {

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type SelectorExpr struct {
Expr Expr

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type SliceExpr struct {
Expr Expr

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type StringLit struct {
Value string

View file

@ -1,8 +1,8 @@
package ast
import (
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
)
type UnaryExpr struct {

View file

@ -1,6 +1,6 @@
package ast
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type UndefinedLit struct {
TokenPos source.Pos

View file

@ -5,9 +5,9 @@ import (
"io"
"reflect"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
"github.com/d5/tengo/objects"
"github.com/d5/tengo/token"
)
type Compiler struct {

View file

@ -4,8 +4,8 @@ import (
"errors"
"fmt"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func (c *Compiler) compileAssign(lhs, rhs []ast.Expr, op token.Token) error {

View file

@ -1,7 +1,7 @@
package compiler
import (
"github.com/d5/tengo/ast"
"github.com/d5/tengo/compiler/ast"
)
func (c *Compiler) compileForStmt(stmt *ast.ForStmt) error {

View file

@ -1,8 +1,8 @@
package compiler
import (
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func (c *Compiler) compileLogical(node *ast.BinaryExpr) error {

View file

@ -8,9 +8,9 @@ import (
"github.com/d5/tengo/assert"
"github.com/d5/tengo/compiler"
"github.com/d5/tengo/compiler/parser"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/objects"
"github.com/d5/tengo/parser"
"github.com/d5/tengo/source"
)
func TestCompiler_Compile(t *testing.T) {

View file

@ -1,6 +1,6 @@
package parser
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type Error struct {
Pos source.FilePos

View file

@ -4,7 +4,7 @@ import (
"fmt"
"sort"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/source"
)
type ErrorList []*Error

View file

@ -3,8 +3,8 @@ package parser
import (
"io"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/source"
)
func ParseFile(file *source.File, src []byte, trace io.Writer) (res *ast.File, err error) {

View file

@ -3,8 +3,8 @@ package parser
import (
"io"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/source"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/source"
)
// ParseSource parses source code 'src' and builds an AST.

View file

@ -5,10 +5,10 @@ import (
"io"
"strconv"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/scanner"
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/scanner"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
)
type bailout struct{}

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestArray(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestAssignment(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestBoolean(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestCall(t *testing.T) {

View file

@ -3,7 +3,7 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/compiler/ast"
)
func TestChar(t *testing.T) {

View file

@ -3,7 +3,7 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/compiler/ast"
)
func TestForIn(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestFor(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestFunction(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestIf(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestIndex(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestLogical(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestMap(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestSelector(t *testing.T) {

View file

@ -3,7 +3,7 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/compiler/ast"
)
func TestSemicolon(t *testing.T) {

View file

@ -3,8 +3,8 @@ package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/token"
)
func TestString(t *testing.T) {

View file

@ -7,10 +7,10 @@ import (
"testing"
"github.com/d5/tengo/assert"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/parser"
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/parser"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
)
type pfn func(int, int) source.Pos // position conversion function

View file

@ -1,6 +1,6 @@
package parser
import "github.com/d5/tengo/token"
import "github.com/d5/tengo/compiler/token"
var stmtStart = map[token.Token]bool{
token.Break: true,

View file

@ -1,5 +1,5 @@
package scanner
import "github.com/d5/tengo/source"
import "github.com/d5/tengo/compiler/source"
type ErrorHandler func(pos source.FilePos, msg string)

View file

@ -5,8 +5,8 @@ import (
"unicode"
"unicode/utf8"
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
)
// byte order mark

View file

@ -8,9 +8,9 @@ import (
"time"
"github.com/d5/tengo/assert"
"github.com/d5/tengo/scanner"
"github.com/d5/tengo/source"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/scanner"
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
)
var testFileSet = source.NewFileSet()

View file

@ -5,7 +5,7 @@ import (
"fmt"
"strings"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type Array struct {

View file

@ -1,7 +1,7 @@
package objects
import (
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type Bool struct {

View file

@ -1,6 +1,6 @@
package objects
import "github.com/d5/tengo/token"
import "github.com/d5/tengo/compiler/token"
type Break struct{}

View file

@ -1,7 +1,7 @@
package objects
import (
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type BuiltinFunction struct {

View file

@ -1,7 +1,7 @@
package objects
import (
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type Char struct {

View file

@ -1,7 +1,7 @@
package objects
import (
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type Closure struct {

View file

@ -1,7 +1,7 @@
package objects
import (
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type CompiledFunction struct {

View file

@ -1,6 +1,6 @@
package objects
import "github.com/d5/tengo/token"
import "github.com/d5/tengo/compiler/token"
type Continue struct {
}

View file

@ -4,7 +4,7 @@ import (
"math"
"strconv"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type Float struct {

View file

@ -3,7 +3,7 @@ package objects
import (
"strconv"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type Int struct {

View file

@ -1,6 +1,6 @@
package objects
import "github.com/d5/tengo/token"
import "github.com/d5/tengo/compiler/token"
type Iterator interface {
Object

View file

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type Map struct {

View file

@ -1,6 +1,6 @@
package objects
import "github.com/d5/tengo/token"
import "github.com/d5/tengo/compiler/token"
type Object interface {
TypeName() string

View file

@ -1,6 +1,6 @@
package objects
import "github.com/d5/tengo/token"
import "github.com/d5/tengo/compiler/token"
type ReturnValue struct {
Value Object

View file

@ -3,7 +3,7 @@ package objects
import (
"fmt"
"github.com/d5/tengo/token"
"github.com/d5/tengo/compiler/token"
)
type String struct {

View file

@ -1,6 +1,6 @@
package objects
import "github.com/d5/tengo/token"
import "github.com/d5/tengo/compiler/token"
var undefined = &Undefined{}

View file

@ -1,4 +1,4 @@
package vm
package runtime
import (
"errors"

View file

@ -1,4 +1,4 @@
package vm
package runtime
import (
"github.com/d5/tengo/objects"

View file

@ -1,11 +1,11 @@
package vm
package runtime
import (
"fmt"
"github.com/d5/tengo/compiler"
"github.com/d5/tengo/compiler/token"
"github.com/d5/tengo/objects"
"github.com/d5/tengo/token"
)
const (

View file

@ -1,4 +1,4 @@
package vm_test
package runtime_test
import (
"testing"

View file

@ -1,4 +1,4 @@
package vm_test
package runtime_test
import (
"testing"
@ -193,8 +193,8 @@ out = func() {
`, 136)
// assigning different type value
expect(t, `a := 1; a = "foo"; out = a`, "foo") // global
expect(t, `func() { a := 1; a = "foo"; out = a }()`, "foo") // local
expect(t, `a := 1; a = "foo"; out = a`, "foo") // global
expect(t, `func() { a := 1; a = "foo"; out = a }()`, "foo") // local
expect(t, `
out = func() {
a := 5

Some files were not shown because too many files have changed in this diff Show more