Changeset d8ba086


Ignore:
Timestamp:
Apr 29, 2016, 2:39:49 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, 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, resolv-new, with_gc
Children:
540de412
Parents:
fea7ca7
Message:

add ?{}, ?{} implicit otype assertions to autogenerated generic type functions

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    rfea7ca7 rd8ba086  
    1010// Created On       : Thu Mar 03 15:45:56 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 14 16:58:35 2016
     12// Last Modified On : Fri Apr 29 13:11:04 2016
    1313// Update Count     : 1
    1414//
     
    161161        }
    162162
    163         /// Creates a new type decl that's the same as src, but renamed and with only the ?=? assertion (for complete types only)
     163        /// Creates a new type decl that's the same as src, but renamed and with only the ?=?, ?{} (default and copy), and ^?{} assertions (for complete types only)
    164164        TypeDecl *cloneAndRename( TypeDecl *src, const std::string &name ) {
    165165                TypeDecl *dst = new TypeDecl( name, src->get_storageClass(), 0, src->get_kind() );
    166166
    167167                if ( src->get_kind() == TypeDecl::Any ) {
    168                         // just include assignment operator assertion
    169                         TypeInstType *assignParamType = new TypeInstType( Type::Qualifiers(), name, dst );
    170                         FunctionType *assignFunctionType = new FunctionType( Type::Qualifiers(), false );
    171                         assignFunctionType->get_returnVals().push_back(
    172                                 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, assignParamType->clone(), 0 ) );
    173                         assignFunctionType->get_parameters().push_back(
    174                                 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), assignParamType->clone() ), 0 ) );
    175                         assignFunctionType->get_parameters().push_back(
    176                                 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, assignParamType, 0 ) );
    177                         FunctionDecl *assignAssert = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignFunctionType, 0, false, false );
     168                        TypeInstType *opParamType = new TypeInstType( Type::Qualifiers(), name, dst );
     169                        FunctionType *opFunctionType = new FunctionType( Type::Qualifiers(), false );
     170                        opFunctionType->get_parameters().push_back(
     171                                new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), opParamType->clone() ), 0 ) );
     172                        FunctionDecl *ctorAssert = new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, opFunctionType->clone(), 0, false, false );
     173                        FunctionDecl *dtorAssert = new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, opFunctionType->clone(), 0, false, false );
     174
     175                        opFunctionType->get_parameters().push_back(
     176                                new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, opParamType, 0 ) );
     177                        FunctionDecl *copyCtorAssert = new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, opFunctionType->clone(), 0, false, false );
     178
     179                        opFunctionType->get_returnVals().push_back(
     180                                new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, opParamType->clone(), 0 ) );
     181                        FunctionDecl *assignAssert = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, opFunctionType, 0, false, false );
     182
    178183                        dst->get_assertions().push_back( assignAssert );
     184                        dst->get_assertions().push_back( ctorAssert );
     185                        dst->get_assertions().push_back( dtorAssert );
     186                        dst->get_assertions().push_back( copyCtorAssert );
    179187                }
    180188
     
    187195                        field = field->clone();
    188196                        genericSubs.apply( field );
     197
     198                        if ( src ) {
     199                                genericSubs.apply( src );
     200                        }
    189201                }
    190202
  • src/SynTree/TypeSubstitution.h

    rfea7ca7 rd8ba086  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Apr 26 11:15:07 2016
     12// Last Modified On : Fri Apr 29 13:50:09 2016
    1313// Update Count     : 2
    1414//
     
    152152template< typename TypeInstListIterator >
    153153void TypeSubstitution::extract( TypeInstListIterator begin, TypeInstListIterator end, TypeSubstitution &result ) {
     154        // xxx - this function doesn't extract varEnv - is this intentional?
    154155        while ( begin != end ) {
    155156                TypeEnvType::iterator cur = typeEnv.find( (*begin++)->get_name() );
Note: See TracChangeset for help on using the changeset viewer.