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 487845d7 was 54d714e, checked in by Andrew Beach <ajbeach@…>, 8 years ago |
Re-worked LinkageSpec. It has almost exactly the same interface but now uses flags instead of a list of specs.
|
-
Property mode
set to
100644
|
File size:
1.9 KB
|
Rev | Line | |
---|
[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>
|
---|
[51b73452] | 17 | #include <string>
|
---|
| 18 | #include <cassert>
|
---|
[faddbd8] | 19 | using namespace std;
|
---|
[51b73452] | 20 |
|
---|
| 21 | #include "LinkageSpec.h"
|
---|
[d3b7937] | 22 | #include "Common/SemanticError.h"
|
---|
[51b73452] | 23 |
|
---|
[54d714e] | 24 | namespace LinkageSpec {
|
---|
| 25 |
|
---|
| 26 | Spec linkageCheck( const string * spec ) {
|
---|
| 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 {
|
---|
[faddbd8] | 36 | throw SemanticError( "Invalid linkage specifier " + *spec );
|
---|
[ab57786] | 37 | } // if
|
---|
[51b73452] | 38 | }
|
---|
| 39 |
|
---|
[54d714e] | 40 | Spec linkageUpdate( 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 | throw SemanticError( "Invalid linkage specifier " + *cmd );
|
---|
| 51 | } // if
|
---|
[51b73452] | 52 | }
|
---|
| 53 |
|
---|
[54d714e] | 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 | }
|
---|
[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.