tc_package.mx raw

   1  package types
   2  
   3  
   4  // TCPackage represents a compiled Moxie package.
   5  type TCPackage struct {
   6  	Path      string
   7  	Name      string
   8  	Scope     *Scope
   9  	Imports   []*TCPackage
  10  	Completed bool
  11  }
  12  
  13  func NewTCPackage(path, name string) (t *TCPackage) {
  14  	t = (&TCPackage{})
  15  	t.Path = path; t.Name = name; t.Scope = NewScope(nil)
  16  	return t
  17  }
  18  
  19  func NewTCPackageWithParent(path, name string, parent *Scope) (t *TCPackage) {
  20  	t = (&TCPackage{})
  21  	t.Path = path; t.Name = name; t.Scope = NewScope(parent)
  22  	return t
  23  }
  24  
  25  func (p *TCPackage) MarkComplete()   { p.Completed = true }
  26  func (p *TCPackage) String() (s string) { return "package " | p.Name | " (" | p.Path | ")" }
  27  
  28  func (p *TCPackage) Release() {
  29  	if p.Scope != nil {
  30  		p.Scope.Release()
  31  		p.Scope = nil
  32  	}
  33  	p.Imports = nil
  34  }
  35