Changeset b87a5ed for translator/Parser/LinkageSpec.cc
- Timestamp:
- May 16, 2015, 3:36:19 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- a32b204
- Parents:
- b8508a2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/Parser/LinkageSpec.cc
rb8508a2 rb87a5ed 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // LinkageSpec.cc -- 8 // 9 // Author : Rodolfo G. Esteves 10 // Created On : Sat May 16 13:22:09 2015 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat May 16 13:23:21 2015 13 // Update Count : 2 14 // 15 1 16 #include <string> 2 17 #include <cassert> … … 6 21 7 22 LinkageSpec::Type LinkageSpec::fromString( const std::string &stringSpec ) { 8 9 return Cforall;10 11 return C;12 13 throw SemanticError( "Invalid linkage specifier " + stringSpec );14 23 if ( stringSpec == "\"Cforall\"" ) { 24 return Cforall; 25 } else if ( stringSpec == "\"C\"" ) { 26 return C; 27 } else { 28 throw SemanticError( "Invalid linkage specifier " + stringSpec ); 29 } 15 30 } 16 31 17 32 std::string LinkageSpec::toString( LinkageSpec::Type linkage ) { 18 19 20 return "intrinsic";21 22 return "Cforall";23 24 return "C";25 26 return "automatically generated";27 28 return "compiler built-in";29 30 31 33 switch ( linkage ) { 34 case Intrinsic: 35 return "intrinsic"; 36 case Cforall: 37 return "Cforall"; 38 case C: 39 return "C"; 40 case AutoGen: 41 return "automatically generated"; 42 case Compiler: 43 return "compiler built-in"; 44 } 45 assert( false ); 46 return ""; 32 47 } 33 48 34 49 bool LinkageSpec::isDecoratable( Type t ) { 35 switch ( t ) { 36 case Intrinsic: 37 case Cforall: 38 case AutoGen: 39 return true; 40 case C: 41 case Compiler: 50 switch ( t ) { 51 case Intrinsic: 52 case Cforall: 53 case AutoGen: 54 return true; 55 case C: 56 case Compiler: 57 return false; 58 } 59 assert( false ); 42 60 return false; 43 }44 assert( false );45 return false;46 61 } 47 62 48 63 bool LinkageSpec::isGeneratable( Type t ) { 49 switch ( t ) { 50 case Intrinsic: 51 case Cforall: 52 case AutoGen: 53 case C: 54 return true; 55 case Compiler: 64 switch ( t ) { 65 case Intrinsic: 66 case Cforall: 67 case AutoGen: 68 case C: 69 return true; 70 case Compiler: 71 return false; 72 } 73 assert( false ); 56 74 return false; 57 }58 assert( false );59 return false;60 75 } 61 76 62 77 bool LinkageSpec::isOverloadable( Type t ) { 63 78 return isDecoratable( t ); 64 79 } 65 80 66 81 bool LinkageSpec::isBuiltin( Type t ) { 67 switch ( t ) { 68 case Cforall: 69 case AutoGen: 70 case C: 82 switch ( t ) { 83 case Cforall: 84 case AutoGen: 85 case C: 86 return false; 87 case Intrinsic: 88 case Compiler: 89 return true; 90 } 91 assert( false ); 71 92 return false; 72 case Intrinsic:73 case Compiler:74 return true;75 }76 assert( false );77 return false;78 93 } 94 95 // Local Variables: // 96 // tab-width: 4 // 97 // mode: c++ // 98 // compile-command: "make install" // 99 // End: //
Note: See TracChangeset
for help on using the changeset viewer.