Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/LinkageSpec.cc

    rfaddbd8 r54d714e  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:22:09 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct  2 23:16:21 2016
    13 // Update Count     : 23
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jul  7 11:11:00 2017
     13// Update Count     : 25
    1414//
    1515
     
    2222#include "Common/SemanticError.h"
    2323
    24 LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) {
     24namespace LinkageSpec {
     25
     26Spec linkageCheck( const string * spec ) {
     27        assert( spec );
    2528        unique_ptr<const string> guard( spec ); // allocated by lexer
    2629        if ( *spec == "\"Cforall\"" ) {
     
    2831        } else if ( *spec == "\"C\"" ) {
    2932                return C;
     33        } else if ( *spec == "\"BuiltinC\"" ) {
     34                return BuiltinC;
    3035        } else {
    3136                throw SemanticError( "Invalid linkage specifier " + *spec );
     
    3338}
    3439
    35 string 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];
     40Spec 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
    4152}
    4253
    43 bool 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];
     54std::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    }
    5073}
    5174
    52 bool 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 
    61 bool 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 
    70 bool 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 }
     75} // LinkageSpec
    7876
    7977// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.