Ignore:
Timestamp:
Oct 5, 2016, 2:29:13 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
d58a39a0
Parents:
4b1fd2c
Message:

more refactoring of parser code, new tuple syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/LinkageSpec.cc

    r4b1fd2c rfaddbd8  
    1010// Created On       : Sat May 16 13:22:09 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 21 12:32:53 2016
    13 // Update Count     : 17
     12// Last Modified On : Sun Oct  2 23:16:21 2016
     13// Update Count     : 23
    1414//
    1515
     
    1717#include <string>
    1818#include <cassert>
     19using namespace std;
    1920
    2021#include "LinkageSpec.h"
    2122#include "Common/SemanticError.h"
    2223
    23 LinkageSpec::Spec LinkageSpec::fromString( const std::string &spec ) {
    24         std::unique_ptr<const std::string> guard(&spec);                // allocated by lexer
    25         if ( spec == "\"Cforall\"" ) {
     24LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) {
     25        unique_ptr<const string> guard( spec ); // allocated by lexer
     26        if ( *spec == "\"Cforall\"" ) {
    2627                return Cforall;
    27         } else if ( spec == "\"C\"" ) {
     28        } else if ( *spec == "\"C\"" ) {
    2829                return C;
    2930        } else {
    30                 throw SemanticError( "Invalid linkage specifier " + spec );
     31                throw SemanticError( "Invalid linkage specifier " + *spec );
    3132        } // if
    3233}
    3334
    34 std::string LinkageSpec::toString( LinkageSpec::Spec linkage ) {
    35         assert( linkage >= 0 && linkage < LinkageSpec::NoOfSpecs );
     35string LinkageSpec::linkageName( LinkageSpec::Spec linkage ) {
     36        assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs );
    3637        static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
    3738                "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in",
     
    4142
    4243bool LinkageSpec::isDecoratable( Spec spec ) {
    43         assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
     44        assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    4445        static bool decoratable[LinkageSpec::NoOfSpecs] = {
    4546                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
     
    5051
    5152bool LinkageSpec::isGeneratable( Spec spec ) {
    52         assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
     53        assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    5354        static bool generatable[LinkageSpec::NoOfSpecs] = {
    5455                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
Note: See TracChangeset for help on using the changeset viewer.