Python 3 interpreter in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

28 lines
682 B

package compiler
import "github.com/brettlangdon/gython/gython"
type Scope struct {
Instructions []*Instruction
Constants *gython.Dict
Names *gython.Dict
VariableNames *gython.Dict
FreeVariableNames *gython.Dict
CellVariableNames *gython.Dict
}
func NewScope() *Scope {
return &Scope{
Instructions: make([]*Instruction, 0),
Constants: gython.NewDict(),
Names: gython.NewDict(),
VariableNames: gython.NewDict(),
FreeVariableNames: gython.NewDict(),
CellVariableNames: gython.NewDict(),
}
}
func (scope *Scope) AddInstruction(instr *Instruction) {
scope.Instructions = append(scope.Instructions, instr)
}