Changes in src/SymTab/Autogen.h [b95fe40:837ce06]
- File:
-
- 1 edited
-
src/SymTab/Autogen.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.h
rb95fe40 r837ce06 45 45 extern FunctionDecl * dereferenceOperator; 46 46 47 // generate the type of an assignment function for paramType 48 FunctionType * genAssignType( Type * paramType ); 49 50 // generate the type of a default constructor or destructor for paramType 51 FunctionType * genDefaultType( Type * paramType ); 52 53 // generate the type of a copy constructor for paramType 54 FunctionType * genCopyType( Type * paramType ); 47 /// generate the type of an assignment function for paramType. 48 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 49 FunctionType * genAssignType( Type * paramType, bool maybePolymorphic = true ); 50 51 /// generate the type of a default constructor or destructor for paramType. 52 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 53 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic = true ); 54 55 /// generate the type of a copy constructor for paramType. 56 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 57 FunctionType * genCopyType( Type * paramType, bool maybePolymorphic = true ); 55 58 56 59 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. 57 60 template< typename OutputIterator > 58 Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, Type * addCast = nullptr, bool forward = true );61 Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true ); 59 62 60 63 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types. 61 64 /// optionally returns a statement which must be inserted prior to the containing loop, if there is one 62 65 template< typename OutputIterator > 63 Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression * dstParam, std::string fname, OutputIterator out, Type * type, Type * addCast = nullptr) {66 Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression * dstParam, std::string fname, OutputIterator out, Type * type, bool addCast = false ) { 64 67 bool isReferenceCtorDtor = false; 65 68 if ( dynamic_cast< ReferenceType * >( type ) && CodeGen::isCtorDtor( fname ) ) { … … 68 71 fname = "?=?"; 69 72 dstParam = new AddressExpr( dstParam ); 70 addCast = nullptr;73 addCast = false; 71 74 isReferenceCtorDtor = true; 72 75 } … … 83 86 // remove lvalue as a qualifier, this can change to 84 87 // type->get_qualifiers() = Type::Qualifiers(); 85 Type * castType = addCast->clone(); 88 assert( type ); 89 Type * castType = type->clone(); 86 90 castType->get_qualifiers() -= Type::Qualifiers( Type::Lvalue | Type::Const | Type::Volatile | Type::Restrict | Type::Atomic ); 87 91 // castType->set_lvalue( true ); // xxx - might not need this … … 114 118 /// If forward is true, loop goes from 0 to N-1, else N-1 to 0 115 119 template< typename OutputIterator > 116 void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, Type * addCast = nullptr, bool forward = true ) {120 void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) { 117 121 static UniqueName indexName( "_index" ); 118 122 119 123 // for a flexible array member nothing is done -- user must define own assignment 120 if ( ! array->get_dimension() ) return; 121 122 if ( addCast ) { 123 // peel off array layer from cast 124 ArrayType * at = strict_dynamic_cast< ArrayType * >( addCast ); 125 addCast = at->base; 126 } 124 if ( ! array->get_dimension() ) return ; 127 125 128 126 Expression * begin, * end, * update, * cmp; … … 176 174 177 175 template< typename OutputIterator > 178 Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, Type *addCast, bool forward ) {176 Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) { 179 177 if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) { 180 178 genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward ); … … 196 194 if ( isUnnamedBitfield( obj ) ) return; 197 195 198 Type * addCast = nullptr; 199 if ( (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && ! obj->get_bitfieldWidth() ) ) ) { 200 assert( dstParam->result ); 201 addCast = dstParam->result; 202 } 196 bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && ! obj->get_bitfieldWidth() ) ); 203 197 std::list< Statement * > stmts; 204 198 genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->type, addCast, forward );
Note:
See TracChangeset
for help on using the changeset viewer.