Changes in / [23b6643f:aefcc3b]
- Location:
- src
- Files:
-
- 2 deleted
- 34 edited
-
CodeGen/GenType.cc (modified) (2 diffs)
-
Makefile.in (modified) (6 diffs)
-
ResolvExpr/AdjustExprType.cc (modified) (2 diffs)
-
ResolvExpr/CommonType.cc (modified) (5 diffs)
-
ResolvExpr/ConversionCost.cc (modified) (3 diffs)
-
ResolvExpr/ConversionCost.h (modified) (1 diff)
-
ResolvExpr/PtrsAssignable.cc (modified) (2 diffs)
-
ResolvExpr/PtrsCastable.cc (modified) (2 diffs)
-
ResolvExpr/RenameVars.cc (modified) (1 diff)
-
ResolvExpr/RenameVars.h (modified) (1 diff)
-
ResolvExpr/Resolver.cc (modified) (2 diffs)
-
ResolvExpr/Unify.cc (modified) (3 diffs)
-
SymTab/FixFunction.cc (modified) (1 diff)
-
SymTab/FixFunction.h (modified) (1 diff)
-
SymTab/ImplementationType.cc (modified) (2 diffs)
-
SymTab/Mangler.cc (modified) (1 diff)
-
SymTab/Mangler.h (modified) (1 diff)
-
SymTab/TypeEquality.cc (modified) (2 diffs)
-
SynTree/Mutator.cc (modified) (1 diff)
-
SynTree/Mutator.h (modified) (1 diff)
-
SynTree/SynTree.h (modified) (1 diff)
-
SynTree/Type.h (modified) (1 diff)
-
SynTree/TypeSubstitution.cc (modified) (2 diffs)
-
SynTree/TypeSubstitution.h (modified) (1 diff)
-
SynTree/Visitor.cc (modified) (1 diff)
-
SynTree/Visitor.h (modified) (1 diff)
-
SynTree/ZeroOneType.cc (deleted)
-
SynTree/module.mk (modified) (1 diff)
-
examples/gc_no_raii/src/internal/card_table.h (modified) (1 diff)
-
examples/gc_no_raii/src/internal/memory_pool.c (modified) (3 diffs)
-
examples/gc_no_raii/src/internal/memory_pool.h (modified) (2 diffs)
-
examples/gc_no_raii/src/internal/state.c (modified) (1 diff)
-
libcfa/containers/vector (modified) (13 diffs)
-
libcfa/containers/vector.c (modified) (6 diffs)
-
tests/.expect/libcfa_vector.txt (deleted)
-
tests/libcfa_vector.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/GenType.cc
r23b6643f raefcc3b 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 );46 44 47 45 private: … … 202 200 } 203 201 204 void GenType::visit( ZeroType *zeroType ) {205 // ideally these wouldn't hit codegen at all, but should be safe to make them ints206 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 ints212 typeString = "int " + typeString;213 handleQualifiers( oneType );214 }215 216 202 void GenType::handleQualifiers( Type *type ) { 217 203 if ( type->get_isConst() ) { -
src/Makefile.in
r23b6643f raefcc3b 164 164 SynTree/driver_cfa_cpp-AttrType.$(OBJEXT) \ 165 165 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) \ 166 SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) \167 166 SynTree/driver_cfa_cpp-Constant.$(OBJEXT) \ 168 167 SynTree/driver_cfa_cpp-Expression.$(OBJEXT) \ … … 389 388 SynTree/ReferenceToType.cc SynTree/TupleType.cc \ 390 389 SynTree/TypeofType.cc SynTree/AttrType.cc \ 391 SynTree/VarArgsType.cc SynTree/ ZeroOneType.cc \392 SynTree/ Constant.cc SynTree/Expression.cc SynTree/TupleExpr.cc \390 SynTree/VarArgsType.cc SynTree/Constant.cc \ 391 SynTree/Expression.cc SynTree/TupleExpr.cc \ 393 392 SynTree/CommaExpr.cc SynTree/TypeExpr.cc \ 394 393 SynTree/ApplicationExpr.cc SynTree/AddressExpr.cc \ … … 711 710 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \ 712 711 SynTree/$(DEPDIR)/$(am__dirstamp) 713 SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT): SynTree/$(am__dirstamp) \714 SynTree/$(DEPDIR)/$(am__dirstamp)715 712 SynTree/driver_cfa_cpp-Constant.$(OBJEXT): SynTree/$(am__dirstamp) \ 716 713 SynTree/$(DEPDIR)/$(am__dirstamp) … … 874 871 -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT) 875 872 -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) 876 -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT)877 873 -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) 878 874 -rm -f Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) … … 979 975 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@ 980 976 @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@982 977 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@ 983 978 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@ … … 2048 2043 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2049 2044 @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.cc2052 @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.cc2053 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po2054 @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.cc2057 2058 SynTree/driver_cfa_cpp-ZeroOneType.obj: SynTree/ZeroOneType.cc2059 @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.Po2061 @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`2064 2045 2065 2046 SynTree/driver_cfa_cpp-Constant.o: SynTree/Constant.cc -
src/ResolvExpr/AdjustExprType.cc
r23b6643f raefcc3b 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 );41 39 42 40 const TypeEnvironment &env; … … 119 117 return varArgsType; 120 118 } 121 122 Type *AdjustExprType::mutate( ZeroType *zeroType ) {123 return zeroType;124 }125 126 Type *AdjustExprType::mutate( OneType *oneType ) {127 return oneType;128 }129 119 } // namespace ResolvExpr 130 120 -
src/ResolvExpr/CommonType.cc
r23b6643f raefcc3b 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 );43 41 44 42 template< typename RefType > void handleRefType( RefType *inst, Type *other ); … … 136 134 result = new BasicType( basicType->get_qualifiers() + otherBasic->get_qualifiers(), newType ); 137 135 } // if 138 } else if ( dynamic_cast< EnumInstType * > ( type2 ) || dynamic_cast< ZeroType* >( type2 ) || dynamic_cast< OneType* >( type2 ) ) {139 // use signed int in lieu of the enum /zero/onetype136 } else if ( EnumInstType *enumInstType = dynamic_cast< EnumInstType * > ( type2 ) ) { 137 // use signed int in lieu of the enum type 140 138 BasicType::Kind newType = combinedType[ basicType->get_kind() ][ BasicType::SignedInt ]; 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 );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 ); 143 141 } // if 144 142 } // if … … 173 171 otherPointer->get_base()->get_qualifiers() = tq2; 174 172 } // if 175 } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) {176 result = pointerType->clone();177 result->get_qualifiers() += type2->get_qualifiers();178 173 } // if 179 174 } … … 195 190 196 191 void CommonType::visit( EnumInstType *enumInstType ) { 197 if ( dynamic_cast< BasicType * >( type2 ) || dynamic_cast< ZeroType* >( type2 ) || dynamic_cast< OneType* >( type2 )) {192 if ( dynamic_cast< BasicType * >( type2 ) ) { 198 193 // reuse BasicType, EnumInstType code by swapping type2 with enumInstType 199 194 Type * temp = type2; … … 235 230 void CommonType::visit( VarArgsType *varArgsType ) { 236 231 } 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 }259 232 } // namespace ResolvExpr 260 233 -
src/ResolvExpr/ConversionCost.cc
r23b6643f raefcc3b 160 160 // xxx - not positive this is correct, but appears to allow casting int => enum 161 161 cost = Cost( 1, 0, 0 ); 162 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) { 163 cost = Cost( 1, 0, 0 ); 164 } // if 162 } // if 165 163 } 166 164 … … 177 175 } // if 178 176 } // if 179 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {180 cost = Cost( 1, 0, 0 );181 177 } // if 182 178 } … … 260 256 } 261 257 } 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 conversions268 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 conversions284 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 }292 258 } // namespace ResolvExpr 293 259 -
src/ResolvExpr/ConversionCost.h
r23b6643f raefcc3b 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);45 43 protected: 46 44 Type *dest; -
src/ResolvExpr/PtrsAssignable.cc
r23b6643f raefcc3b 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 );43 41 private: 44 42 Type *dest; … … 143 141 void PtrsAssignable::visit( VarArgsType *varArgsType ) { 144 142 } 145 146 void PtrsAssignable::visit( ZeroType *zeroType ) {147 }148 149 void PtrsAssignable::visit( OneType *oneType ) {150 }151 152 143 } // namespace ResolvExpr 153 144 -
src/ResolvExpr/PtrsCastable.cc
r23b6643f raefcc3b 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);44 42 private: 45 43 Type *dest; … … 146 144 result = objectCast( dest, env, indexer ); 147 145 } 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 }156 146 } // namespace ResolvExpr 157 147 -
src/ResolvExpr/RenameVars.cc
r23b6643f raefcc3b 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 122 112 void RenameVars::typeBefore( Type *type ) { 123 113 if ( ! type->get_forall().empty() ) { -
src/ResolvExpr/RenameVars.h
r23b6643f raefcc3b 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 );48 46 49 47 void typeBefore( Type *type ); -
src/ResolvExpr/Resolver.cc
r23b6643f raefcc3b 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;138 136 } else { 139 137 return false; … … 457 455 } 458 456 } else { 459 assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) 460 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) ); 457 assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) ); 461 458 // basic types are handled here 462 459 Visitor::visit( listInit ); -
src/ResolvExpr/Unify.cc
r23b6643f raefcc3b 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);64 62 65 63 template< typename RefType > void handleRefType( RefType *inst, Type *other ); … … 590 588 } 591 589 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 600 590 // xxx - compute once and store in the FunctionType? 601 591 Type * extractResultType( FunctionType * function ) { … … 612 602 } 613 603 } 604 614 605 } // namespace ResolvExpr 615 606 -
src/SymTab/FixFunction.cc
r23b6643f raefcc3b 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 }87 79 } // namespace SymTab 88 80 -
src/SymTab/FixFunction.h
r23b6643f raefcc3b 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);46 44 47 45 bool isVoid; -
src/SymTab/ImplementationType.cc
r23b6643f raefcc3b 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);45 43 46 44 Type *result; // synthesized … … 122 120 void ImplementationType::visit(VarArgsType *varArgsType) { 123 121 } 124 125 void ImplementationType::visit(ZeroType *zeroType) {126 }127 128 void ImplementationType::visit(OneType *oneType) {129 }130 122 } // namespace SymTab 131 123 -
src/SymTab/Mangler.cc
r23b6643f raefcc3b 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";239 231 } 240 232 -
src/SymTab/Mangler.h
r23b6643f raefcc3b 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 );50 48 51 49 std::string get_mangleName() { return mangleName.str(); } -
src/SymTab/TypeEquality.cc
r23b6643f raefcc3b 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 );46 44 47 45 void handleQualifiers( Type * t ); … … 201 199 } 202 200 } 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 }217 201 } // namespace SymTab -
src/SynTree/Mutator.cc
r23b6643f raefcc3b 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 492 482 Initializer *Mutator::mutate( SingleInit *singleInit ) { 493 483 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) ); -
src/SynTree/Mutator.h
r23b6643f raefcc3b 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 );103 101 104 102 virtual Initializer* mutate( SingleInit *singleInit ); -
src/SynTree/SynTree.h
r23b6643f raefcc3b 106 106 class AttrType; 107 107 class VarArgsType; 108 class ZeroType;109 class OneType;110 108 111 109 class Initializer; -
src/SynTree/Type.h
r23b6643f raefcc3b 436 436 }; 437 437 438 /// Represents a zero constant439 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 constant451 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 462 438 inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) { 463 439 isConst &= other.isConst; -
src/SynTree/TypeSubstitution.cc
r23b6643f raefcc3b 179 179 } 180 180 181 Type * TypeSubstitution::mutate( VoidType * voidType ) {182 return handleType( voidType );181 Type * TypeSubstitution::mutate( VoidType *basicType ) { 182 return handleType( basicType ); 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 );231 223 } 232 224 -
src/SynTree/TypeSubstitution.h
r23b6643f raefcc3b 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);80 78 81 79 // TODO: worry about traversing into a forall-qualified function type or type decl with assertions -
src/SynTree/Visitor.cc
r23b6643f raefcc3b 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 416 408 void Visitor::visit( SingleInit *singleInit ) { 417 409 singleInit->get_value()->accept( *this ); -
src/SynTree/Visitor.h
r23b6643f raefcc3b 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 );103 101 104 102 virtual void visit( SingleInit *singleInit ); -
src/SynTree/module.mk
r23b6643f raefcc3b 26 26 SynTree/AttrType.cc \ 27 27 SynTree/VarArgsType.cc \ 28 SynTree/ZeroOneType.cc \29 28 SynTree/Constant.cc \ 30 29 SynTree/Expression.cc \ -
src/examples/gc_no_raii/src/internal/card_table.h
r23b6643f raefcc3b 18 18 }; 19 19 20 static inline void ?{}(card_table_t*this)20 static inline void ctor_card(card_table_t* const this) 21 21 { 22 22 this->count = 0; 23 23 } 24 24 25 static inline void ^?{}(card_table_t*this)25 static inline void dtor_card(card_table_t* const this) 26 26 { 27 27 -
src/examples/gc_no_raii/src/internal/memory_pool.c
r23b6643f raefcc3b 11 11 const size_t gc_pool_header_size = (size_t)( &(((gc_memory_pool*)NULL)->start_p) ); 12 12 13 void ?{}(gc_memory_pool*this, size_t size, gc_memory_pool* next, gc_memory_pool* mirror, uint8_t type)13 void ctor(gc_memory_pool *const 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 this->cards = ( (card_table_t*)malloc(sizeof(card_table_t)) ){}; 19 card_table_t* new = (card_table_t*)malloc(sizeof(card_table_t)); 20 this->cards = new; 21 ctor_card(this->cards); 20 22 21 23 this->end_p = ((uint8_t*)this) + size; … … 27 29 } 28 30 29 void ^?{}(gc_memory_pool*this)31 void dtor(gc_memory_pool *const this) 30 32 { 31 ^(&this->cards){};33 dtor_card(this->cards); 32 34 free(this->cards); 33 35 } -
src/examples/gc_no_raii/src/internal/memory_pool.h
r23b6643f raefcc3b 27 27 }; 28 28 29 void ?{}( gc_memory_pool*this,29 void ctor( gc_memory_pool *const this, 30 30 size_t size, 31 31 gc_memory_pool* next, … … 34 34 ); 35 35 36 void ^?{}(gc_memory_pool*this);36 void dtor(gc_memory_pool *const this); 37 37 38 38 struct gc_pool_object_iterator -
src/examples/gc_no_raii/src/internal/state.c
r23b6643f raefcc3b 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 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 };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); 137 137 138 138 this->total_space += gc_pool_size_used(this->from_space); -
src/libcfa/containers/vector
r23b6643f raefcc3b 20 20 } 21 21 22 #define DESTROY(x) 23 22 24 //------------------------------------------------------------------------------ 23 25 //Declaration 24 26 trait allocator_c(otype T, otype allocator_t) 25 27 { 26 void realloc_storage(allocator_t*, size_t); 27 T* data(allocator_t*); 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); 28 32 }; 29 30 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))31 struct vector;32 33 //------------------------------------------------------------------------------34 //Initialization35 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);46 33 47 34 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) … … 53 40 54 41 //------------------------------------------------------------------------------ 42 //Initialization 43 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 //------------------------------------------------------------------------------ 55 50 //Capacity 56 51 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 57 static inline bool empty(vector(T, allocator_t) *this)52 static inline bool empty(vector(T, allocator_t) *const this) 58 53 { 59 54 return this->size == 0; … … 61 56 62 57 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 63 static inline size_t size(vector(T, allocator_t) *this)58 static inline size_t size(vector(T, allocator_t) *const this) 64 59 { 65 60 return this->size; … … 67 62 68 63 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 69 static inline void reserve(vector(T, allocator_t) *this, size_t size)64 static inline void reserve(vector(T, allocator_t) *const this, size_t size) 70 65 { 71 66 realloc_storage(&this->storage, this->size+1); … … 75 70 //Element access 76 71 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 77 static inline T at(vector(T, allocator_t) *this, size_t index)72 static inline T at(vector(T, allocator_t) *const this, size_t index) 78 73 { 79 74 return data(&this->storage)[index]; … … 81 76 82 77 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 83 static inline T ?[?](vector(T, allocator_t) *this, size_t index)78 static inline T ?[?](vector(T, allocator_t) *const this, size_t index) 84 79 { 85 80 return data(&this->storage)[index]; … … 87 82 88 83 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 89 static inline T front(vector(T, allocator_t) *this)84 static inline T front(vector(T, allocator_t) *const this) 90 85 { 91 86 return data(&this->storage)[0]; … … 93 88 94 89 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 95 static inline T back(vector(T, allocator_t) *this)90 static inline T back(vector(T, allocator_t) *const this) 96 91 { 97 92 return data(&this->storage)[this->size - 1]; … … 101 96 //Modifiers 102 97 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 103 void push_back(vector(T, allocator_t) *this, T value);98 void push_back(vector(T, allocator_t) *const this, T value); 104 99 105 100 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 106 void pop_back(vector(T, allocator_t) *this);101 void pop_back(vector(T, allocator_t) *const this); 107 102 108 103 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 109 void clear(vector(T, allocator_t) *this);104 void clear(vector(T, allocator_t) *const this); 110 105 111 106 //------------------------------------------------------------------------------ 112 107 //Iterators 113 108 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 114 static inline T* begin(vector(T, allocator_t) *this)109 static inline T* begin(vector(T, allocator_t) *const this) 115 110 { 116 111 return data(&this->storage); … … 118 113 119 114 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 120 static inline const T* cbegin(const vector(T, allocator_t) *this)115 static inline const T* cbegin(const vector(T, allocator_t) *const this) 121 116 { 122 117 return data(&this->storage); … … 124 119 125 120 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 126 static inline T* end(vector(T, allocator_t) *this)121 static inline T* end(vector(T, allocator_t) *const this) 127 122 { 128 123 return data(&this->storage) + this->size; … … 130 125 131 126 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 132 static inline const T* cend(const vector(T, allocator_t) *this)127 static inline const T* cend(const vector(T, allocator_t) *const this) 133 128 { 134 129 return data(&this->storage) + this->size; … … 145 140 146 141 forall(otype T) 147 void ?{}(heap_allocator(T)*this);142 void ctor(heap_allocator(T) *const this); 148 143 149 144 forall(otype T) 150 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);145 void dtor(heap_allocator(T) *const this); 151 146 152 147 forall(otype T) 153 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);148 void realloc_storage(heap_allocator(T) *const this, size_t size); 154 149 155 150 forall(otype T) 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) 151 static inline T* data(heap_allocator(T) *const this) 163 152 { 164 153 return this->storage; -
src/libcfa/containers/vector.c
r23b6643f raefcc3b 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 23 20 //------------------------------------------------------------------------------ 24 21 //Initialization 25 22 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 26 void ?{}(vector(T, allocator_t)*this)23 void ctor(vector(T, allocator_t) *const this) 27 24 { 28 (&this->storage){};25 ctor(&this->storage); 29 26 this->size = 0; 30 27 } 31 28 32 29 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 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) 30 void dtor(vector(T, allocator_t) *const this) 49 31 { 50 32 clear(this); 51 ^(&this->storage){};33 dtor(&this->storage); 52 34 } 53 35 … … 55 37 //Modifiers 56 38 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 57 void push_back(vector(T, allocator_t) *this, T value)39 void push_back(vector(T, allocator_t) *const this, T value) 58 40 { 59 41 realloc_storage(&this->storage, this->size+1); … … 63 45 64 46 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 65 void pop_back(vector(T, allocator_t) *this)47 void pop_back(vector(T, allocator_t) *const this) 66 48 { 67 49 this->size--; 68 ^(&data(&this->storage)[this->size]){};50 DESTROY(data(&this->storage)[this->size]); 69 51 } 70 52 71 53 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 72 void clear(vector(T, allocator_t) *this)54 void clear(vector(T, allocator_t) *const this) 73 55 { 74 56 for(size_t i = 0; i < this->size; i++) 75 57 { 76 ^(&data(&this->storage)[this->size]){};58 DESTROY(data(&this->storage)[this->size]); 77 59 } 78 60 this->size = 0; … … 80 62 81 63 //------------------------------------------------------------------------------ 82 //Internal Helpers83 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 //------------------------------------------------------------------------------94 64 //Allocator 95 65 forall(otype T) 96 void ?{}(heap_allocator(T)*this)66 void ctor(heap_allocator(T) *const this) 97 67 { 98 68 this->storage = 0; … … 101 71 102 72 forall(otype T) 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) 73 void dtor(heap_allocator(T) *const this) 119 74 { 120 75 free(this->storage); … … 122 77 123 78 forall(otype T) 124 inline void realloc_storage(heap_allocator(T) *this, size_t size)79 inline void realloc_storage(heap_allocator(T) *const this, size_t size) 125 80 { 126 81 enum { GROWTH_RATE = 2 }; -
src/tests/libcfa_vector.c
r23b6643f raefcc3b 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 ); 30 31 31 32 assert( empty( &iv ) );
Note:
See TracChangeset
for help on using the changeset viewer.