Changeset eef8dfb for src/SymTab/Autogen.h
- Timestamp:
- Jan 7, 2021, 2:55:57 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 58fe85a
- Parents:
- bdfc032 (diff), 44e37ef (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.h
rbdfc032 reef8dfb 21 21 22 22 #include "AST/Decl.hpp" 23 #include "AST/Eval.hpp" 23 24 #include "AST/Expr.hpp" 24 25 #include "AST/Init.hpp" … … 54 55 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 55 56 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic = true ); 57 58 ast::FunctionDecl * genDefaultFunc(const CodeLocation loc, const std::string fname, const ast::Type * paramType, bool maybePolymorphic = true); 56 59 57 60 /// generate the type of a copy constructor for paramType. … … 164 167 fExpr->args.emplace_back( dstParam ); 165 168 166 const ast::Stmt *listInit = srcParam.buildListInit( fExpr );169 ast::ptr<ast::Stmt> listInit = srcParam.buildListInit( fExpr ); 167 170 168 171 // fetch next set of arguments … … 265 268 } 266 269 267 ast::ptr< ast::Expr > begin, end, cmp, update; 270 ast::ptr< ast::Expr > begin, end; 271 std::string cmp, update; 268 272 269 273 if ( forward ) { … … 271 275 begin = ast::ConstantExpr::from_int( loc, 0 ); 272 276 end = array->dimension; 273 cmp = new ast::NameExpr{ loc, "?<?" };274 update = new ast::NameExpr{ loc, "++?" };277 cmp = "?<?"; 278 update = "++?"; 275 279 } else { 276 280 // generate: for ( int i = N-1; i >= 0; --i ) 277 begin = new ast::UntypedExpr{ 278 loc, new ast::NameExpr{ loc, "?-?" }, 279 { array->dimension, ast::ConstantExpr::from_int( loc, 1 ) } }; 281 begin = ast::call( 282 loc, "?-?", array->dimension, ast::ConstantExpr::from_int( loc, 1 ) ); 280 283 end = ast::ConstantExpr::from_int( loc, 0 ); 281 cmp = new ast::NameExpr{ loc, "?>=?" };282 update = new ast::NameExpr{ loc, "--?" };284 cmp = "?>=?"; 285 update = "--?"; 283 286 } 284 287 … … 286 289 loc, indexName.newName(), new ast::BasicType{ ast::BasicType::SignedInt }, 287 290 new ast::SingleInit{ loc, begin } }; 288 289 ast::ptr< ast::Expr > cond = new ast::UntypedExpr{ 290 loc, cmp, { new ast::VariableExpr{ loc, index }, end } }; 291 292 ast::ptr< ast::Expr > inc = new ast::UntypedExpr{ 293 loc, update, { new ast::VariableExpr{ loc, index } } }; 294 295 ast::ptr< ast::Expr > dstIndex = new ast::UntypedExpr{ 296 loc, new ast::NameExpr{ loc, "?[?]" }, 297 { dstParam, new ast::VariableExpr{ loc, index } } }; 291 ast::ptr< ast::Expr > indexVar = new ast::VariableExpr{ loc, index }; 292 293 ast::ptr< ast::Expr > cond = ast::call( loc, cmp, indexVar, end ); 294 295 ast::ptr< ast::Expr > inc = ast::call( loc, update, indexVar ); 296 297 ast::ptr< ast::Expr > dstIndex = ast::call( loc, "?[?]", dstParam, indexVar ); 298 298 299 299 // srcParam must keep track of the array indices to build the source parameter and/or 300 300 // array list initializer 301 srcParam.addArrayIndex( new ast::VariableExpr{ loc, index }, array->dimension );301 srcParam.addArrayIndex( indexVar, array->dimension ); 302 302 303 303 // for stmt's body, eventually containing call … … 385 385 if ( isUnnamedBitfield( obj ) ) return {}; 386 386 387 ast::ptr< ast::Type > addCast = nullptr;387 ast::ptr< ast::Type > addCast; 388 388 if ( (fname == "?{}" || fname == "^?{}") && ( ! obj || ( obj && ! obj->bitfieldWidth ) ) ) { 389 389 assert( dstParam->result );
Note:
See TracChangeset
for help on using the changeset viewer.