Changeset db0b3ce for src/GenPoly
- Timestamp:
- Dec 14, 2015, 4:28:46 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 5e92fee
- Parents:
- 56fcd77
- Location:
- src/GenPoly
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r56fcd77 rdb0b3ce 309 309 Type *concrete = env->lookup( tyParm->first ); 310 310 if ( concrete ) { 311 // TODO add alignment312 311 arg = appExpr->get_args().insert( arg, new SizeofExpr( concrete->clone() ) ); 312 arg++; 313 arg = appExpr->get_args().insert( arg, new AlignofExpr( concrete->clone() ) ); 313 314 arg++; 314 315 } else { … … 1008 1009 std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin(); 1009 1010 std::list< DeclarationWithType *> inferredParams; 1010 // TODO add alignment1011 1011 ObjectDecl *newObj = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ); 1012 1012 // ObjectDecl *newFunPtr = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ); 1013 1013 for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) { 1014 ObjectDecl * thisParm;1015 // add all size parameters to parameter list1014 ObjectDecl *sizeParm, *alignParm; 1015 // add all size and alignment parameters to parameter list 1016 1016 if ( (*tyParm)->get_kind() == TypeDecl::Any ) { 1017 thisParm = newObj->clone(); 1018 thisParm->set_name( (*tyParm)->get_name() ); 1019 last = funcType->get_parameters().insert( last, thisParm ); 1017 sizeParm = newObj->clone(); 1018 sizeParm->set_name( std::string("_sizeof_") + (*tyParm)->get_name() ); 1019 last = funcType->get_parameters().insert( last, sizeParm ); 1020 ++last; 1021 alignParm = newObj->clone(); 1022 alignParm->set_name( std::string("_alignof_") + (*tyParm)->get_name() ); 1023 last = funcType->get_parameters().insert( last, alignParm ); 1020 1024 ++last; 1021 1025 } -
src/GenPoly/ScrubTyVars.cc
r56fcd77 rdb0b3ce 13 13 // Update Count : 2 14 14 // 15 16 #include <string> 15 17 16 18 #include "GenPoly.h" … … 42 44 43 45 Expression * ScrubTyVars::mutate( SizeofExpr *szeof ) { 44 // sizeof( T ) => T parameter, which is the size of T46 // sizeof( T ) => _sizeof_T parameter, which is the size of T 45 47 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( szeof->get_type() ) ) { 46 Expression *expr = new NameExpr( typeInst->get_name() );48 Expression *expr = new NameExpr( std::string("_sizeof_") + typeInst->get_name() ); 47 49 return expr; 48 50 } else { 49 51 return Mutator::mutate( szeof ); 52 } // if 53 } 54 55 Expression * ScrubTyVars::mutate( AlignofExpr *algnof ) { 56 // alignof( T ) => _alignof_T parameter, which is the alignment of T 57 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( algnof->get_type() ) ) { 58 Expression *expr = new NameExpr( std::string("_alignof_") + typeInst->get_name() ); 59 return expr; 60 } else { 61 return Mutator::mutate( algnof ); 50 62 } // if 51 63 } -
src/GenPoly/ScrubTyVars.h
r56fcd77 rdb0b3ce 36 36 virtual Type* mutate( TypeInstType *typeInst ); 37 37 Expression* mutate( SizeofExpr *szeof ); 38 Expression* mutate( AlignofExpr *algnof ); 38 39 virtual Type* mutate( PointerType *pointer ); 39 40 private:
Note: See TracChangeset
for help on using the changeset viewer.