Changeset 23b6643f
- Timestamp:
- Sep 20, 2016, 4:47:34 PM (8 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:
- 1132b62
- Parents:
- aefcc3b (diff), db46512 (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:
-
- 2 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/GenType.cc
raefcc3b r23b6643f 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/Makefile.in
raefcc3b r23b6643f 164 164 SynTree/driver_cfa_cpp-AttrType.$(OBJEXT) \ 165 165 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) \ 166 SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) \ 166 167 SynTree/driver_cfa_cpp-Constant.$(OBJEXT) \ 167 168 SynTree/driver_cfa_cpp-Expression.$(OBJEXT) \ … … 388 389 SynTree/ReferenceToType.cc SynTree/TupleType.cc \ 389 390 SynTree/TypeofType.cc SynTree/AttrType.cc \ 390 SynTree/VarArgsType.cc SynTree/ Constant.cc \391 SynTree/ Expression.cc SynTree/TupleExpr.cc \391 SynTree/VarArgsType.cc SynTree/ZeroOneType.cc \ 392 SynTree/Constant.cc SynTree/Expression.cc SynTree/TupleExpr.cc \ 392 393 SynTree/CommaExpr.cc SynTree/TypeExpr.cc \ 393 394 SynTree/ApplicationExpr.cc SynTree/AddressExpr.cc \ … … 710 711 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \ 711 712 SynTree/$(DEPDIR)/$(am__dirstamp) 713 SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT): SynTree/$(am__dirstamp) \ 714 SynTree/$(DEPDIR)/$(am__dirstamp) 712 715 SynTree/driver_cfa_cpp-Constant.$(OBJEXT): SynTree/$(am__dirstamp) \ 713 716 SynTree/$(DEPDIR)/$(am__dirstamp) … … 871 874 -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT) 872 875 -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) 876 -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) 873 877 -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) 874 878 -rm -f Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) … … 975 979 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@ 976 980 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ 981 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@ 977 982 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@ 978 983 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@ … … 2043 2048 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2044 2049 @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` 2050 2051 SynTree/driver_cfa_cpp-ZeroOneType.o: SynTree/ZeroOneType.cc 2052 @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 2053 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po 2054 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/ZeroOneType.cc' object='SynTree/driver_cfa_cpp-ZeroOneType.o' libtool=no @AMDEPBACKSLASH@ 2055 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2056 @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 2057 2058 SynTree/driver_cfa_cpp-ZeroOneType.obj: SynTree/ZeroOneType.cc 2059 @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` 2060 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po 2061 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/ZeroOneType.cc' object='SynTree/driver_cfa_cpp-ZeroOneType.obj' libtool=no @AMDEPBACKSLASH@ 2062 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2063 @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` 2045 2064 2046 2065 SynTree/driver_cfa_cpp-Constant.o: SynTree/Constant.cc -
src/ResolvExpr/AdjustExprType.cc
raefcc3b r23b6643f 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/CommonType.cc
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 134 134 } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) { 135 135 return bt->isInteger(); 136 } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) { 137 return true; 136 138 } else { 137 139 return false; … … 455 457 } 456 458 } else { 457 assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) ); 459 assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) 460 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) ); 458 461 // basic types are handled here 459 462 Visitor::visit( listInit ); -
src/ResolvExpr/Unify.cc
raefcc3b r23b6643f 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 // xxx - compute once and store in the FunctionType? 591 601 Type * extractResultType( FunctionType * function ) { … … 602 612 } 603 613 } 604 605 614 } // namespace ResolvExpr 606 615 -
src/SymTab/FixFunction.cc
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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/SynTree/Mutator.cc
raefcc3b r23b6643f 480 480 } 481 481 482 Type *Mutator::mutate( ZeroType *zeroType ) { 483 mutateAll( zeroType->get_forall(), *this ); 484 return zeroType; 485 } 486 487 Type *Mutator::mutate( OneType *oneType ) { 488 mutateAll( oneType->get_forall(), *this ); 489 return oneType; 490 } 491 482 492 Initializer *Mutator::mutate( SingleInit *singleInit ) { 483 493 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) ); -
src/SynTree/Mutator.h
raefcc3b r23b6643f 99 99 virtual Type* mutate( AttrType *attrType ); 100 100 virtual Type* mutate( VarArgsType *varArgsType ); 101 virtual Type* mutate( ZeroType *zeroType ); 102 virtual Type* mutate( OneType *oneType ); 101 103 102 104 virtual Initializer* mutate( SingleInit *singleInit ); -
src/SynTree/SynTree.h
raefcc3b r23b6643f 106 106 class AttrType; 107 107 class VarArgsType; 108 class ZeroType; 109 class OneType; 108 110 109 111 class Initializer; -
src/SynTree/Type.h
raefcc3b r23b6643f 436 436 }; 437 437 438 /// Represents a zero constant 439 class ZeroType : public Type { 440 public: 441 ZeroType(); 442 ZeroType( Type::Qualifiers tq ); 443 444 virtual ZeroType *clone() const { return new ZeroType( *this ); } 445 virtual void accept( Visitor &v ) { v.visit( this ); } 446 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } 447 virtual void print( std::ostream &os, int indent = 0 ) const; 448 }; 449 450 /// Represents a one constant 451 class OneType : public Type { 452 public: 453 OneType(); 454 OneType( Type::Qualifiers tq ); 455 456 virtual OneType *clone() const { return new OneType( *this ); } 457 virtual void accept( Visitor &v ) { v.visit( this ); } 458 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } 459 virtual void print( std::ostream &os, int indent = 0 ) const; 460 }; 461 438 462 inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) { 439 463 isConst &= other.isConst; -
src/SynTree/TypeSubstitution.cc
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 406 406 } 407 407 408 void Visitor::visit( ZeroType *zeroType ) { 409 acceptAll( zeroType->get_forall(), *this ); 410 } 411 412 void Visitor::visit( OneType *oneType ) { 413 acceptAll( oneType->get_forall(), *this ); 414 } 415 408 416 void Visitor::visit( SingleInit *singleInit ) { 409 417 singleInit->get_value()->accept( *this ); -
src/SynTree/Visitor.h
raefcc3b r23b6643f 99 99 virtual void visit( AttrType *attrType ); 100 100 virtual void visit( VarArgsType *varArgsType ); 101 virtual void visit( ZeroType *zeroType ); 102 virtual void visit( OneType *oneType ); 101 103 102 104 virtual void visit( SingleInit *singleInit ); -
src/SynTree/module.mk
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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/libcfa/containers/vector
raefcc3b r23b6643f 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
raefcc3b r23b6643f 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/tests/libcfa_vector.c
raefcc3b r23b6643f 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.