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