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
Line 
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 <string>
17#include <cassert>
18
19#include "LinkageSpec.h"
20#include "Common/SemanticError.h"
21
22LinkageSpec::Spec LinkageSpec::fromString( const std::string &spec ) {
23        if ( spec == "\"Cforall\"" ) {
24                return Cforall;
25        } else if ( spec == "\"C\"" ) {
26                return C;
27        } else {
28                throw SemanticError( "Invalid linkage specifier " + spec );
29        } // if
30        delete &spec;                                                                           // allocated by lexer
31}
32
33std::string LinkageSpec::toString( LinkageSpec::Spec linkage ) {
34        static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
35                "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in",
36        };
37        return linkageKinds[linkage];
38}
39
40bool LinkageSpec::isDecoratable( Spec spec ) {
41        static bool decoratable[LinkageSpec::NoOfSpecs] = {
42                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
43                        true,           true,           false,  true,           false, 
44        };
45        return decoratable[spec];
46}
47
48bool LinkageSpec::isGeneratable( Spec spec ) {
49        static bool generatable[LinkageSpec::NoOfSpecs] = {
50                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
51                        true,           true,           true,   true,           false, 
52        };
53        return generatable[spec];
54}
55
56bool LinkageSpec::isOverridable( Spec spec ) {
57        static bool overridable[LinkageSpec::NoOfSpecs] = {
58                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
59                        true,           false,          false,  true,           false, 
60        };
61        return overridable[spec];
62}
63
64bool LinkageSpec::isBuiltin( Spec spec ) {
65        static bool builtin[LinkageSpec::NoOfSpecs] = {
66                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
67                        true,           false,          false,  false,          true, 
68        };
69        return builtin[spec];
70}
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.