logo
class

compiler::EnumDef

sys::Obj
  compiler::Node
    compiler::EnumDef
  1  //
  2  // Copyright (c) 2006, Brian Frank and Andy Frank
  3  // Licensed under the Academic Free License version 3.0
  4  //
  5  // History:
  6  //   16 Apr 06  Brian Frank  Creation
  7  //   19 Jul 06  Brian Frank  Ported from Java to Fan
  8  //
  9  
 10  **
 11  ** EnumDef is used to define one ordinal/named enum value in
 12  ** an enum TypeDef.  If using a custom constructor, it includes
 13  ** the constructor arguments.
 14  **
 15  class EnumDef : Node
 16  {
 17  
 18  //////////////////////////////////////////////////////////////////////////
 19  // Construction
 20  //////////////////////////////////////////////////////////////////////////
 21  
 22    new make(Location location)
 23      : super(location)
 24    {
 25      ctorArgs = Expr[,]
 26    }
 27  
 28  //////////////////////////////////////////////////////////////////////////
 29  // Debug
 30  //////////////////////////////////////////////////////////////////////////
 31  
 32    override Str toStr()
 33    {
 34      return "$ordinal:$name"
 35    }
 36  
 37    override Void print(AstWriter out)
 38    {
 39      out.w(name)
 40      if (!ctorArgs.isEmpty)
 41        out.w("(").w(ctorArgs.join(", ")).w(")")
 42      out.w("  // ").w(ordinal).nl
 43    }
 44  
 45  //////////////////////////////////////////////////////////////////////////
 46  // Fields
 47  //////////////////////////////////////////////////////////////////////////
 48  
 49    Str[] doc
 50    Int ordinal
 51    Str name
 52    Expr[] ctorArgs
 53  }