Changeset 7ae930a


Ignore:
Timestamp:
Sep 22, 2016, 3:52:33 AM (8 years ago)
Author:
Aaron Moss <bruceiv@…>
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:
9c23f31
Parents:
4e8d8a23 (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' of plg2.cs.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
1 added
27 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/GenType.cc

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    165165        SynTree/driver_cfa_cpp-AttrType.$(OBJEXT) \
    166166        SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) \
     167        SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) \
    167168        SynTree/driver_cfa_cpp-Constant.$(OBJEXT) \
    168169        SynTree/driver_cfa_cpp-Expression.$(OBJEXT) \
     
    390391        SynTree/ReferenceToType.cc SynTree/TupleType.cc \
    391392        SynTree/TypeofType.cc SynTree/AttrType.cc \
    392         SynTree/VarArgsType.cc SynTree/Constant.cc \
    393         SynTree/Expression.cc SynTree/TupleExpr.cc \
     393        SynTree/VarArgsType.cc SynTree/ZeroOneType.cc \
     394        SynTree/Constant.cc SynTree/Expression.cc SynTree/TupleExpr.cc \
    394395        SynTree/CommaExpr.cc SynTree/TypeExpr.cc \
    395396        SynTree/ApplicationExpr.cc SynTree/AddressExpr.cc \
     
    715716SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \
    716717        SynTree/$(DEPDIR)/$(am__dirstamp)
     718SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT): SynTree/$(am__dirstamp) \
     719        SynTree/$(DEPDIR)/$(am__dirstamp)
    717720SynTree/driver_cfa_cpp-Constant.$(OBJEXT): SynTree/$(am__dirstamp) \
    718721        SynTree/$(DEPDIR)/$(am__dirstamp)
     
    877880        -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT)
    878881        -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT)
     882        -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT)
    879883        -rm -f Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)
    880884        -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT)
     
    982986@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@
    983987@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@
     988@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@
    984989@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po@am__quote@
    985990@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@
     
    20642069@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    20652070@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarArgsType.obj `if test -f 'SynTree/VarArgsType.cc'; then $(CYGPATH_W) 'SynTree/VarArgsType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarArgsType.cc'; fi`
     2071
     2072SynTree/driver_cfa_cpp-ZeroOneType.o: SynTree/ZeroOneType.cc
     2073@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-ZeroOneType.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo -c -o SynTree/driver_cfa_cpp-ZeroOneType.o `test -f 'SynTree/ZeroOneType.cc' || echo '$(srcdir)/'`SynTree/ZeroOneType.cc
     2074@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po
     2075@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/ZeroOneType.cc' object='SynTree/driver_cfa_cpp-ZeroOneType.o' libtool=no @AMDEPBACKSLASH@
     2076@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2077@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-ZeroOneType.o `test -f 'SynTree/ZeroOneType.cc' || echo '$(srcdir)/'`SynTree/ZeroOneType.cc
     2078
     2079SynTree/driver_cfa_cpp-ZeroOneType.obj: SynTree/ZeroOneType.cc
     2080@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-ZeroOneType.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo -c -o SynTree/driver_cfa_cpp-ZeroOneType.obj `if test -f 'SynTree/ZeroOneType.cc'; then $(CYGPATH_W) 'SynTree/ZeroOneType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ZeroOneType.cc'; fi`
     2081@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po
     2082@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/ZeroOneType.cc' object='SynTree/driver_cfa_cpp-ZeroOneType.obj' libtool=no @AMDEPBACKSLASH@
     2083@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2084@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-ZeroOneType.obj `if test -f 'SynTree/ZeroOneType.cc'; then $(CYGPATH_W) 'SynTree/ZeroOneType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ZeroOneType.cc'; fi`
    20662085
    20672086SynTree/driver_cfa_cpp-Constant.o: SynTree/Constant.cc
  • src/ResolvExpr/AdjustExprType.cc

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    133133                        } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) {
    134134                                return bt->isInteger();
     135                        } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) {
     136                                return true;
    135137                        } else {
    136138                                return false;
     
    459461                        }
    460462                } else {
    461                         assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) );
     463                        assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext )
     464                                || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) );
    462465                        // basic types are handled here
    463466                        Visitor::visit( listInit );
  • src/ResolvExpr/Unify.cc

    r4e8d8a23 r7ae930a  
    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} // namespace ResolvExpr
    591601
  • src/SymTab/FixFunction.cc

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    453453}
    454454
     455Type *Mutator::mutate( ZeroType *zeroType ) {
     456        mutateAll( zeroType->get_forall(), *this );
     457        return zeroType;
     458}
     459
     460Type *Mutator::mutate( OneType *oneType ) {
     461        mutateAll( oneType->get_forall(), *this );
     462        return oneType;
     463}
     464
    455465Initializer *Mutator::mutate( SingleInit *singleInit ) {
    456466        singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
  • src/SynTree/Mutator.h

    r4e8d8a23 r7ae930a  
    9595        virtual Type* mutate( AttrType *attrType );
    9696        virtual Type* mutate( VarArgsType *varArgsType );
     97        virtual Type* mutate( ZeroType *zeroType );
     98        virtual Type* mutate( OneType *oneType );
    9799
    98100        virtual Initializer* mutate( SingleInit *singleInit );
  • src/SynTree/SynTree.h

    r4e8d8a23 r7ae930a  
    102102class AttrType;
    103103class VarArgsType;
     104class ZeroType;
     105class OneType;
    104106
    105107class Initializer;
  • src/SynTree/Type.h

    r4e8d8a23 r7ae930a  
    418418};
    419419
     420/// Represents a zero constant
     421class ZeroType : public Type {
     422  public:
     423        ZeroType();
     424        ZeroType( Type::Qualifiers tq );
     425
     426        virtual ZeroType *clone() const { return new ZeroType( *this ); }
     427        virtual void accept( Visitor &v ) { v.visit( this ); }
     428        virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     429        virtual void print( std::ostream &os, int indent = 0 ) const;
     430};
     431
     432/// Represents a one constant
     433class OneType : public Type {
     434  public:
     435        OneType();
     436        OneType( Type::Qualifiers tq );
     437
     438        virtual OneType *clone() const { return new OneType( *this ); }
     439        virtual void accept( Visitor &v ) { v.visit( this ); }
     440        virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     441        virtual void print( std::ostream &os, int indent = 0 ) const;
     442};
     443
    420444inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) {
    421445        isConst |= other.isConst;
  • src/SynTree/TypeSubstitution.cc

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    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

    r4e8d8a23 r7ae930a  
    383383}
    384384
     385void Visitor::visit( ZeroType *zeroType ) {
     386        acceptAll( zeroType->get_forall(), *this );
     387}
     388
     389void Visitor::visit( OneType *oneType ) {
     390        acceptAll( oneType->get_forall(), *this );
     391}
     392
    385393void Visitor::visit( SingleInit *singleInit ) {
    386394        singleInit->get_value()->accept( *this );
  • src/SynTree/Visitor.h

    r4e8d8a23 r7ae930a  
    9595        virtual void visit( AttrType *attrType );
    9696        virtual void visit( VarArgsType *varArgsType );
     97        virtual void visit( ZeroType *zeroType );
     98        virtual void visit( OneType *oneType );
    9799
    98100        virtual void visit( SingleInit *singleInit );
  • src/SynTree/module.mk

    r4e8d8a23 r7ae930a  
    2626       SynTree/AttrType.cc \
    2727       SynTree/VarArgsType.cc \
     28       SynTree/ZeroOneType.cc \
    2829       SynTree/Constant.cc \
    2930       SynTree/Expression.cc \
Note: See TracChangeset for help on using the changeset viewer.