ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 65cdc1e was
54d714e,
checked in by Andrew Beach <ajbeach@…>, 7 years ago
|
Re-worked LinkageSpec?. It has almost exactly the same interface but now uses flags instead of a list of specs.
|
-
Property mode set to
100644
|
File size:
1.9 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 : Andrew Beach |
---|
12 | // Last Modified On : Fri Jul 7 11:11:00 2017 |
---|
13 | // Update Count : 25 |
---|
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 | namespace LinkageSpec { |
---|
25 | |
---|
26 | Spec linkageCheck( const string * spec ) { |
---|
27 | assert( spec ); |
---|
28 | unique_ptr<const string> guard( spec ); // allocated by lexer |
---|
29 | if ( *spec == "\"Cforall\"" ) { |
---|
30 | return Cforall; |
---|
31 | } else if ( *spec == "\"C\"" ) { |
---|
32 | return C; |
---|
33 | } else if ( *spec == "\"BuiltinC\"" ) { |
---|
34 | return BuiltinC; |
---|
35 | } else { |
---|
36 | throw SemanticError( "Invalid linkage specifier " + *spec ); |
---|
37 | } // if |
---|
38 | } |
---|
39 | |
---|
40 | Spec linkageUpdate( Spec old_spec, const string * cmd ) { |
---|
41 | assert( cmd ); |
---|
42 | unique_ptr<const string> guard( cmd ); // allocated by lexer |
---|
43 | if ( *cmd == "\"Cforall\"" ) { |
---|
44 | old_spec.is_mangled = true; |
---|
45 | return old_spec; |
---|
46 | } else if ( *cmd == "\"C\"" ) { |
---|
47 | old_spec.is_mangled = false; |
---|
48 | return old_spec; |
---|
49 | } else { |
---|
50 | throw SemanticError( "Invalid linkage specifier " + *cmd ); |
---|
51 | } // if |
---|
52 | } |
---|
53 | |
---|
54 | std::string linkageName( Spec linkage ) { |
---|
55 | switch ( linkage ) { |
---|
56 | case Intrinsic: |
---|
57 | return "intrinsic"; |
---|
58 | case C: |
---|
59 | return "C"; |
---|
60 | case Cforall: |
---|
61 | return "Cforall"; |
---|
62 | case AutoGen: |
---|
63 | return "autogenerated cfa"; |
---|
64 | case Compiler: |
---|
65 | return "compiler built-in"; |
---|
66 | case BuiltinCFA: |
---|
67 | return "cfa built-in"; |
---|
68 | case BuiltinC: |
---|
69 | return "c built-in"; |
---|
70 | default: |
---|
71 | return "<unnamed linkage spec>"; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | } // LinkageSpec |
---|
76 | |
---|
77 | // Local Variables: // |
---|
78 | // tab-width: 4 // |
---|
79 | // mode: c++ // |
---|
80 | // compile-command: "make install" // |
---|
81 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.