Changeset 89e6ffc for src/SynTree


Ignore:
Timestamp:
Sep 19, 2016, 5:23:41 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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:
a6fe3de
Parents:
fc4a0fa
Message:

Added support for ZeroType? and OneType? to all relevant visitors

Location:
src/SynTree
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Mutator.cc

    rfc4a0fa r89e6ffc  
    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

    rfc4a0fa r89e6ffc  
    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

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

    rfc4a0fa r89e6ffc  
    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

    rfc4a0fa r89e6ffc  
    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

    rfc4a0fa r89e6ffc  
    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

    rfc4a0fa r89e6ffc  
    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

    rfc4a0fa r89e6ffc  
    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

    rfc4a0fa r89e6ffc  
    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.