Changeset db0b3ce for src


Ignore:
Timestamp:
Dec 14, 2015, 4:28:46 PM (8 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:
5e92fee
Parents:
56fcd77
Message:

Initial draft of switch-over of size/align names

Location:
src
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r56fcd77 rdb0b3ce  
    309309                                        Type *concrete = env->lookup( tyParm->first );
    310310                                        if ( concrete ) {
    311                                                 // TODO add alignment
    312311                                                arg = appExpr->get_args().insert( arg, new SizeofExpr( concrete->clone() ) );
     312                                                arg++;
     313                                                arg = appExpr->get_args().insert( arg, new AlignofExpr( concrete->clone() ) );
    313314                                                arg++;
    314315                                        } else {
     
    10081009                        std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin();
    10091010                        std::list< DeclarationWithType *> inferredParams;
    1010                         // TODO add alignment
    10111011                        ObjectDecl *newObj = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );
    10121012//   ObjectDecl *newFunPtr = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 );
    10131013                        for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
    1014                                 ObjectDecl *thisParm;
    1015                                 // add all size parameters to parameter list
     1014                                ObjectDecl *sizeParm, *alignParm;
     1015                                // add all size and alignment parameters to parameter list
    10161016                                if ( (*tyParm)->get_kind() == TypeDecl::Any ) {
    1017                                         thisParm = newObj->clone();
    1018                                         thisParm->set_name( (*tyParm)->get_name() );
    1019                                         last = funcType->get_parameters().insert( last, thisParm );
     1017                                        sizeParm = newObj->clone();
     1018                                        sizeParm->set_name( std::string("_sizeof_") + (*tyParm)->get_name() );
     1019                                        last = funcType->get_parameters().insert( last, sizeParm );
     1020                                        ++last;
     1021                                        alignParm = newObj->clone();
     1022                                        alignParm->set_name( std::string("_alignof_") + (*tyParm)->get_name() );
     1023                                        last = funcType->get_parameters().insert( last, alignParm );
    10201024                                        ++last;
    10211025                                }
  • src/GenPoly/ScrubTyVars.cc

    r56fcd77 rdb0b3ce  
    1313// Update Count     : 2
    1414//
     15
     16#include <string>
    1517
    1618#include "GenPoly.h"
     
    4244
    4345        Expression * ScrubTyVars::mutate( SizeofExpr *szeof ) {
    44                 // sizeof( T ) => T parameter, which is the size of T
     46                // sizeof( T ) => _sizeof_T parameter, which is the size of T
    4547                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( szeof->get_type() ) ) {
    46                         Expression *expr = new NameExpr( typeInst->get_name() );
     48                        Expression *expr = new NameExpr( std::string("_sizeof_") + typeInst->get_name() );
    4749                        return expr;
    4850                } else {
    4951                        return Mutator::mutate( szeof );
     52                } // if
     53        }
     54
     55        Expression * ScrubTyVars::mutate( AlignofExpr *algnof ) {
     56                // alignof( T ) => _alignof_T parameter, which is the alignment of T
     57                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( algnof->get_type() ) ) {
     58                        Expression *expr = new NameExpr( std::string("_alignof_") + typeInst->get_name() );
     59                        return expr;
     60                } else {
     61                        return Mutator::mutate( algnof );
    5062                } // if
    5163        }
  • src/GenPoly/ScrubTyVars.h

    r56fcd77 rdb0b3ce  
    3636                virtual Type* mutate( TypeInstType *typeInst );
    3737                Expression* mutate( SizeofExpr *szeof );
     38                Expression* mutate( AlignofExpr *algnof );
    3839                virtual Type* mutate( PointerType *pointer );
    3940          private:
Note: See TracChangeset for help on using the changeset viewer.