Changeset d0bacde


Ignore:
Timestamp:
Sep 28, 2018, 5:34:46 PM (3 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
04bdc26
Parents:
bb0f974 (diff), 6c89ecc (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:software/cfa/cfa-cc

Location:
src/SynTree
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Constant.cc

    rbb0f974 rd0bacde  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul 14 14:50:00 2017
    13 // Update Count     : 29
     12// Last Modified On : Fri Spt 28 14:49:00 2018
     13// Update Count     : 30
    1414//
    1515
     
    1919
    2020#include "Constant.h"
     21#include "Expression.h" // for ConstantExpr
    2122#include "Type.h"    // for BasicType, Type, Type::Qualifiers, PointerType
    2223
     
    4849Constant Constant::from_double( double d ) {
    4950        return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ), d );
     51}
     52
     53Constant Constant::from_string( std::string const & str ) {
     54        return Constant(
     55                new ArrayType(
     56                        noQualifiers,
     57                        new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
     58                        new ConstantExpr( Constant::from_int( str.size() + 1 /* \0 */ )),
     59                        false, false ),
     60                std::string("\"") + str + "\"", (unsigned long long int)0 );
    5061}
    5162
  • src/SynTree/Constant.h

    rbb0f974 rd0bacde  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:54:46 2017
    13 // Update Count     : 17
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Spt 28 14:48:00 2018
     13// Update Count     : 18
    1414//
    1515
     
    5151        /// generates a floating point constant of the given double
    5252        static Constant from_double( double d );
     53        /// generates an array of chars constant of the given string
     54        static Constant from_string( std::string const & s );
    5355
    5456        /// generates a null pointer value for the given type. void * if omitted.
Note: See TracChangeset for help on using the changeset viewer.