source: src/Parser/LinkageSpec.cc @ 60ba456

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change on this file since 60ba456 was a16764a6, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Changed warning system to prepare for toggling warnings

  • Property mode set to 100644
File size: 1.9 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
[fa4805f]11// Last Modified By : Andrew Beach
[54d714e]12// Last Modified On : Fri Jul  7 11:11:00 2017
13// Update Count     : 25
[79970ed]14//
[b87a5ed]15
[f2a4f6c]16#include <memory>
[51b7345]17#include <string>
18#include <cassert>
[faddbd8]19using namespace std;
[51b7345]20
21#include "LinkageSpec.h"
[d3b7937]22#include "Common/SemanticError.h"
[51b7345]23
[54d714e]24namespace LinkageSpec {
25
[d55d7a6]26Spec linkageCheck( CodeLocation location, const string * spec ) {
[54d714e]27        assert( spec );
[faddbd8]28        unique_ptr<const string> guard( spec ); // allocated by lexer
29        if ( *spec == "\"Cforall\"" ) {
[b87a5ed]30                return Cforall;
[faddbd8]31        } else if ( *spec == "\"C\"" ) {
[b87a5ed]32                return C;
[fa4805f]33        } else if ( *spec == "\"BuiltinC\"" ) {
34                return BuiltinC;
[b87a5ed]35        } else {
[a16764a6]36                SemanticError( location, "Invalid linkage specifier " + *spec );
[ab57786]37        } // if
[51b7345]38}
39
[d55d7a6]40Spec linkageUpdate( CodeLocation location, Spec old_spec, const string * cmd ) {
[54d714e]41        assert( cmd );
42        unique_ptr<const string> guard( cmd ); // allocated by lexer
43        if ( *cmd == "\"Cforall\"" ) {
44                old_spec.is_mangled = true;
45                return old_spec;
46        } else if ( *cmd == "\"C\"" ) {
47                old_spec.is_mangled = false;
48                return old_spec;
49        } else {
[a16764a6]50                SemanticError( location, "Invalid linkage specifier " + *cmd );
[54d714e]51        } // if
[51b7345]52}
53
[54d714e]54std::string linkageName( Spec linkage ) {
55    switch ( linkage ) {
56    case Intrinsic:
57        return "intrinsic";
58    case C:
59        return "C";
60    case Cforall:
61        return "Cforall";
62    case AutoGen:
63        return "autogenerated cfa";
64    case Compiler:
65        return "compiler built-in";
66    case BuiltinCFA:
67        return "cfa built-in";
68    case BuiltinC:
69        return "c built-in";
70    default:
71        return "<unnamed linkage spec>";
72    }
[4aa0858]73}
74
[54d714e]75} // LinkageSpec
[b87a5ed]76
77// Local Variables: //
78// tab-width: 4 //
79// mode: c++ //
80// compile-command: "make install" //
81// End: //
Note: See TracBrowser for help on using the repository browser.