source: src/Parser/LinkageSpec.cc@ 2acf5fc

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox memory 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 2acf5fc was ab57786, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

more refactoring of parser code

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[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
[3b8e52c]11// Last Modified By : Peter A. Buhr
[ab57786]12// Last Modified On : Sun Aug 21 12:32:53 2016
13// Update Count : 17
[b87a5ed]14//
15
[51b73452]16#include <string>
17#include <cassert>
18
19#include "LinkageSpec.h"
[d3b7937]20#include "Common/SemanticError.h"
[51b73452]21
[ab57786]22LinkageSpec::Spec LinkageSpec::fromString( const std::string &spec ) {
23 if ( spec == "\"Cforall\"" ) {
[b87a5ed]24 return Cforall;
[ab57786]25 } else if ( spec == "\"C\"" ) {
[b87a5ed]26 return C;
27 } else {
[ab57786]28 throw SemanticError( "Invalid linkage specifier " + spec );
29 } // if
30 delete &spec; // allocated by lexer
[51b73452]31}
32
[8b7ee09]33std::string LinkageSpec::toString( LinkageSpec::Spec linkage ) {
34 static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
[3b8e52c]35 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in",
36 };
37 return linkageKinds[linkage];
[51b73452]38}
39
[ab57786]40bool LinkageSpec::isDecoratable( Spec spec ) {
[8b7ee09]41 static bool decoratable[LinkageSpec::NoOfSpecs] = {
[3b8e52c]42 // Intrinsic, Cforall, C, AutoGen, Compiler
43 true, true, false, true, false,
44 };
[ab57786]45 return decoratable[spec];
[51b73452]46}
47
[ab57786]48bool LinkageSpec::isGeneratable( Spec spec ) {
[8b7ee09]49 static bool generatable[LinkageSpec::NoOfSpecs] = {
[3b8e52c]50 // Intrinsic, Cforall, C, AutoGen, Compiler
51 true, true, true, true, false,
52 };
[ab57786]53 return generatable[spec];
[51b73452]54}
55
[ab57786]56bool LinkageSpec::isOverridable( Spec spec ) {
[8b7ee09]57 static bool overridable[LinkageSpec::NoOfSpecs] = {
[3b8e52c]58 // Intrinsic, Cforall, C, AutoGen, Compiler
59 true, false, false, true, false,
60 };
[ab57786]61 return overridable[spec];
[4aa0858]62}
63
[ab57786]64bool LinkageSpec::isBuiltin( Spec spec ) {
[8b7ee09]65 static bool builtin[LinkageSpec::NoOfSpecs] = {
[3b8e52c]66 // Intrinsic, Cforall, C, AutoGen, Compiler
67 true, false, false, false, true,
68 };
[ab57786]69 return builtin[spec];
[51b73452]70}
[b87a5ed]71
72// Local Variables: //
73// tab-width: 4 //
74// mode: c++ //
75// compile-command: "make install" //
76// End: //
Note: See TracBrowser for help on using the repository browser.