Changeset 937e51d for src/SymTab


Ignore:
Timestamp:
Jun 26, 2015, 4:00:26 PM (11 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
0df292b, e0ff3e6
Parents:
eb50842 (diff), 1869adf (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 pointer to pointer to qualified fix into master

Location:
src/SymTab
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    reb50842 r937e51d  
    1010// Created On       : Sun May 17 21:37:33 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 16:49:55 2015
    13 // Update Count     : 3
     12// Last Modified On : Fri Jun  5 08:05:17 2015
     13// Update Count     : 5
    1414//
    1515
     
    5151        }
    5252
    53 /********
    54  * A NOTE ON THE ORDER OF TRAVERSAL
    55  *
    56  * Types and typedefs have their base types visited before they are added to the type table.
    57  * This is ok, since there is no such thing as a recursive type or typedef.
    58  *             typedef struct { T *x; } T; // never allowed
    59  *
    60  * for structs/unions, it is possible to have recursion, so the decl should be added as if it's
    61  * incomplete to begin, the members are traversed, and then the complete type should be added
    62  * (assuming the type is completed by this particular declaration).
    63  *             struct T { struct T *x; }; // allowed
    64  *
    65  * It's important to add the complete type to the symbol table *after* the members/base has been
    66  * traversed, since that traversal may modify the definition of the type and these modifications
    67  * should be visible when the symbol table is queried later in this pass.
    68  *
    69  * TODO: figure out whether recursive contexts are sensible/possible/reasonable.
    70  */
     53
     54// A NOTE ON THE ORDER OF TRAVERSAL
     55//
     56// Types and typedefs have their base types visited before they are added to the type table.  This is ok, since there is
     57// no such thing as a recursive type or typedef.
     58//
     59//             typedef struct { T *x; } T; // never allowed
     60//
     61// for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
     62// members are traversed, and then the complete type should be added (assuming the type is completed by this particular
     63// declaration).
     64//
     65//             struct T { struct T *x; }; // allowed
     66//
     67// It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
     68// traversal may modify the definition of the type and these modifications should be visible when the symbol table is
     69// queried later in this pass.
     70//
     71// TODO: figure out whether recursive contexts are sensible/possible/reasonable.
     72
    7173
    7274        void Indexer::visit( TypeDecl *typeDecl ) {
    7375                // see A NOTE ON THE ORDER OF TRAVERSAL, above
    74                 // note that assertions come after the type is added to the symtab, since they aren't part
    75                 // of the type proper and may depend on the type itself
     76                // note that assertions come after the type is added to the symtab, since they are not part of the type proper
     77                // and may depend on the type itself
    7678                enterScope();
    7779                acceptAll( typeDecl->get_parameters(), *this );
  • src/SymTab/Mangler.cc

    reb50842 r937e51d  
    1010// Created On       : Sun May 17 21:40:29 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 16:50:47 2015
    13 // Update Count     : 3
     12// Last Modified On : Mon Jun  8 15:12:12 2015
     13// Update Count     : 8
    1414//
    1515
     
    160160                } else {
    161161                        printQualifiers( typeInst );
    162                         std::ostrstream numStream;
     162                        std::ostringstream numStream;
    163163                        numStream << varNum->second.first;
    164                         mangleName << (numStream.pcount() + 1);
    165164                        switch ( (TypeDecl::Kind )varNum->second.second ) {
    166165                          case TypeDecl::Any:
     
    174173                                break;
    175174                        } // switch
    176                         mangleName << std::string( numStream.str(), numStream.pcount() );
     175                        mangleName << numStream.str();
    177176                } // if
    178177        }
     
    220219                                        sub_mangler.varNums = varNums;
    221220                                        (*assert)->accept( sub_mangler );
    222                                         assertionNames.push_back( std::string( sub_mangler.mangleName.str(), sub_mangler.mangleName.pcount() ) );
     221                                        assertionNames.push_back( sub_mangler.mangleName.str() );
    223222                                } // for
    224223                        } // for
  • src/SymTab/Mangler.h

    reb50842 r937e51d  
    1010// Created On       : Sun May 17 21:44:03 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 16:49:21 2015
    13 // Update Count     : 3
     12// Last Modified On : Mon Jun  8 14:47:14 2015
     13// Update Count     : 5
    1414//
    1515
     
    1717#define MANGLER_H
    1818
    19 #include <strstream>
     19#include <sstream>
    2020#include "SynTree/SynTree.h"
    2121#include "SynTree/Visitor.h"
     
    4343                virtual void visit( TupleType *tupleType );
    4444 
    45                 std::string get_mangleName() { return std::string( mangleName.str(), mangleName.pcount() ); }
     45                std::string get_mangleName() { return mangleName.str(); }
    4646          private:
    47                 std::ostrstream mangleName;
     47                std::ostringstream mangleName;
    4848                typedef std::map< std::string, std::pair< int, int > > VarMapType;
    4949                VarMapType varNums;
  • src/SymTab/Validate.cc

    reb50842 r937e51d  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 16:50:09 2015
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Jun 24 16:20:50 2015
     13// Update Count     : 30
    1414//
    1515
     
    4545#include "SynTree/Type.h"
    4646#include "SynTree/Statement.h"
     47#include "SynTree/TypeSubstitution.h"
    4748#include "Indexer.h"
    48 #include "SynTree/TypeSubstitution.h"
    4949#include "FixFunction.h"
    5050#include "ImplementationType.h"
     
    176176                acceptAll( translationUnit, pass1 );
    177177                acceptAll( translationUnit, pass2 );
     178                // need to collect all of the assignment operators prior to
     179                // this point and only generate assignment operators if one doesn't exist
    178180                AddStructAssignment::addStructAssignment( translationUnit );
    179181                acceptAll( translationUnit, pass3 );
     
    506508                if ( ! array->get_dimension() ) return;
    507509 
    508                 ObjectDecl *index = new ObjectDecl( indexName.newName(), Declaration::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 );
     510                ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 );
    509511                *out++ = new DeclStmt( noLabels, index );
    510512 
     
    544546                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    545547 
    546                 ObjectDecl *returnVal = new ObjectDecl( "", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );
     548                ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );
    547549                assignType->get_returnVals().push_back( returnVal );
    548550 
    549                 ObjectDecl *dstParam = new ObjectDecl( "_dst", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 );
     551                ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 );
    550552                assignType->get_parameters().push_back( dstParam );
    551553 
    552                 ObjectDecl *srcParam = new ObjectDecl( "_src", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 );
     554                ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 );
    553555                assignType->get_parameters().push_back( srcParam );
    554556
    555557                // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
    556558                // because each unit generates copies of the default routines for each aggregate.
    557                 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? Declaration::NoStorageClass : Declaration::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true );
     559                FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false );
    558560                assignDecl->fixUniqueId();
    559561 
    560562                for ( std::list< Declaration * >::const_iterator member = aggregateDecl->get_members().begin(); member != aggregateDecl->get_members().end(); ++member ) {
    561563                        if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member ) ) {
     564                                // query the type qualifiers of this field and skip assigning it if it is marked const.
     565                                // If it is an array type, we need to strip off the array layers to find its qualifiers.
     566                                Type * type = dwt->get_type();
     567                                while ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
     568                                        type = at->get_base();
     569                                }
     570
     571                                if ( type->get_qualifiers().isConst ) {
     572                                        // don't assign const members
     573                                        continue;
     574                                }
     575
    562576                                if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) {
    563577                                        makeArrayAssignment( srcParam, dstParam, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) );
     
    575589                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    576590 
    577                 ObjectDecl *returnVal = new ObjectDecl( "", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );
     591                ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );
    578592                assignType->get_returnVals().push_back( returnVal );
    579593 
    580                 ObjectDecl *dstParam = new ObjectDecl( "_dst", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 );
     594                ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 );
    581595                assignType->get_parameters().push_back( dstParam );
    582596 
    583                 ObjectDecl *srcParam = new ObjectDecl( "_src", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 );
     597                ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 );
    584598                assignType->get_parameters().push_back( srcParam );
    585599 
    586600                // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
    587601                // because each unit generates copies of the default routines for each aggregate.
    588                 FunctionDecl *assignDecl = new FunctionDecl( "?=?",  functionNesting > 0 ? Declaration::NoStorageClass : Declaration::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true );
     602                FunctionDecl *assignDecl = new FunctionDecl( "?=?",  functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false );
    589603                assignDecl->fixUniqueId();
    590604 
     
    621635                TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false );
    622636                typeInst->set_baseType( typeDecl );
    623                 ObjectDecl *src = new ObjectDecl( "_src", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, typeInst->clone(), 0 );
    624                 ObjectDecl *dst = new ObjectDecl( "_dst", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 );
     637                ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst->clone(), 0 );
     638                ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 );
    625639                if ( typeDecl->get_base() ) {
    626640                        stmts = new CompoundStmt( std::list< Label >() );
     
    631645                } // if
    632646                FunctionType *type = new FunctionType( Type::Qualifiers(), false );
    633                 type->get_returnVals().push_back( new ObjectDecl( "", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );
     647                type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );
    634648                type->get_parameters().push_back( dst );
    635649                type->get_parameters().push_back( src );
    636                 FunctionDecl *func = new FunctionDecl( "?=?", Declaration::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false );
     650                FunctionDecl *func = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false, false );
    637651                declsToAdd.push_back( func );
    638652        }
    639653
    640654        void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) {
    641                 if ( ! declsToAdd.empty() ) {
    642                         for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) {
    643                                 statements.insert( i, new DeclStmt( noLabels, *decl ) );
    644                         } // for
    645                         declsToAdd.clear();
    646                 } // if
     655                for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) {
     656                        statements.insert( i, new DeclStmt( noLabels, *decl ) );
     657                } // for
     658                declsToAdd.clear();
    647659        }
    648660
  • src/SymTab/module.mk

    reb50842 r937e51d  
     1######################### -*- Mode: Makefile-Gmake -*- ########################
     2##
     3## Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     4##
     5## The contents of this file are covered under the licence agreement in the
     6## file "LICENCE" distributed with Cforall.
     7##
     8## module.mk --
     9##
     10## Author           : Richard C. Bilson
     11## Created On       : Mon Jun  1 17:49:17 2015
     12## Last Modified By : Peter A. Buhr
     13## Last Modified On : Mon Jun  1 17:53:50 2015
     14## Update Count     : 1
     15###############################################################################
     16
    117SRC += SymTab/IdTable.cc \
    218       SymTab/Indexer.cc \
Note: See TracChangeset for help on using the changeset viewer.