Changeset 21f0aa8 for src/Common


Ignore:
Timestamp:
Aug 17, 2017, 2:45:12 PM (7 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
6ac5223, e9145a3
Parents:
936e9f4
Message:

Seperated CodeLocation? out from the general utilities.

Location:
src/Common
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.h

    r936e9f4 r21f0aa8  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:18:59 2017
    13 // Update Count     : 6
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Aug 17 14:01:00 2017
     13// Update Count     : 7
    1414//
    1515
     
    2121#include <string>     // for string
    2222
    23 #include "utility.h"  // for CodeLocation, toString
     23#include "CodeLocation.h"  // for CodeLocation, toString
    2424
    2525struct error {
  • src/Common/utility.h

    r936e9f4 r21f0aa8  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:19:13 2017
    13 // Update Count     : 33
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Aug 17 11:38:00 2017
     13// Update Count     : 34
    1414//
    1515
     
    341341}
    342342
    343 struct CodeLocation {
    344         int linenumber;
    345         std::string filename;
    346 
    347         /// Create a new unset CodeLocation.
    348         CodeLocation()
    349                 : linenumber( -1 )
    350                 , filename("")
    351         {}
    352 
    353         /// Create a new CodeLocation with the given values.
    354         CodeLocation( const char* filename, int lineno )
    355                 : linenumber( lineno )
    356                 , filename(filename ? filename : "")
    357         {}
    358 
    359         CodeLocation( const CodeLocation& rhs ) = default;
    360 
    361         bool isSet () const {
    362                 return -1 != linenumber;
    363         }
    364 
    365         bool isUnset () const {
    366                 return !isSet();
    367         }
    368 
    369         void unset () {
    370                 linenumber = -1;
    371                 filename = "";
    372         }
    373 
    374         // Use field access for set.
    375 };
    376 
    377 inline std::string to_string( const CodeLocation& location ) {
    378         return location.isSet() ? location.filename + ":" + std::to_string(location.linenumber) + " " : "";
    379 }
    380 
    381343// Local Variables: //
    382344// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.