Ignore:
Timestamp:
Jun 17, 2019, 11:01:04 AM (7 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b4d34fa
Parents:
6a1dfda
Message:

Fixed handling of "literals.cfa" string-detail test cases by simplifying constant analysis. Now a ConstantExpr is a minial passthrough from parser to code generator, with special-case analysis only for integer values. Awareness of how to build a string-constant type is back in ExpressionNode.cc; now, this knowlede is only needed there. AST conversion no longer specializes string-int-float constants; it just converts types and passes values through. Unused constant API features are removed, notably from-to-float and from-string.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Constant.h

    r6a1dfda rc36298d  
    1818#include <iosfwd>     // for ostream
    1919#include <string>     // for string
     20#include <optional>   // for optional
    2021
    2122#include "BaseSyntaxNode.h"
     
    2728class Constant : public BaseSyntaxNode {
    2829  public:
    29         Constant( Type * type, std::string rep, unsigned long long val );
    30         Constant( Type * type, std::string rep, double val );
     30        Constant( Type * type, std::string rep, std::optional<unsigned long long> i );
    3131        Constant( const Constant & other );
    3232        virtual ~Constant();
     
    3939        void set_value( std::string newValue ) { rep = newValue; }
    4040        unsigned long long get_ival() const;
    41         double get_dval() const;
    4241
    4342        /// generates a boolean constant of the given bool
    4443        static Constant from_bool( bool b );
    45         /// generates a char constant of the given char
    46         static Constant from_char( char c );
    4744        /// generates an integer constant of the given int
    4845        static Constant from_int( int i );
    4946        /// generates an integer constant of the given unsigned long int
    5047        static Constant from_ulong( unsigned long i );
    51         /// generates a floating point constant of the given double
    52         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 & cEscapedVal, Type *charType  );
    5548
    5649        /// generates a null pointer value for the given type. void * if omitted.
     
    6356        Type * type;
    6457        std::string rep;
    65         union Val {
    66                 unsigned long long ival;
    67                 double dval;
    68                 Val( unsigned long long ival ) : ival( ival ) {}
    69                 Val( double dval ) : dval( dval ) {}
    70         } val;
     58        std::optional<unsigned long long> ival;
     59
     60        friend class ConverterOldToNew;
    7161};
    7262
Note: See TracChangeset for help on using the changeset viewer.