From abd26c80b5cb5ec7af53480d518ada43d210df9d Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Sun, 4 Oct 2015 18:49:41 -0700 Subject: [PATCH] move bytecode/codeobject to gython/codeobject --- compiler/compiler.go | 9 +++++---- compiler/interface.go | 4 ++-- {bytecode => gython}/codeobject.go | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) rename {bytecode => gython}/codeobject.go (83%) diff --git a/compiler/compiler.go b/compiler/compiler.go index d2464b9..405b16d 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -5,6 +5,7 @@ import ( "github.com/brettlangdon/gython/ast" "github.com/brettlangdon/gython/bytecode" + "github.com/brettlangdon/gython/gython" ) type Compiler struct { @@ -42,13 +43,13 @@ func (compiler *Compiler) exitScope() *Scope { return scope } -func (compiler *Compiler) assemble(addNone bool) *bytecode.CodeObject { +func (compiler *Compiler) assemble(addNone bool) *gython.CodeObject { if addNone { compiler.addOp(bytecode.LOAD_CONST) compiler.addOp(bytecode.RETURN_VALUE) } - codeobject := bytecode.NewCodeObject() + codeobject := gython.NewCodeObject() return codeobject } @@ -93,10 +94,10 @@ func (compiler *Compiler) compileBody(stmts []ast.Statement) bool { return true } -func (compiler *Compiler) CompileMod(root ast.Mod) *bytecode.CodeObject { +func (compiler *Compiler) CompileMod(root ast.Mod) *gython.CodeObject { addNone := true compiler.enterScope() - var codeobject *bytecode.CodeObject + var codeobject *gython.CodeObject switch root := root.(type) { case *ast.Module: if !compiler.compileBody(root.Body) { diff --git a/compiler/interface.go b/compiler/interface.go index 46a9cab..01a30ea 100644 --- a/compiler/interface.go +++ b/compiler/interface.go @@ -2,10 +2,10 @@ package compiler import ( "github.com/brettlangdon/gython/ast" - "github.com/brettlangdon/gython/bytecode" + "github.com/brettlangdon/gython/gython" ) -func CompileAST(root ast.Mod) *bytecode.CodeObject { +func CompileAST(root ast.Mod) *gython.CodeObject { compiler := NewCompiler() return compiler.CompileMod(root) } diff --git a/bytecode/codeobject.go b/gython/codeobject.go similarity index 83% rename from bytecode/codeobject.go rename to gython/codeobject.go index 2305432..d883980 100644 --- a/bytecode/codeobject.go +++ b/gython/codeobject.go @@ -1,4 +1,4 @@ -package bytecode +package gython type CodeObject struct { }