Changes in src/SymTab/Autogen.h [16ba4a6f:07de76b]
- File:
-
- 1 edited
-
src/SymTab/Autogen.h (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.h
r16ba4a6f r07de76b 21 21 22 22 #include "AST/Decl.hpp" 23 #include "AST/Eval.hpp"24 23 #include "AST/Expr.hpp" 25 24 #include "AST/Init.hpp" … … 55 54 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 56 55 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);59 56 60 57 /// generate the type of a copy constructor for paramType. … … 167 164 fExpr->args.emplace_back( dstParam ); 168 165 169 ast::ptr<ast::Stmt>listInit = srcParam.buildListInit( fExpr );166 const ast::Stmt * listInit = srcParam.buildListInit( fExpr ); 170 167 171 168 // fetch next set of arguments … … 268 265 } 269 266 270 ast::ptr< ast::Expr > begin, end; 271 std::string cmp, update; 267 ast::ptr< ast::Expr > begin, end, cmp, update; 272 268 273 269 if ( forward ) { … … 275 271 begin = ast::ConstantExpr::from_int( loc, 0 ); 276 272 end = array->dimension; 277 cmp = "?<?";278 update = "++?";273 cmp = new ast::NameExpr{ loc, "?<?" }; 274 update = new ast::NameExpr{ loc, "++?" }; 279 275 } else { 280 276 // generate: for ( int i = N-1; i >= 0; --i ) 281 begin = ast::call( 282 loc, "?-?", array->dimension, ast::ConstantExpr::from_int( loc, 1 ) ); 277 begin = new ast::UntypedExpr{ 278 loc, new ast::NameExpr{ loc, "?-?" }, 279 { array->dimension, ast::ConstantExpr::from_int( loc, 1 ) } }; 283 280 end = ast::ConstantExpr::from_int( loc, 0 ); 284 cmp = "?>=?";285 update = "--?";281 cmp = new ast::NameExpr{ loc, "?>=?" }; 282 update = new ast::NameExpr{ loc, "--?" }; 286 283 } 287 284 … … 289 286 loc, indexName.newName(), new ast::BasicType{ ast::BasicType::SignedInt }, 290 287 new ast::SingleInit{ loc, begin } }; 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 ); 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 } } }; 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( indexVar, array->dimension );301 srcParam.addArrayIndex( new ast::VariableExpr{ loc, index }, 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 ;387 ast::ptr< ast::Type > addCast = nullptr; 388 388 if ( (fname == "?{}" || fname == "^?{}") && ( ! obj || ( obj && ! obj->bitfieldWidth ) ) ) { 389 389 assert( dstParam->result );
Note:
See TracChangeset
for help on using the changeset viewer.