Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/LinkageSpec.cc

    r54d714e rfaddbd8  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:22:09 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul  7 11:11:00 2017
    13 // Update Count     : 25
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Oct  2 23:16:21 2016
     13// Update Count     : 23
    1414//
    1515
     
    2222#include "Common/SemanticError.h"
    2323
    24 namespace LinkageSpec {
    25 
    26 Spec linkageCheck( const string * spec ) {
    27         assert( spec );
     24LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) {
    2825        unique_ptr<const string> guard( spec ); // allocated by lexer
    2926        if ( *spec == "\"Cforall\"" ) {
     
    3128        } else if ( *spec == "\"C\"" ) {
    3229                return C;
    33         } else if ( *spec == "\"BuiltinC\"" ) {
    34                 return BuiltinC;
    3530        } else {
    3631                throw SemanticError( "Invalid linkage specifier " + *spec );
     
    3833}
    3934
    40 Spec linkageUpdate( Spec old_spec, const string * cmd ) {
    41         assert( cmd );
    42         unique_ptr<const string> guard( cmd ); // allocated by lexer
    43         if ( *cmd == "\"Cforall\"" ) {
    44                 old_spec.is_mangled = true;
    45                 return old_spec;
    46         } else if ( *cmd == "\"C\"" ) {
    47                 old_spec.is_mangled = false;
    48                 return old_spec;
    49         } else {
    50                 throw SemanticError( "Invalid linkage specifier " + *cmd );
    51         } // if
     35string LinkageSpec::linkageName( LinkageSpec::Spec linkage ) {
     36        assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs );
     37        static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
     38                "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in",
     39        };
     40        return linkageKinds[linkage];
    5241}
    5342
    54 std::string linkageName( Spec linkage ) {
    55     switch ( linkage ) {
    56     case Intrinsic:
    57         return "intrinsic";
    58     case C:
    59         return "C";
    60     case Cforall:
    61         return "Cforall";
    62     case AutoGen:
    63         return "autogenerated cfa";
    64     case Compiler:
    65         return "compiler built-in";
    66     case BuiltinCFA:
    67         return "cfa built-in";
    68     case BuiltinC:
    69         return "c built-in";
    70     default:
    71         return "<unnamed linkage spec>";
    72     }
     43bool LinkageSpec::isDecoratable( Spec spec ) {
     44        assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
     45        static bool decoratable[LinkageSpec::NoOfSpecs] = {
     46                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
     47                        true,           true,           false,  true,           false,
     48        };
     49        return decoratable[spec];
    7350}
    7451
    75 } // LinkageSpec
     52bool LinkageSpec::isGeneratable( Spec spec ) {
     53        assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
     54        static bool generatable[LinkageSpec::NoOfSpecs] = {
     55                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
     56                        true,           true,           true,   true,           false,
     57        };
     58        return generatable[spec];
     59}
     60
     61bool LinkageSpec::isOverridable( Spec spec ) {
     62        assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
     63        static bool overridable[LinkageSpec::NoOfSpecs] = {
     64                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
     65                        true,           false,          false,  true,           false,
     66        };
     67        return overridable[spec];
     68}
     69
     70bool LinkageSpec::isBuiltin( Spec spec ) {
     71        assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
     72        static bool builtin[LinkageSpec::NoOfSpecs] = {
     73                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
     74                        true,           false,          false,  false,          true,
     75        };
     76        return builtin[spec];
     77}
    7678
    7779// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.