Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/LinkageSpec.hpp

    r260dad7 r7f3f63c  
    2525namespace Linkage {
    2626
    27 /// Bitflags for linkage specifiers
    28 enum {
    29         Mangle       = 1 << 0,
    30         Generate     = 1 << 1,
    31         Overrideable = 1 << 2,
    32         Builtin      = 1 << 3,
    33         GccBuiltin   = 1 << 4
    34 };
    35 
    36 /// Bitflag type for storage classes
    37 struct spec_flags {
    38         union {
    39                 unsigned int val;
    40                 struct {
    41                         bool is_mangled      : 1;
    42                         bool is_generatable  : 1;
    43                         bool is_overrideable : 1;
    44                         bool is_builtin      : 1;
    45                         bool is_gcc_builtin  : 1;
    46                 };
     27        /// Bitflags for linkage specifiers
     28        enum {
     29                Mangle       = 1 << 0,
     30                Generate     = 1 << 1,
     31                Overrideable = 1 << 2,
     32                Builtin      = 1 << 3,
     33                GccBuiltin   = 1 << 4
    4734        };
    4835
    49         constexpr spec_flags( unsigned int val ) : val(val) {}
    50 };
     36        /// Bitflag type for storage classes
     37        struct spec_flags {
     38                union {
     39                        unsigned int val;
     40                        struct {
     41                                bool is_mangled      : 1;
     42                                bool is_generatable  : 1;
     43                                bool is_overrideable : 1;
     44                                bool is_builtin      : 1;
     45                                bool is_gcc_builtin  : 1;
     46                        };
     47                };
    5148
    52 using Spec = bitfield<spec_flags>;
     49                constexpr spec_flags( unsigned int val ) : val(val) {}
     50        };
    5351
    54 /// If `cmd` = "C" returns `spec` with `is_mangled = false`.
    55 /// If `cmd` = "Cforall" returns `spec` with `is_mangled = true`.
    56 Spec update( CodeLocation loc, Spec spec, const std::string * cmd );
     52        using Spec = bitfield<spec_flags>;
    5753
    58 /// A human-readable name for this spec
    59 std::string name( Spec spec );
     54        /// If `cmd` = "C" returns `spec` with `is_mangled = false`.
     55        /// If `cmd` = "Cforall" returns `spec` with `is_mangled = true`.
     56        Spec update( CodeLocation loc, Spec spec, const std::string * cmd );
    6057
    61 // Pre-defined flag combinations
     58        /// A human-readable name for this spec
     59        std::string name( Spec spec );
    6260
    63 /// C built-in defined in prelude
    64 constexpr Spec Intrinsic  = { Mangle | Generate | Overrideable | Builtin };
    65 /// Ordinary Cforall
    66 constexpr Spec Cforall    = { Mangle | Generate };
    67 /// C code: not overloadable, not mangled
    68 constexpr Spec C          = { Generate };
    69 /// Built by translator (e.g. struct assignment)
    70 constexpr Spec AutoGen    = { Mangle | Generate | Overrideable };
    71 /// GCC internal
    72 constexpr Spec Compiler   = { Mangle | Builtin | GccBuiltin };
    73 /// Mangled builtins
    74 constexpr Spec BuiltinCFA = { Mangle | Generate | Builtin };
    75 /// Non-mangled builtins
    76 constexpr Spec BuiltinC   = { Generate | Builtin };
     61        // Pre-defined flag combinations
    7762
     63        /// C built-in defined in prelude
     64        constexpr Spec Intrinsic  = { Mangle | Generate | Overrideable | Builtin };
     65        /// Ordinary Cforall
     66        constexpr Spec Cforall    = { Mangle | Generate };
     67        /// C code: not overloadable, not mangled
     68        constexpr Spec C          = { Generate };
     69        /// Built by translator (e.g. struct assignment)
     70        constexpr Spec AutoGen    = { Mangle | Generate | Overrideable };
     71        /// GCC internal
     72        constexpr Spec Compiler   = { Mangle | Builtin | GccBuiltin };
     73        /// Mangled builtins
     74        constexpr Spec BuiltinCFA = { Mangle | Generate | Builtin };
     75        /// Non-mangled builtins
     76        constexpr Spec BuiltinC   = { Generate | Builtin };
    7877}
    7978
Note: See TracChangeset for help on using the changeset viewer.