Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    r60aaa51d rc36298d  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 15 17:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Created On       : Wed May 15 17:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Andrew Beach
     12// Created On       : Thr Jun 13 13:38:00 2019
     13// Update Count     : 2
    1414//
    1515
     
    194194        if ( const BasicType * bty = result.as< BasicType >() ) {
    195195                if ( bty->isInteger() ) {
    196                         return val.ival;
     196                        assert(ival);
     197                        return ival.value();
    197198                }
    198199        } else if ( result.as< ZeroType >() ) {
     
    204205}
    205206
    206 double ConstantExpr::floatValue() const {
    207         if ( const BasicType * bty = result.as< BasicType >() ) {
    208                 if ( ! bty->isInteger() ) {
    209                         return val.dval;
    210                 }
    211         }
    212         SemanticError( this, "Constant expression of non-floating-point type " );
    213 }
    214 
    215207ConstantExpr * ConstantExpr::from_bool( const CodeLocation & loc, bool b ) {
    216208        return new ConstantExpr{
    217209                loc, new BasicType{ BasicType::Bool }, b ? "1" : "0", (unsigned long long)b };
    218 }
    219 
    220 ConstantExpr * ConstantExpr::from_char( const CodeLocation & loc, char c ) {
    221         return new ConstantExpr{
    222                 loc, new BasicType{ BasicType::Char }, std::to_string( c ), (unsigned long long)c };
    223210}
    224211
     
    232219                loc, new BasicType{ BasicType::LongUnsignedInt }, std::to_string( i ),
    233220                (unsigned long long)i };
    234 }
    235 
    236 ConstantExpr * ConstantExpr::from_double( const CodeLocation & loc, double d ) {
    237         return new ConstantExpr{ loc, new BasicType{ BasicType::Double }, std::to_string( d ), d };
    238 }
    239 
    240 ConstantExpr * ConstantExpr::from_string( const CodeLocation & loc, const std::string & s ) {
    241         return new ConstantExpr{
    242                 loc,
    243                 new ArrayType{
    244                         new BasicType{ BasicType::Char, CV::Const },
    245                         ConstantExpr::from_int( loc, s.size() + 1 /* null terminator */ ),
    246                         FixedLen, DynamicDim },
    247                 std::string{"\""} + s + "\"",
    248                 (unsigned long long)0,
    249                 ConstantExpr::String };
    250221}
    251222
     
    382353
    383354UniqueExpr::UniqueExpr( const CodeLocation & loc, const Expr * e, unsigned long long i )
    384 : Expr( loc, e->result ), id( i ) {
     355: Expr( loc, e->result ), expr( e ), id( i ) {
    385356        assert( expr );
    386357        if ( id == -1ull ) {
Note: See TracChangeset for help on using the changeset viewer.