Changeset cb4c607


Ignore:
Timestamp:
May 11, 2016, 1:09:33 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, with_gc
Children:
af18713
Parents:
7b937575
Message:

Refactor Constant::from to disambiguate type

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r7b937575 rcb4c607  
    499499                       
    500500                        // place current size in the current offset index
    501                         addExpr( layoutDecl->get_statements(), makeOp( "?=?", makeOp( "?[?]", new VariableExpr( offsetParam ), new ConstantExpr( Constant::from( n_members ) ) ),
     501                        addExpr( layoutDecl->get_statements(), makeOp( "?=?", makeOp( "?[?]", new VariableExpr( offsetParam ), new ConstantExpr( Constant::from_ulong( n_members ) ) ),
    502502                                                                              derefVar( sizeParam ) ) );
    503503                        ++n_members;
     
    20662066                                if ( n_members == 0 ) {
    20672067                                        // all empty structs have the same layout - size 1, align 1
    2068                                         makeVar( sizeofName( typeName ), layoutType, new SingleInit( new ConstantExpr( Constant::from( (unsigned long)1 ) ) ) );
    2069                                         makeVar( alignofName( typeName ), layoutType->clone(), new SingleInit( new ConstantExpr( Constant::from( (unsigned long)1 ) ) ) );
     2068                                        makeVar( sizeofName( typeName ), layoutType, new SingleInit( new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
     2069                                        makeVar( alignofName( typeName ), layoutType->clone(), new SingleInit( new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
    20702070                                        // NOTE zero-length arrays are forbidden in C, so empty structs have no offsetof array
    20712071                                } else {
    20722072                                        ObjectDecl *sizeVar = makeVar( sizeofName( typeName ), layoutType );
    20732073                                        ObjectDecl *alignVar = makeVar( alignofName( typeName ), layoutType->clone() );
    2074                                         ObjectDecl *offsetVar = makeVar( offsetofName( typeName ), new ArrayType( Type::Qualifiers(), layoutType->clone(), new ConstantExpr( Constant::from( n_members ) ), false, false ) );
     2074                                        ObjectDecl *offsetVar = makeVar( offsetofName( typeName ), new ArrayType( Type::Qualifiers(), layoutType->clone(), new ConstantExpr( Constant::from_int( n_members ) ), false, false ) );
    20752075
    20762076                                        // generate call to layout function
     
    21912191
    21922192                                        // build the offset array and replace the pack with a reference to it
    2193                                         ObjectDecl *offsetArray = makeVar( offsetName, new ArrayType( Type::Qualifiers(), offsetType, new ConstantExpr( Constant::from( baseMembers.size() ) ), false, false ),
     2193                                        ObjectDecl *offsetArray = makeVar( offsetName, new ArrayType( Type::Qualifiers(), offsetType, new ConstantExpr( Constant::from_ulong( baseMembers.size() ) ), false, false ),
    21942194                                                        new ListInit( inits ) );
    21952195                                        ret = new VariableExpr( offsetArray );
  • src/SynTree/Constant.cc

    r7b937575 rcb4c607  
    3030Constant::~Constant() { delete type; }
    3131
    32 Constant Constant::from( int i ) {
     32Constant Constant::from_int( int i ) {
    3333        return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ) );
    3434}
    3535
    36 Constant Constant::from( unsigned long i ) {
     36Constant Constant::from_ulong( unsigned long i ) {
    3737        return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ) );
    3838}
    3939
    40 Constant Constant::from( double d ) {
     40Constant Constant::from_double( double d ) {
    4141        return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ) );
    4242}
  • src/SynTree/Constant.h

    r7b937575 rcb4c607  
    3333
    3434        /// generates an integer constant of the given int
    35         static Constant from( int i );
     35        static Constant from_int( int i );
    3636        /// generates an integer constant of the given unsigned long int
    37         static Constant from( unsigned long i );
     37        static Constant from_ulong( unsigned long i );
    3838        /// generates a floating point constant of the given double
    39         static Constant from( double d );
     39        static Constant from_double( double d );
    4040
    4141        virtual Constant *clone() const;
Note: See TracChangeset for help on using the changeset viewer.