[2bb4a01] | 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.hpp -- |
---|
| 8 | // |
---|
| 9 | // Author : Aaron B. Moss |
---|
| 10 | // Created On : Thu May 9 10:00:00 2019 |
---|
| 11 | // Last Modified By : Aaron B. Moss |
---|
| 12 | // Last Modified On : Thu May 9 10:00:00 2019 |
---|
| 13 | // Update Count : 1 |
---|
| 14 | // |
---|
| 15 | |
---|
| 16 | #include "LinkageSpec.hpp" |
---|
| 17 | |
---|
| 18 | #include <cassert> |
---|
| 19 | #include <memory> // for unique_ptr |
---|
| 20 | #include <string> |
---|
| 21 | |
---|
| 22 | #include "Common/CodeLocation.h" |
---|
| 23 | #include "Common/SemanticError.h" |
---|
| 24 | |
---|
| 25 | namespace ast { |
---|
| 26 | |
---|
[a300e4a] | 27 | namespace Linkage { |
---|
| 28 | |
---|
[260dad7] | 29 | Spec update( CodeLocation loc, Spec spec, const std::string * cmd ) { |
---|
| 30 | assert( cmd ); |
---|
| 31 | std::unique_ptr<const std::string> guard( cmd ); // allocated by lexer |
---|
| 32 | if ( *cmd == "\"Cforall\"" ) { |
---|
| 33 | spec.is_mangled = true; |
---|
| 34 | return spec; |
---|
| 35 | } else if ( *cmd == "\"C\"" ) { |
---|
| 36 | spec.is_mangled = false; |
---|
| 37 | return spec; |
---|
| 38 | } else { |
---|
| 39 | SemanticError( loc, "Invalid linkage specifier " + *cmd ); |
---|
[a300e4a] | 40 | } |
---|
[260dad7] | 41 | } |
---|
[a300e4a] | 42 | |
---|
[260dad7] | 43 | std::string name( Spec spec ) { |
---|
| 44 | switch ( spec.val ) { |
---|
| 45 | case Intrinsic.val: return "intrinsic"; |
---|
| 46 | case C.val: return "C"; |
---|
| 47 | case Cforall.val: return "Cforall"; |
---|
| 48 | case AutoGen.val: return "autogenerated cfa"; |
---|
| 49 | case Compiler.val: return "compiler built-in"; |
---|
| 50 | case BuiltinCFA.val: return "cfa built-in"; |
---|
| 51 | case BuiltinC.val: return "c built-in"; |
---|
| 52 | default: return "<unnamed linkage spec>"; |
---|
[2bb4a01] | 53 | } |
---|
[260dad7] | 54 | } |
---|
[14cebb7a] | 55 | |
---|
[a300e4a] | 56 | } |
---|
| 57 | |
---|
[2bb4a01] | 58 | } |
---|
| 59 | |
---|
| 60 | // Local Variables: // |
---|
| 61 | // tab-width: 4 // |
---|
| 62 | // mode: c++ // |
---|
| 63 | // compile-command: "make install" // |
---|
| 64 | // End: // |
---|