Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/LinkageSpec.cc

    rfa4805f r54d714e  
    1010// Created On       : Sat May 16 13:22:09 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 11:51:00 2017
    13 // Update Count     : 24
     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\"" ) {
     
    3538}
    3639
    37 string LinkageSpec::linkageName( LinkageSpec::Spec linkage ) {
    38         assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs );
    39         static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
    40                 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in", "cfa built-in", "c built-in",
    41         };
    42         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
    4352}
    4453
    45 bool LinkageSpec::isMangled( Spec spec ) {
    46         assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    47         static bool decoratable[LinkageSpec::NoOfSpecs] = {
    48                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    49                         true,           true,           false,  true,           false,
    50                 //      Builtin,        BuiltinC,
    51                         true,           false,
    52         };
    53         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    }
    5473}
    5574
    56 bool LinkageSpec::isGeneratable( Spec spec ) {
    57         assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    58         static bool generatable[LinkageSpec::NoOfSpecs] = {
    59                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    60                         true,           true,           true,   true,           false,
    61                 //      Builtin,        BuiltinC,
    62                         true,           true,
    63         };
    64         return generatable[spec];
    65 }
    66 
    67 bool LinkageSpec::isOverridable( Spec spec ) {
    68         assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
    69         static bool overridable[LinkageSpec::NoOfSpecs] = {
    70                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    71                         true,           false,          false,  true,           false,
    72                 //      Builtin,        BuiltinC,
    73                         false,          false,
    74         };
    75         return overridable[spec];
    76 }
    77 
    78 bool LinkageSpec::isBuiltin( Spec spec ) {
    79         assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
    80         static bool builtin[LinkageSpec::NoOfSpecs] = {
    81                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    82                         true,           false,          false,  false,          true,
    83                 //      Builtin,        BuiltinC,
    84                         true,           true,
    85         };
    86         return builtin[spec];
    87 }
     75} // LinkageSpec
    8876
    8977// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.