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