Changeset b66d14a


Ignore:
Timestamp:
Jan 11, 2021, 10:10:33 PM (9 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
20207c0
Parents:
2501ae5
Message:

add new type kinds DStype and ALtype

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    r2501ae5 rb66d14a  
    1010// Created On       : Thu May 9 10:00:00 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 16:23:15 2019
    13 // Update Count     : 20
     12// Last Modified On : Mon Jan 11 20:53:23 2021
     13// Update Count     : 21
    1414//
    1515
     
    7878
    7979const char * TypeDecl::typeString() const {
    80         static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sized tuple type" };
    81         static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." );
     80        static const char * kindNames[] = { "data type", "sized data type", "sized object type", "sized function type", "sized tuple type", "array length type" };
     81        static_assert( sizeof(kindNames) / sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." );
    8282        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
    8383        return sized ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'
     
    8585
    8686const char * TypeDecl::genTypeString() const {
    87         static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" };
    88         static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );
     87        static const char * kindNames[] = { "T &", "T *", "T", "(*)", "T ...", "[T]" };
     88        static_assert( sizeof(kindNames) / sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );
    8989        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
    9090        return kindNames[ kind ];
  • src/AST/Decl.hpp

    r2501ae5 rb66d14a  
    1010// Created On       : Thu May 9 10:00:00 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 17:38:33 2019
    13 // Update Count     : 29
     12// Last Modified On : Mon Jan 11 20:48:38 2021
     13// Update Count     : 30
    1414//
    1515
     
    175175class TypeDecl final : public NamedTypeDecl {
    176176  public:
    177         enum Kind { Dtype, Otype, Ftype, Ttype, NUMBER_OF_KINDS };
     177        enum Kind { Dtype, DStype, Otype, Ftype, Ttype, ALtype, NUMBER_OF_KINDS };
    178178
    179179        Kind kind;
  • src/Parser/DeclarationNode.cc

    r2501ae5 rb66d14a  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Oct  8 08:03:38 2020
    13 // Update Count     : 1135
     12// Last Modified On : Mon Jan 11 20:58:07 2021
     13// Update Count     : 1137
    1414//
    1515
     
    10751075        if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) {
    10761076                // otype is internally converted to dtype + otype parameters
    1077                 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype };
    1078                 static_assert( sizeof(kindMap)/sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." );
     1077                static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::DStype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype, TypeDecl::ALtype };
     1078                static_assert( sizeof(kindMap) / sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." );
    10791079                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    10801080                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype, variable.initializer ? variable.initializer->buildType() : nullptr );
  • src/Parser/parser.yy

    r2501ae5 rb66d14a  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 11 14:14:16 2021
    13 // Update Count     : 4630
     12// Last Modified On : Mon Jan 11 21:32:10 2021
     13// Update Count     : 4633
    1414//
    1515
     
    24492449                { $$ = DeclarationNode::newTypeParam( $2, $1 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    24502450        | '[' identifier_or_type_name ']'
    2451                 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
     2451                {
     2452                        typedefTable.addToScope( *$2, TYPEDEFname, "9" );
     2453                        $$ = DeclarationNode::newTypeParam( TypeDecl::ALtype, $2 );
     2454                }
    24522455        // | type_specifier identifier_parameter_declarator
    24532456        | assertion_list
     
    24612464                { $$ = TypeDecl::Dtype; }
    24622465        | '*'
    2463                 { $$ = TypeDecl::Dtype; }                                               // dtype + sized
     2466                { $$ = TypeDecl::DStype; }                                              // dtype + sized
    24642467        | ELLIPSIS
    24652468                { $$ = TypeDecl::Ttype; }
  • src/SymTab/Demangle.cc

    r2501ae5 rb66d14a  
    1010// Created On       : Thu Jul 19 12:52:41 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb 11 15:09:18 2020
    13 // Update Count     : 10
     12// Last Modified On : Mon Jan 11 21:28:27 2021
     13// Update Count     : 11
    1414//
    1515
     
    367367                                // type variable types
    368368                                for (size_t k = 0; k < TypeDecl::NUMBER_OF_KINDS; ++k) {
    369                                         static const std::string typeVariableNames[] = { "DT", "OT", "FT", "TT", };
     369                                        static const std::string typeVariableNames[] = { "DT", "DST", "OT", "FT", "TT", "ALT", };
    370370                                        static_assert(
    371371                                                sizeof(typeVariableNames)/sizeof(typeVariableNames[0]) == TypeDecl::NUMBER_OF_KINDS,
  • src/SymTab/Mangler.cc

    r2501ae5 rb66d14a  
    1010// Created On       : Sun May 17 21:40:29 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Nov 18 12:01:38 2020
    13 // Update Count     : 64
     12// Last Modified On : Mon Jan 11 21:56:06 2021
     13// Update Count     : 74
    1414//
    1515#include "Mangler.h"
     
    313313                                // and the case has not yet come up in practice. Alternatively, if not then this code can be removed
    314314                                // aside from the assert false.
    315                                 assertf(false, "Mangler_old should not visit typedecl: %s", toCString(decl));
     315                                assertf( false, "Mangler_old should not visit typedecl: %s", toCString(decl));
    316316                                assertf( decl->kind < TypeDecl::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind );
    317317                                mangleName += Encoding::typeVariables[ decl->kind ] + std::to_string( decl->name.length() ) + decl->name;
     
    343343                                                        break;
    344344                                                  default:
    345                                                         assert( false );
     345                                                        assertf( false, "unimplemented kind for type variable %s", SymTab::Mangler::Encoding::typeVariables[i->kind].c_str() );
    346346                                                } // switch
    347347                                                varNums[ i->name ] = std::make_pair( nextVarNum, (int)i->kind );
     
    673673                                        for ( auto & decl : ptype->forall ) {
    674674                                                switch ( decl->kind ) {
    675                                                 case ast::TypeDecl::Kind::Dtype:
     675                                                  case ast::TypeDecl::Kind::Dtype:
    676676                                                        dcount++;
    677677                                                        break;
    678                                                 case ast::TypeDecl::Kind::Ftype:
     678                                                  case ast::TypeDecl::Kind::Ftype:
    679679                                                        fcount++;
    680680                                                        break;
    681                                                 case ast::TypeDecl::Kind::Ttype:
     681                                                  case ast::TypeDecl::Kind::Ttype:
    682682                                                        vcount++;
    683683                                                        break;
    684                                                 default:
    685                                                         assert( false );
     684                                                  default:
     685                                                        assertf( false, "unimplemented kind for type variable %s", SymTab::Mangler::Encoding::typeVariables[decl->kind].c_str() );
    686686                                                } // switch
    687687                                                varNums[ decl->name ] = std::make_pair( nextVarNum, (int)decl->kind );
  • src/SymTab/ManglerCommon.cc

    r2501ae5 rb66d14a  
    1010// Created On       : Sun May 17 21:44:03 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 14:54:38 2019
    13 // Update Count     : 28
     12// Last Modified On : Mon Jan 11 21:23:10 2021
     13// Update Count     : 29
    1414//
    1515
     
    104104                        const std::string typeVariables[] = {
    105105                                "BD", // dtype
     106                                "BDS", // dtype + sized
    106107                                "BO", // otype
    107108                                "BF", // ftype
    108109                                "BT", // ttype
     110                                "BAL", // array length type
    109111                        };
    110112                        static_assert(
    111                                 sizeof(typeVariables)/sizeof(typeVariables[0]) == TypeDecl::NUMBER_OF_KINDS,
     113                                sizeof(typeVariables) / sizeof(typeVariables[0]) == TypeDecl::NUMBER_OF_KINDS,
    112114                                "Each type variable kind should have a corresponding mangler prefix"
    113115                        );
  • src/SynTree/Declaration.h

    r2501ae5 rb66d14a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 23:11:22 2019
    13 // Update Count     : 157
     12// Last Modified On : Mon Jan 11 20:48:39 2021
     13// Update Count     : 158
    1414//
    1515
     
    201201        typedef NamedTypeDecl Parent;
    202202  public:
    203         enum Kind { Dtype, Otype, Ftype, Ttype, NUMBER_OF_KINDS };
     203        enum Kind { Dtype, DStype, Otype, Ftype, Ttype, ALtype, NUMBER_OF_KINDS };
    204204
    205205        Kind kind;
  • src/SynTree/TypeDecl.cc

    r2501ae5 rb66d14a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Oct  8 18:18:55 2020
    13 // Update Count     : 22
     12// Last Modified On : Mon Jan 11 21:26:50 2021
     13// Update Count     : 23
    1414//
    1515
     
    3333
    3434const char * TypeDecl::typeString() const {
    35         static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sized tuple type" };
     35        static const char * kindNames[] = { "data type", "sized data type", "sized object type", "sized function type", "sized tuple type", "array length type" };
    3636        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." );
    3737        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
     
    4040
    4141const char * TypeDecl::genTypeString() const {
    42         static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" };
     42        static const char * kindNames[] = { "T &", "T *", "T", "(*)", "T ...", "[T]" };
    4343        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );
    4444        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
Note: See TracChangeset for help on using the changeset viewer.