/* NSC -- new Scala compiler
 * Copyright 2005-2011 LAMP/EPFL
 * @author  Martin Odersky
 */

package scala.tools.nsc
package symtab

// Flags at each index of a flags Long.  Those marked with /M are used in
// Parsers/JavaParsers and therefore definitely appear on Modifiers; but the
// absence of /M on the other flags does not imply they aren't.
//
// Generated by mkFlagsTable() at Mon Oct 11 10:01:09 PDT 2010
//
//  0:     PROTECTED/M                          
//  1:      OVERRIDE/M                          
//  2:       PRIVATE/M                          
//  3:      ABSTRACT/M                          
//  4:      DEFERRED/M                          
//  5:         FINAL/M                          
//  6:          METHOD                          
//  7:     INTERFACE/M                          
//  8:          MODULE                          
//  9:      IMPLICIT/M                          
// 10:        SEALED/M                          
// 11:          CASE/M                          
// 12:       MUTABLE/M                          
// 13:         PARAM/M                          
// 14:         PACKAGE                          
// 15:                                          
// 16:   BYNAMEPARAM/M      CAPTURED COVARIANT/M
// 17: CONTRAVARIANT/M INCONSTRUCTOR       LABEL
// 18:   ABSOVERRIDE/M                          
// 19:         LOCAL/M                          
// 20:          JAVA/M                          
// 21:       SYNTHETIC                          
// 22:          STABLE                          
// 23:        STATIC/M                          
// 24:  CASEACCESSOR/M                          
// 25:  DEFAULTPARAM/M       TRAIT/M            
// 26:          BRIDGE                          
// 27:        ACCESSOR                          
// 28:   SUPERACCESSOR                          
// 29: PARAMACCESSOR/M                          
// 30:       MODULEVAR
// 31:          LAZY/M                          
// 32:        IS_ERROR                          
// 33:      OVERLOADED                          
// 34:          LIFTED                          
// 35:     EXISTENTIAL       MIXEDIN            
// 36:    EXPANDEDNAME                          
// 37:       IMPLCLASS    PRESUPER/M            
// 38:      TRANS_FLAG                          
// 39:          LOCKED                          
// 40:     SPECIALIZED                          
// 41:   DEFAULTINIT/M                          
// 42:         VBRIDGE                          
// 43:         VARARGS
// 44:                                          
// 45:                                          
// 46:                                          
// 47:                                          
// 48:                                          
// 49:     latePRIVATE                          
// 50:    lateABSTRACT                          
// 51:    lateDEFERRED                          
// 52:       lateFINAL                          
// 53:      lateMETHOD                          
// 54:   lateINTERFACE                          
// 55:      lateMODULE                          
// 56:    notPROTECTED                          
// 57:     notOVERRIDE                          
// 58:      notPRIVATE                          
// 59:     notABSTRACT                          
// 60:     notDEFERRED                          
// 61:        notFINAL                          
// 62:       notMETHOD                          
// 63:
class Flags extends reflect.generic.Flags {

  final val InitialFlags  = 0x0001FFFFFFFFFFFFL // flags that are enabled from phase 1.
  final val LateFlags     = 0x00FE000000000000L // flags that override flags in 0x1FC.
  final val AntiFlags     = 0x7F00000000000000L // flags that cancel flags in 0x07F
  final val LateShift     = 47L
  final val AntiShift     = 56L

  // late flags (set by a transformer phase)
  final val latePRIVATE   = (PRIVATE: Long) << LateShift
  final val lateABSTRACT  = (ABSTRACT: Long) << LateShift
  final val lateDEFERRED  = (DEFERRED: Long) << LateShift
  final val lateINTERFACE = (INTERFACE: Long) << LateShift
  final val lateMODULE    = (MODULE: Long) << LateShift
  final val lateFINAL     = (FINAL: Long) << LateShift
  final val lateMETHOD    = (METHOD: Long) << LateShift
  
  final val notFINAL      = (FINAL: Long) << AntiShift
  final val notPRIVATE    = (PRIVATE: Long) << AntiShift
  final val notDEFERRED   = (DEFERRED: Long) << AntiShift
  final val notPROTECTED  = (PROTECTED: Long) << AntiShift
  final val notABSTRACT   = (ABSTRACT: Long) << AntiShift
  final val notOVERRIDE   = (OVERRIDE: Long) << AntiShift
  final val notMETHOD     = (METHOD: Long) << AntiShift
  
  final val notFlagMap = Map[Int, Long](
    FINAL -> notFINAL,
    PRIVATE -> notPRIVATE,
    DEFERRED -> notDEFERRED,
    PROTECTED -> notPROTECTED,
    ABSTRACT -> notABSTRACT,
    OVERRIDE -> notOVERRIDE,
    METHOD -> notMETHOD
  )

  // masks
  /** These flags can be set when class or module symbol is first created. */
  final val TopLevelCreationFlags: Long =
    MODULE | PACKAGE | FINAL | JAVA

  /** These modifiers can be set explicitly in source programs. */
  final val ExplicitFlags: Long =
    PRIVATE | PROTECTED | ABSTRACT | FINAL | SEALED |
    OVERRIDE | CASE | IMPLICIT | ABSOVERRIDE | LAZY

  /** These modifiers appear in TreePrinter output. */
  final val PrintableFlags: Long =
    ExplicitFlags | LOCAL | SYNTHETIC | STABLE | CASEACCESSOR |
    ACCESSOR | SUPERACCESSOR | PARAMACCESSOR | BRIDGE | STATIC | VBRIDGE | SPECIALIZED

  /** The two bridge flags */
  final val BRIDGES = BRIDGE | VBRIDGE

  final val FieldFlags: Long =
    MUTABLE | CASEACCESSOR | PARAMACCESSOR | STATIC | FINAL | PRESUPER | LAZY

