Changeset a56d544 for src


Ignore:
Timestamp:
Feb 14, 2026, 10:38:00 PM (5 days ago)
Author:
Matthew Au-Yeung <mw2auyeu@…>
Branches:
stuck-waitfor-destruct
Children:
7e8c071
Parents:
c9d36b1
git-author:
Matthew Au-Yeung <mw2auyeu@…> (02/14/26 22:30:32)
git-committer:
Matthew Au-Yeung <mw2auyeu@…> (02/14/26 22:38:00)
Message:

cleanup and add tests

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    rc9d36b1 ra56d544  
    264264}
    265265
     266ConstantExpr * ConstantExpr::from_ulonglong( const CodeLocation & loc, unsigned long long i ) {
     267        return new ConstantExpr{
     268                loc, new BasicType{ BasicKind::LongLongUnsignedInt }, std::to_string( i ) + "ULL",
     269                (unsigned long long)i };
     270}
     271
    266272ConstantExpr * ConstantExpr::from_string( const CodeLocation & loc, const std::string & str ) {
    267273        const Type * charType = new BasicType( BasicKind::Char, ast::CV::Const );
  • src/AST/Expr.hpp

    rc9d36b1 ra56d544  
    464464        /// Generates an integer constant of the given unsigned long int.
    465465        static ConstantExpr * from_ulong( const CodeLocation & loc, unsigned long i );
     466        /// Generates an integer constant of the given unsigned long long int.
     467        static ConstantExpr * from_ulonglong( const CodeLocation & loc, unsigned long long i );
    466468        /// Generates a string constant from the given string (char type, unquoted string).
    467469        static ConstantExpr * from_string( const CodeLocation & loc, const std::string & string );
  • src/Concurrency/MutexFuncHash.hpp

    rc9d36b1 ra56d544  
    1818#include "AST/Decl.hpp"
    1919#include "AST/Expr.hpp"
    20 #include "AST/Type.hpp"
    2120#include "SymTab/Mangler.hpp"
    2221
     
    2726// since function pointers may differ for static inline functions.
    2827static inline uint64_t hashMangle( const ast::DeclWithType * decl ) {
    29         std::string name = Mangle::mangle( decl );
     28        std::string name = Mangle::mangleType( decl );
    3029        uint64_t hash = 14695981039346656037ULL; // FNV offset basis
    3130        for ( char c : name ) {
     
    3635}
    3736
    38 // Create a ConstantExpr for the hash with proper ULL suffix to avoid
    39 // C compiler warnings about large unsigned constants.
    40 static inline ast::ConstantExpr * hashMangleExpr(
    41                 const CodeLocation & location, const ast::DeclWithType * decl ) {
    42         uint64_t hash = hashMangle( decl );
    43         return new ast::ConstantExpr{
    44                 location,
    45                 new ast::BasicType{ ast::BasicKind::LongLongUnsignedInt },
    46                 std::to_string( hash ) + "ull",
    47                 (unsigned long long)hash };
     37// Create a ConstantExpr with the hash of the mangled name.
     38static inline ast::ConstantExpr * hashMangleExpr(
     39        const CodeLocation & location, const ast::DeclWithType * decl ) {
     40        return ast::ConstantExpr::from_ulonglong( location, hashMangle( decl ) );
    4841}
    4942
Note: See TracChangeset for help on using the changeset viewer.