[b87a5ed] | 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 |
---|
[3b8e52c] | 11 | // Last Modified By : Peter A. Buhr |
---|
[ab57786] | 12 | // Last Modified On : Sun Aug 21 12:32:53 2016 |
---|
| 13 | // Update Count : 17 |
---|
[b87a5ed] | 14 | // |
---|
| 15 | |
---|
[51b7345] | 16 | #include <string> |
---|
| 17 | #include <cassert> |
---|
| 18 | |
---|
| 19 | #include "LinkageSpec.h" |
---|
[d3b7937] | 20 | #include "Common/SemanticError.h" |
---|
[51b7345] | 21 | |
---|
[ab57786] | 22 | LinkageSpec::Spec LinkageSpec::fromString( const std::string &spec ) { |
---|
| 23 | if ( spec == "\"Cforall\"" ) { |
---|
[b87a5ed] | 24 | return Cforall; |
---|
[ab57786] | 25 | } else if ( spec == "\"C\"" ) { |
---|
[b87a5ed] | 26 | return C; |
---|
| 27 | } else { |
---|
[ab57786] | 28 | throw SemanticError( "Invalid linkage specifier " + spec ); |
---|
| 29 | } // if |
---|
| 30 | delete &spec; // allocated by lexer |
---|
[51b7345] | 31 | } |
---|
| 32 | |
---|
[8b7ee09] | 33 | std::string LinkageSpec::toString( LinkageSpec::Spec linkage ) { |
---|
| 34 | static const char *linkageKinds[LinkageSpec::NoOfSpecs] = { |
---|
[3b8e52c] | 35 | "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in", |
---|
| 36 | }; |
---|
| 37 | return linkageKinds[linkage]; |
---|
[51b7345] | 38 | } |
---|
| 39 | |
---|
[ab57786] | 40 | bool LinkageSpec::isDecoratable( Spec spec ) { |
---|
[8b7ee09] | 41 | static bool decoratable[LinkageSpec::NoOfSpecs] = { |
---|
[3b8e52c] | 42 | // Intrinsic, Cforall, C, AutoGen, Compiler |
---|
| 43 | true, true, false, true, false, |
---|
| 44 | }; |
---|
[ab57786] | 45 | return decoratable[spec]; |
---|
[51b7345] | 46 | } |
---|
| 47 | |
---|
[ab57786] | 48 | bool LinkageSpec::isGeneratable( Spec spec ) { |
---|
[8b7ee09] | 49 | static bool generatable[LinkageSpec::NoOfSpecs] = { |
---|
[3b8e52c] | 50 | // Intrinsic, Cforall, C, AutoGen, Compiler |
---|
| 51 | true, true, true, true, false, |
---|
| 52 | }; |
---|
[ab57786] | 53 | return generatable[spec]; |
---|
[51b7345] | 54 | } |
---|
| 55 | |
---|
[ab57786] | 56 | bool LinkageSpec::isOverridable( Spec spec ) { |
---|
[8b7ee09] | 57 | static bool overridable[LinkageSpec::NoOfSpecs] = { |
---|
[3b8e52c] | 58 | // Intrinsic, Cforall, C, AutoGen, Compiler |
---|
| 59 | true, false, false, true, false, |
---|
| 60 | }; |
---|
[ab57786] | 61 | return overridable[spec]; |
---|
[4aa0858] | 62 | } |
---|
| 63 | |
---|
[ab57786] | 64 | bool LinkageSpec::isBuiltin( Spec spec ) { |
---|
[8b7ee09] | 65 | static bool builtin[LinkageSpec::NoOfSpecs] = { |
---|
[3b8e52c] | 66 | // Intrinsic, Cforall, C, AutoGen, Compiler |
---|
| 67 | true, false, false, false, true, |
---|
| 68 | }; |
---|
[ab57786] | 69 | return builtin[spec]; |
---|
[51b7345] | 70 | } |
---|
[b87a5ed] | 71 | |
---|
| 72 | // Local Variables: // |
---|
| 73 | // tab-width: 4 // |
---|
| 74 | // mode: c++ // |
---|
| 75 | // compile-command: "make install" // |
---|
| 76 | // End: // |
---|