  final val AccessFlags: Long   = PRIVATE | PROTECTED | LOCAL
  final val VarianceFlags       = COVARIANT | CONTRAVARIANT
  final val ConstrFlags: Long   = JAVA

  /** Module flags inherited by their module-class */
  final val ModuleToClassFlags: Long = AccessFlags | MODULE | PACKAGE | CASE | SYNTHETIC | JAVA

  def getterFlags(fieldFlags: Long): Long = ACCESSOR + (
    if ((fieldFlags & MUTABLE) != 0) fieldFlags & ~MUTABLE & ~PRESUPER
    else fieldFlags & ~PRESUPER | STABLE
  )

  def setterFlags(fieldFlags: Long): Long = 
    getterFlags(fieldFlags) & ~STABLE & ~CASEACCESSOR
  
  // Generated by mkFlagToStringMethod() at Mon Oct 11 10:12:36 PDT 2010
  @annotation.switch override def flagToString(flag: Long): String = flag match {
    case           PROTECTED => "protected"                           // (1L << 0)
    case            OVERRIDE => "override"                            // (1L << 1)
    case             PRIVATE => "private"                             // (1L << 2)
    case            ABSTRACT => "abstract"                            // (1L << 3)
    case            DEFERRED => "<deferred>"                          // (1L << 4)
    case               FINAL => "final"                               // (1L << 5)
    case              METHOD => "<method>"                            // (1L << 6)
    case           INTERFACE => "<interface>"                         // (1L << 7)
    case              MODULE => "<module>"                            // (1L << 8)
    case            IMPLICIT => "implicit"                            // (1L << 9)
    case              SEALED => "sealed"                              // (1L << 10)
    case                CASE => "case"                                // (1L << 11)
    case             MUTABLE => "<mutable>"                           // (1L << 12)
    case               PARAM => "<param>"                             // (1L << 13)
    case             PACKAGE => "<package>"                           // (1L << 14)
    case             0x8000L => ""                                    // (1L << 15)
    case         BYNAMEPARAM => "<bynameparam/captured/covariant>"    // (1L << 16)
    case       CONTRAVARIANT => "<contravariant/inconstructor/label>" // (1L << 17)
    case         ABSOVERRIDE => "absoverride"                         // (1L << 18)
    case               LOCAL => "<local>"                             // (1L << 19)
    case                JAVA => "<java>"                              // (1L << 20)
    case           SYNTHETIC => "<synthetic>"                         // (1L << 21)
    case              STABLE => "<stable>"                            // (1L << 22)
    case              STATIC => "<static>"                            // (1L << 23)
    case        CASEACCESSOR => "<caseaccessor>"                      // (1L << 24)
    case        DEFAULTPARAM => "<defaultparam/trait>"                // (1L << 25)
    case              BRIDGE => "<bridge>"                            // (1L << 26)
    case            ACCESSOR => "<accessor>"                          // (1L << 27)
    case       SUPERACCESSOR => "<superaccessor>"                     // (1L << 28)
    case       PARAMACCESSOR => "<paramaccessor>"                     // (1L << 29)
    case           MODULEVAR => "<modulevar>"                         // (1L << 30)
    case                LAZY => "lazy"                                // (1L << 31)
    case            IS_ERROR => "<is_error>"                          // (1L << 32)
    case          OVERLOADED => "<overloaded>"                        // (1L << 33)
    case              LIFTED => "<lifted>"                            // (1L << 34)
    case         EXISTENTIAL => "<existential/mixedin>"               // (1L << 35)
    case        EXPANDEDNAME => "<expandedname>"                      // (1L << 36)
    case           IMPLCLASS => "<implclass/presuper>"                // (1L << 37)
    case          TRANS_FLAG => "<trans_flag>"                        // (1L << 38)
    case              LOCKED => "<locked>"                            // (1L << 39)
    case         SPECIALIZED => "<specialized>"                       // (1L << 40)
    case         DEFAULTINIT => "<defaultinit>"                       // (1L << 41)
    case             VBRIDGE => "<vbridge>"                           // (1L << 42)
    case             VARARGS => "<varargs>"                           // (1L << 43)
    case     0x100000000000L => ""                                    // (1L << 44)
    case     0x200000000000L => ""                                    // (1L << 45)
    case     0x400000000000L => ""                                    // (1L << 46)
    case     0x800000000000L => ""                                    // (1L << 47)
    case    0x1000000000000L => ""                                    // (1L << 48)
    case       `latePRIVATE` => "<lateprivate>"                       // (1L << 49)
    case      `lateABSTRACT` => "<lateabstract>"                      // (1L << 50)
    case      `lateDEFERRED` => "<latedeferred>"                      // (1L << 51)
    case         `lateFINAL` => "<latefinal>"                         // (1L << 52)
    case        `lateMETHOD` => "<latemethod>"                        // (1L << 53)
    case     `lateINTERFACE` => "<lateinterface>"                     // (1L << 54)
    case        `lateMODULE` => "<latemodule>"                        // (1L << 55)
    case      `notPROTECTED` => "<notprotected>"                      // (1L << 56)
    case       `notOVERRIDE` => "<notoverride>"                       // (1L << 57)
    case        `notPRIVATE` => "<notprivate>"                        // (1L << 58)
    case       `notABSTRACT` => "<notabstract>"                       // (1L << 59)
    case       `notDEFERRED` => "<notdeferred>"                       // (1L << 60)
    case          `notFINAL` => "<notfinal>"                          // (1L << 61)
    case         `notMETHOD` => "<notmethod>"                         // (1L << 62)
    case 0x8000000000000000L => ""                                    // (1L << 63)
    case _ => ""
  }
}

object Flags extends Flags { }