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