Changeset 20cba76
- Timestamp:
- Feb 2, 2018, 3:44:27 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- c20b0fea
- Parents:
- a33fdbe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
ra33fdbe r20cba76 988 988 989 989 Expression *Pass1::handleIntrinsics( ApplicationExpr *appExpr ) { 990 if ( VariableExpr *varExpr = dynamic_cast< VariableExpr *>( appExpr-> get_function()) ) {991 if ( varExpr-> get_var()->get_linkage()== LinkageSpec::Intrinsic ) {992 if ( varExpr-> get_var()->get_name()== "?[?]" ) {990 if ( VariableExpr *varExpr = dynamic_cast< VariableExpr *>( appExpr->function ) ) { 991 if ( varExpr->var->linkage == LinkageSpec::Intrinsic ) { 992 if ( varExpr->var->name == "?[?]" ) { 993 993 assert( appExpr->result ); 994 994 assert( appExpr->get_args().size() == 2 ); 995 Type *baseType1 = isPolyPtr( appExpr-> get_args().front()->get_result(), scopeTyVars, env );996 Type *baseType2 = isPolyPtr( appExpr-> get_args().back()->get_result(), scopeTyVars, env );995 Type *baseType1 = isPolyPtr( appExpr->args.front()->result, scopeTyVars, env ); 996 Type *baseType2 = isPolyPtr( appExpr->args.back()->result, scopeTyVars, env ); 997 997 assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers 998 998 UntypedExpr *ret = 0; … … 1555 1555 // only mutate member expressions for polymorphic types 1556 1556 int tyDepth; 1557 Type *objectType = hasPolyBase( memberExpr-> get_aggregate()->get_result(), scopeTyVars, &tyDepth );1557 Type *objectType = hasPolyBase( memberExpr->aggregate->result, scopeTyVars, &tyDepth ); 1558 1558 if ( ! objectType ) return memberExpr; 1559 1559 findGeneric( objectType ); // ensure layout for this type is available 1560 1560 1561 1561 // replace member expression with dynamically-computed layout expression 1562 Expression *newMemberExpr = 0;1562 Expression *newMemberExpr = nullptr; 1563 1563 if ( StructInstType *structType = dynamic_cast< StructInstType* >( objectType ) ) { 1564 1564 // look up offset index 1565 long i = findMember( memberExpr-> get_member(), structType->get_baseStruct()->get_members());1565 long i = findMember( memberExpr->member, structType->baseStruct->members ); 1566 1566 if ( i == -1 ) return memberExpr; 1567 1567 1568 1568 // replace member expression with pointer to base plus offset 1569 1569 UntypedExpr *fieldLoc = new UntypedExpr( new NameExpr( "?+?" ) ); 1570 Expression * aggr = memberExpr-> get_aggregate()->clone();1571 delete aggr-> get_env(); // xxx - there's a problem with keeping the env for some reason, so for now just get rid of it1572 aggr-> set_env( nullptr );1570 Expression * aggr = memberExpr->aggregate->clone(); 1571 delete aggr->env; // xxx - there's a problem with keeping the env for some reason, so for now just get rid of it 1572 aggr->env = nullptr; 1573 1573 fieldLoc->get_args().push_back( aggr ); 1574 1574 fieldLoc->get_args().push_back( makeOffsetIndex( objectType, i ) ); 1575 fieldLoc->set_result( memberExpr-> get_result()->clone() );1575 fieldLoc->set_result( memberExpr->result->clone() ); 1576 1576 newMemberExpr = fieldLoc; 1577 1577 } else if ( dynamic_cast< UnionInstType* >( objectType ) ) { 1578 1578 // union members are all at offset zero, so just use the aggregate expr 1579 Expression * aggr = memberExpr-> get_aggregate()->clone();1580 delete aggr-> get_env(); // xxx - there's a problem with keeping the env for some reason, so for now just get rid of it1581 aggr-> set_env( nullptr );1579 Expression * aggr = memberExpr->aggregate->clone(); 1580 delete aggr->env; // xxx - there's a problem with keeping the env for some reason, so for now just get rid of it 1581 aggr->env= nullptr; 1582 1582 newMemberExpr = aggr; 1583 newMemberExpr-> set_result( memberExpr->get_result()->clone());1583 newMemberExpr->result = memberExpr->result->clone(); 1584 1584 } else return memberExpr; 1585 1585 assert( newMemberExpr ); 1586 1586 1587 Type *memberType = memberExpr-> get_member()->get_type();1587 Type *memberType = memberExpr->member->get_type(); 1588 1588 if ( ! isPolyType( memberType, scopeTyVars ) ) { 1589 1589 // Not all members of a polymorphic type are themselves of polymorphic type; in this case the member expression should be wrapped and dereferenced to form an lvalue … … 1598 1598 1599 1599 ObjectDecl *PolyGenericCalculator::makeVar( const std::string &name, Type *type, Initializer *init ) { 1600 ObjectDecl *newObj = new ObjectDecl( name, Type::StorageClasses(), LinkageSpec::C, 0, type, init );1600 ObjectDecl *newObj = new ObjectDecl( name, Type::StorageClasses(), LinkageSpec::C, nullptr, type, init ); 1601 1601 stmtsToAddBefore.push_back( new DeclStmt( newObj ) ); 1602 1602 return newObj;
Note: See TracChangeset
for help on using the changeset viewer.