Ignore:
Timestamp:
Nov 10, 2020, 12:20:37 AM (4 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
18f0b70
Parents:
3febb2d
Message:

factor out resolver calls in pre-resolution stage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ResolveTypeof.cc

    r3febb2d r16ba4a6  
    2929#include "SynTree/Mutator.h"     // for Mutator
    3030#include "SynTree/Type.h"        // for TypeofType, Type
     31#include "SymTab/Mangler.h"
     32#include "InitTweak/InitTweak.h" // for isConstExpr
    3133
    3234namespace SymTab {
     
    163165}
    164166
     167const ast::ObjectDecl * fixObjectType( const ast::ObjectDecl * decl , const ast::SymbolTable & symtab ) {
     168        if (!decl->isTypeFixed) {
     169                auto mutDecl = mutate(decl);
     170                auto resolvedType = resolveTypeof(decl->type, symtab);
     171                mutDecl->type = resolvedType;
     172
     173                // check variable length if object is an array.
     174                // xxx - should this be part of fixObjectType?
     175                if (auto arrayType = dynamic_cast<const ast::ArrayType *>(resolvedType)) {
     176                        if (auto varexpr = arrayType->dimension.as<ast::VariableExpr>()) {// hoisted previously
     177                                if (InitTweak::isConstExpr(varexpr->var.strict_as<ast::ObjectDecl>()->init)) {
     178                                        auto mutType = mutate(arrayType);
     179                                        mutType->isVarLen = ast::LengthFlag::VariableLen;
     180                                        mutDecl->type = mutType;
     181                                }
     182                        }
     183                }
     184
     185                if (!mutDecl->name.empty())
     186                        mutDecl->mangleName = Mangle::mangle(mutDecl); // do not mangle unnamed variables
     187               
     188                mutDecl->isTypeFixed = true;
     189                return mutDecl;
     190        }
     191        return decl;
     192}
     193
    165194} // namespace ResolvExpr
    166195
Note: See TracChangeset for help on using the changeset viewer.