source: src/Parser/LinkageSpec.cc @ f87408e

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since f87408e was ab57786, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

more refactoring of parser code

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[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]22LinkageSpec::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]33std::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]40bool 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]48bool 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]56bool 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]64bool 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: //
Note: See TracBrowser for help on using the repository browser.