| 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 : Andrew Beach
|
|---|
| 12 | // Last Modified On : Fri Jul 7 11:11:00 2017
|
|---|
| 13 | // Update Count : 25
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | #include <memory>
|
|---|
| 17 | #include <string>
|
|---|
| 18 | #include <cassert>
|
|---|
| 19 | using namespace std;
|
|---|
| 20 |
|
|---|
| 21 | #include "LinkageSpec.h"
|
|---|
| 22 | #include "Common/SemanticError.h"
|
|---|
| 23 |
|
|---|
| 24 | namespace LinkageSpec {
|
|---|
| 25 |
|
|---|
| 26 | Spec linkageCheck( CodeLocation location, const string * spec ) {
|
|---|
| 27 | assert( spec );
|
|---|
| 28 | unique_ptr<const string> guard( spec ); // allocated by lexer
|
|---|
| 29 | if ( *spec == "\"Cforall\"" ) {
|
|---|
| 30 | return Cforall;
|
|---|
| 31 | } else if ( *spec == "\"C\"" ) {
|
|---|
| 32 | return C;
|
|---|
| 33 | } else if ( *spec == "\"BuiltinC\"" ) {
|
|---|
| 34 | return BuiltinC;
|
|---|
| 35 | } else {
|
|---|
| 36 | SemanticError( location, "Invalid linkage specifier " + *spec );
|
|---|
| 37 | } // if
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | Spec linkageUpdate( CodeLocation location, Spec old_spec, const string * cmd ) {
|
|---|
| 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 {
|
|---|
| 50 | SemanticError( location, "Invalid linkage specifier " + *cmd );
|
|---|
| 51 | } // if
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | std::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 | }
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | } // LinkageSpec
|
|---|
| 76 |
|
|---|
| 77 | // Local Variables: //
|
|---|
| 78 | // tab-width: 4 //
|
|---|
| 79 | // mode: c++ //
|
|---|
| 80 | // compile-command: "make install" //
|
|---|
| 81 | // End: //
|
|---|