Changeset 0dd9a5e for src/ResolvExpr
- Timestamp:
- Nov 10, 2020, 3:14:14 AM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3ff4c1e
- Parents:
- 18f0b70
- Location:
- src/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/ResolveTypeof.cc
r18f0b70 r0dd9a5e 165 165 } 166 166 167 struct FixArrayDimension { 168 // should not require a mutable symbol table - prevent pass template instantiation 169 const ast::SymbolTable & _symtab; 170 FixArrayDimension(const ast::SymbolTable & symtab): _symtab(symtab) {} 171 172 const ast::ArrayType * previsit (const ast::ArrayType * arrayType) { 173 if (!arrayType->dimension) return arrayType; 174 auto mutType = mutate(arrayType); 175 ast::ptr<ast::Type> sizetype = ast::sizeType ? ast::sizeType : new ast::BasicType(ast::BasicType::LongUnsignedInt); 176 mutType->dimension = findSingleExpression(arrayType->dimension, sizetype, _symtab); 177 178 if (InitTweak::isConstExpr(mutType->dimension)) { 179 mutType->isVarLen = ast::LengthFlag::FixedLen; 180 } 181 else { 182 mutType->isVarLen = ast::LengthFlag::VariableLen; 183 } 184 return mutType; 185 } 186 }; 187 188 const ast::Type * fixArrayType( const ast::Type * type, const ast::SymbolTable & symtab) { 189 ast::Pass<FixArrayDimension> visitor {symtab}; 190 return type->accept(visitor); 191 } 192 167 193 const ast::ObjectDecl * fixObjectType( const ast::ObjectDecl * decl , const ast::SymbolTable & symtab ) { 168 194 if (!decl->isTypeFixed) { 169 195 auto mutDecl = mutate(decl); 170 196 auto resolvedType = resolveTypeof(decl->type, symtab); 197 resolvedType = fixArrayType(resolvedType, symtab); 171 198 mutDecl->type = resolvedType; 172 199 173 200 // check variable length if object is an array. 174 201 // xxx - should this be part of fixObjectType? 202 203 /* 175 204 if (auto arrayType = dynamic_cast<const ast::ArrayType *>(resolvedType)) { 205 auto dimExpr = findSingleExpression(arrayType->dimension, ast::sizeType, symtab); 176 206 if (auto varexpr = arrayType->dimension.as<ast::VariableExpr>()) {// hoisted previously 177 207 if (InitTweak::isConstExpr(varexpr->var.strict_as<ast::ObjectDecl>()->init)) { … … 182 212 } 183 213 } 214 */ 215 184 216 185 217 if (!mutDecl->name.empty()) -
src/ResolvExpr/Resolver.cc
r18f0b70 r0dd9a5e 1289 1289 void beginScope() { managedTypes.beginScope(); } 1290 1290 void endScope() { managedTypes.endScope(); } 1291 bool onError(ast::ptr<ast::Decl> & decl); 1291 1292 }; 1292 1293 // size_t Resolver_new::traceId = Stats::Heap::new_stacktrace_id("Resolver"); … … 2066 2067 } 2067 2068 2069 // suppress error on autogen functions and mark invalid autogen as deleted. 2070 bool Resolver_new::onError(ast::ptr<ast::Decl> & decl) { 2071 if (auto functionDecl = decl.as<ast::FunctionDecl>()) { 2072 // xxx - can intrinsic gen ever fail? 2073 if (functionDecl->linkage == ast::Linkage::AutoGen) { 2074 auto mutDecl = mutate(functionDecl); 2075 mutDecl->isDeleted = true; 2076 mutDecl->stmts = nullptr; 2077 decl = mutDecl; 2078 return false; 2079 } 2080 } 2081 return true; 2082 } 2083 2068 2084 } // namespace ResolvExpr 2069 2085
Note: See TracChangeset
for help on using the changeset viewer.