source: src/Parser/LinkageSpec.cc@ 262f085f

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 262f085f was faddbd8, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

more refactoring of parser code, new tuple syntax

  • Property mode set to 100644
File size: 2.3 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 : Peter A. Buhr
12// Last Modified On : Sun Oct 2 23:16:21 2016
13// Update Count : 23
14//
15
16#include <memory>
17#include <string>
18#include <cassert>
19using namespace std;
20
21#include "LinkageSpec.h"
22#include "Common/SemanticError.h"
23
24LinkageSpec::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 {
31 throw SemanticError( "Invalid linkage specifier " + *spec );
32 } // if
33}
34
35string LinkageSpec::linkageName( LinkageSpec::Spec linkage ) {
36 assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs );
37 static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
38 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in",
39 };
40 return linkageKinds[linkage];
41}
42
43bool LinkageSpec::isDecoratable( Spec spec ) {
44 assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
45 static bool decoratable[LinkageSpec::NoOfSpecs] = {
46 // Intrinsic, Cforall, C, AutoGen, Compiler
47 true, true, false, true, false,
48 };
49 return decoratable[spec];
50}
51
52bool LinkageSpec::isGeneratable( Spec spec ) {
53 assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
54 static bool generatable[LinkageSpec::NoOfSpecs] = {
55 // Intrinsic, Cforall, C, AutoGen, Compiler
56 true, true, true, true, false,
57 };
58 return generatable[spec];
59}
60
61bool LinkageSpec::isOverridable( Spec spec ) {
62 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
63 static bool overridable[LinkageSpec::NoOfSpecs] = {
64 // Intrinsic, Cforall, C, AutoGen, Compiler
65 true, false, false, true, false,
66 };
67 return overridable[spec];
68}
69
70bool LinkageSpec::isBuiltin( Spec spec ) {
71 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
72 static bool builtin[LinkageSpec::NoOfSpecs] = {
73 // Intrinsic, Cforall, C, AutoGen, Compiler
74 true, false, false, false, true,
75 };
76 return builtin[spec];
77}
78
79// Local Variables: //
80// tab-width: 4 //
81// mode: c++ //
82// compile-command: "make install" //
83// End: //
Note: See TracBrowser for help on using the repository browser.