Changeset 0698aa1


Ignore:
Timestamp:
Jul 12, 2017, 4:44:44 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
cda7889
Parents:
aca65621
Message:

Add stripReferences, fix createDeref and makeSub to work with reference types

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Makefile.in

    raca65621 r0698aa1  
    221221        SynTree/driver_cfa_cpp-PointerType.$(OBJEXT) \
    222222        SynTree/driver_cfa_cpp-ArrayType.$(OBJEXT) \
     223        SynTree/driver_cfa_cpp-ReferenceType.$(OBJEXT) \
    223224        SynTree/driver_cfa_cpp-FunctionType.$(OBJEXT) \
    224225        SynTree/driver_cfa_cpp-ReferenceToType.$(OBJEXT) \
     
    517518        SynTree/VoidType.cc SynTree/BasicType.cc \
    518519        SynTree/PointerType.cc SynTree/ArrayType.cc \
    519         SynTree/FunctionType.cc SynTree/ReferenceToType.cc \
    520         SynTree/TupleType.cc SynTree/TypeofType.cc SynTree/AttrType.cc \
     520        SynTree/ReferenceType.cc SynTree/FunctionType.cc \
     521        SynTree/ReferenceToType.cc SynTree/TupleType.cc \
     522        SynTree/TypeofType.cc SynTree/AttrType.cc \
    521523        SynTree/VarArgsType.cc SynTree/ZeroOneType.cc \
    522524        SynTree/Constant.cc SynTree/Expression.cc SynTree/TupleExpr.cc \
     
    864866SynTree/driver_cfa_cpp-ArrayType.$(OBJEXT): SynTree/$(am__dirstamp) \
    865867        SynTree/$(DEPDIR)/$(am__dirstamp)
     868SynTree/driver_cfa_cpp-ReferenceType.$(OBJEXT):  \
     869        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
    866870SynTree/driver_cfa_cpp-FunctionType.$(OBJEXT):  \
    867871        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
     
    10581062@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-PointerType.Po@am__quote@
    10591063@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceToType.Po@am__quote@
     1064@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Po@am__quote@
    10601065@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Statement.Po@am__quote@
    10611066@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TupleExpr.Po@am__quote@
     
    21542159@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    21552160@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-ArrayType.obj `if test -f 'SynTree/ArrayType.cc'; then $(CYGPATH_W) 'SynTree/ArrayType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ArrayType.cc'; fi`
     2161
     2162SynTree/driver_cfa_cpp-ReferenceType.o: SynTree/ReferenceType.cc
     2163@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-ReferenceType.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Tpo -c -o SynTree/driver_cfa_cpp-ReferenceType.o `test -f 'SynTree/ReferenceType.cc' || echo '$(srcdir)/'`SynTree/ReferenceType.cc
     2164@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Po
     2165@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/ReferenceType.cc' object='SynTree/driver_cfa_cpp-ReferenceType.o' libtool=no @AMDEPBACKSLASH@
     2166@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2167@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-ReferenceType.o `test -f 'SynTree/ReferenceType.cc' || echo '$(srcdir)/'`SynTree/ReferenceType.cc
     2168
     2169SynTree/driver_cfa_cpp-ReferenceType.obj: SynTree/ReferenceType.cc
     2170@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-ReferenceType.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Tpo -c -o SynTree/driver_cfa_cpp-ReferenceType.obj `if test -f 'SynTree/ReferenceType.cc'; then $(CYGPATH_W) 'SynTree/ReferenceType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ReferenceType.cc'; fi`
     2171@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Po
     2172@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/ReferenceType.cc' object='SynTree/driver_cfa_cpp-ReferenceType.obj' libtool=no @AMDEPBACKSLASH@
     2173@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2174@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-ReferenceType.obj `if test -f 'SynTree/ReferenceType.cc'; then $(CYGPATH_W) 'SynTree/ReferenceType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ReferenceType.cc'; fi`
    21562175
    21572176SynTree/driver_cfa_cpp-FunctionType.o: SynTree/FunctionType.cc
  • src/SynTree/Expression.cc

    raca65621 r0698aa1  
    335335namespace {
    336336        TypeSubstitution makeSub( Type * t ) {
    337                 if ( StructInstType * aggInst = dynamic_cast< StructInstType * >( t ) ) {
     337                if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( t ) ) {
     338                        return makeSub( refType->get_base() );
     339                } else if ( StructInstType * aggInst = dynamic_cast< StructInstType * >( t ) ) {
    338340                        return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->get_parameters().begin() );
    339341                } else if ( UnionInstType * aggInst = dynamic_cast< UnionInstType * >( t ) ) {
     
    400402        if ( Type * type = expr->get_result() ) {
    401403                Type * base = InitTweak::getPointerBase( type );
    402                 if ( ! base ) {
    403                         std::cerr << type << std::endl;
    404                 }
    405                 assertf( base, "expected pointer type in dereference\n" );
    406                 ret->set_result( maybeClone( base ) );
     404                assertf( base, "expected pointer type in dereference (type was %s)", toString( type ).c_str() );
     405                ret->set_result( new ReferenceType( Type::Qualifiers(), base->clone() ) );
    407406        }
    408407        return ret;
  • src/SynTree/Type.cc

    raca65621 r0698aa1  
    6565const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
    6666
    67 Type *Type::stripDeclarator() {
     67Type * Type::stripDeclarator() {
    6868        Type * type = this;
    6969        while ( Type * at = InitTweak::getPointerBase( type ) ) {
    7070                type = at;
     71        }
     72        return type;
     73}
     74
     75Type * Type::stripReferences() {
     76        Type * type = this;
     77        while ( ReferenceType * ref = dynamic_cast<ReferenceType *>( type ) ) {
     78                type = ref->get_base();
    7179        }
    7280        return type;
  • src/SynTree/Type.h

    raca65621 r0698aa1  
    158158
    159159        /// return type without outer pointers and arrays
    160         Type *stripDeclarator();
     160        Type * stripDeclarator();
     161
     162        /// return type without outer references
     163        Type * stripReferences();
    161164
    162165        virtual bool isComplete() const { return true; }
Note: See TracChangeset for help on using the changeset viewer.