Ignore:
Timestamp:
Jun 17, 2019, 11:01:04 AM (5 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/Parser/ExpressionNode.cc

    r6a1dfda rc36298d  
    354354                strtype = new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char );
    355355        } // switch
    356         Expression * ret = new ConstantExpr( Constant::from_string( str, strtype ) );
     356        ArrayType * at = new ArrayType( noQualifiers, strtype,
     357                                                                        new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"'
     358                                                                        false, false );
     359        Expression * ret = new ConstantExpr( Constant( at, str, std::nullopt ) );
    357360        if ( units.length() != 0 ) {
    358361                ret = new UntypedExpr( new NameExpr( units ), { ret } );
Note: See TracChangeset for help on using the changeset viewer.