logo
mixin

compiler::CPod

sys::Obj
  compiler::CPod
  1  //
  2  // Copyright (c) 2006, Brian Frank and Andy Frank
  3  // Licensed under the Academic Free License version 3.0
  4  //
  5  // History:
  6  //   4 Jun 06  Brian Frank  Creation
  7  //
  8  
  9  **
 10  ** CPod is a "compiler pod" used for representing a Pod in the compiler.
 11  **
 12  mixin CPod
 13  {
 14  
 15    **
 16    ** Associated namespace for this pod representation
 17    **
 18    abstract Namespace ns()
 19  
 20    **
 21    ** Get the pod name
 22    **
 23    abstract Str name()
 24  
 25    **
 26    ** Get the pod version
 27    **
 28    abstract Version version()
 29  
 30    **
 31    ** List of the all defined types.
 32    **
 33    abstract CType[] types()
 34  
 35    **
 36    ** Lookup a type by its simple name.  If the type doesn't
 37    ** exist and checked is true then throw UnknownTypeErr
 38    ** otherwise return null.
 39    **
 40    abstract CType resolveType(Str name, Bool checked)
 41  
 42    **
 43    ** Hash on name.
 44    **
 45    override Int hash()
 46    {
 47      return name.hash
 48    }
 49  
 50    **
 51    ** Equality based on pod name.
 52    **
 53    override Bool equals(Obj t)
 54    {
 55      if (this === t) return true
 56      that := t as CPod
 57      if (that == null) return false
 58      return name == that.name
 59    }
 60  
 61  }