source:
src/Parser/LinkageSpec.cc
@
a3e7d34
Last change on this file since a3e7d34 was d3b7937, checked in by , 9 years ago | |
---|---|
|
|
File size: 2.1 KB |
Rev | Line | |
---|---|---|
[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 | |
[4aa0858] | 11 | // Last Modified By : Rob Schluntz |
12 | // Last Modified On : Wed Aug 19 15:53:05 2015 | |
13 | // Update Count : 5 | |
[b87a5ed] | 14 | // |
15 | ||
[51b7345] | 16 | #include <string> |
17 | #include <cassert> | |
18 | ||
19 | #include "LinkageSpec.h" | |
[d3b7937] | 20 | #include "Common/SemanticError.h" |
[51b7345] | 21 | |
[3848e0e] | 22 | LinkageSpec::Type LinkageSpec::fromString( const std::string &stringSpec ) { |
[b87a5ed] | 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 | } | |
[51b7345] | 30 | } |
31 | ||
[3848e0e] | 32 | std::string LinkageSpec::toString( LinkageSpec::Type linkage ) { |
[b87a5ed] | 33 | switch ( linkage ) { |
34 | case Intrinsic: | |
35 | return "intrinsic"; | |
36 | case Cforall: | |
37 | return "Cforall"; | |
38 | case C: | |
39 | return "C"; | |
40 | case AutoGen: | |
41 | return "automatically generated"; | |
42 | case Compiler: | |
43 | return "compiler built-in"; | |
44 | } | |
45 | assert( false ); | |
46 | return ""; | |
[51b7345] | 47 | } |
48 | ||
[3848e0e] | 49 | bool LinkageSpec::isDecoratable( Type t ) { |
[b87a5ed] | 50 | switch ( t ) { |
51 | case Intrinsic: | |
52 | case Cforall: | |
53 | case AutoGen: | |
54 | return true; | |
55 | case C: | |
56 | case Compiler: | |
57 | return false; | |
58 | } | |
59 | assert( false ); | |
[3848e0e] | 60 | return false; |
[51b7345] | 61 | } |
62 | ||
[3848e0e] | 63 | bool LinkageSpec::isGeneratable( Type t ) { |
[b87a5ed] | 64 | switch ( t ) { |
65 | case Intrinsic: | |
66 | case Cforall: | |
67 | case AutoGen: | |
68 | case C: | |
69 | return true; | |
70 | case Compiler: | |
71 | return false; | |
72 | } | |
73 | assert( false ); | |
[3848e0e] | 74 | return false; |
[51b7345] | 75 | } |
76 | ||
[3848e0e] | 77 | bool LinkageSpec::isOverloadable( Type t ) { |
[b87a5ed] | 78 | return isDecoratable( t ); |
[51b7345] | 79 | } |
80 | ||
[4aa0858] | 81 | |
82 | bool LinkageSpec::isOverridable( Type t ) { | |
83 | switch ( t ) { | |
84 | case Intrinsic: | |
85 | case AutoGen: | |
86 | return true; | |
87 | case Cforall: | |
88 | case C: | |
89 | case Compiler: | |
90 | return false; | |
91 | } | |
92 | assert( false ); | |
93 | return false; | |
94 | } | |
95 | ||
[3848e0e] | 96 | bool LinkageSpec::isBuiltin( Type t ) { |
[b87a5ed] | 97 | switch ( t ) { |
98 | case Cforall: | |
99 | case AutoGen: | |
100 | case C: | |
101 | return false; | |
102 | case Intrinsic: | |
103 | case Compiler: | |
104 | return true; | |
105 | } | |
106 | assert( false ); | |
[3848e0e] | 107 | return false; |
[51b7345] | 108 | } |
[b87a5ed] | 109 | |
110 | // Local Variables: // | |
111 | // tab-width: 4 // | |
112 | // mode: c++ // | |
113 | // compile-command: "make install" // | |
114 | // End: // |
Note: See TracBrowser
for help on using the repository browser.