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