Ignore:
Timestamp:
Mar 21, 2022, 1:44:06 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
a76202d
Parents:
ef3c383 (diff), dbe2533 (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ResolveTypeof.cc

    ref3c383 rd672350  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:12:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 16:49:04 2015
    13 // Update Count     : 3
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Mar 16 16:09:00 2022
     13// Update Count     : 4
    1414//
    1515
     
    2222#include "AST/Node.hpp"
    2323#include "AST/Pass.hpp"
     24#include "AST/TranslationUnit.hpp"
    2425#include "AST/Type.hpp"
    2526#include "AST/TypeEnvironment.hpp"
     
    119120namespace {
    120121        struct ResolveTypeof_new : public ast::WithShortCircuiting {
    121                 const ast::SymbolTable & localSymtab;
    122 
    123                 ResolveTypeof_new( const ast::SymbolTable & syms ) : localSymtab( syms ) {}
     122                const ResolveContext & context;
     123
     124                ResolveTypeof_new( const ResolveContext & context ) :
     125                        context( context ) {}
    124126
    125127                void previsit( const ast::TypeofType * ) { visit_children = false; }
     
    137139                                ast::TypeEnvironment dummy;
    138140                                ast::ptr< ast::Expr > newExpr =
    139                                         resolveInVoidContext( typeofType->expr, localSymtab, dummy );
     141                                        resolveInVoidContext( typeofType->expr, context, dummy );
    140142                                assert( newExpr->result && ! newExpr->result->isVoid() );
    141143                                newType = newExpr->result;
     
    161163} // anonymous namespace
    162164
    163 const ast::Type * resolveTypeof( const ast::Type * type , const ast::SymbolTable & symtab ) {
    164         ast::Pass< ResolveTypeof_new > mutator{ symtab };
     165const ast::Type * resolveTypeof( const ast::Type * type , const ResolveContext & context ) {
     166        ast::Pass< ResolveTypeof_new > mutator( context );
    165167        return type->accept( mutator );
    166168}
     
    168170struct FixArrayDimension {
    169171        // should not require a mutable symbol table - prevent pass template instantiation
    170         const ast::SymbolTable & _symtab;
    171         FixArrayDimension(const ast::SymbolTable & symtab): _symtab(symtab) {}
     172        const ResolveContext & context;
     173        FixArrayDimension(const ResolveContext & context) : context( context ) {}
    172174
    173175        const ast::ArrayType * previsit (const ast::ArrayType * arrayType) {
    174176                if (!arrayType->dimension) return arrayType;
    175177                auto mutType = mutate(arrayType);
    176                 ast::ptr<ast::Type> sizetype = ast::sizeType ? ast::sizeType : new ast::BasicType(ast::BasicType::LongUnsignedInt);
    177                 mutType->dimension = findSingleExpression(arrayType->dimension, sizetype, _symtab);
     178                auto globalSizeType = context.global.sizeType;
     179                ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType(ast::BasicType::LongUnsignedInt);
     180                mutType->dimension = findSingleExpression(arrayType->dimension, sizetype, context );
    178181
    179182                if (InitTweak::isConstExpr(mutType->dimension)) {
     
    187190};
    188191
    189 const ast::Type * fixArrayType( const ast::Type * type, const ast::SymbolTable & symtab) {
    190         ast::Pass<FixArrayDimension> visitor {symtab};
     192const ast::Type * fixArrayType( const ast::Type * type, const ResolveContext & context ) {
     193        ast::Pass<FixArrayDimension> visitor(context);
    191194        return type->accept(visitor);
    192195}
    193196
    194 const ast::ObjectDecl * fixObjectType( const ast::ObjectDecl * decl , const ast::SymbolTable & symtab ) {
    195         if (!decl->isTypeFixed) { 
     197const ast::ObjectDecl * fixObjectType( const ast::ObjectDecl * decl , const ResolveContext & context ) {
     198        if (!decl->isTypeFixed) {
    196199                auto mutDecl = mutate(decl);
    197                 auto resolvedType = resolveTypeof(decl->type, symtab);
    198                 resolvedType = fixArrayType(resolvedType, symtab);
     200                auto resolvedType = resolveTypeof(decl->type, context);
     201                resolvedType = fixArrayType(resolvedType, context);
    199202                mutDecl->type = resolvedType;
    200203
Note: See TracChangeset for help on using the changeset viewer.