Changes in src/SymTab/Autogen.h [07de76b:490fb92e]
- File:
-
- 1 edited
-
src/SymTab/Autogen.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.h
r07de76b r490fb92e 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. … … 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.