Changeset 23b6643f


Ignore:
Timestamp:
Sep 20, 2016, 4:47:34 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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.
Message:

Merge branch 'master' into tuples

Conflicts:

src/Makefile.in
src/ResolvExpr/Unify.cc
src/SynTree/Type.h

Location:
src
Files:
2 added
34 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/GenType.cc

    raefcc3b r23b6643f  
    4242                virtual void visit( TypeInstType *typeInst );
    4343                virtual void visit( VarArgsType *varArgsType );
     44                virtual void visit( ZeroType *zeroType );
     45                virtual void visit( OneType *oneType );
    4446
    4547          private:
     
    200202        }
    201203
     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
    202216        void GenType::handleQualifiers( Type *type ) {
    203217                if ( type->get_isConst() ) {
  • src/Makefile.in

    raefcc3b r23b6643f  
    164164        SynTree/driver_cfa_cpp-AttrType.$(OBJEXT) \
    165165        SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) \
     166        SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) \
    166167        SynTree/driver_cfa_cpp-Constant.$(OBJEXT) \
    167168        SynTree/driver_cfa_cpp-Expression.$(OBJEXT) \
     
    388389        SynTree/ReferenceToType.cc SynTree/TupleType.cc \
    389390        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 \
    392393        SynTree/CommaExpr.cc SynTree/TypeExpr.cc \
    393394        SynTree/ApplicationExpr.cc SynTree/AddressExpr.cc \
     
    710711SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \
    711712        SynTree/$(DEPDIR)/$(am__dirstamp)
     713SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT): SynTree/$(am__dirstamp) \
     714        SynTree/$(DEPDIR)/$(am__dirstamp)
    712715SynTree/driver_cfa_cpp-Constant.$(OBJEXT): SynTree/$(am__dirstamp) \
    713716        SynTree/$(DEPDIR)/$(am__dirstamp)
     
    871874        -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT)
    872875        -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT)
     876        -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT)
    873877        -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT)
    874878        -rm -f Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT)
     
    975979@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@
    976980@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@
    977982@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@
    978983@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@
     
    20432048@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    20442049@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
     2051SynTree/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
     2058SynTree/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`
    20452064
    20462065SynTree/driver_cfa_cpp-Constant.o: SynTree/Constant.cc
  • src/ResolvExpr/AdjustExprType.cc

    raefcc3b r23b6643f  
    3737                virtual Type* mutate( TupleType *tupleType );
    3838                virtual Type* mutate( VarArgsType *varArgsType );
     39                virtual Type* mutate( ZeroType *zeroType );
     40                virtual Type* mutate( OneType *oneType );
    3941
    4042                const TypeEnvironment &env;
     
    117119                return varArgsType;
    118120        }
     121
     122        Type *AdjustExprType::mutate( ZeroType *zeroType ) {
     123                return zeroType;
     124        }
     125
     126        Type *AdjustExprType::mutate( OneType *oneType ) {
     127                return oneType;
     128        }
    119129} // namespace ResolvExpr
    120130
  • src/ResolvExpr/CommonType.cc

    raefcc3b r23b6643f  
    3939                virtual void visit( TupleType *tupleType );
    4040                virtual void visit( VarArgsType *varArgsType );
     41                virtual void visit( ZeroType *zeroType );
     42                virtual void visit( OneType *oneType );
    4143
    4244                template< typename RefType > void handleRefType( RefType *inst, Type *other );
     
    134136                                result = new BasicType( basicType->get_qualifiers() + otherBasic->get_qualifiers(), newType );
    135137                        } // if
    136                 } else if ( EnumInstType *enumInstType = dynamic_cast< EnumInstType * > ( type2 ) ) {
    137                         // use signed int in lieu of the enum type
     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/one type
    138140                        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 );
    141143                        } // if
    142144                } // if
     
    171173                                otherPointer->get_base()->get_qualifiers() = tq2;
    172174                        } // if
     175                } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) {
     176                        result = pointerType->clone();
     177                        result->get_qualifiers() += type2->get_qualifiers();
    173178                } // if
    174179        }
     
    190195
    191196        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 ) ) {
    193198                        // reuse BasicType, EnumInstType code by swapping type2 with enumInstType
    194199                        Type * temp = type2;
     
    230235        void CommonType::visit( VarArgsType *varArgsType ) {
    231236        }
     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        }
    232259} // namespace ResolvExpr
    233260
  • src/ResolvExpr/ConversionCost.cc

    raefcc3b r23b6643f  
    160160                        // xxx - not positive this is correct, but appears to allow casting int => enum
    161161                        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
    163165        }
    164166
     
    175177                                } // if
    176178                        } // if
     179                } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {
     180                        cost = Cost( 1, 0, 0 );
    177181                } // if
    178182        }
     
    256260                }
    257261        }
     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        }
    258292} // namespace ResolvExpr
    259293
  • src/ResolvExpr/ConversionCost.h

    raefcc3b r23b6643f  
    4141                virtual void visit(TupleType *tupleType);
    4242                virtual void visit(VarArgsType *varArgsType);
     43                virtual void visit(ZeroType *zeroType);
     44                virtual void visit(OneType *oneType);
    4345          protected:
    4446                Type *dest;
  • src/ResolvExpr/PtrsAssignable.cc

    raefcc3b r23b6643f  
    3939                virtual void visit( TupleType *tupleType );
    4040                virtual void visit( VarArgsType *varArgsType );
     41                virtual void visit( ZeroType *zeroType );
     42                virtual void visit( OneType *oneType );
    4143          private:
    4244                Type *dest;
     
    141143        void PtrsAssignable::visit( VarArgsType *varArgsType ) {
    142144        }
     145
     146        void PtrsAssignable::visit( ZeroType *zeroType ) {
     147        }
     148       
     149        void PtrsAssignable::visit( OneType *oneType ) {
     150        }
     151       
    143152} // namespace ResolvExpr
    144153
  • src/ResolvExpr/PtrsCastable.cc

    raefcc3b r23b6643f  
    4040                virtual void visit(TupleType *tupleType);
    4141                virtual void visit(VarArgsType *varArgsType);
     42                virtual void visit(ZeroType *zeroType);
     43                virtual void visit(OneType *oneType);
    4244          private:
    4345                Type *dest;
     
    144146                result = objectCast( dest, env, indexer );
    145147        }
     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        }
    146156} // namespace ResolvExpr
    147157
  • src/ResolvExpr/RenameVars.cc

    raefcc3b r23b6643f  
    110110        }
    111111
     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
    112122        void RenameVars::typeBefore( Type *type ) {
    113123                if ( ! type->get_forall().empty() ) {
  • src/ResolvExpr/RenameVars.h

    raefcc3b r23b6643f  
    4444                virtual void visit( TupleType *tupleType );
    4545                virtual void visit( VarArgsType *varArgsType );
     46                virtual void visit( ZeroType *zeroType );
     47                virtual void visit( OneType *oneType );
    4648
    4749                void typeBefore( Type *type );
  • src/ResolvExpr/Resolver.cc

    raefcc3b r23b6643f  
    134134                        } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) {
    135135                                return bt->isInteger();
     136                        } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) {
     137                                return true;
    136138                        } else {
    137139                                return false;
     
    455457                        }
    456458                } 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 ) );
    458461                        // basic types are handled here
    459462                        Visitor::visit( listInit );
  • src/ResolvExpr/Unify.cc

    raefcc3b r23b6643f  
    6060                virtual void visit(TupleType *tupleType);
    6161                virtual void visit(VarArgsType *varArgsType);
     62                virtual void visit(ZeroType *zeroType);
     63                virtual void visit(OneType *oneType);
    6264
    6365                template< typename RefType > void handleRefType( RefType *inst, Type *other );
     
    588590        }
    589591
     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
    590600        // xxx - compute once and store in the FunctionType?
    591601        Type * extractResultType( FunctionType * function ) {
     
    602612                }
    603613        }
    604 
    605614} // namespace ResolvExpr
    606615
  • src/SymTab/FixFunction.cc

    raefcc3b r23b6643f  
    7777                return varArgsType;
    7878        }
     79
     80        Type * FixFunction::mutate(ZeroType *zeroType) {
     81                return zeroType;
     82        }
     83
     84        Type * FixFunction::mutate(OneType *oneType) {
     85                return oneType;
     86        }
    7987} // namespace SymTab
    8088
  • src/SymTab/FixFunction.h

    raefcc3b r23b6643f  
    4242                virtual Type* mutate(TupleType *tupleType);
    4343                virtual Type* mutate(VarArgsType *varArgsType);
     44                virtual Type* mutate(ZeroType *zeroType);
     45                virtual Type* mutate(OneType *oneType);
    4446 
    4547                bool isVoid;
  • src/SymTab/ImplementationType.cc

    raefcc3b r23b6643f  
    4141                virtual void visit(TupleType *tupleType);
    4242                virtual void visit(VarArgsType *varArgsType);
     43                virtual void visit(ZeroType *zeroType);
     44                virtual void visit(OneType *oneType);
    4345
    4446                Type *result;                   // synthesized
     
    120122        void ImplementationType::visit(VarArgsType *varArgsType) {
    121123        }
     124
     125        void ImplementationType::visit(ZeroType *zeroType) {
     126        }
     127
     128        void ImplementationType::visit(OneType *oneType) {
     129        }
    122130} // namespace SymTab
    123131
  • src/SymTab/Mangler.cc

    raefcc3b r23b6643f  
    229229                printQualifiers( varArgsType );
    230230                mangleName << "VARGS";
     231        }
     232
     233        void Mangler::visit( ZeroType *zeroType ) {
     234                mangleName << "Z";
     235        }
     236
     237        void Mangler::visit( OneType *oneType ) {
     238                mangleName << "O";
    231239        }
    232240
  • src/SymTab/Mangler.h

    raefcc3b r23b6643f  
    4646                virtual void visit( TupleType *tupleType );
    4747                virtual void visit( VarArgsType *varArgsType );
     48                virtual void visit( ZeroType *zeroType );
     49                virtual void visit( OneType *oneType );
    4850 
    4951                std::string get_mangleName() { return mangleName.str(); }
  • src/SymTab/TypeEquality.cc

    raefcc3b r23b6643f  
    4242                virtual void visit( TypeInstType *typeInst );
    4343                virtual void visit( VarArgsType *varArgsType );
     44                virtual void visit( ZeroType *zeroType );
     45                virtual void visit( OneType *oneType );
    4446
    4547                void handleQualifiers( Type * t );
     
    199201                }
    200202        }
     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        }
    201217} // namespace SymTab
  • src/SynTree/Mutator.cc

    raefcc3b r23b6643f  
    480480}
    481481
     482Type *Mutator::mutate( ZeroType *zeroType ) {
     483        mutateAll( zeroType->get_forall(), *this );
     484        return zeroType;
     485}
     486
     487Type *Mutator::mutate( OneType *oneType ) {
     488        mutateAll( oneType->get_forall(), *this );
     489        return oneType;
     490}
     491
    482492Initializer *Mutator::mutate( SingleInit *singleInit ) {
    483493        singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
  • src/SynTree/Mutator.h

    raefcc3b r23b6643f  
    9999        virtual Type* mutate( AttrType *attrType );
    100100        virtual Type* mutate( VarArgsType *varArgsType );
     101        virtual Type* mutate( ZeroType *zeroType );
     102        virtual Type* mutate( OneType *oneType );
    101103
    102104        virtual Initializer* mutate( SingleInit *singleInit );
  • src/SynTree/SynTree.h

    raefcc3b r23b6643f  
    106106class AttrType;
    107107class VarArgsType;
     108class ZeroType;
     109class OneType;
    108110
    109111class Initializer;
  • src/SynTree/Type.h

    raefcc3b r23b6643f  
    436436};
    437437
     438/// Represents a zero constant
     439class 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
     451class 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
    438462inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) {
    439463        isConst &= other.isConst;
  • src/SynTree/TypeSubstitution.cc

    raefcc3b r23b6643f  
    179179}
    180180
    181 Type * TypeSubstitution::mutate( VoidType *basicType ) {
    182         return handleType( basicType );
     181Type * TypeSubstitution::mutate( VoidType *voidType ) {
     182        return handleType( voidType );
    183183}
    184184
     
    221221Type * TypeSubstitution::mutate( VarArgsType *varArgsType ) {
    222222        return handleType( varArgsType );
     223}
     224
     225Type * TypeSubstitution::mutate( ZeroType *zeroType ) {
     226        return handleType( zeroType );
     227}
     228
     229Type * TypeSubstitution::mutate( OneType *oneType ) {
     230        return handleType( oneType );
    223231}
    224232
  • src/SynTree/TypeSubstitution.h

    raefcc3b r23b6643f  
    7676        virtual Type* mutate(TupleType *tupleType);
    7777        virtual Type* mutate(VarArgsType *varArgsType);
     78        virtual Type* mutate(ZeroType *zeroType);
     79        virtual Type* mutate(OneType *oneType);
    7880
    7981        // TODO: worry about traversing into a forall-qualified function type or type decl with assertions
  • src/SynTree/Visitor.cc

    raefcc3b r23b6643f  
    406406}
    407407
     408void Visitor::visit( ZeroType *zeroType ) {
     409        acceptAll( zeroType->get_forall(), *this );
     410}
     411
     412void Visitor::visit( OneType *oneType ) {
     413        acceptAll( oneType->get_forall(), *this );
     414}
     415
    408416void Visitor::visit( SingleInit *singleInit ) {
    409417        singleInit->get_value()->accept( *this );
  • src/SynTree/Visitor.h

    raefcc3b r23b6643f  
    9999        virtual void visit( AttrType *attrType );
    100100        virtual void visit( VarArgsType *varArgsType );
     101        virtual void visit( ZeroType *zeroType );
     102        virtual void visit( OneType *oneType );
    101103
    102104        virtual void visit( SingleInit *singleInit );
  • src/SynTree/module.mk

    raefcc3b r23b6643f  
    2626       SynTree/AttrType.cc \
    2727       SynTree/VarArgsType.cc \
     28       SynTree/ZeroOneType.cc \
    2829       SynTree/Constant.cc \
    2930       SynTree/Expression.cc \
  • src/examples/gc_no_raii/src/internal/card_table.h

    raefcc3b r23b6643f  
    1818};
    1919
    20 static inline void ctor_card(card_table_t* const this)
     20static inline void ?{}(card_table_t* this)
    2121{
    2222        this->count = 0;
    2323}
    2424
    25 static inline void dtor_card(card_table_t* const this)
     25static inline void ^?{}(card_table_t* this)
    2626{
    2727
  • src/examples/gc_no_raii/src/internal/memory_pool.c

    raefcc3b r23b6643f  
    1111const size_t gc_pool_header_size = (size_t)(  &(((gc_memory_pool*)NULL)->start_p) );
    1212
    13 void ctor(gc_memory_pool *const this, size_t size, gc_memory_pool* next, gc_memory_pool* mirror, uint8_t type)
     13void ?{}(gc_memory_pool* this, size_t size, gc_memory_pool* next, gc_memory_pool* mirror, uint8_t type)
    1414{
    1515        this->mirror = mirror;
     
    1717        this->type_code = type;
    1818
    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)) ){};
    2220
    2321        this->end_p = ((uint8_t*)this) + size;
     
    2927}
    3028
    31 void dtor(gc_memory_pool *const this)
     29void ^?{}(gc_memory_pool* this)
    3230{
    33         dtor_card(this->cards);
     31        ^(&this->cards){};
    3432        free(this->cards);
    3533}
  • src/examples/gc_no_raii/src/internal/memory_pool.h

    raefcc3b r23b6643f  
    2727};
    2828
    29 void ctor(      gc_memory_pool *const this,
     29void ?{}(       gc_memory_pool* this,
    3030                size_t size,
    3131                gc_memory_pool* next,
     
    3434        );
    3535
    36 void dtor(gc_memory_pool *const this);
     36void ^?{}(gc_memory_pool* this);
    3737
    3838struct gc_pool_object_iterator
  • src/examples/gc_no_raii/src/internal/state.c

    raefcc3b r23b6643f  
    131131
    132132      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 };
    137137
    138138        this->total_space += gc_pool_size_used(this->from_space);
  • src/libcfa/containers/vector

    raefcc3b r23b6643f  
    2020}
    2121
    22 #define DESTROY(x)
    23 
    2422//------------------------------------------------------------------------------
    2523//Declaration
    2624trait allocator_c(otype T, otype allocator_t)
    2725{
    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*);
    3228};
     29
     30forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     31struct vector;
     32
     33//------------------------------------------------------------------------------
     34//Initialization
     35forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     36void ?{}(vector(T, allocator_t)* this);
     37
     38forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     39void ?{}(vector(T, allocator_t)* this, vector(T, allocator_t) rhs);
     40
     41forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     42vector(T, allocator_t) ?=?(vector(T, allocator_t)* this, vector(T, allocator_t) rhs);
     43
     44forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     45void ^?{}(vector(T, allocator_t)* this);
    3346
    3447forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     
    4053
    4154//------------------------------------------------------------------------------
    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 //------------------------------------------------------------------------------
    5055//Capacity
    5156forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    52 static inline bool empty(vector(T, allocator_t) *const this)
     57static inline bool empty(vector(T, allocator_t)* this)
    5358{
    5459        return this->size == 0;
     
    5661
    5762forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    58 static inline size_t size(vector(T, allocator_t) *const this)
     63static inline size_t size(vector(T, allocator_t)* this)
    5964{
    6065        return this->size;
     
    6267
    6368forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    64 static inline void reserve(vector(T, allocator_t) *const this, size_t size)
     69static inline void reserve(vector(T, allocator_t)* this, size_t size)
    6570{
    6671        realloc_storage(&this->storage, this->size+1);
     
    7075//Element access
    7176forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    72 static inline T at(vector(T, allocator_t) *const this, size_t index)
     77static inline T at(vector(T, allocator_t)* this, size_t index)
    7378{
    7479        return data(&this->storage)[index];
     
    7681
    7782forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    78 static inline T ?[?](vector(T, allocator_t) *const this, size_t index)
     83static inline T ?[?](vector(T, allocator_t)* this, size_t index)
    7984{
    8085        return data(&this->storage)[index];
     
    8287
    8388forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    84 static inline T front(vector(T, allocator_t) *const this)
     89static inline T front(vector(T, allocator_t)* this)
    8590{
    8691        return data(&this->storage)[0];
     
    8893
    8994forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    90 static inline T back(vector(T, allocator_t) *const this)
     95static inline T back(vector(T, allocator_t)* this)
    9196{
    9297        return data(&this->storage)[this->size - 1];
     
    96101//Modifiers
    97102forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    98 void push_back(vector(T, allocator_t) *const this, T value);
     103void push_back(vector(T, allocator_t)* this, T value);
    99104
    100105forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    101 void pop_back(vector(T, allocator_t) *const this);
     106void pop_back(vector(T, allocator_t)* this);
    102107
    103108forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    104 void clear(vector(T, allocator_t) *const this);
     109void clear(vector(T, allocator_t)* this);
    105110
    106111//------------------------------------------------------------------------------
    107112//Iterators
    108113forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    109 static inline T* begin(vector(T, allocator_t) *const this)
     114static inline T* begin(vector(T, allocator_t)* this)
    110115{
    111116        return data(&this->storage);
     
    113118
    114119forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    115 static inline const T* cbegin(const vector(T, allocator_t) *const this)
     120static inline const T* cbegin(const vector(T, allocator_t)* this)
    116121{
    117122        return data(&this->storage);
     
    119124
    120125forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    121 static inline T* end(vector(T, allocator_t) *const this)
     126static inline T* end(vector(T, allocator_t)* this)
    122127{
    123128        return data(&this->storage) + this->size;
     
    125130
    126131forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    127 static inline const T* cend(const vector(T, allocator_t) *const this)
     132static inline const T* cend(const vector(T, allocator_t)* this)
    128133{
    129134        return data(&this->storage) + this->size;
     
    140145
    141146forall(otype T)
    142 void ctor(heap_allocator(T) *const this);
     147void ?{}(heap_allocator(T)* this);
    143148
    144149forall(otype T)
    145 void dtor(heap_allocator(T) *const this);
     150void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);
    146151
    147152forall(otype T)
    148 void realloc_storage(heap_allocator(T) *const this, size_t size);
     153heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);
    149154
    150155forall(otype T)
    151 static inline T* data(heap_allocator(T) *const this)
     156void ^?{}(heap_allocator(T)* this);
     157
     158forall(otype T)
     159void realloc_storage(heap_allocator(T)* this, size_t size);
     160
     161forall(otype T)
     162static inline T* data(heap_allocator(T)* this)
    152163{
    153164        return this->storage;
  • src/libcfa/containers/vector.c

    raefcc3b r23b6643f  
    1818#include <stdlib>
    1919
     20forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     21void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other);
     22
    2023//------------------------------------------------------------------------------
    2124//Initialization
    2225forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    23 void ctor(vector(T, allocator_t) *const this)
     26void ?{}(vector(T, allocator_t)* this)
    2427{
    25         ctor(&this->storage);
     28        (&this->storage){};
    2629        this->size = 0;
    2730}
    2831
    2932forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    30 void dtor(vector(T, allocator_t) *const this)
     33void ?{}(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
     47forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     48void ^?{}(vector(T, allocator_t)* this)
    3149{
    3250        clear(this);
    33         dtor(&this->storage);
     51        ^(&this->storage){};
    3452}
    3553
     
    3755//Modifiers
    3856forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    39 void push_back(vector(T, allocator_t) *const this, T value)
     57void push_back(vector(T, allocator_t)* this, T value)
    4058{
    4159        realloc_storage(&this->storage, this->size+1);
     
    4563
    4664forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    47 void pop_back(vector(T, allocator_t) *const this)
     65void pop_back(vector(T, allocator_t)* this)
    4866{
    4967        this->size--;
    50         DESTROY(data(&this->storage)[this->size]);
     68        ^(&data(&this->storage)[this->size]){};
    5169}
    5270
    5371forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    54 void clear(vector(T, allocator_t) *const this)
     72void clear(vector(T, allocator_t)* this)
    5573{
    5674        for(size_t i = 0; i < this->size; i++)
    5775        {
    58                 DESTROY(data(&this->storage)[this->size]);
     76                ^(&data(&this->storage)[this->size]){};
    5977        }
    6078        this->size = 0;
     
    6280
    6381//------------------------------------------------------------------------------
     82//Internal Helpers
     83
     84forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     85void 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//------------------------------------------------------------------------------
    6494//Allocator
    6595forall(otype T)
    66 void ctor(heap_allocator(T) *const this)
     96void ?{}(heap_allocator(T)* this)
    6797{
    6898        this->storage = 0;
     
    71101
    72102forall(otype T)
    73 void dtor(heap_allocator(T) *const this)
     103void ?{}(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
     109forall(otype T)
     110heap_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
     117forall(otype T)
     118void ^?{}(heap_allocator(T)* this)
    74119{
    75120        free(this->storage);
     
    77122
    78123forall(otype T)
    79 inline void realloc_storage(heap_allocator(T) *const this, size_t size)
     124inline void realloc_storage(heap_allocator(T)* this, size_t size)
    80125{
    81126        enum { GROWTH_RATE = 2 };
  • src/tests/libcfa_vector.c

    raefcc3b r23b6643f  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // libcfa_vector.c -- 
    8 // 
     6//
     7// libcfa_vector.c --
     8//
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Jul  4 23:36:19 2016
     
    1212// Last Modified On : Tue Jul  5 15:08:05 2016
    1313// Update Count     : 26
    14 // 
     14//
    1515
    1616#include <fstream>
     
    2828int main() {
    2929        vector( int, heap_allocator(int) ) iv;
    30         ctor( &iv );
    3130
    3231        assert( empty( &iv ) );
Note: See TracChangeset for help on using the changeset viewer.