Changeset a32346b for src


Ignore:
Timestamp:
Sep 25, 2018, 4:56:55 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
34a6b2e, a332d432
Parents:
48b7085e (diff), 560812b (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:
6 edited

Legend:

Unmodified
Added
Removed
  • src/CodeTools/ResolvProtoDump.cc

    r48b7085e ra32346b  
    196196                        }
    197197                       
    198                         // default to just name
    199                         ss << pre << name;
     198                        // default to just name, with first character in lowercase
     199                        ss << pre
     200                           << (char)std::tolower( static_cast<unsigned char>(name[0]) )
     201                           << (name.c_str() + 1);
    200202                }
    201203
    202204                /// ensures type inst names are uppercase
    203205                static void ti_name( const std::string& name, std::stringstream& ss ) {
    204                         ss << (char)std::toupper( static_cast<unsigned char>(name[0]) )
    205                            << (name.c_str() + 1);
     206                        unsigned i = 0;
     207                        while ( i < name.size() && name[i] == '_' ) { ++i; }
     208                        if ( i == name.size() ) {
     209                                ss << "Anon";
     210                                return;
     211                        }
     212                        ss << (char)std::toupper( static_cast<unsigned char>(name[i]) )
     213                           << (name.c_str() + i + 1);
    206214                }
    207215
     
    219227                        void previsit( BasicType* bt ) { ss << (int)bt->get_kind(); }
    220228
    221                         // pointers represented as generic type
    222                         // TODO except pointer to function
    223                         void previsit( PointerType* ) { ss << "#$ptr<"; ++depth; }
    224                         void postvisit( PointerType* ) { --depth; ss << '>'; }
    225 
    226                         // arrays represented as generic type
     229                        // pointers (except function pointers) represented as generic type
     230                        void previsit( PointerType* pt ) {
     231                                if ( ! dynamic_cast<FunctionType*>(pt->base) ) { ss << "#$ptr<"; ++depth; }
     232                        }
     233                        void postvisit( PointerType* pt ) {
     234                                if ( ! dynamic_cast<FunctionType*>(pt->base) ) { --depth; ss << '>'; }
     235                        }
     236
     237                        // arrays represented as generic pointers
    227238                        void previsit( ArrayType* at ) {
    228                                 ss << "#$arr<";
     239                                ss << "#$ptr<";
    229240                                ++depth;
    230241                                at->base->accept( *visitor );
     
    244255                        }
    245256
    246                         // encode function type as a 2-param generic type
    247                         // TODO handle forall functions
     257                        // print function types using prototype syntax
    248258                        void previsit( FunctionType* ft ) {
    249                                 ss << "#$fn<";
     259                                ss << '[';
    250260                                ++depth;
    251                                 buildAsTuple( *visitor, from_decls( ft->returnVals ), ss );
    252                                 ss << ' ';
    253                                 buildAsTuple( *visitor, from_decls( ft->parameters ), ss );
     261                                build( *visitor, from_decls( ft->returnVals ), ss, preceded );
     262                                ss << " : ";
     263                                build( *visitor, from_decls( ft->parameters ), ss, terminated );
    254264                                --depth;
    255                                 ss << '>';
     265                                ss << ']';
    256266                                visit_children = false;
    257267                        }
     
    341351                        }
    342352
    343                         // print variable declaration as zero-arg function
     353                        // print variable declaration in prototype syntax
    344354                        PassVisitor<TypePrinter> printTy{ closed, ss };
    345355                        norefs->accept( printTy );
    346                         ss << ' ';
     356                        ss << " &";
    347357                        rp_name( name, ss );
    348358                }
     
    381391                                : closed(closed), ss(ss) {}
    382392
    383                         /// Names handled as nullary function calls
     393                        /// Names handled as name expressions
    384394                        void previsit( NameExpr* expr ) {
     395                                ss << '&';
    385396                                rp_name( expr->name, ss );
    386                                 ss << "()";
    387397                        }
    388398
     
    416426                        }
    417427
     428                        /// Already-resolved calls skipped
     429                        void previsit( ApplicationExpr* ) {
     430                                visit_children = false;
     431                        }
     432
    418433                        /// Address-of handled as operator
    419434                        void previsit( AddressExpr* expr ) {
     
    585600
    586601                void previsit( FunctionDecl *decl ) {
     602                        // skip decls with ftype parameters
     603                        for ( TypeDecl* tyvar : decl->type->forall ) {
     604                                if ( tyvar->get_kind() == TypeDecl::Ftype ) {
     605                                        visit_children = false;
     606                                        return;
     607                                }
     608                        }
     609
    587610                        // add function as declaration
    588611                        std::stringstream ss;
  • src/Makefile.am

    r48b7085e ra32346b  
    5050AM_CXXFLAGS = @HOST_FLAGS@ -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I./Parser -I$(srcdir)/Parser -I$(srcdir)/include -DYY_NO_INPUT -O2 -g -std=c++14
    5151AM_LDFLAGS  = @HOST_FLAGS@ -Xlinker -export-dynamic
     52ARFLAGS     = cr
    5253
    5354demangler_SOURCES = SymTab/demangler.cc
  • src/Makefile.in

    r48b7085e ra32346b  
    152152LIBRARIES = $(noinst_LIBRARIES)
    153153AR = ar
    154 ARFLAGS = cru
    155154AM_V_AR = $(am__v_AR_@AM_V@)
    156155am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
     
    582581AM_CXXFLAGS = @HOST_FLAGS@ -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I./Parser -I$(srcdir)/Parser -I$(srcdir)/include -DYY_NO_INPUT -O2 -g -std=c++14
    583582AM_LDFLAGS = @HOST_FLAGS@ -Xlinker -export-dynamic
     583ARFLAGS = cr
    584584demangler_SOURCES = SymTab/demangler.cc
    585585demangler_LDADD = libdemangle.a     # yywrap
  • src/SymTab/Demangle.cc

    r48b7085e ra32346b  
    392392                                parsers.emplace_back(Encoding::enum_t, [this](Type::Qualifiers tq) { return parseEnum(tq); });
    393393                                parsers.emplace_back(Encoding::type, [this](Type::Qualifiers tq) { return parseType(tq); });
    394                                 parsers.emplace_back(Encoding::zero, [this](Type::Qualifiers tq) { return new ZeroType(tq); });
    395                                 parsers.emplace_back(Encoding::one, [this](Type::Qualifiers tq) { return new OneType(tq); });
     394                                parsers.emplace_back(Encoding::zero, [](Type::Qualifiers tq) { return new ZeroType(tq); });
     395                                parsers.emplace_back(Encoding::one, [](Type::Qualifiers tq) { return new OneType(tq); });
    396396                        }
    397397
  • src/cfa.make

    r48b7085e ra32346b  
    66am__v_CFA_1 =
    77
    8 .cfa.o: $(CFACC) $(CFACPP)
     8.cfa.o:
    99        $(AM_V_CFA)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
    1010        $(CFACOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
  • src/main.cc

    r48b7085e ra32346b  
    172172                        if ( filename == nullptr ) filename = argv[ optind ];
    173173                        // prelude filename comes in differently
    174                         if ( libcfap ) filename = "prelude.cf";
     174                        if ( libcfap ) filename = "prelude.cfa";
    175175                        optind += 1;
    176176                } else {                                                                                // no input file name
     
    199199                        if ( ! libcfap ) {
    200200                                // read the prelude in, if not generating the cfa library
    201                                 FILE * prelude = fopen( (PreludeDirector + "/prelude.cf").c_str(), "r" );
    202                                 assertf( prelude, "cannot open prelude.cf\n" );
     201                                FILE * prelude = fopen( (PreludeDirector + "/prelude.cfa").c_str(), "r" );
     202                                assertf( prelude, "cannot open prelude.cfa\n" );
    203203                                parse( prelude, LinkageSpec::Intrinsic );
    204204
Note: See TracChangeset for help on using the changeset viewer.