- Timestamp:
- Sep 24, 2016, 12:19:33 PM (9 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:
- 3b5e3aa
- Parents:
- 2298f728 (diff), 7ae930a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 3 added
- 44 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/GenType.cc
r2298f728 r9c23f31 42 42 virtual void visit( TypeInstType *typeInst ); 43 43 virtual void visit( VarArgsType *varArgsType ); 44 virtual void visit( ZeroType *zeroType ); 45 virtual void visit( OneType *oneType ); 44 46 45 47 private: … … 200 202 } 201 203 204 void GenType::visit( ZeroType *zeroType ) { 205 // ideally these wouldn't hit codegen at all, but should be safe to make them ints 206 typeString = "int " + typeString; 207 handleQualifiers( zeroType ); 208 } 209 210 void GenType::visit( OneType *oneType ) { 211 // ideally these wouldn't hit codegen at all, but should be safe to make them ints 212 typeString = "int " + typeString; 213 handleQualifiers( oneType ); 214 } 215 202 216 void GenType::handleQualifiers( Type *type ) { 203 217 if ( type->get_isConst() ) { -
src/InitTweak/FixInit.cc
r2298f728 r9c23f31 33 33 #include "SymTab/Autogen.h" 34 34 #include "GenPoly/PolyMutator.h" 35 #include "GenPoly/DeclMutator.h" 35 36 #include "SynTree/AddStmtVisitor.h" 36 37 #include "CodeGen/GenType.h" // for warnings … … 216 217 SymTab::Indexer & indexer; 217 218 }; 219 220 class FixCtorExprs : public GenPoly::DeclMutator { 221 public: 222 /// expands ConstructorExpr nodes into comma expressions, using a temporary for the first argument 223 static void fix( std::list< Declaration * > & translationUnit ); 224 225 virtual Expression * mutate( ConstructorExpr * ctorExpr ); 226 }; 218 227 } // namespace 219 228 … … 221 230 // fixes ConstructorInit for global variables. should happen before fixInitializers. 222 231 InitTweak::fixGlobalInit( translationUnit, filename, inLibrary ); 232 223 233 224 234 InsertImplicitCalls::insert( translationUnit ); … … 231 241 232 242 GenStructMemberCalls::generate( translationUnit ); 243 // xxx - ctor expansion currently has to be after FixCopyCtors, because there is currently a 244 // hack in the way untyped assignments are generated, where the first argument cannot have 245 // its address taken because of the way codegeneration handles UntypedExpr vs. ApplicationExpr. 246 // Thus such assignment exprs must never pushed through expression resolution (and thus should 247 // not go through the FixCopyCtors pass), otherwise they will fail -- guaranteed. 248 // Also needs to happen after GenStructMemberCalls, since otherwise member constructors exprs 249 // don't look right, and a member can be constructed more than once. 250 FixCtorExprs::fix( translationUnit ); 233 251 } 234 252 … … 283 301 throw warner.errors; 284 302 } 303 } 304 305 void FixCtorExprs::fix( std::list< Declaration * > & translationUnit ) { 306 FixCtorExprs fixer; 307 fixer.mutateDeclarationList( translationUnit ); 285 308 } 286 309 … … 480 503 retExpr = deref; 481 504 } // if 482 // xxx - might need to set env on retExpr... 483 // retExpr->set_env( env->clone() ); 505 retExpr->set_env( env->clone() ); 484 506 return retExpr; 485 507 } else { … … 914 936 return safe_dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untypedExpr, indexer ) ); 915 937 } 938 939 Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) { 940 static UniqueName tempNamer( "_tmp_ctor_expr" ); 941 assert( ctorExpr->get_results().size() == 1 ); 942 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_results().front()->clone(), nullptr ); 943 addDeclaration( tmp ); 944 945 ApplicationExpr * callExpr = safe_dynamic_cast< ApplicationExpr * > ( ctorExpr->get_callExpr() ); 946 TypeSubstitution * env = ctorExpr->get_env(); 947 ctorExpr->set_callExpr( nullptr ); 948 ctorExpr->set_env( nullptr ); 949 950 Expression *& firstArg = callExpr->get_args().front(); 951 UntypedExpr * assign = new UntypedExpr( new NameExpr( "?=?" ) ); 952 assign->get_args().push_back( new VariableExpr( tmp ) ); 953 assign->get_args().push_back( firstArg ); 954 cloneAll( ctorExpr->get_results(), assign->get_results() ); 955 firstArg = assign; 956 957 CommaExpr * commaExpr = new CommaExpr( callExpr, new VariableExpr( tmp ) ); 958 commaExpr->set_env( env ); 959 delete ctorExpr; 960 return commaExpr; 961 } 916 962 } // namespace 917 963 } // namespace InitTweak -
src/InitTweak/InitTweak.cc
r2298f728 r9c23f31 358 358 template<typename CallExpr> 359 359 Expression *& callArg( CallExpr * callExpr, unsigned int pos ) { 360 if ( pos >= callExpr->get_args().size() ) assert ( false &&"asking for argument that doesn't exist. Return NULL/throw exception?" );360 if ( pos >= callExpr->get_args().size() ) assertf( false, "asking for argument that doesn't exist. Return NULL/throw exception?" ); 361 361 for ( Expression *& arg : callExpr->get_args() ) { 362 362 if ( pos == 0 ) return arg; … … 373 373 return callArg( untypedExpr, pos ); 374 374 } else { 375 assert ( false &&"Unexpected expression type passed to getCallArg" );375 assertf( false, "Unexpected expression type passed to getCallArg" ); 376 376 } 377 377 } … … 387 387 } else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( func ) ) { 388 388 return memberExpr->get_member()->get_name(); 389 } else if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * > ( func ) ) { 390 return memberExpr->get_member(); 389 391 } else { 390 assert ( false &&"Unexpected expression type being called as a function in call expression" );392 assertf( false, "Unexpected expression type being called as a function in call expression" ); 391 393 } 392 394 } … … 400 402 } else { 401 403 std::cerr << expr << std::endl; 402 assert ( false &&"Unexpected expression type passed to getFunctionName" );404 assertf( false, "Unexpected expression type passed to getFunctionName" ); 403 405 } 404 406 } -
src/Makefile.in
r2298f728 r9c23f31 165 165 SynTree/driver_cfa_cpp-AttrType.$(OBJEXT) \ 166 166 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) \ 167 SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) \ 167 168 SynTree/driver_cfa_cpp-Constant.$(OBJEXT) \ 168 169 SynTree/driver_cfa_cpp-Expression.$(OBJEXT) \ … … 390 391 SynTree/ReferenceToType.cc SynTree/TupleType.cc \ 391 392 SynTree/TypeofType.cc SynTree/AttrType.cc \ 392 SynTree/VarArgsType.cc SynTree/ Constant.cc \393 SynTree/ Expression.cc SynTree/TupleExpr.cc \393 SynTree/VarArgsType.cc SynTree/ZeroOneType.cc \ 394 SynTree/Constant.cc SynTree/Expression.cc SynTree/TupleExpr.cc \ 394 395 SynTree/CommaExpr.cc SynTree/TypeExpr.cc \ 395 396 SynTree/ApplicationExpr.cc SynTree/AddressExpr.cc \ … … 715 716 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \ 716 717 SynTree/$(DEPDIR)/$(am__dirstamp) 718 SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT): SynTree/$(am__dirstamp) \ 719 SynTree/$(DEPDIR)/$(am__dirstamp) 717 720 SynTree/driver_cfa_cpp-Constant.$(OBJEXT): SynTree/$(am__dirstamp) \ 718 721 SynTree/$(DEPDIR)/$(am__dirstamp) … … 877 880 -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT) 878 881 -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) 882 -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) 879 883 -rm -f Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT) 880 884 -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) … … 982 986 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@ 983 987 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ 988 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@ 984 989 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po@am__quote@ 985 990 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@ … … 2064 2069 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2065 2070 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarArgsType.obj `if test -f 'SynTree/VarArgsType.cc'; then $(CYGPATH_W) 'SynTree/VarArgsType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarArgsType.cc'; fi` 2071 2072 SynTree/driver_cfa_cpp-ZeroOneType.o: SynTree/ZeroOneType.cc 2073 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-ZeroOneType.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo -c -o SynTree/driver_cfa_cpp-ZeroOneType.o `test -f 'SynTree/ZeroOneType.cc' || echo '$(srcdir)/'`SynTree/ZeroOneType.cc 2074 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po 2075 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/ZeroOneType.cc' object='SynTree/driver_cfa_cpp-ZeroOneType.o' libtool=no @AMDEPBACKSLASH@ 2076 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2077 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-ZeroOneType.o `test -f 'SynTree/ZeroOneType.cc' || echo '$(srcdir)/'`SynTree/ZeroOneType.cc 2078 2079 SynTree/driver_cfa_cpp-ZeroOneType.obj: SynTree/ZeroOneType.cc 2080 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-ZeroOneType.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo -c -o SynTree/driver_cfa_cpp-ZeroOneType.obj `if test -f 'SynTree/ZeroOneType.cc'; then $(CYGPATH_W) 'SynTree/ZeroOneType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ZeroOneType.cc'; fi` 2081 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po 2082 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/ZeroOneType.cc' object='SynTree/driver_cfa_cpp-ZeroOneType.obj' libtool=no @AMDEPBACKSLASH@ 2083 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2084 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-ZeroOneType.obj `if test -f 'SynTree/ZeroOneType.cc'; then $(CYGPATH_W) 'SynTree/ZeroOneType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ZeroOneType.cc'; fi` 2066 2085 2067 2086 SynTree/driver_cfa_cpp-Constant.o: SynTree/Constant.cc -
src/Parser/parser.yy
r2298f728 r9c23f31 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 24 1 1:30:40201613 // Update Count : 199 112 // Last Modified On : Sat Sep 24 12:16:53 2016 13 // Update Count : 1992 14 14 // 15 15 … … 390 390 { 391 391 Token fn; 392 fn.str = new st ring( "?{}" ); // location undefined393 $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3) ) );392 fn.str = new std::string( "?{}" ); // location undefined - use location of '{'? 393 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) ); 394 394 } 395 395 ; -
src/ResolvExpr/AdjustExprType.cc
r2298f728 r9c23f31 37 37 virtual Type* mutate( TupleType *tupleType ); 38 38 virtual Type* mutate( VarArgsType *varArgsType ); 39 virtual Type* mutate( ZeroType *zeroType ); 40 virtual Type* mutate( OneType *oneType ); 39 41 40 42 const TypeEnvironment &env; … … 117 119 return varArgsType; 118 120 } 121 122 Type *AdjustExprType::mutate( ZeroType *zeroType ) { 123 return zeroType; 124 } 125 126 Type *AdjustExprType::mutate( OneType *oneType ) { 127 return oneType; 128 } 119 129 } // namespace ResolvExpr 120 130 -
src/ResolvExpr/AlternativeFinder.cc
r2298f728 r9c23f31 197 197 } 198 198 199 void AlternativeFinder::find( Expression *expr, bool adjust ) {199 void AlternativeFinder::find( Expression *expr, bool adjust, bool prune ) { 200 200 expr->accept( *this ); 201 201 if ( alternatives.empty() ) { … … 207 207 } 208 208 } 209 PRINT( 210 std::cerr << "alternatives before prune:" << std::endl; 211 printAlts( alternatives, std::cerr ); 212 ) 213 AltList::iterator oldBegin = alternatives.begin(); 214 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ), indexer ); 215 if ( alternatives.begin() == oldBegin ) { 216 std::ostringstream stream; 217 stream << "Can't choose between alternatives for expression "; 218 expr->print( stream ); 219 stream << "Alternatives are:"; 220 AltList winners; 221 findMinCost( alternatives.begin(), alternatives.end(), back_inserter( winners ) ); 222 printAlts( winners, stream, 8 ); 223 throw SemanticError( stream.str() ); 224 } 225 alternatives.erase( oldBegin, alternatives.end() ); 226 PRINT( 227 std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl; 228 ) 209 if ( prune ) { 210 PRINT( 211 std::cerr << "alternatives before prune:" << std::endl; 212 printAlts( alternatives, std::cerr ); 213 ) 214 AltList::iterator oldBegin = alternatives.begin(); 215 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ), indexer ); 216 if ( alternatives.begin() == oldBegin ) { 217 std::ostringstream stream; 218 stream << "Can't choose between alternatives for expression "; 219 expr->print( stream ); 220 stream << "Alternatives are:"; 221 AltList winners; 222 findMinCost( alternatives.begin(), alternatives.end(), back_inserter( winners ) ); 223 printAlts( winners, stream, 8 ); 224 throw SemanticError( stream.str() ); 225 } 226 alternatives.erase( oldBegin, alternatives.end() ); 227 PRINT( 228 std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl; 229 ) 230 } 229 231 230 232 // Central location to handle gcc extension keyword for all expression types. … … 234 236 } 235 237 236 void AlternativeFinder::findWithAdjustment( Expression *expr ) {237 find( expr, true );238 void AlternativeFinder::findWithAdjustment( Expression *expr, bool prune ) { 239 find( expr, true, prune ); 238 240 } 239 241 240 242 template< typename StructOrUnionType > 241 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const std::string &name ) {243 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ) { 242 244 std::list< Declaration* > members; 243 245 aggInst->lookup( name, members ); … … 760 762 if ( agg->expr->get_results().size() == 1 ) { 761 763 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_results().front() ) ) { 762 addAggMembers( structInst, agg->expr, agg->cost, memberExpr->get_member() );764 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 763 765 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_results().front() ) ) { 764 addAggMembers( unionInst, agg->expr, agg->cost, memberExpr->get_member() );766 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 765 767 } // if 766 768 } // if … … 789 791 renameTypes( alternatives.back().expr ); 790 792 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( (*i)->get_type() ) ) { 791 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), "" );793 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, "" ); 792 794 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( (*i)->get_type() ) ) { 793 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), "" );795 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, "" ); 794 796 } // if 795 797 } // for … … 1012 1014 alternatives.push_back( Alternative( impCpCtorExpr->clone(), env, Cost::zero ) ); 1013 1015 } 1016 1017 void AlternativeFinder::visit( ConstructorExpr * ctorExpr ) { 1018 AlternativeFinder finder( indexer, env ); 1019 // don't prune here, since it's guaranteed all alternatives will have the same type 1020 // (giving the alternatives different types is half of the point of ConstructorExpr nodes) 1021 finder.findWithAdjustment( ctorExpr->get_callExpr(), false ); 1022 for ( Alternative & alt : finder.alternatives ) { 1023 alternatives.push_back( Alternative( new ConstructorExpr( alt.expr->clone() ), alt.env, alt.cost ) ); 1024 } 1025 } 1014 1026 } // namespace ResolvExpr 1015 1027 -
src/ResolvExpr/AlternativeFinder.h
r2298f728 r9c23f31 29 29 public: 30 30 AlternativeFinder( const SymTab::Indexer &indexer, const TypeEnvironment &env ); 31 void find( Expression *expr, bool adjust = false );31 void find( Expression *expr, bool adjust = false, bool prune = true ); 32 32 /// Calls find with the adjust flag set; adjustment turns array and function types into equivalent pointer types 33 void findWithAdjustment( Expression *expr );33 void findWithAdjustment( Expression *expr, bool prune = true ); 34 34 AltList &get_alternatives() { return alternatives; } 35 35 … … 66 66 virtual void visit( TupleExpr *tupleExpr ); 67 67 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ); 68 virtual void visit( ConstructorExpr * ctorExpr ); 68 69 public: // xxx - temporary hack - should make Tuples::TupleAssignment a friend 69 70 template< typename InputIterator, typename OutputIterator > … … 72 73 private: 73 74 /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member 74 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const std::string &name );75 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ); 75 76 /// Adds alternatives for offsetof expressions, given the base type and name of the member 76 77 template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name ); -
src/ResolvExpr/CommonType.cc
r2298f728 r9c23f31 39 39 virtual void visit( TupleType *tupleType ); 40 40 virtual void visit( VarArgsType *varArgsType ); 41 virtual void visit( ZeroType *zeroType ); 42 virtual void visit( OneType *oneType ); 41 43 42 44 template< typename RefType > void handleRefType( RefType *inst, Type *other ); … … 134 136 result = new BasicType( basicType->get_qualifiers() + otherBasic->get_qualifiers(), newType ); 135 137 } // if 136 } else if ( EnumInstType *enumInstType = dynamic_cast< EnumInstType * >( type2 ) ) {137 // use signed int in lieu of the enum type138 } else if ( dynamic_cast< EnumInstType * > ( type2 ) || dynamic_cast< ZeroType* >( type2 ) || dynamic_cast< OneType* >( type2 ) ) { 139 // use signed int in lieu of the enum/zero/one type 138 140 BasicType::Kind newType = combinedType[ basicType->get_kind() ][ BasicType::SignedInt ]; 139 if ( ( ( newType == basicType->get_kind() && basicType->get_qualifiers() >= enumInstType->get_qualifiers() ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->get_qualifiers() <= enumInstType->get_qualifiers() ) || widenSecond ) ) {140 result = new BasicType( basicType->get_qualifiers() + enumInstType->get_qualifiers(), newType );141 if ( ( ( newType == basicType->get_kind() && basicType->get_qualifiers() >= type2->get_qualifiers() ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->get_qualifiers() <= type2->get_qualifiers() ) || widenSecond ) ) { 142 result = new BasicType( basicType->get_qualifiers() + type2->get_qualifiers(), newType ); 141 143 } // if 142 144 } // if … … 171 173 otherPointer->get_base()->get_qualifiers() = tq2; 172 174 } // if 175 } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) { 176 result = pointerType->clone(); 177 result->get_qualifiers() += type2->get_qualifiers(); 173 178 } // if 174 179 } … … 190 195 191 196 void CommonType::visit( EnumInstType *enumInstType ) { 192 if ( dynamic_cast< BasicType * >( type2 ) ) {197 if ( dynamic_cast< BasicType * >( type2 ) || dynamic_cast< ZeroType* >( type2 ) || dynamic_cast< OneType* >( type2 ) ) { 193 198 // reuse BasicType, EnumInstType code by swapping type2 with enumInstType 194 199 Type * temp = type2; … … 230 235 void CommonType::visit( VarArgsType *varArgsType ) { 231 236 } 237 238 void CommonType::visit( ZeroType *zeroType ) { 239 if ( widenFirst ) { 240 if ( dynamic_cast< BasicType* >( type2 ) || dynamic_cast< PointerType* >( type2 ) || dynamic_cast< EnumInstType* >( type2 ) ) { 241 if ( widenSecond || zeroType->get_qualifiers() <= type2->get_qualifiers() ) { 242 result = type2->clone(); 243 result->get_qualifiers() += zeroType->get_qualifiers(); 244 } 245 } 246 } 247 } 248 249 void CommonType::visit( OneType *oneType ) { 250 if ( widenFirst ) { 251 if ( dynamic_cast< BasicType* >( type2 ) || dynamic_cast< EnumInstType* >( type2 ) ) { 252 if ( widenSecond || oneType->get_qualifiers() <= type2->get_qualifiers() ) { 253 result = type2->clone(); 254 result->get_qualifiers() += oneType->get_qualifiers(); 255 } 256 } 257 } 258 } 232 259 } // namespace ResolvExpr 233 260 -
src/ResolvExpr/ConversionCost.cc
r2298f728 r9c23f31 160 160 // xxx - not positive this is correct, but appears to allow casting int => enum 161 161 cost = Cost( 1, 0, 0 ); 162 } // if 162 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) { 163 cost = Cost( 1, 0, 0 ); 164 } // if 163 165 } 164 166 … … 175 177 } // if 176 178 } // if 179 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) { 180 cost = Cost( 1, 0, 0 ); 177 181 } // if 178 182 } … … 256 260 } 257 261 } 262 263 void ConversionCost::visit(ZeroType *zeroType) { 264 if ( dynamic_cast< ZeroType* >( dest ) ) { 265 cost = Cost::zero; 266 } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) { 267 // copied from visit(BasicType*) for signed int, but +1 for safe conversions 268 int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->get_kind() ]; 269 if ( tableResult == -1 ) { 270 cost = Cost( 1, 0, 0 ); 271 } else { 272 cost = Cost( 0, 0, tableResult + 1 ); 273 } 274 } else if ( dynamic_cast< PointerType* >( dest ) ) { 275 cost = Cost( 0, 0, 1 ); 276 } 277 } 278 279 void ConversionCost::visit(OneType *oneType) { 280 if ( dynamic_cast< OneType* >( dest ) ) { 281 cost = Cost::zero; 282 } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) { 283 // copied from visit(BasicType*) for signed int, but +1 for safe conversions 284 int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->get_kind() ]; 285 if ( tableResult == -1 ) { 286 cost = Cost( 1, 0, 0 ); 287 } else { 288 cost = Cost( 0, 0, tableResult + 1 ); 289 } 290 } 291 } 258 292 } // namespace ResolvExpr 259 293 -
src/ResolvExpr/ConversionCost.h
r2298f728 r9c23f31 41 41 virtual void visit(TupleType *tupleType); 42 42 virtual void visit(VarArgsType *varArgsType); 43 virtual void visit(ZeroType *zeroType); 44 virtual void visit(OneType *oneType); 43 45 protected: 44 46 Type *dest; -
src/ResolvExpr/PtrsAssignable.cc
r2298f728 r9c23f31 39 39 virtual void visit( TupleType *tupleType ); 40 40 virtual void visit( VarArgsType *varArgsType ); 41 virtual void visit( ZeroType *zeroType ); 42 virtual void visit( OneType *oneType ); 41 43 private: 42 44 Type *dest; … … 141 143 void PtrsAssignable::visit( VarArgsType *varArgsType ) { 142 144 } 145 146 void PtrsAssignable::visit( ZeroType *zeroType ) { 147 } 148 149 void PtrsAssignable::visit( OneType *oneType ) { 150 } 151 143 152 } // namespace ResolvExpr 144 153 -
src/ResolvExpr/PtrsCastable.cc
r2298f728 r9c23f31 40 40 virtual void visit(TupleType *tupleType); 41 41 virtual void visit(VarArgsType *varArgsType); 42 virtual void visit(ZeroType *zeroType); 43 virtual void visit(OneType *oneType); 42 44 private: 43 45 Type *dest; … … 144 146 result = objectCast( dest, env, indexer ); 145 147 } 148 149 void PtrsCastable::visit(ZeroType *zeroType) { 150 result = objectCast( dest, env, indexer ); 151 } 152 153 void PtrsCastable::visit(OneType *oneType) { 154 result = objectCast( dest, env, indexer ); 155 } 146 156 } // namespace ResolvExpr 147 157 -
src/ResolvExpr/RenameVars.cc
r2298f728 r9c23f31 110 110 } 111 111 112 void RenameVars::visit( ZeroType *zeroType ) { 113 typeBefore( zeroType ); 114 typeAfter( zeroType ); 115 } 116 117 void RenameVars::visit( OneType *oneType ) { 118 typeBefore( oneType ); 119 typeAfter( oneType ); 120 } 121 112 122 void RenameVars::typeBefore( Type *type ) { 113 123 if ( ! type->get_forall().empty() ) { -
src/ResolvExpr/RenameVars.h
r2298f728 r9c23f31 44 44 virtual void visit( TupleType *tupleType ); 45 45 virtual void visit( VarArgsType *varArgsType ); 46 virtual void visit( ZeroType *zeroType ); 47 virtual void visit( OneType *oneType ); 46 48 47 49 void typeBefore( Type *type ); -
src/ResolvExpr/Resolver.cc
r2298f728 r9c23f31 133 133 } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) { 134 134 return bt->isInteger(); 135 } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) { 136 return true; 135 137 } else { 136 138 return false; … … 459 461 } 460 462 } else { 461 assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) ); 463 assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) 464 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) ); 462 465 // basic types are handled here 463 466 Visitor::visit( listInit ); -
src/ResolvExpr/Unify.cc
r2298f728 r9c23f31 60 60 virtual void visit(TupleType *tupleType); 61 61 virtual void visit(VarArgsType *varArgsType); 62 virtual void visit(ZeroType *zeroType); 63 virtual void visit(OneType *oneType); 62 64 63 65 template< typename RefType > void handleRefType( RefType *inst, Type *other ); … … 588 590 } 589 591 592 void Unify::visit(ZeroType *zeroType) { 593 result = dynamic_cast< ZeroType* >( type2 ); 594 } 595 596 void Unify::visit(OneType *oneType) { 597 result = dynamic_cast< OneType* >( type2 ); 598 } 599 590 600 } // namespace ResolvExpr 591 601 -
src/SymTab/FixFunction.cc
r2298f728 r9c23f31 77 77 return varArgsType; 78 78 } 79 80 Type * FixFunction::mutate(ZeroType *zeroType) { 81 return zeroType; 82 } 83 84 Type * FixFunction::mutate(OneType *oneType) { 85 return oneType; 86 } 79 87 } // namespace SymTab 80 88 -
src/SymTab/FixFunction.h
r2298f728 r9c23f31 42 42 virtual Type* mutate(TupleType *tupleType); 43 43 virtual Type* mutate(VarArgsType *varArgsType); 44 virtual Type* mutate(ZeroType *zeroType); 45 virtual Type* mutate(OneType *oneType); 44 46 45 47 bool isVoid; -
src/SymTab/ImplementationType.cc
r2298f728 r9c23f31 41 41 virtual void visit(TupleType *tupleType); 42 42 virtual void visit(VarArgsType *varArgsType); 43 virtual void visit(ZeroType *zeroType); 44 virtual void visit(OneType *oneType); 43 45 44 46 Type *result; // synthesized … … 120 122 void ImplementationType::visit(VarArgsType *varArgsType) { 121 123 } 124 125 void ImplementationType::visit(ZeroType *zeroType) { 126 } 127 128 void ImplementationType::visit(OneType *oneType) { 129 } 122 130 } // namespace SymTab 123 131 -
src/SymTab/Mangler.cc
r2298f728 r9c23f31 229 229 printQualifiers( varArgsType ); 230 230 mangleName << "VARGS"; 231 } 232 233 void Mangler::visit( ZeroType *zeroType ) { 234 mangleName << "Z"; 235 } 236 237 void Mangler::visit( OneType *oneType ) { 238 mangleName << "O"; 231 239 } 232 240 -
src/SymTab/Mangler.h
r2298f728 r9c23f31 46 46 virtual void visit( TupleType *tupleType ); 47 47 virtual void visit( VarArgsType *varArgsType ); 48 virtual void visit( ZeroType *zeroType ); 49 virtual void visit( OneType *oneType ); 48 50 49 51 std::string get_mangleName() { return mangleName.str(); } -
src/SymTab/TypeEquality.cc
r2298f728 r9c23f31 42 42 virtual void visit( TypeInstType *typeInst ); 43 43 virtual void visit( VarArgsType *varArgsType ); 44 virtual void visit( ZeroType *zeroType ); 45 virtual void visit( OneType *oneType ); 44 46 45 47 void handleQualifiers( Type * t ); … … 199 201 } 200 202 } 203 204 void TypeEquality::visit( ZeroType *zeroType ) { 205 handleQualifiers( zeroType ); 206 if ( ! dynamic_cast< ZeroType * >( other ) ) { 207 result = false; 208 } 209 } 210 211 void TypeEquality::visit( OneType *oneType ) { 212 handleQualifiers( oneType ); 213 if ( ! dynamic_cast< OneType * >( other ) ) { 214 result = false; 215 } 216 } 201 217 } // namespace SymTab -
src/SymTab/Validate.cc
r2298f728 r9c23f31 60 60 #include "ResolvExpr/typeops.h" 61 61 #include <algorithm> 62 #include "InitTweak/InitTweak.h" 62 63 63 64 #define debugPrint( x ) if ( doDebug ) { std::cout << x; } … … 171 172 }; 172 173 173 class VerifyCtorDtor : public Visitor {174 class VerifyCtorDtorAssign : public Visitor { 174 175 public: 175 /// ensure that constructors and destructorshave at least one176 /// parameter, the first of which must be a pointer, and no176 /// ensure that constructors, destructors, and assignment have at least one 177 /// parameter, the first of which must be a pointer, and that ctor/dtors have no 177 178 /// return values. 178 179 static void verify( std::list< Declaration * > &translationUnit ); … … 202 203 compoundliteral.mutateDeclarationList( translationUnit ); 203 204 acceptAll( translationUnit, pass3 ); 204 VerifyCtorDtor ::verify( translationUnit );205 VerifyCtorDtorAssign::verify( translationUnit ); 205 206 } 206 207 … … 687 688 } 688 689 689 void VerifyCtorDtor ::verify( std::list< Declaration * > & translationUnit ) {690 VerifyCtorDtor verifier;690 void VerifyCtorDtorAssign::verify( std::list< Declaration * > & translationUnit ) { 691 VerifyCtorDtorAssign verifier; 691 692 acceptAll( translationUnit, verifier ); 692 693 } 693 694 694 void VerifyCtorDtor ::visit( FunctionDecl * funcDecl ) {695 void VerifyCtorDtorAssign::visit( FunctionDecl * funcDecl ) { 695 696 FunctionType * funcType = funcDecl->get_functionType(); 696 697 std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals(); 697 698 std::list< DeclarationWithType * > ¶ms = funcType->get_parameters(); 698 699 699 if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}") {700 if ( InitTweak::isCtorDtorAssign( funcDecl->get_name() ) ) { 700 701 if ( params.size() == 0 ) { 701 throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl );702 throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl ); 702 703 } 703 704 if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) { 704 throw SemanticError( "First parameter of a constructor or destructormust be a pointer ", funcDecl );705 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a pointer ", funcDecl ); 705 706 } 706 if ( returnVals.size() != 0 ) {707 if ( InitTweak::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 707 708 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl ); 708 709 } -
src/SynTree/Expression.cc
r2298f728 r9c23f31 28 28 #include "TypeSubstitution.h" 29 29 #include "Common/utility.h" 30 #include "InitTweak/InitTweak.h" 30 31 31 32 … … 493 494 494 495 void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const { 495 os << std::string( indent, ' ' ) <<"Implicit Copy Constructor Expression: " << std::endl;496 os << "Implicit Copy Constructor Expression: " << std::endl; 496 497 assert( callExpr ); 497 498 callExpr->print( os, indent + 2 ); … … 503 504 } 504 505 506 507 ConstructorExpr::ConstructorExpr( Expression * callExpr ) : callExpr( callExpr ) { 508 // allow resolver to type a constructor used as an expression as if it has the same type as its first argument 509 assert( callExpr ); 510 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 511 assert( arg ); 512 cloneAll( arg->get_results(), results ); 513 } 514 515 ConstructorExpr::ConstructorExpr( const ConstructorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) { 516 } 517 518 ConstructorExpr::~ConstructorExpr() { 519 delete callExpr; 520 } 521 522 void ConstructorExpr::print( std::ostream &os, int indent ) const { 523 os << "Constructor Expression: " << std::endl; 524 assert( callExpr ); 525 os << std::string( indent+2, ' ' ); 526 callExpr->print( os, indent + 2 ); 527 Expression::print( os, indent ); 528 } 529 530 531 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 532 add_result( type->clone() ); 533 } 534 535 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {} 536 537 CompoundLiteralExpr::~CompoundLiteralExpr() { 538 delete initializer; 539 delete type; 540 } 541 542 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 543 os << "Compound Literal Expression: " << std::endl; 544 if ( type ) type->print( os, indent + 2 ); 545 if ( initializer ) initializer->print( os, indent + 2 ); 546 } 547 505 548 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {} 506 549 … … 511 554 if ( get_body() != 0 ) 512 555 get_body()->print( os, indent + 2 ); 513 }514 515 516 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {517 add_result( type->clone() );518 }519 520 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}521 522 CompoundLiteralExpr::~CompoundLiteralExpr() {523 delete initializer;524 delete type;525 }526 527 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {528 os << "Compound Literal Expression: " << std::endl;529 if ( type ) type->print( os, indent + 2 );530 if ( initializer ) initializer->print( os, indent + 2 );531 556 } 532 557 -
src/SynTree/Expression.h
r2298f728 r9c23f31 595 595 }; 596 596 597 /// ConstructorExpr represents the use of a constructor in an expression context, e.g. int * x = malloc() { 5 }; 598 class ConstructorExpr : public Expression { 599 public: 600 ConstructorExpr( Expression * callExpr ); 601 ConstructorExpr( const ConstructorExpr & other ); 602 ~ConstructorExpr(); 603 604 Expression *get_callExpr() const { return callExpr; } 605 void set_callExpr( Expression *newValue ) { callExpr = newValue; } 606 607 virtual ConstructorExpr *clone() const { return new ConstructorExpr( *this ); } 608 virtual void accept( Visitor &v ) { v.visit( this ); } 609 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 610 virtual void print( std::ostream &os, int indent = 0 ) const; 611 private: 612 Expression * callExpr; 613 }; 614 615 /// CompoundLiteralExpr represents a C99 'compound literal' 616 class CompoundLiteralExpr : public Expression { 617 public: 618 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 ~CompoundLiteralExpr(); 621 622 Type * get_type() const { return type; } 623 void set_type( Type * t ) { type = t; } 624 625 Initializer * get_initializer() const { return initializer; } 626 void set_initializer( Initializer * i ) { initializer = i; } 627 628 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } 629 virtual void accept( Visitor &v ) { v.visit( this ); } 630 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 631 virtual void print( std::ostream &os, int indent = 0 ) const; 632 private: 633 Type * type; 634 Initializer * initializer; 635 }; 636 597 637 /// ValofExpr represents a GCC 'lambda expression' 598 638 class UntypedValofExpr : public Expression { … … 613 653 }; 614 654 615 /// CompoundLiteralExpr represents a C99 'compound literal' 616 class CompoundLiteralExpr : public Expression { 617 public: 618 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 ~CompoundLiteralExpr(); 621 622 Type * get_type() const { return type; } 623 void set_type( Type * t ) { type = t; } 624 625 Initializer * get_initializer() const { return initializer; } 626 void set_initializer( Initializer * i ) { initializer = i; } 627 628 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } 629 virtual void accept( Visitor &v ) { v.visit( this ); } 630 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 631 virtual void print( std::ostream &os, int indent = 0 ) const; 632 private: 633 Type * type; 634 Initializer * initializer; 635 }; 636 655 /// RangeExpr represents a range e.g. '3 ... 5' or '1~10' 637 656 class RangeExpr : public Expression { 638 657 public: -
src/SynTree/Mutator.cc
r2298f728 r9c23f31 339 339 } 340 340 341 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 342 mutateAll( valofExpr->get_results(), *this ); 343 return valofExpr; 341 Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) { 342 mutateAll( ctorExpr->get_results(), *this ); 343 ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) ); 344 return ctorExpr; 344 345 } 345 346 … … 349 350 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); 350 351 return compLitExpr; 352 } 353 354 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 355 mutateAll( valofExpr->get_results(), *this ); 356 return valofExpr; 351 357 } 352 358 … … 447 453 } 448 454 455 Type *Mutator::mutate( ZeroType *zeroType ) { 456 mutateAll( zeroType->get_forall(), *this ); 457 return zeroType; 458 } 459 460 Type *Mutator::mutate( OneType *oneType ) { 461 mutateAll( oneType->get_forall(), *this ); 462 return oneType; 463 } 464 449 465 Initializer *Mutator::mutate( SingleInit *singleInit ) { 450 466 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) ); -
src/SynTree/Mutator.h
r2298f728 r9c23f31 76 76 virtual Expression* mutate( AsmExpr *asmExpr ); 77 77 virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr ); 78 virtual Expression* mutate( ConstructorExpr *ctorExpr ); 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 78 80 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );80 81 virtual Expression* mutate( RangeExpr *rangeExpr ); 81 82 … … 94 95 virtual Type* mutate( AttrType *attrType ); 95 96 virtual Type* mutate( VarArgsType *varArgsType ); 97 virtual Type* mutate( ZeroType *zeroType ); 98 virtual Type* mutate( OneType *oneType ); 96 99 97 100 virtual Initializer* mutate( SingleInit *singleInit ); -
src/SynTree/SynTree.h
r2298f728 r9c23f31 81 81 class AsmExpr; 82 82 class ImplicitCopyCtorExpr; 83 class ConstructorExpr; 84 class CompoundLiteralExpr; 83 85 class UntypedValofExpr; 84 class CompoundLiteralExpr;85 86 class RangeExpr; 86 87 … … 101 102 class AttrType; 102 103 class VarArgsType; 104 class ZeroType; 105 class OneType; 103 106 104 107 class Initializer; -
src/SynTree/Type.h
r2298f728 r9c23f31 418 418 }; 419 419 420 /// Represents a zero constant 421 class ZeroType : public Type { 422 public: 423 ZeroType(); 424 ZeroType( Type::Qualifiers tq ); 425 426 virtual ZeroType *clone() const { return new ZeroType( *this ); } 427 virtual void accept( Visitor &v ) { v.visit( this ); } 428 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } 429 virtual void print( std::ostream &os, int indent = 0 ) const; 430 }; 431 432 /// Represents a one constant 433 class OneType : public Type { 434 public: 435 OneType(); 436 OneType( Type::Qualifiers tq ); 437 438 virtual OneType *clone() const { return new OneType( *this ); } 439 virtual void accept( Visitor &v ) { v.visit( this ); } 440 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } 441 virtual void print( std::ostream &os, int indent = 0 ) const; 442 }; 443 420 444 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { 421 445 isConst |= other.isConst; -
src/SynTree/TypeSubstitution.cc
r2298f728 r9c23f31 179 179 } 180 180 181 Type * TypeSubstitution::mutate( VoidType * basicType ) {182 return handleType( basicType );181 Type * TypeSubstitution::mutate( VoidType *voidType ) { 182 return handleType( voidType ); 183 183 } 184 184 … … 221 221 Type * TypeSubstitution::mutate( VarArgsType *varArgsType ) { 222 222 return handleType( varArgsType ); 223 } 224 225 Type * TypeSubstitution::mutate( ZeroType *zeroType ) { 226 return handleType( zeroType ); 227 } 228 229 Type * TypeSubstitution::mutate( OneType *oneType ) { 230 return handleType( oneType ); 223 231 } 224 232 -
src/SynTree/TypeSubstitution.h
r2298f728 r9c23f31 76 76 virtual Type* mutate(TupleType *tupleType); 77 77 virtual Type* mutate(VarArgsType *varArgsType); 78 virtual Type* mutate(ZeroType *zeroType); 79 virtual Type* mutate(OneType *oneType); 78 80 79 81 // TODO: worry about traversing into a forall-qualified function type or type decl with assertions -
src/SynTree/Visitor.cc
r2298f728 r9c23f31 287 287 } 288 288 289 void Visitor::visit( UntypedValofExpr *valofExpr ) {290 acceptAll( valofExpr->get_results(), *this );291 maybeAccept( valofExpr->get_body(), *this );289 void Visitor::visit( ConstructorExpr * ctorExpr ) { 290 acceptAll( ctorExpr->get_results(), *this ); 291 maybeAccept( ctorExpr->get_callExpr(), *this ); 292 292 } 293 293 … … 296 296 maybeAccept( compLitExpr->get_type(), *this ); 297 297 maybeAccept( compLitExpr->get_initializer(), *this ); 298 } 299 300 void Visitor::visit( UntypedValofExpr *valofExpr ) { 301 acceptAll( valofExpr->get_results(), *this ); 302 maybeAccept( valofExpr->get_body(), *this ); 298 303 } 299 304 … … 378 383 } 379 384 385 void Visitor::visit( ZeroType *zeroType ) { 386 acceptAll( zeroType->get_forall(), *this ); 387 } 388 389 void Visitor::visit( OneType *oneType ) { 390 acceptAll( oneType->get_forall(), *this ); 391 } 392 380 393 void Visitor::visit( SingleInit *singleInit ) { 381 394 singleInit->get_value()->accept( *this ); -
src/SynTree/Visitor.h
r2298f728 r9c23f31 76 76 virtual void visit( AsmExpr *asmExpr ); 77 77 virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr ); 78 virtual void visit( ConstructorExpr * ctorExpr ); 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); 78 80 virtual void visit( UntypedValofExpr *valofExpr ); 79 virtual void visit( CompoundLiteralExpr *compLitExpr );80 81 virtual void visit( RangeExpr *rangeExpr ); 81 82 … … 94 95 virtual void visit( AttrType *attrType ); 95 96 virtual void visit( VarArgsType *varArgsType ); 97 virtual void visit( ZeroType *zeroType ); 98 virtual void visit( OneType *oneType ); 96 99 97 100 virtual void visit( SingleInit *singleInit ); -
src/SynTree/module.mk
r2298f728 r9c23f31 26 26 SynTree/AttrType.cc \ 27 27 SynTree/VarArgsType.cc \ 28 SynTree/ZeroOneType.cc \ 28 29 SynTree/Constant.cc \ 29 30 SynTree/Expression.cc \ -
src/examples/gc_no_raii/src/internal/card_table.h
r2298f728 r9c23f31 18 18 }; 19 19 20 static inline void ctor_card(card_table_t* constthis)20 static inline void ?{}(card_table_t* this) 21 21 { 22 22 this->count = 0; 23 23 } 24 24 25 static inline void dtor_card(card_table_t* constthis)25 static inline void ^?{}(card_table_t* this) 26 26 { 27 27 -
src/examples/gc_no_raii/src/internal/memory_pool.c
r2298f728 r9c23f31 11 11 const size_t gc_pool_header_size = (size_t)( &(((gc_memory_pool*)NULL)->start_p) ); 12 12 13 void ctor(gc_memory_pool *constthis, size_t size, gc_memory_pool* next, gc_memory_pool* mirror, uint8_t type)13 void ?{}(gc_memory_pool* this, size_t size, gc_memory_pool* next, gc_memory_pool* mirror, uint8_t type) 14 14 { 15 15 this->mirror = mirror; … … 17 17 this->type_code = type; 18 18 19 card_table_t* new = (card_table_t*)malloc(sizeof(card_table_t)); 20 this->cards = new; 21 ctor_card(this->cards); 19 this->cards = ( (card_table_t*)malloc(sizeof(card_table_t)) ){}; 22 20 23 21 this->end_p = ((uint8_t*)this) + size; … … 29 27 } 30 28 31 void dtor(gc_memory_pool *constthis)29 void ^?{}(gc_memory_pool* this) 32 30 { 33 dtor_card(this->cards);31 ^(&this->cards){}; 34 32 free(this->cards); 35 33 } -
src/examples/gc_no_raii/src/internal/memory_pool.h
r2298f728 r9c23f31 27 27 }; 28 28 29 void ctor( gc_memory_pool *constthis,29 void ?{}( gc_memory_pool* this, 30 30 size_t size, 31 31 gc_memory_pool* next, … … 34 34 ); 35 35 36 void dtor(gc_memory_pool *constthis);36 void ^?{}(gc_memory_pool* this); 37 37 38 38 struct gc_pool_object_iterator -
src/examples/gc_no_raii/src/internal/state.c
r2298f728 r9c23f31 131 131 132 132 this->from_space = (gc_memory_pool*)(pal_allocPool(POOL_SIZE_BYTES, 1)); 133 this->to_space = (gc_memory_pool*)(pal_allocPool(POOL_SIZE_BYTES, 1));134 135 ctor(this->from_space, POOL_SIZE_BYTES, old_from_space, this->to_space, this->from_code);136 ctor(this->to_space, POOL_SIZE_BYTES, old_to_space, this->from_space, (~this->from_code) & 0x01);133 this->to_space = (gc_memory_pool*)(pal_allocPool(POOL_SIZE_BYTES, 1)); 134 135 this->from_space{ POOL_SIZE_BYTES, old_from_space, this->to_space, this->from_code }; 136 this->to_space { POOL_SIZE_BYTES, old_to_space, this->from_space, (~this->from_code) & 0x01 }; 137 137 138 138 this->total_space += gc_pool_size_used(this->from_space); -
src/include/assert.h
r2298f728 r9c23f31 22 22 #define assertf(expr, fmt, ...) ((expr) ? static_cast<void>(0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ )) 23 23 24 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) ;24 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) __attribute__((noreturn)); 25 25 26 26 template<typename T, typename U> -
src/libcfa/containers/vector
r2298f728 r9c23f31 20 20 } 21 21 22 #define DESTROY(x)23 24 22 //------------------------------------------------------------------------------ 25 23 //Declaration 26 24 trait allocator_c(otype T, otype allocator_t) 27 25 { 28 void ctor(allocator_t* const); 29 void dtor(allocator_t* const); 30 void realloc_storage(allocator_t* const, size_t); 31 T* data(allocator_t* const); 26 void realloc_storage(allocator_t*, size_t); 27 T* data(allocator_t*); 32 28 }; 29 30 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 31 struct vector; 32 33 //------------------------------------------------------------------------------ 34 //Initialization 35 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 36 void ?{}(vector(T, allocator_t)* this); 37 38 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 39 void ?{}(vector(T, allocator_t)* this, vector(T, allocator_t) rhs); 40 41 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 42 vector(T, allocator_t) ?=?(vector(T, allocator_t)* this, vector(T, allocator_t) rhs); 43 44 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 45 void ^?{}(vector(T, allocator_t)* this); 33 46 34 47 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) … … 40 53 41 54 //------------------------------------------------------------------------------ 42 //Initialization43 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))44 void ctor(vector(T, allocator_t) *const this);45 46 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))47 void dtor(vector(T, allocator_t) *const this);48 49 //------------------------------------------------------------------------------50 55 //Capacity 51 56 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 52 static inline bool empty(vector(T, allocator_t) *constthis)57 static inline bool empty(vector(T, allocator_t)* this) 53 58 { 54 59 return this->size == 0; … … 56 61 57 62 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 58 static inline size_t size(vector(T, allocator_t) *constthis)63 static inline size_t size(vector(T, allocator_t)* this) 59 64 { 60 65 return this->size; … … 62 67 63 68 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 64 static inline void reserve(vector(T, allocator_t) *constthis, size_t size)69 static inline void reserve(vector(T, allocator_t)* this, size_t size) 65 70 { 66 71 realloc_storage(&this->storage, this->size+1); … … 70 75 //Element access 71 76 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 72 static inline T at(vector(T, allocator_t) *constthis, size_t index)77 static inline T at(vector(T, allocator_t)* this, size_t index) 73 78 { 74 79 return data(&this->storage)[index]; … … 76 81 77 82 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 78 static inline T ?[?](vector(T, allocator_t) *constthis, size_t index)83 static inline T ?[?](vector(T, allocator_t)* this, size_t index) 79 84 { 80 85 return data(&this->storage)[index]; … … 82 87 83 88 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 84 static inline T front(vector(T, allocator_t) *constthis)89 static inline T front(vector(T, allocator_t)* this) 85 90 { 86 91 return data(&this->storage)[0]; … … 88 93 89 94 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 90 static inline T back(vector(T, allocator_t) *constthis)95 static inline T back(vector(T, allocator_t)* this) 91 96 { 92 97 return data(&this->storage)[this->size - 1]; … … 96 101 //Modifiers 97 102 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 98 void push_back(vector(T, allocator_t) *constthis, T value);103 void push_back(vector(T, allocator_t)* this, T value); 99 104 100 105 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 101 void pop_back(vector(T, allocator_t) *constthis);106 void pop_back(vector(T, allocator_t)* this); 102 107 103 108 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 104 void clear(vector(T, allocator_t) *constthis);109 void clear(vector(T, allocator_t)* this); 105 110 106 111 //------------------------------------------------------------------------------ 107 112 //Iterators 108 113 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 109 static inline T* begin(vector(T, allocator_t) *constthis)114 static inline T* begin(vector(T, allocator_t)* this) 110 115 { 111 116 return data(&this->storage); … … 113 118 114 119 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 115 static inline const T* cbegin(const vector(T, allocator_t) *constthis)120 static inline const T* cbegin(const vector(T, allocator_t)* this) 116 121 { 117 122 return data(&this->storage); … … 119 124 120 125 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 121 static inline T* end(vector(T, allocator_t) *constthis)126 static inline T* end(vector(T, allocator_t)* this) 122 127 { 123 128 return data(&this->storage) + this->size; … … 125 130 126 131 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 127 static inline const T* cend(const vector(T, allocator_t) *constthis)132 static inline const T* cend(const vector(T, allocator_t)* this) 128 133 { 129 134 return data(&this->storage) + this->size; … … 140 145 141 146 forall(otype T) 142 void ctor(heap_allocator(T) *constthis);147 void ?{}(heap_allocator(T)* this); 143 148 144 149 forall(otype T) 145 void dtor(heap_allocator(T) *const this);150 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs); 146 151 147 152 forall(otype T) 148 void realloc_storage(heap_allocator(T) *const this, size_t size);153 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs); 149 154 150 155 forall(otype T) 151 static inline T* data(heap_allocator(T) *const this) 156 void ^?{}(heap_allocator(T)* this); 157 158 forall(otype T) 159 void realloc_storage(heap_allocator(T)* this, size_t size); 160 161 forall(otype T) 162 static inline T* data(heap_allocator(T)* this) 152 163 { 153 164 return this->storage; -
src/libcfa/containers/vector.c
r2298f728 r9c23f31 18 18 #include <stdlib> 19 19 20 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 21 void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other); 22 20 23 //------------------------------------------------------------------------------ 21 24 //Initialization 22 25 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 23 void ctor(vector(T, allocator_t) *constthis)26 void ?{}(vector(T, allocator_t)* this) 24 27 { 25 ctor(&this->storage);28 (&this->storage){}; 26 29 this->size = 0; 27 30 } 28 31 29 32 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 30 void dtor(vector(T, allocator_t) *const this) 33 void ?{}(vector(T, allocator_t)* this, vector(T, allocator_t) rhs) 34 { 35 (&this->storage){ rhs.storage }; 36 copy_internal(this, &rhs); 37 } 38 39 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 40 // vector(T, allocator_t) ?=?(vector(T, allocator_t)* this, vector(T, allocator_t) rhs) 41 // { 42 // (&this->storage){}; 43 // copy_internal(this, &rhs); 44 // return *this; 45 // } 46 47 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 48 void ^?{}(vector(T, allocator_t)* this) 31 49 { 32 50 clear(this); 33 dtor(&this->storage);51 ^(&this->storage){}; 34 52 } 35 53 … … 37 55 //Modifiers 38 56 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 39 void push_back(vector(T, allocator_t) *constthis, T value)57 void push_back(vector(T, allocator_t)* this, T value) 40 58 { 41 59 realloc_storage(&this->storage, this->size+1); … … 45 63 46 64 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 47 void pop_back(vector(T, allocator_t) *constthis)65 void pop_back(vector(T, allocator_t)* this) 48 66 { 49 67 this->size--; 50 DESTROY(data(&this->storage)[this->size]);68 ^(&data(&this->storage)[this->size]){}; 51 69 } 52 70 53 71 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 54 void clear(vector(T, allocator_t) *constthis)72 void clear(vector(T, allocator_t)* this) 55 73 { 56 74 for(size_t i = 0; i < this->size; i++) 57 75 { 58 DESTROY(data(&this->storage)[this->size]);76 ^(&data(&this->storage)[this->size]){}; 59 77 } 60 78 this->size = 0; … … 62 80 63 81 //------------------------------------------------------------------------------ 82 //Internal Helpers 83 84 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 85 void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other) 86 { 87 this->size = other->size; 88 for(size_t i = 0; i < this->size; i++) { 89 (&data(&this->storage)[this->size]){ data(&other->storage)[other->size] }; 90 } 91 } 92 93 //------------------------------------------------------------------------------ 64 94 //Allocator 65 95 forall(otype T) 66 void ctor(heap_allocator(T) *constthis)96 void ?{}(heap_allocator(T)* this) 67 97 { 68 98 this->storage = 0; … … 71 101 72 102 forall(otype T) 73 void dtor(heap_allocator(T) *const this) 103 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs) 104 { 105 this->capacity = rhs.capacity; 106 this->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T)); 107 } 108 109 forall(otype T) 110 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs) 111 { 112 this->capacity = rhs.capacity; 113 this->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T)); 114 return *this; 115 } 116 117 forall(otype T) 118 void ^?{}(heap_allocator(T)* this) 74 119 { 75 120 free(this->storage); … … 77 122 78 123 forall(otype T) 79 inline void realloc_storage(heap_allocator(T) *constthis, size_t size)124 inline void realloc_storage(heap_allocator(T)* this, size_t size) 80 125 { 81 126 enum { GROWTH_RATE = 2 }; -
src/libcfa/prelude.cf
r2298f728 r9c23f31 636 636 637 637 // default ctor 638 void ?{}( _Bool * ) , ?{}( volatile _Bool * );639 void ?{}( char * ) , ?{}( volatile char * );640 void ?{}( unsigned char * ) , ?{}( volatile unsigned char * );641 void ?{}( char signed * ) , ?{}( volatile char signed * );642 void ?{}( int short * ) , ?{}( volatile int short * );643 void ?{}( int short unsigned * ) , ?{}( volatile int short unsigned * );644 void ?{}( signed int * ) , ?{}( volatile signed int * );645 void ?{}( unsigned int * ) , ?{}( volatile unsigned int * );646 void ?{}( signed long int * ) , ?{}( volatile signed long int * );647 void ?{}( unsigned long int * ) , ?{}( volatile unsigned long int * );648 void ?{}( signed long long int * ) , ?{}( volatile signed long long int * );649 void ?{}( unsigned long long int * ) , ?{}( volatile unsigned long long int * );650 void ?{}( float * ) , ?{}( volatile float * );651 void ?{}( double * ) , ?{}( volatile double * );652 void ?{}( long double * ) , ?{}( volatile long double * );653 void ?{}( float _Complex * ) , ?{}( volatile float _Complex * );654 void ?{}( double _Complex * ) , ?{}( volatile double _Complex * );655 void ?{}( long double _Complex * ) , ?{}( volatile long double _Complex * );638 void ?{}( _Bool * ); 639 void ?{}( char * ); 640 void ?{}( unsigned char * ); 641 void ?{}( char signed * ); 642 void ?{}( int short * ); 643 void ?{}( int short unsigned * ); 644 void ?{}( signed int * ); 645 void ?{}( unsigned int * ); 646 void ?{}( signed long int * ); 647 void ?{}( unsigned long int * ); 648 void ?{}( signed long long int * ); 649 void ?{}( unsigned long long int * ); 650 void ?{}( float * ); 651 void ?{}( double * ); 652 void ?{}( long double * ); 653 void ?{}( float _Complex * ); 654 void ?{}( double _Complex * ); 655 void ?{}( long double _Complex * ); 656 656 657 657 // copy ctor 658 void ?{}( _Bool *, _Bool ) , ?{}( volatile _Bool *, _Bool );659 void ?{}( char *, char ) , ?{}( volatile char *, char );660 void ?{}( unsigned char *, unsigned char ) , ?{}( volatile unsigned char *, unsigned char );661 void ?{}( char signed *, char signed ) , ?{}( volatile char signed *, char signed );662 void ?{}( int short *, int short ) , ?{}( volatile int short *, int short );663 void ?{}( int short unsigned *, int short unsigned ) , ?{}( volatile int short unsigned *, int short unsigned );664 void ?{}( signed int *, signed int) , ?{}( volatile signed int *, signed int );665 void ?{}( unsigned int *, unsigned int) , ?{}( volatile unsigned int *, unsigned int );666 void ?{}( signed long int *, signed long int) , ?{}( volatile signed long int *, signed long int );667 void ?{}( unsigned long int *, unsigned long int) , ?{}( volatile unsigned long int *, unsigned long int );668 void ?{}( signed long long int *, signed long long int) , ?{}( volatile signed long long int *, signed long long int );669 void ?{}( unsigned long long int *, unsigned long long int) , ?{}( volatile unsigned long long int *, unsigned long long int );670 void ?{}( float *, float) , ?{}( volatile float *, float );671 void ?{}( double *, double) , ?{}( volatile double *, double );672 void ?{}( long double *, long double) , ?{}( volatile long double *, long double );673 void ?{}( float _Complex *, float _Complex) , ?{}( volatile float _Complex *, float _Complex );674 void ?{}( double _Complex *, double _Complex) , ?{}( volatile double _Complex *, double _Complex );675 void ?{}( long double _Complex *, long double _Complex) , ?{}( volatile long double _Complex *, long double _Complex );658 void ?{}( _Bool *, _Bool ); 659 void ?{}( char *, char ); 660 void ?{}( unsigned char *, unsigned char ); 661 void ?{}( char signed *, char signed ); 662 void ?{}( int short *, int short ); 663 void ?{}( int short unsigned *, int short unsigned ); 664 void ?{}( signed int *, signed int); 665 void ?{}( unsigned int *, unsigned int); 666 void ?{}( signed long int *, signed long int); 667 void ?{}( unsigned long int *, unsigned long int); 668 void ?{}( signed long long int *, signed long long int); 669 void ?{}( unsigned long long int *, unsigned long long int); 670 void ?{}( float *, float); 671 void ?{}( double *, double); 672 void ?{}( long double *, long double); 673 void ?{}( float _Complex *, float _Complex); 674 void ?{}( double _Complex *, double _Complex); 675 void ?{}( long double _Complex *, long double _Complex); 676 676 677 677 // dtor 678 void ^?{}( _Bool * ) , ^?{}( volatile _Bool * );679 void ^?{}( char * ) , ^?{}( volatile char * );680 void ^?{}( char unsigned * ) , ^?{}( volatile char unsigned * );681 void ^?{}( char signed * ) , ^?{}( volatile char signed * );682 void ^?{}( int short * ) , ^?{}( volatile int short * );683 void ^?{}( int short unsigned * ) , ^?{}( volatile int short unsigned * );684 void ^?{}( signed int * ) , ^?{}( volatile signed int * );685 void ^?{}( unsigned int * ) , ^?{}( volatile unsigned int * );686 void ^?{}( signed long int * ) , ^?{}( volatile signed long int * );687 void ^?{}( unsigned long int * ) , ^?{}( volatile unsigned long int * );688 void ^?{}( signed long long int * ) , ^?{}( volatile signed long long int * );689 void ^?{}( unsigned long long int * ) , ^?{}( volatile unsigned long long int * );690 void ^?{}( float * ) , ^?{}( volatile float * );691 void ^?{}( double * ) , ^?{}( volatile double * );692 void ^?{}( long double * ) , ^?{}( volatile long double * );693 void ^?{}( float _Complex * ) , ^?{}( volatile float _Complex * );694 void ^?{}( double _Complex * ) , ^?{}( volatile double _Complex * );695 void ^?{}( long double _Complex * ) , ^?{}( volatile long double _Complex * );678 void ^?{}( _Bool * ); 679 void ^?{}( char * ); 680 void ^?{}( char unsigned * ); 681 void ^?{}( char signed * ); 682 void ^?{}( int short * ); 683 void ^?{}( int short unsigned * ); 684 void ^?{}( signed int * ); 685 void ^?{}( unsigned int * ); 686 void ^?{}( signed long int * ); 687 void ^?{}( unsigned long int * ); 688 void ^?{}( signed long long int * ); 689 void ^?{}( unsigned long long int * ); 690 void ^?{}( float * ); 691 void ^?{}( double * ); 692 void ^?{}( long double * ); 693 void ^?{}( float _Complex * ); 694 void ^?{}( double _Complex * ); 695 void ^?{}( long double _Complex * ); 696 696 697 697 // // default ctor … … 719 719 720 720 forall( dtype DT ) void ?{}( DT * *, DT * ); 721 forall( dtype DT ) void ?{}( DT * volatile *, DT * );722 721 forall( dtype DT ) void ?{}( const DT * *, DT * ); 723 forall( dtype DT ) void ?{}( const DT * volatile *, DT * );724 722 forall( dtype DT ) void ?{}( const DT * *, const DT * ); 725 forall( dtype DT ) void ?{}( const DT * volatile *, const DT * );726 723 forall( dtype DT ) void ?{}( volatile DT * *, DT * ); 727 forall( dtype DT ) void ?{}( volatile DT * volatile *, DT * );728 724 forall( dtype DT ) void ?{}( volatile DT * *, volatile DT * ); 729 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile DT * );730 725 731 726 forall( dtype DT ) void ?{}( const volatile DT * *, DT * ); 732 forall( dtype DT ) void ?{}( const volatile DT * volatile *, DT * );733 727 forall( dtype DT ) void ?{}( const volatile DT * *, const DT * ); 734 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const DT * );735 728 forall( dtype DT ) void ?{}( const volatile DT * *, volatile DT * ); 736 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile DT * );737 729 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile DT * ); 738 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile DT * );739 730 740 731 forall( dtype DT ) void ?{}( DT * *, void * ); 741 forall( dtype DT ) void ?{}( DT * volatile *, void * );742 732 forall( dtype DT ) void ?{}( const DT * *, void * ); 743 forall( dtype DT ) void ?{}( const DT * volatile *, void * );744 733 forall( dtype DT ) void ?{}( const DT * *, const void * ); 745 forall( dtype DT ) void ?{}( const DT * volatile *, const void * );746 734 forall( dtype DT ) void ?{}( volatile DT * *, void * ); 747 forall( dtype DT ) void ?{}( volatile DT * volatile *, void * );748 735 forall( dtype DT ) void ?{}( volatile DT * *, volatile void * ); 749 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile void * );750 736 751 737 forall( dtype DT ) void ?{}( const volatile DT * *, void * ); 752 forall( dtype DT ) void ?{}( const volatile DT * volatile *, void * );753 738 forall( dtype DT ) void ?{}( const volatile DT * *, const void * ); 754 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const void * );755 739 forall( dtype DT ) void ?{}( const volatile DT * *, volatile void * ); 756 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile void * );757 740 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile void * ); 758 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile void * );759 741 760 742 forall( dtype DT ) void ?{}( void * *, DT * ); 761 forall( dtype DT ) void ?{}( void * volatile *, DT * );762 743 forall( dtype DT ) void ?{}( const void * *, DT * ); 763 forall( dtype DT ) void ?{}( const void * volatile *, DT * );764 744 forall( dtype DT ) void ?{}( const void * *, const DT * ); 765 forall( dtype DT ) void ?{}( const void * volatile *, const DT * );766 745 forall( dtype DT ) void ?{}( volatile void * *, DT * ); 767 forall( dtype DT ) void ?{}( volatile void * volatile *, DT * );768 746 forall( dtype DT ) void ?{}( volatile void * *, volatile DT * ); 769 forall( dtype DT ) void ?{}( volatile void * volatile *, volatile DT * );770 747 forall( dtype DT ) void ?{}( const volatile void * *, DT * ); 771 forall( dtype DT ) void ?{}( const volatile void * volatile *, DT * );772 748 forall( dtype DT ) void ?{}( const volatile void * *, const DT * ); 773 forall( dtype DT ) void ?{}( const volatile void * volatile *, const DT * );774 749 forall( dtype DT ) void ?{}( const volatile void * *, volatile DT * ); 775 forall( dtype DT ) void ?{}( const volatile void * volatile *, volatile DT * );776 750 forall( dtype DT ) void ?{}( const volatile void * *, const volatile DT * ); 777 forall( dtype DT ) void ?{}( const volatile void * volatile *, const volatile DT * );778 751 779 752 void ?{}( void * *, void * ); 780 void ?{}( void * volatile *, void * );781 753 void ?{}( const void * *, void * ); 782 void ?{}( const void * volatile *, void * );783 754 void ?{}( const void * *, const void * ); 784 void ?{}( const void * volatile *, const void * );785 755 void ?{}( volatile void * *, void * ); 786 void ?{}( volatile void * volatile *, void * );787 756 void ?{}( volatile void * *, volatile void * ); 788 void ?{}( volatile void * volatile *, volatile void * );789 757 void ?{}( const volatile void * *, void * ); 790 void ?{}( const volatile void * volatile *, void * );791 758 void ?{}( const volatile void * *, const void * ); 792 void ?{}( const volatile void * volatile *, const void * );793 759 void ?{}( const volatile void * *, volatile void * ); 794 void ?{}( const volatile void * volatile *, volatile void * );795 760 void ?{}( const volatile void * *, const volatile void * ); 796 void ?{}( const volatile void * volatile *, const volatile void * );797 761 798 762 //forall( dtype DT ) void ?{}( DT * *, forall( dtype DT2 ) const DT2 * ); 799 763 //forall( dtype DT ) void ?{}( DT * volatile *, forall( dtype DT2 ) const DT2 * ); 800 764 forall( dtype DT ) void ?{}( const DT * *, forall( dtype DT2 ) const DT2 * ); 801 forall( dtype DT ) void ?{}( const DT * volatile *, forall( dtype DT2 ) const DT2 * );802 765 //forall( dtype DT ) void ?{}( volatile DT * *, forall( dtype DT2 ) const DT2 * ); 803 766 //forall( dtype DT ) void ?{}( volatile DT * volatile *, forall( dtype DT2 ) const DT2 * ); 804 767 forall( dtype DT ) void ?{}( const volatile DT * *, forall( dtype DT2 ) const DT2 * ); 805 forall( dtype DT ) void ?{}( const volatile DT * volatile *, forall( dtype DT2 ) const DT2 * );806 768 807 769 forall( ftype FT ) void ?{}( FT * *, forall( ftype FT2 ) FT2 * ); 808 forall( ftype FT ) void ?{}( FT * volatile *, forall( ftype FT2 ) FT2 * );809 770 810 771 // default ctors 811 772 forall( ftype FT ) void ?{}( FT * * ); 812 forall( ftype FT ) void ?{}( FT * volatile * );813 773 814 774 forall( dtype DT ) void ?{}( DT * *); 815 forall( dtype DT ) void ?{}( DT * volatile *);816 775 forall( dtype DT ) void ?{}( const DT * *); 817 forall( dtype DT ) void ?{}( const DT * volatile *);818 776 forall( dtype DT ) void ?{}( volatile DT * *); 819 forall( dtype DT ) void ?{}( volatile DT * volatile *);820 777 forall( dtype DT ) void ?{}( const volatile DT * *); 821 forall( dtype DT ) void ?{}( const volatile DT * volatile *);822 778 823 779 void ?{}( void * *); 824 void ?{}( void * volatile *);825 780 void ?{}( const void * *); 826 void ?{}( const void * volatile *);827 781 void ?{}( volatile void * *); 828 void ?{}( volatile void * volatile *);829 782 void ?{}( const volatile void * *); 830 void ?{}( const volatile void * volatile *);831 783 832 784 // dtors 833 785 forall( ftype FT ) void ^?{}( FT * * ); 834 forall( ftype FT ) void ^?{}( FT * volatile * );835 786 836 787 forall( dtype DT ) void ^?{}( DT * *); 837 forall( dtype DT ) void ^?{}( DT * volatile *);838 788 forall( dtype DT ) void ^?{}( const DT * *); 839 forall( dtype DT ) void ^?{}( const DT * volatile *);840 789 forall( dtype DT ) void ^?{}( volatile DT * *); 841 forall( dtype DT ) void ^?{}( volatile DT * volatile *);842 790 forall( dtype DT ) void ^?{}( const volatile DT * *); 843 forall( dtype DT ) void ^?{}( const volatile DT * volatile *);844 791 845 792 void ^?{}( void * *); 846 void ^?{}( void * volatile *);847 793 void ^?{}( const void * *); 848 void ^?{}( const void * volatile *);849 794 void ^?{}( volatile void * *); 850 void ^?{}( volatile void * volatile *);851 795 void ^?{}( const volatile void * *); 852 void ^?{}( const volatile void * volatile *);853 796 854 797 // Local Variables: // -
src/tests/libcfa_vector.c
r2298f728 r9c23f31 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // libcfa_vector.c -- 8 // 6 // 7 // libcfa_vector.c -- 8 // 9 9 // Author : Thierry Delisle 10 10 // Created On : Mon Jul 4 23:36:19 2016 … … 12 12 // Last Modified On : Tue Jul 5 15:08:05 2016 13 13 // Update Count : 26 14 // 14 // 15 15 16 16 #include <fstream> … … 28 28 int main() { 29 29 vector( int, heap_allocator(int) ) iv; 30 ctor( &iv );31 30 32 31 assert( empty( &iv ) );
Note:
See TracChangeset
for help on using the changeset viewer.