Changeset d7dc824
- Timestamp:
- Jun 7, 2017, 4:53:42 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:
- c77fd8b, ec95d11
- Parents:
- af397ef8
- Location:
- src
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
raf397ef8 rd7dc824 112 112 113 113 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ) {} 114 115 CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp )116 : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) {117 //output << std::string( init );118 }119 120 CodeGenerator::CodeGenerator( std::ostream & os, char * init, int indentation, bool infunp )121 : indent( *this ), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) {122 //output << std::string( init );123 }124 114 125 115 string CodeGenerator::mangleName( DeclarationWithType * decl ) { -
src/Common/PassVisitor.h
raf397ef8 rd7dc824 90 90 virtual void visit( TupleExpr *tupleExpr ) override final; 91 91 virtual void visit( TupleIndexExpr *tupleExpr ) override final; 92 virtual void visit( MemberTupleExpr *tupleExpr ) override final;93 92 virtual void visit( TupleAssignExpr *assignExpr ) override final; 94 93 virtual void visit( StmtExpr * stmtExpr ) override final; … … 176 175 virtual Expression* mutate( TupleExpr *tupleExpr ) override final; 177 176 virtual Expression* mutate( TupleIndexExpr *tupleExpr ) override final; 178 virtual Expression* mutate( MemberTupleExpr *tupleExpr ) override final;179 177 virtual Expression* mutate( TupleAssignExpr *assignExpr ) override final; 180 178 virtual Expression* mutate( StmtExpr * stmtExpr ) override final; -
src/Common/PassVisitor.impl.h
raf397ef8 rd7dc824 617 617 618 618 template< typename pass_type > 619 void PassVisitor< pass_type >::visit( MemberTupleExpr * node ) {620 VISIT_BODY( node );621 }622 623 template< typename pass_type >624 619 void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) { 625 620 VISIT_BODY( node ); … … 999 994 1000 995 template< typename pass_type > 1001 Expression * PassVisitor< pass_type >::mutate( MemberTupleExpr * node ) {1002 MUTATE_BODY( Expression, node );1003 }1004 1005 template< typename pass_type >1006 996 Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) { 1007 997 MUTATE_BODY( Expression, node ); -
src/Common/PassVisitor.proto.h
raf397ef8 rd7dc824 18 18 // Visit 19 19 template<typename pass_type, typename node_type> 20 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.previsit( node ), void() ) {20 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.previsit( node ), void() ) { 21 21 pass.previsit( node ); 22 22 } … … 27 27 28 28 template<typename pass_type, typename node_type> 29 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postvisit( node ), void() ) {29 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postvisit( node ), void() ) { 30 30 pass.postvisit( node ); 31 31 } … … 36 36 // Mutate 37 37 template<typename pass_type, typename node_type> 38 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.premutate( node ), void() ) {38 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.premutate( node ), void() ) { 39 39 return pass.premutate( node ); 40 40 } … … 45 45 46 46 template<typename return_type, typename pass_type, typename node_type> 47 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postmutate( node ) ) {47 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postmutate( node ) ) { 48 48 return pass.postmutate( node ); 49 49 } … … 54 54 // Begin/End scope 55 55 template<typename pass_type> 56 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.beginScope(), void() ) {56 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.beginScope(), void() ) { 57 57 pass.beginScope(); 58 58 } … … 63 63 64 64 template<typename pass_type> 65 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.endScope(), void() ) {65 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.endScope(), void() ) { 66 66 pass.endScope(); 67 67 } … … 73 73 #define FIELD_PTR( type, name ) \ 74 74 template<typename pass_type> \ 75 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( &pass.name ) { return &pass.name; } \75 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( &pass.name ) { return &pass.name; } \ 76 76 \ 77 77 template<typename pass_type> \ -
src/GenPoly/Box.cc
raf397ef8 rd7dc824 110 110 Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true ); 111 111 /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value 112 Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function,Type *polyType, std::list< Expression *>::iterator &arg );112 Expression *addDynRetParam( ApplicationExpr *appExpr, Type *polyType, std::list< Expression *>::iterator &arg ); 113 113 Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 114 114 void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars ); … … 728 728 } 729 729 730 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function,Type *dynType, std::list< Expression *>::iterator &arg ) {730 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, Type *dynType, std::list< Expression *>::iterator &arg ) { 731 731 assert( env ); 732 732 Type *concrete = replaceWithConcrete( appExpr, dynType ); … … 1148 1148 if ( dynRetType ) { 1149 1149 Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result(); 1150 ret = addDynRetParam( appExpr, function,concRetType, arg ); // xxx - used to use dynRetType instead of concRetType1150 ret = addDynRetParam( appExpr, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType 1151 1151 } else if ( needsAdapter( function, scopeTyVars ) && ! needsAdapter( function, exprTyVars) ) { // xxx - exprTyVars is used above...? 1152 1152 // xxx - the ! needsAdapter check may be incorrect. It seems there is some situation where an adapter is applied where it shouldn't be, and this fixes it for some cases. More investigation is needed. -
src/GenPoly/Specialize.cc
raf397ef8 rd7dc824 93 93 } 94 94 95 bool needsTupleSpecialization( Type *formalType, Type *actualType , TypeSubstitution *env) {95 bool needsTupleSpecialization( Type *formalType, Type *actualType ) { 96 96 // Needs tuple specialization if the structure of the formal type and actual type do not match. 97 97 // This is the case if the formal type has ttype polymorphism, or if the structure of tuple types … … 112 112 113 113 bool needsSpecialization( Type *formalType, Type *actualType, TypeSubstitution *env ) { 114 return needsPolySpecialization( formalType, actualType, env ) || needsTupleSpecialization( formalType, actualType , env);114 return needsPolySpecialization( formalType, actualType, env ) || needsTupleSpecialization( formalType, actualType ); 115 115 } 116 116 -
src/InitTweak/FixInit.cc
raf397ef8 rd7dc824 902 902 } 903 903 904 void InsertDtors::visit( ReturnStmt * returnStmt ) {904 void InsertDtors::visit( __attribute((unused)) ReturnStmt * returnStmt ) { 905 905 // return exits all scopes, so dump destructors for all scopes 906 906 for ( OrderedDecls & od : reverseDeclOrder ) { -
src/Parser/ExpressionNode.cc
raf397ef8 rd7dc824 223 223 } // build_field_name_REALDECIMALconstant 224 224 225 NameExpr * build_varref( const string *name , bool labelp) {225 NameExpr * build_varref( const string *name ) { 226 226 NameExpr *expr = new NameExpr( *name, nullptr ); 227 227 delete name; -
src/Parser/ParseNode.h
raf397ef8 rd7dc824 166 166 Expression * build_field_name_REALDECIMALconstant( const std::string & str ); 167 167 168 NameExpr * build_varref( const std::string * name , bool labelp = false);168 NameExpr * build_varref( const std::string * name ); 169 169 Expression * build_typevalue( DeclarationNode * decl ); 170 170 -
src/Parser/parser.yy
raf397ef8 rd7dc824 547 547 { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); } 548 548 // | ANDAND IDENTIFIER // GCC, address of label 549 // { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2 , true) ); }549 // { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2 ) ); } 550 550 ; 551 551 -
src/ResolvExpr/AlternativeFinder.cc
raf397ef8 rd7dc824 97 97 /// Prunes a list of alternatives down to those that have the minimum conversion cost for a given return type; skips ambiguous interpretations 98 98 template< typename InputIterator, typename OutputIterator > 99 void pruneAlternatives( InputIterator begin, InputIterator end, OutputIterator out , const SymTab::Indexer &indexer) {99 void pruneAlternatives( InputIterator begin, InputIterator end, OutputIterator out ) { 100 100 // select the alternatives that have the minimum conversion cost for a particular set of result types 101 101 std::map< std::string, PruneStruct > selected; … … 183 183 ) 184 184 AltList::iterator oldBegin = alternatives.begin(); 185 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ) , indexer);185 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ) ); 186 186 if ( alternatives.begin() == oldBegin ) { 187 187 std::ostringstream stream; -
src/ResolvExpr/CommonType.cc
raf397ef8 rd7dc824 157 157 void CommonType::visit( PointerType *pointerType ) { 158 158 if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) { 159 if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base() , indexer) ) {159 if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base()) ) { 160 160 getCommonWithVoidPointer( otherPointer, pointerType ); 161 } else if ( widenSecond && dynamic_cast< VoidType* >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base() , indexer) ) {161 } else if ( widenSecond && dynamic_cast< VoidType* >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base()) ) { 162 162 getCommonWithVoidPointer( pointerType, otherPointer ); 163 163 } else if ( ( pointerType->get_base()->get_qualifiers() >= otherPointer->get_base()->get_qualifiers() || widenFirst ) -
src/ResolvExpr/Unify.cc
raf397ef8 rd7dc824 114 114 } 115 115 116 bool isFtype( Type *type , const SymTab::Indexer &indexer) {116 bool isFtype( Type *type ) { 117 117 if ( dynamic_cast< FunctionType* >( type ) ) { 118 118 return true; … … 123 123 } 124 124 125 bool tyVarCompatible( const TypeDecl::Data & data, Type *type , const SymTab::Indexer &indexer) {125 bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) { 126 126 switch ( data.kind ) { 127 127 case TypeDecl::Any: … … 131 131 // type must also be complete 132 132 // xxx - should this also check that type is not a tuple type and that it's not a ttype? 133 return ! isFtype( type , indexer) && (! data.isComplete || type->isComplete() );133 return ! isFtype( type ) && (! data.isComplete || type->isComplete() ); 134 134 case TypeDecl::Ftype: 135 return isFtype( type , indexer);135 return isFtype( type ); 136 136 case TypeDecl::Ttype: 137 137 // ttype unifies with any tuple type … … 144 144 OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() ); 145 145 assert( tyvar != openVars.end() ); 146 if ( ! tyVarCompatible( tyvar->second, other , indexer) ) {146 if ( ! tyVarCompatible( tyvar->second, other ) ) { 147 147 return false; 148 148 } // if -
src/ResolvExpr/typeops.h
raf397ef8 rd7dc824 118 118 119 119 // in Unify.cc 120 bool isFtype( Type *type , const SymTab::Indexer &indexer);120 bool isFtype( Type *type ); 121 121 bool typesCompatible( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env ); 122 122 bool typesCompatibleIgnoreQualifiers( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env ); -
src/SymTab/Autogen.cc
raf397ef8 rd7dc824 262 262 // E ?=?(E volatile*, int), 263 263 // ?=?(E _Atomic volatile*, int); 264 void makeEnumFunctions( Enum Decl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {264 void makeEnumFunctions( EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) { 265 265 266 266 // T ?=?(E *, E); … … 486 486 487 487 /// generates the body of a union assignment/copy constructor/field constructor 488 void makeUnionAssignBody( FunctionDecl * funcDecl , bool isDynamicLayout) {488 void makeUnionAssignBody( FunctionDecl * funcDecl ) { 489 489 FunctionType * ftype = funcDecl->get_functionType(); 490 490 assert( ftype->get_parameters().size() == 2 ); … … 506 506 // Make function polymorphic in same parameters as generic union, if applicable 507 507 const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions 508 bool isDynamicLayout = hasDynamicLayout( aggregateDecl ); // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct) 509 508 510 509 // default ctor/dtor need only first parameter 511 510 // void ?{}(T *); void ^?{}(T *); … … 533 532 FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting ); 534 533 535 makeUnionAssignBody( assignDecl , isDynamicLayout);534 makeUnionAssignBody( assignDecl ); 536 535 537 536 // body of assignment and copy ctor is the same 538 makeUnionAssignBody( copyCtorDecl , isDynamicLayout);537 makeUnionAssignBody( copyCtorDecl ); 539 538 540 539 // create a constructor which takes the first member type as a parameter. … … 551 550 FunctionDecl * ctor = genFunc( "?{}", memCtorType, functionNesting ); 552 551 553 makeUnionAssignBody( ctor , isDynamicLayout);552 makeUnionAssignBody( ctor ); 554 553 memCtors.push_back( ctor ); 555 554 // only generate a ctor for the first field … … 578 577 EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() ); 579 578 // enumInst->set_baseEnum( enumDecl ); 580 makeEnumFunctions( enum Decl, enumInst, functionNesting, declsToAddAfter );579 makeEnumFunctions( enumInst, functionNesting, declsToAddAfter ); 581 580 } 582 581 } -
src/SymTab/Indexer.cc
raf397ef8 rd7dc824 518 518 acceptNewScope( tupleExpr->get_result(), *this ); 519 519 maybeAccept( tupleExpr->get_tuple(), *this ); 520 }521 522 void Indexer::visit( MemberTupleExpr *tupleExpr ) {523 acceptNewScope( tupleExpr->get_result(), *this );524 maybeAccept( tupleExpr->get_member(), *this );525 maybeAccept( tupleExpr->get_aggregate(), *this );526 520 } 527 521 -
src/SymTab/Indexer.h
raf397ef8 rd7dc824 74 74 virtual void visit( TupleExpr *tupleExpr ); 75 75 virtual void visit( TupleIndexExpr *tupleExpr ); 76 virtual void visit( MemberTupleExpr *tupleExpr );77 76 virtual void visit( TupleAssignExpr *tupleExpr ); 78 77 virtual void visit( StmtExpr * stmtExpr ); -
src/SynTree/Expression.h
raf397ef8 rd7dc824 690 690 }; 691 691 692 /// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer693 class MemberTupleExpr : public Expression {694 public:695 MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr );696 MemberTupleExpr( const MemberTupleExpr & other );697 virtual ~MemberTupleExpr();698 699 Expression * get_member() const { return member; }700 Expression * get_aggregate() const { return aggregate; }701 MemberTupleExpr * set_member( Expression * newValue ) { member = newValue; return this; }702 MemberTupleExpr * set_aggregate( Expression * newValue ) { aggregate = newValue; return this; }703 704 virtual MemberTupleExpr * clone() const { return new MemberTupleExpr( * this ); }705 virtual void accept( Visitor & v ) { v.visit( this ); }706 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }707 virtual void print( std::ostream & os, int indent = 0 ) const;708 private:709 Expression * member;710 Expression * aggregate;711 };712 713 692 /// TupleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];, a mass assignment operation, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0;, or a tuple ctor/dtor expression 714 693 class TupleAssignExpr : public Expression { -
src/SynTree/Initializer.cc
raf397ef8 rd7dc824 33 33 } 34 34 35 void Initializer::print( std::ostream &os,int indent ) {}35 // void Initializer::print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent ) {} 36 36 37 37 SingleInit::SingleInit( Expression *v, const std::list< Expression *> &_designators, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ), designators( _designators ) { -
src/SynTree/Initializer.h
raf397ef8 rd7dc824 53 53 virtual void accept( Visitor &v ) = 0; 54 54 virtual Initializer *acceptMutator( Mutator &m ) = 0; 55 virtual void print( std::ostream &os, int indent = 0 ) ;55 virtual void print( std::ostream &os, int indent = 0 ) = 0; 56 56 private: 57 57 // std::string name; -
src/SynTree/Mutator.cc
raf397ef8 rd7dc824 408 408 } 409 409 410 Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) {411 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );412 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );413 tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) );414 tupleExpr->set_aggregate( maybeMutate( tupleExpr->get_aggregate(), *this ) );415 return tupleExpr;416 }417 418 410 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) { 419 411 assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) ); -
src/SynTree/Mutator.h
raf397ef8 rd7dc824 82 82 virtual Expression* mutate( TupleExpr *tupleExpr ); 83 83 virtual Expression* mutate( TupleIndexExpr *tupleExpr ); 84 virtual Expression* mutate( MemberTupleExpr *tupleExpr );85 84 virtual Expression* mutate( TupleAssignExpr *assignExpr ); 86 85 virtual Expression* mutate( StmtExpr * stmtExpr ); -
src/SynTree/SynTree.h
raf397ef8 rd7dc824 89 89 class TupleExpr; 90 90 class TupleIndexExpr; 91 class MemberTupleExpr;92 91 class TupleAssignExpr; 93 92 class StmtExpr; -
src/SynTree/TupleExpr.cc
raf397ef8 rd7dc824 78 78 } 79 79 80 MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {81 set_result( maybeClone( member->get_result() ) ); // xxx - ???82 }83 84 MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {85 }86 87 MemberTupleExpr::~MemberTupleExpr() {88 delete member;89 delete aggregate;90 }91 92 void MemberTupleExpr::print( std::ostream &os, int indent ) const {93 os << "Member Tuple Expression, with aggregate:" << std::endl;94 os << std::string( indent+2, ' ' );95 aggregate->print( os, indent+2 );96 os << std::string( indent+2, ' ' ) << "with member: " << std::endl;97 os << std::string( indent+2, ' ' );98 member->print( os, indent+2 );99 Expression::print( os, indent );100 }101 102 80 TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ) { 103 81 // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments -
src/SynTree/Visitor.cc
raf397ef8 rd7dc824 321 321 } 322 322 323 void Visitor::visit( MemberTupleExpr *tupleExpr ) {324 maybeAccept( tupleExpr->get_result(), *this );325 maybeAccept( tupleExpr->get_member(), *this );326 maybeAccept( tupleExpr->get_aggregate(), *this );327 }328 329 323 void Visitor::visit( TupleAssignExpr *assignExpr ) { 330 324 maybeAccept( assignExpr->get_result(), *this ); -
src/SynTree/Visitor.h
raf397ef8 rd7dc824 85 85 virtual void visit( TupleExpr *tupleExpr ); 86 86 virtual void visit( TupleIndexExpr *tupleExpr ); 87 virtual void visit( MemberTupleExpr *tupleExpr );88 87 virtual void visit( TupleAssignExpr *assignExpr ); 89 88 virtual void visit( StmtExpr * stmtExpr );
Note: See TracChangeset
for help on using the changeset viewer.