Changeset ecae5860 for src


Ignore:
Timestamp:
Jun 1, 2018, 7:53:43 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, with_gc
Children:
adb6a4f1
Parents:
b368dd8
Message:

more push/pop updates

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypedefTable.cc

    rb368dd8 recae5860  
    1010// Created On       : Sat May 16 15:20:13 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 30 18:04:38 2018
    13 // Update Count     : 148
     12// Last Modified On : Fri Jun  1 16:54:18 2018
     13// Update Count     : 155
    1414//
    1515
     
    5454void TypedefTable::makeTypedef( const string & name ) {
    5555        if ( ! typedefTable.exists( name ) ) {
    56                 typedefTable.addToEnclosingScope( name, TYPEDEFname /*, "MTD"*/ );
     56                typedefTable.addToEnclosingScope( name, TYPEDEFname, "MTD" );
    5757        } // if
    5858} // TypedefTable::makeTypedef
    5959
    60 void TypedefTable::addToScope( const std::string & identifier, int kind /*, const char * locn*/ ) {
     60void TypedefTable::addToScope( const std::string & identifier, int kind, const char * locn __attribute__((unused)) ) {
    6161        auto scope = kindTable.currentScope();
    62         debugPrint( cerr << "Adding at " /* << locn */ << " " << identifier << " as kind " << kind << " scope " << scope << endl );
     62        debugPrint( cerr << "Adding at " << locn << " " << identifier << " as kind " << kind << " scope " << scope << endl );
    6363        auto ret = kindTable.insertAt( scope, identifier, kind );
    6464        if ( ! ret.second ) ret.first->second = kind;           // exists => update
    6565} // TypedefTable::addToScope
    6666
    67 void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind /*, const char * locn*/ ) {
     67void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind, const char * locn __attribute__((unused)) ) {
    6868        assert( kindTable.currentScope() >= 1 );
    6969        auto scope = kindTable.currentScope() - 1;
    70         debugPrint( cerr << "Adding2 at " /* << locn */ << " " << identifier << " as kind " << kind << " scope " << scope << endl );
     70        debugPrint( cerr << "Adding+1 at " << locn << " " << identifier << " as kind " << kind << " scope " << scope << endl );
    7171        auto ret = kindTable.insertAt( scope, identifier, kind );
    7272        if ( ! ret.second ) ret.first->second = kind;           // exists => update
  • src/Parser/TypedefTable.h

    rb368dd8 recae5860  
    1010// Created On       : Sat May 16 15:24:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 30 17:02:49 2018
    13 // Update Count     : 82
     12// Last Modified On : Thu May 31 23:23:47 2018
     13// Update Count     : 83
    1414//
    1515
     
    3232        void changeKind( const std::string & identifier, int kind );
    3333        void makeTypedef( const std::string & name );
    34         void addToScope( const std::string & identifier, int kind /*, const char **/ );
    35         void addToEnclosingScope( const std::string & identifier, int kind /*, const char */ );
     34        void addToScope( const std::string & identifier, int kind, const char * );
     35        void addToEnclosingScope( const std::string & identifier, int kind, const char * );
    3636
    3737        void enterScope();
  • src/Parser/parser.yy

    rb368dd8 recae5860  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May 31 15:11:40 2018
    13 // Update Count     : 3444
     12// Last Modified On : Fri Jun  1 17:59:57 2018
     13// Update Count     : 3476
    1414//
    1515
     
    304304%type<en> enumerator_value_opt
    305305
    306 %type<decl> exception_declaration external_definition external_definition_list external_definition_list_opt
     306%type<decl> exception_declaration external_definition external_definition_list external_definition_list_no_pop_push external_definition_list_opt
    307307
    308308%type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list
     
    644644                // semantics checks, e.g., ++3, 3--, *3, &&3
    645645        | constant
    646                 { $$ = $1; }
    647646        | string_literal
    648647                { $$ = new ExpressionNode( $1 ); }
     
    988987                { $$ = new StatementNode( build_if( $3, $5, $7 ) ); }
    989988        ;
    990 
    991989
    992990if_control_expression:
     
    13831381cfa_function_declaration:                                                               // CFA
    13841382        cfa_function_specifier
    1385                 { $$ = $1; }
    13861383        | type_qualifier_list cfa_function_specifier
    13871384                { $$ = $2->addQualifiers( $1 ); }
     
    14401437        TYPEDEF cfa_variable_specifier
    14411438                {
    1442                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "1"*/ );
     1439                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "1" );
    14431440                        $$ = $2->addTypedef();
    14441441                }
    14451442        | TYPEDEF cfa_function_specifier
    14461443                {
    1447                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "2"*/ );
     1444                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "2" );
    14481445                        $$ = $2->addTypedef();
    14491446                }
    14501447        | cfa_typedef_declaration pop ',' push no_attr_identifier
    14511448                {
    1452                         typedefTable.addToEnclosingScope( *$5, TYPEDEFname /*, "3"*/ );
     1449                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" );
    14531450                        $$ = $1->appendList( $1->cloneType( $5 ) );
    14541451                }
     
    14611458        TYPEDEF type_specifier declarator
    14621459                {
    1463                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "4"*/ );
     1460                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
    14641461                        $$ = $3->addType( $2 )->addTypedef();
    14651462                }
    14661463        | typedef_declaration pop ',' push declarator
    14671464                {
    1468                         typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname /*, "5"*/ );
     1465                        typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname, "5" );
    14691466                        $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() );
    14701467                }
    14711468        | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 )
    14721469                {
    1473                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "6"*/ );
     1470                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "6" );
    14741471                        $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef();
    14751472                }
    14761473        | type_specifier TYPEDEF declarator
    14771474                {
    1478                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "7"*/ );
     1475                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "7" );
    14791476                        $$ = $3->addType( $1 )->addTypedef();
    14801477                }
    14811478        | type_specifier TYPEDEF type_qualifier_list declarator
    14821479                {
    1483                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "8"*/ );
     1480                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "8" );
    14841481                        $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 );
    14851482                }
     
    19371934                { $$ = nullptr; }
    19381935        | bit_subrange_size
    1939                 { $$ = $1; }
    19401936        ;
    19411937
     
    21872183type_parameter_list:                                                                    // CFA
    21882184        type_parameter
    2189                 { $$ = $1; }
    21902185        | type_parameter_list ',' type_parameter
    21912186                { $$ = $1->appendList( $3 ); }
     
    22012196type_parameter:                                                                                 // CFA
    22022197        type_class no_attr_identifier_or_type_name
    2203                 { typedefTable.addToScope( *$2, TYPEDEFname /*, "9"*/ ); }
     2198                { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
    22042199          type_initializer_opt assertion_list_opt
    22052200                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
     
    22702265        no_attr_identifier_or_type_name
    22712266                {
    2272                         typedefTable.addToEnclosingScope( *$1, TYPEDEFname /*, "10"*/ );
     2267                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
    22732268                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    22742269                }
    22752270        | no_attr_identifier_or_type_name '(' type_parameter_list ')'
    22762271                {
    2277                         typedefTable.addToEnclosingScope( *$1, TYPEGENname /*, "11"*/ );
     2272                        typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" );
    22782273                        $$ = DeclarationNode::newTypeDecl( $1, $3 );
    22792274                }
     
    23302325        ;
    23312326
     2327        // SKULLDUGGERY: Declarations in extern "X" and distribution need to be added to the current lexical scope.
     2328        // However, external_definition_list creates a new scope around each external_definition, but the pop loses all the
     2329        // types in the extern "X" and distribution at the end of the block. This version of external_definition_list does
     2330
     2331        // not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of
     2332        // external_definition_list within the extern "X" and distribution block correctly pushes/pops for that scope level.
     2333external_definition_list_no_pop_push:
     2334        external_definition
     2335        | external_definition_list_no_pop_push
     2336                { forall = xxx; }
     2337          external_definition
     2338                { $$ = $1 ? $1->appendList( $3 ) : $3; }
     2339        ;
     2340
    23322341external_definition_list_opt:
    23332342        // empty
    23342343                { $$ = nullptr; }
    2335         | external_definition_list
     2344        | external_definition_list_no_pop_push
    23362345        ;
    23372346
     
    23392348        declaration
    23402349        | external_function_definition
     2350        | EXTENSION external_definition                                         // GCC, multiple __extension__ allowed, meaning unknown
     2351                {
     2352                        distExt( $2 );                                                          // mark all fields in list
     2353                        $$ = $2;
     2354                }
    23412355        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    23422356                {
     
    23482362                        linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
    23492363                }
    2350                         // SKULLDUGGERY: Declarations in extern "X" need to be added to the current lexical scope.  However,
    2351                         // external_definition_list_opt creates a new scope that loses the types at the end of the extern block. The
    2352                         // correction is a pop/push (reverse order) to undo the push/pop from external_definition_list_opt.  This
    2353                         // trick works for nested extern "X"s, as each one undoes itself in the nesting.
    2354           '{' pop external_definition_list_opt push '}'
     2364          '{' external_definition_list_opt '}'
    23552365                {
    23562366                        linkage = linkageStack.top();
    23572367                        linkageStack.pop();
    2358                         $$ = $6;
    2359                 }
    2360         | EXTENSION external_definition                                         // GCC, multiple __extension__ allowed, meaning unknown
    2361                 {
    2362                         distExt( $2 );                                                          // mark all fields in list
    2363                         $$ = $2;
     2368                        $$ = $5;
    23642369                }
    23652370        | type_qualifier_list
    23662371                { if ( $1->type->forall ) xxx = forall = true; } // remember generic type
    2367           '{' external_definition_list push '}'                  // CFA, namespace
     2372          '{' external_definition_list_opt '}'                          // CFA, namespace
    23682373                {
    23692374                        for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     
    23782383        | declaration_qualifier_list
    23792384                { if ( $1->type->forall ) xxx = forall = true; } // remember generic type
    2380           '{' external_definition_list '}'                                       // CFA, namespace
     2385          '{' external_definition_list_opt '}'                          // CFA, namespace
    23812386                {
    23822387                        for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     
    23942399                        if ( $2->type->forall ) xxx = forall = true; // remember generic type
    23952400                }
    2396           '{' external_definition_list '}'                                      // CFA, namespace
     2401          '{' external_definition_list_opt '}'                          // CFA, namespace
    23972402                {
    23982403                        for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     
    27152720        typedef
    27162721                // hide type name in enclosing scope by variable name
    2717                 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER /*, "ID"*/ ); }
     2722                { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" ); }
    27182723        | '(' paren_type ')'
    27192724                { $$ = $2; }
  • src/libcfa/stdlib

    rb368dd8 recae5860  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 16 07:53:10 2018
    13 // Update Count     : 300
     12// Last Modified On : Fri Jun  1 19:52:52 2018
     13// Update Count     : 302
    1414//
    1515
     
    6767                return posix_memalign( (void **)ptr, align, sizeof(T) ); // C posix_memalign
    6868        } // posix_memalign
    69 
    70 
    71         // Cforall dynamic allocation
     69} // distribution
     70
     71// Cforall dynamic allocation
     72static inline forall( dtype T | sized(T) ) {
    7273        extern "C" { void * memset( void * dest, int c, size_t size ); } // use default C routine for void *
    7374
Note: See TracChangeset for help on using the changeset viewer.