Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/LinkageSpec.h

    r54d714e rfaddbd8  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // LinkageSpec.h --
     7// LinkageSpec.h -- 
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:24:28 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul  7 11:03:00 2017
    13 // Update Count     : 13
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Oct  1 23:03:17 2016
     13// Update Count     : 11
    1414//
    1515
     
    1919#include <string>
    2020
    21 namespace LinkageSpec {
    22         // All linkage specs are some combination of these flags:
    23         enum {
    24                 Mangle = 1 << 0,
    25                 Generate = 1 << 1,
    26                 Overrideable = 1 << 2,
    27                 Builtin = 1 << 3,
    28 
    29                 NoOfSpecs = 1 << 4,
     21struct LinkageSpec {
     22        enum Spec {
     23                Intrinsic,                                                                              // C built-in defined in prelude
     24                Cforall,                                                                                // ordinary
     25                C,                                                                                              // not overloadable, not mangled
     26                AutoGen,                                                                                // built by translator (struct assignment)
     27                Compiler,                                                                               // gcc internal
     28                NoOfSpecs
    3029        };
    31 
    32         union Spec {
    33                 unsigned int val;
    34                 struct {
    35                         bool is_mangled : 1;
    36                         bool is_generatable : 1;
    37                         bool is_overridable : 1;
    38                         bool is_builtin : 1;
    39                 };
    40                 constexpr Spec( unsigned int val ) : val( val ) {}
    41                 constexpr Spec( Spec const &other ) : val( other.val ) {}
    42                 // Operators may go here.
    43                 // Supports == and !=
    44                 constexpr operator unsigned int () const { return val; }
    45         };
    46 
    47 
    48         Spec linkageCheck( const std::string * );
    49         // Returns the Spec with the given name (limited to C, Cforall & BuiltinC)
    50         Spec linkageUpdate( Spec old_spec, const std::string * cmd );
    51         /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false
    52          * If cmd = "Cforall" returns old_spec Spec with is_mangled = true
    53          */
    54 
    55         std::string linkageName( Spec );
    56 
    57         // To Update: LinkageSpec::isXyz( cur_spec ) -> cur_spec.is_xyz
    58         inline bool isMangled( Spec spec ) { return spec.is_mangled; }
    59         inline bool isGeneratable( Spec spec ) { return spec.is_generatable; }
    60         inline bool isOverridable( Spec spec ) { return spec.is_overridable; }
    61         inline bool isBuiltin( Spec spec ) { return spec.is_builtin; }
    62 
    63         // Pre-defined flag combinations:
    64         // C built-in defined in prelude
    65         constexpr Spec const Intrinsic = { Mangle | Generate | Overrideable | Builtin };
    66         // ordinary
    67         constexpr Spec const Cforall = { Mangle | Generate };
    68         // not overloadable, not mangled
    69         constexpr Spec const C = { Generate };
    70         // built by translator (struct assignment)
    71         constexpr Spec const AutoGen = { Mangle | Generate | Overrideable };
    72         // gcc internal
    73         constexpr Spec const Compiler = { Builtin };
    74         // mangled builtins
    75         constexpr Spec const BuiltinCFA = { Mangle | Generate | Builtin };
    76         // non-mangled builtins
    77         constexpr Spec const BuiltinC = { Generate | Builtin };
     30 
     31        static Spec linkageCheck( const std::string * );
     32        static std::string linkageName( Spec );
     33 
     34        static bool isDecoratable( Spec );
     35        static bool isGeneratable( Spec );
     36        static bool isOverridable( Spec );
     37        static bool isBuiltin( Spec );
    7838};
    7939
Note: See TracChangeset for help on using the changeset viewer.