Ignore:
Timestamp:
Aug 11, 2017, 10:33:37 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, resolv-new, with_gc
Children:
54cd58b0
Parents:
3d4b23fa (diff), 59a75cb (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' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r3d4b23fa r0720e049  
    2727#include "Box.h"
    2828#include "DeclMutator.h"
     29#include "Lvalue.h"
     30#include "FindFunction.h"
    2931#include "PolyMutator.h"
    30 #include "FindFunction.h"
    3132#include "ScopedSet.h"
    3233#include "ScrubTyVars.h"
     
    202203                };
    203204
    204                 /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable
     205                /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, sizeof expressions of polymorphic types with the proper variable, and strips fields from generic struct declarations.
    205206                class Pass3 final : public PolyMutator {
    206207                  public:
     
    210211                        using PolyMutator::mutate;
    211212                        virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override;
     213                        virtual Declaration *mutate( StructDecl *structDecl ) override;
     214                        virtual Declaration *mutate( UnionDecl *unionDecl ) override;
    212215                        virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override;
    213216                        virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override;
     
    753756
    754757                void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
    755                         assert( arg->has_result() );
     758                        assertf( arg->has_result(), "arg does not have result: %s", toString( arg ).c_str() );
    756759                        if ( isPolyType( param, exprTyVars ) ) {
    757                                 if ( isPolyType( arg->get_result() ) ) {
     760                                Type * newType = arg->get_result()->clone();
     761                                if ( env ) env->apply( newType );
     762                                std::auto_ptr<Type> manager( newType );
     763                                if ( isPolyType( newType ) ) {
    758764                                        // if the argument's type is polymorphic, we don't need to box again!
    759765                                        return;
    760766                                } else if ( arg->get_result()->get_lvalue() ) {
    761                                         // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue)
    762                                         // xxx - need to test that this code is still reachable
    763                                         if ( CommaExpr *commaArg = dynamic_cast< CommaExpr* >( arg ) ) {
    764                                                 commaArg->set_arg2( new AddressExpr( commaArg->get_arg2() ) );
    765                                         } else {
    766                                                 arg = new AddressExpr( arg );
    767                                         }
     767                                        // argument expression may be CFA lvalue, but not C lvalue -- apply generalizedLvalue transformations.
     768                                        arg =  generalizedLvalue( new AddressExpr( arg ) );
    768769                                        if ( ! ResolvExpr::typesCompatible( param, arg->get_result(), SymTab::Indexer() ) ) {
    769770                                                // silence warnings by casting boxed parameters when the actual type does not match up with the formal type.
     
    17481749
    17491750                Expression *PolyGenericCalculator::mutate( SizeofExpr *sizeofExpr ) {
    1750                         Type *ty = sizeofExpr->get_type();
     1751                        Type *ty = sizeofExpr->get_isType() ? sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result();
    17511752                        if ( findGeneric( ty ) ) {
    17521753                                Expression *ret = new NameExpr( sizeofName( mangleType( ty ) ) );
     
    17581759
    17591760                Expression *PolyGenericCalculator::mutate( AlignofExpr *alignofExpr ) {
    1760                         Type *ty = alignofExpr->get_type();
     1761                        Type *ty = alignofExpr->get_isType() ? alignofExpr->get_type() : alignofExpr->get_expr()->get_result();
    17611762                        if ( findGeneric( ty ) ) {
    17621763                                Expression *ret = new NameExpr( alignofName( mangleType( ty ) ) );
     
    18681869                }
    18691870
     1871                /// Strips the members from a generic aggregate
     1872                void stripGenericMembers(AggregateDecl* decl) {
     1873                        if ( ! decl->get_parameters().empty() ) decl->get_members().clear();
     1874                }
     1875
     1876                Declaration *Pass3::mutate( StructDecl *structDecl ) {
     1877                        stripGenericMembers( structDecl );
     1878                        return structDecl;
     1879                }
     1880
     1881                Declaration *Pass3::mutate( UnionDecl *unionDecl ) {
     1882                        stripGenericMembers( unionDecl );
     1883                        return unionDecl;
     1884                }
     1885
    18701886                TypeDecl * Pass3::mutate( TypeDecl *typeDecl ) {
    18711887//   Initializer *init = 0;
Note: See TracChangeset for help on using the changeset viewer.