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
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//
[79970ed]7// LinkageSpec.cc --
8//
[b87a5ed]9// Author : Rodolfo G. Esteves
10// Created On : Sat May 16 13:22:09 2015
[3b8e52c]11// Last Modified By : Peter A. Buhr
[faddbd8]12// Last Modified On : Sun Oct 2 23:16:21 2016
13// Update Count : 23
[79970ed]14//
[b87a5ed]15
[f2a4f6c]16#include <memory>
[51b73452]17#include <string>
18#include <cassert>
[faddbd8]19using namespace std;
[51b73452]20
21#include "LinkageSpec.h"
[d3b7937]22#include "Common/SemanticError.h"
[51b73452]23
[faddbd8]24LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) {
25 unique_ptr<const string> guard( spec ); // allocated by lexer
26 if ( *spec == "\"Cforall\"" ) {
[b87a5ed]27 return Cforall;
[faddbd8]28 } else if ( *spec == "\"C\"" ) {
[b87a5ed]29 return C;
30 } else {
[faddbd8]31 throw SemanticError( "Invalid linkage specifier " + *spec );
[ab57786]32 } // if
[51b73452]33}
34
[faddbd8]35string LinkageSpec::linkageName( LinkageSpec::Spec linkage ) {
36 assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs );
[8b7ee09]37 static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
[3b8e52c]38 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in",
39 };
40 return linkageKinds[linkage];
[51b73452]41}
42
[ab57786]43bool LinkageSpec::isDecoratable( Spec spec ) {
[faddbd8]44 assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
[8b7ee09]45 static bool decoratable[LinkageSpec::NoOfSpecs] = {
[3b8e52c]46 // Intrinsic, Cforall, C, AutoGen, Compiler
[79970ed]47 true, true, false, true, false,
[3b8e52c]48 };
[ab57786]49 return decoratable[spec];
[51b73452]50}
51
[ab57786]52bool LinkageSpec::isGeneratable( Spec spec ) {
[faddbd8]53 assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
[8b7ee09]54 static bool generatable[LinkageSpec::NoOfSpecs] = {
[3b8e52c]55 // Intrinsic, Cforall, C, AutoGen, Compiler
[79970ed]56 true, true, true, true, false,
[3b8e52c]57 };
[ab57786]58 return generatable[spec];
[51b73452]59}
60
[ab57786]61bool LinkageSpec::isOverridable( Spec spec ) {
[79970ed]62 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
[8b7ee09]63 static bool overridable[LinkageSpec::NoOfSpecs] = {
[3b8e52c]64 // Intrinsic, Cforall, C, AutoGen, Compiler
[79970ed]65 true, false, false, true, false,
[3b8e52c]66 };
[ab57786]67 return overridable[spec];
[4aa0858]68}
69
[ab57786]70bool LinkageSpec::isBuiltin( Spec spec ) {
[79970ed]71 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
[8b7ee09]72 static bool builtin[LinkageSpec::NoOfSpecs] = {
[3b8e52c]73 // Intrinsic, Cforall, C, AutoGen, Compiler
[79970ed]74 true, false, false, false, true,
[3b8e52c]75 };
[ab57786]76 return builtin[spec];
[51b73452]77}
[b87a5ed]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.