Changeset d63eeb0 for src/SymTab


Ignore:
Timestamp:
Feb 9, 2016, 3:25:05 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, with_gc
Children:
7528ba1
Parents:
771b3c3 (diff), bd85400 (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' into ctor

Conflicts:

src/CodeGen/CodeGenerator.cc
src/GenPoly/Box.cc
src/Makefile.in
src/Parser/ParseNode.h
src/Parser/parser.cc
src/Parser/parser.yy
src/SymTab/Validate.cc
src/SynTree/Initializer.h
src/SynTree/ObjectDecl.cc
src/SynTree/Visitor.h
src/main.cc

Location:
src/SymTab
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/FixFunction.cc

    r771b3c3 rd63eeb0  
    1818#include "SynTree/Type.h"
    1919#include "SynTree/Expression.h"
    20 #include "utility.h"
     20#include "Common/utility.h"
    2121
    2222namespace SymTab {
  • src/SymTab/IdTable.cc

    r771b3c3 rd63eeb0  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 17:04:02 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Oct 07 12:21:13 2015
    13 // Update Count     : 73
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Jan  8 22:59:23 2016
     13// Update Count     : 74
    1414//
    1515
     
    2121#include "Mangler.h"
    2222#include "IdTable.h"
    23 #include "SemanticError.h"
     23#include "Common/SemanticError.h"
    2424
    2525using std::string;
     
    5454                        manglename = name;
    5555                } else if ( LinkageSpec::isOverridable( decl->get_linkage() ) ) {
    56                         // mangle the name without including the appropriate suffix
    57                         // this will make it so that overridable routines are placed
    58                         // into the same "bucket" as their user defined versions.
     56                        // mangle the name without including the appropriate suffix, so overridable routines are placed into the
     57                        // same "bucket" as their user defined versions.
    5958                        manglename = Mangler::mangle( decl, false );
    6059                } else {
     
    7170                        std::stack< DeclEntry >& entry = it->second;
    7271                        if ( ! entry.empty() && entry.top().second == scopeLevel ) {
    73                                 // if we're giving the same name mangling to things of
    74                                 //  different types then there is something wrong
     72                                // if we're giving the same name mangling to things of different types then there is something wrong
    7573                                Declaration *old = entry.top().first;
    7674                                assert( (dynamic_cast<ObjectDecl*>( decl ) && dynamic_cast<ObjectDecl*>( old ) )
  • src/SymTab/ImplementationType.cc

    r771b3c3 rd63eeb0  
    1919#include "SynTree/Visitor.h"
    2020#include "SymTab/Indexer.h"
    21 #include "utility.h"
     21#include "Common/utility.h"
    2222
    2323
  • src/SymTab/Indexer.cc

    r771b3c3 rd63eeb0  
    2121#include "Indexer.h"
    2222#include <typeinfo>
    23 #include "utility.h"
     23#include "Common/utility.h"
    2424
    2525#define debugPrint(x) if ( doDebug ) { std::cout << x; }
     
    225225                        maybeAccept( alignofExpr->get_expr(), *this );
    226226                }
     227        }
     228
     229        void Indexer::visit( UntypedOffsetofExpr *offsetofExpr ) {
     230                acceptAllNewScope( offsetofExpr->get_results(), *this );
     231                maybeAccept( offsetofExpr->get_type(), *this );
     232        }
     233
     234        void Indexer::visit( OffsetofExpr *offsetofExpr ) {
     235                acceptAllNewScope( offsetofExpr->get_results(), *this );
     236                maybeAccept( offsetofExpr->get_type(), *this );
     237                maybeAccept( offsetofExpr->get_member(), *this );
    227238        }
    228239
  • src/SymTab/Indexer.h

    r771b3c3 rd63eeb0  
    5555                virtual void visit( SizeofExpr *sizeofExpr );
    5656                virtual void visit( AlignofExpr *alignofExpr );
     57                virtual void visit( UntypedOffsetofExpr *offsetofExpr );
     58                virtual void visit( OffsetofExpr *offsetofExpr );
    5759                virtual void visit( AttrExpr *attrExpr );
    5860                virtual void visit( LogicalExpr *logicalExpr );
  • src/SymTab/Validate.cc

    r771b3c3 rd63eeb0  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Jan 07 11:27:49 2016
    13 // Update Count     : 269
     12// Last Modified On : Tue Feb 09 13:21:56 2016
     13// Update Count     : 270
    1414//
    1515
     
    4949#include "FixFunction.h"
    5050// #include "ImplementationType.h"
    51 #include "utility.h"
    52 #include "UniqueName.h"
     51#include "Common/utility.h"
     52#include "Common/UniqueName.h"
    5353#include "AddVisit.h"
    5454#include "MakeLibCfa.h"
     
    599599        }
    600600
     601        template< typename OutputIterator >
     602        void makeUnionFieldsAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, UnionInstType *unionType, OutputIterator out ) {
     603                UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) );
     604                copy->get_args().push_back( new VariableExpr( dstParam ) );
     605                copy->get_args().push_back( new AddressExpr( new VariableExpr( srcParam ) ) );
     606                copy->get_args().push_back( new SizeofExpr( unionType ) );
     607
     608                *out++ = new ExprStmt( noLabels, copy );
     609        }
     610
    601611        //E ?=?(E volatile*, int),
    602612        //  ?=?(E _Atomic volatile*, int);
     
    667677
    668678                // Make function polymorphic in same parameters as generic struct, if applicable
     679                bool isGeneric = false;  // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for union)
    669680                std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters();
    670681                std::list< Expression* > structParams;  // List of matching parameters to put on types
    671682                for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) {
     683                        isGeneric = true;
    672684                        TypeDecl *typeParam = (*param)->clone();
    673685                        assignType->get_forall().push_back( typeParam );
     
    675687                }
    676688
    677                 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 );
     689                ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 );
    678690                assignType->get_returnVals().push_back( returnVal );
    679691
     
    705717                                if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) {
    706718                                        makeArrayAssignment( srcParam, dstParam, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) );
     719                                        if ( isGeneric ) makeArrayAssignment( srcParam, returnVal, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) );
    707720                                } else {
    708721                                        makeScalarAssignment( srcParam, dstParam, dwt, back_inserter( assignDecl->get_statements()->get_kids() ) );
     722                                        if ( isGeneric ) makeScalarAssignment( srcParam, returnVal, dwt, back_inserter( assignDecl->get_statements()->get_kids() ) );
    709723                                } // if
    710724                        } // if
    711725                } // for
    712                 assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
     726                if ( ! isGeneric ) assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
    713727
    714728                return assignDecl;
     
    719733
    720734                // Make function polymorphic in same parameters as generic union, if applicable
     735                bool isGeneric = false;  // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct)
    721736                std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters();
    722737                std::list< Expression* > unionParams;  // List of matching parameters to put on types
    723738                for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) {
     739                        isGeneric = true;
    724740                        TypeDecl *typeParam = (*param)->clone();
    725741                        assignType->get_forall().push_back( typeParam );
     
    727743                }
    728744
    729                 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );
     745                ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );
    730746                assignType->get_returnVals().push_back( returnVal );
    731747
     
    741757                assignDecl->fixUniqueId();
    742758
    743                 UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) );
    744                 copy->get_args().push_back( new VariableExpr( dstParam ) );
    745                 copy->get_args().push_back( new AddressExpr( new VariableExpr( srcParam ) ) );
    746                 copy->get_args().push_back( new SizeofExpr( cloneWithParams( refType, unionParams ) ) );
    747 
    748                 assignDecl->get_statements()->get_kids().push_back( new ExprStmt( noLabels, copy ) );
    749                 assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
     759                makeUnionFieldsAssignment( srcParam, dstParam, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) );
     760                if ( isGeneric ) makeUnionFieldsAssignment( srcParam, returnVal, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) );
     761
     762                if ( ! isGeneric ) assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
    750763
    751764                return assignDecl;
Note: See TracChangeset for help on using the changeset viewer.