Changeset 1894e03


Ignore:
Timestamp:
Dec 2, 2021, 4:38:22 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
58b2638
Parents:
8157bde (diff), 56f519b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    r8157bde r1894e03  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 15 17:00:00 2019
    11 // Last Modified By : Peter A. Buhr
    12 // Created On       : Thr Jun 13 13:38:00 2019
    13 // Update Count     : 6
     11// Last Modified By : Andrew Beach
     12// Created On       : Tue Nov 30 14:23:00 2021
     13// Update Count     : 7
    1414//
    1515
     
    141141        /// The type of the address of a type.
    142142        /// Caller is responsible for managing returned memory
    143         Type * addrType( const Type * type ) {
    144                 if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * >( type ) ) {
    145                         return new ReferenceType{ addrType( refType->base ), refType->qualifiers };
     143        Type * addrType( const ptr<Type> & type ) {
     144                if ( auto refType = type.as< ReferenceType >() ) {
     145                        return new ReferenceType( addrType( refType->base ), refType->qualifiers );
    146146                } else {
    147                         return new PointerType{ type };
     147                        return new PointerType( type );
    148148                }
    149149        }
    150 }
    151 
    152 AddressExpr::AddressExpr( const CodeLocation & loc, const Expr * a ) : Expr( loc ), arg( a ) {
    153         if ( arg->result ) {
    154                 if ( arg->get_lvalue() ) {
    155                         // lvalue, retains all levels of reference, and gains a pointer inside the references
    156                         Type * res = addrType( arg->result );
    157                         result = res;
     150
     151        /// The type of the address of an expression.
     152        /// Caller is responsible for managing returned memory
     153        Type * addrExprType( const CodeLocation & loc, const Expr * arg ) {
     154                assert( arg );
     155                // If the expression's type is unknown, the address type is unknown.
     156                if ( nullptr == arg->result ) {
     157                        return nullptr;
     158                // An lvalue is transformed directly.
     159                } else if ( arg->get_lvalue() ) {
     160                        return addrType( arg->result );
     161                // Strip a layer of reference to "create" an lvalue expression.
     162                } else if ( auto refType = arg->result.as< ReferenceType >() ) {
     163                        return addrType( refType->base );
    158164                } else {
    159                         // taking address of non-lvalue, must be a reference, loses one layer of reference
    160                         if ( const ReferenceType * refType =
    161                                         dynamic_cast< const ReferenceType * >( arg->result.get() ) ) {
    162                                 Type * res = addrType( refType->base );
    163                                 result = res;
    164                         } else {
    165                                 SemanticError( loc, arg->result.get(),
    166                                         "Attempt to take address of non-lvalue expression: " );
    167                         }
     165                        SemanticError( loc, arg->result.get(),
     166                                "Attempt to take address of non-lvalue expression: " );
    168167                }
    169168        }
    170169}
     170
     171AddressExpr::AddressExpr( const CodeLocation & loc, const Expr * a ) :
     172        Expr( loc, addrExprType( loc, a ) ), arg( a )
     173{}
    171174
    172175// --- LabelAddressExpr
  • src/Concurrency/Keywords.h

    r8157bde r1894e03  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Keywords.h --
     7// Keywords.h -- Implement concurrency constructs from their keywords.
    88//
    99// Author           : Thierry Delisle
     
    1919
    2020class Declaration;
     21namespace ast {
     22        class TranslationUnit;
     23}
    2124
    2225namespace Concurrency {
     
    2427        void implementMutexFuncs( std::list< Declaration * > & translationUnit );
    2528        void implementThreadStarter( std::list< Declaration * > & translationUnit );
     29
     30/// Implement the sue-like keywords and the suspend keyword.
     31void implementKeywords( ast::TranslationUnit & translationUnit );
     32/// Implement the mutex parameters and mutex statement.
     33void implementMutex( ast::TranslationUnit & translationUnit );
     34/// Add the thread starter code to constructors.
     35void implementThreadStarter( ast::TranslationUnit & translationUnit );
    2636};
    2737
  • src/Concurrency/module.mk

    r8157bde r1894e03  
    1515###############################################################################
    1616
    17 SRC += Concurrency/Keywords.cc Concurrency/Keywords.h Concurrency/Waitfor.cc Concurrency/Waitfor.h
    18 SRCDEMANGLE += Concurrency/Keywords.cc
     17SRC_CONCURRENCY = \
     18        Concurrency/KeywordsNew.cpp \
     19        Concurrency/Keywords.cc
    1920
     21SRC += $(SRC_CONCURRENCY) \
     22        Concurrency/Keywords.h \
     23        Concurrency/Waitfor.cc \
     24        Concurrency/Waitfor.h
     25
     26SRCDEMANGLE += $(SRC_CONCURRENCY)
     27
  • src/Validate/module.mk

    r8157bde r1894e03  
    1616
    1717SRC_VALIDATE = \
     18        Validate/CompoundLiteral.cpp \
     19        Validate/CompoundLiteral.hpp \
    1820        Validate/HandleAttributes.cc \
    1921        Validate/HandleAttributes.h \
  • src/main.cc

    r8157bde r1894e03  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Nov 12 11:06:00 2021
    13 // Update Count     : 658
     12// Last Modified On : Tue Nov 30 10:25:00 2021
     13// Update Count     : 659
    1414//
    1515
     
    5050#include "Common/UnimplementedError.h"      // for UnimplementedError
    5151#include "Common/utility.h"                 // for deleteAll, filter, printAll
     52#include "Concurrency/Keywords.h"           // for implementMutex, implement...
    5253#include "Concurrency/Waitfor.h"            // for generateWaitfor
    5354#include "ControlStruct/ExceptDecl.h"       // for translateExcept
     
    7374#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
    7475#include "Validate/FindSpecialDecls.h"      // for findGlobalDecls
     76#include "Validate/CompoundLiteral.hpp"     // for handleCompoundLiterals
    7577#include "Validate/InitializerLength.hpp"   // for setLengthFromInitializer
    7678#include "Validate/LabelAddressFixer.hpp"   // for fixLabelAddresses
     
    325327                PASS( "Validate-C", SymTab::validate_C( translationUnit ) );
    326328                PASS( "Validate-D", SymTab::validate_D( translationUnit ) );
    327                 PASS( "Validate-E", SymTab::validate_E( translationUnit ) );
    328329
    329330                CodeTools::fillLocations( translationUnit );
     
    338339                        forceFillCodeLocations( transUnit );
    339340
     341                        PASS( "Implement Mutex", Concurrency::implementMutex( transUnit ) );
     342                        PASS( "Implement Thread Start", Concurrency::implementThreadStarter( transUnit ) );
     343                        PASS( "Compound Literal", Validate::handleCompoundLiterals( transUnit ) );
    340344                        PASS( "Set Length From Initializer", Validate::setLengthFromInitializer( transUnit ) );
    341345                        PASS( "Find Global Decls", Validate::findGlobalDecls( transUnit ) );
     
    402406                        translationUnit = convert( move( transUnit ) );
    403407                } else {
     408                        PASS( "Validate-E", SymTab::validate_E( translationUnit ) );
    404409                        PASS( "Validate-F", SymTab::validate_F( translationUnit ) );
    405410
Note: See TracChangeset for help on using the changeset viewer.