source: src/Parser/LinkageSpec.cc @ 1e8b02f5

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 1e8b02f5 was f2a4f6c, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

fixed memory leak in lexer

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