Changes in src/Parser/LinkageSpec.cc [faddbd8:54d714e]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/LinkageSpec.cc
rfaddbd8 r54d714e 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:22:09 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Oct 2 23:16:21 201613 // Update Count : 2 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jul 7 11:11:00 2017 13 // Update Count : 25 14 14 // 15 15 … … 22 22 #include "Common/SemanticError.h" 23 23 24 LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) { 24 namespace LinkageSpec { 25 26 Spec linkageCheck( const string * spec ) { 27 assert( spec ); 25 28 unique_ptr<const string> guard( spec ); // allocated by lexer 26 29 if ( *spec == "\"Cforall\"" ) { … … 28 31 } else if ( *spec == "\"C\"" ) { 29 32 return C; 33 } else if ( *spec == "\"BuiltinC\"" ) { 34 return BuiltinC; 30 35 } else { 31 36 throw SemanticError( "Invalid linkage specifier " + *spec ); … … 33 38 } 34 39 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]; 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 41 52 } 42 53 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]; 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 } 50 73 } 51 74 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 78 76 79 77 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.