Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    rdb70fe4 rbeec62c  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Sep 14 23:09:34 2017
    13 // Update Count     : 690
     12// Last Modified On : Tue Sep 12 10:00:29 2017
     13// Update Count     : 672
    1414//
    1515
     
    250250        sepString( str, units, '"' );                                           // separate constant from units
    251251
    252         Type * strtype;
    253         switch ( str[0] ) {                                                                     // str has >= 2 characters, i.e, null string "" => safe to look at subscripts 0/1
     252        BasicType::Kind strtype = BasicType::Char;                      // default string type
     253        switch ( str[0] ) {                                                                     // str has >= 2 characters, i.e, null string ""
    254254          case 'u':
    255                 if ( str[1] == '8' ) goto Default;                              // utf-8 characters => array of char
    256                 // lookup type of associated typedef
    257                 strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "char16_t", false );
     255                if ( str[1] == '8' ) break;                                             // utf-8 characters
     256                strtype = BasicType::ShortUnsignedInt;
    258257                break;
    259258          case 'U':
    260                 strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "char32_t", false );
     259                strtype = BasicType::UnsignedInt;
    261260                break;
    262261          case 'L':
    263                 strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "wchar_t", false );
     262                strtype = BasicType::SignedInt;
    264263                break;
    265           Default:                                                                                      // char default string type
    266           default:
    267                 strtype = new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char );
    268264        } // switch
    269         ArrayType * at = new ArrayType( noQualifiers, strtype,
     265        ArrayType * at = new ArrayType( noQualifiers, new BasicType( Type::Qualifiers( Type::Const ), strtype ),
    270266                                                                        new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"'
    271267                                                                        false, false );
     
    348344
    349345Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
    350         return new VirtualCastExpr( maybeMoveBuild< Expression >( expr_node ), maybeMoveBuildType( decl_node ) );
     346        Type * targetType = maybeMoveBuildType( decl_node );
     347        Expression * castArg = maybeMoveBuild< Expression >( expr_node );
     348        return new VirtualCastExpr( castArg, targetType );
    351349} // build_virtual_cast
    352350
    353351Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ) {
    354         return new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
     352        UntypedMemberExpr * ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
     353        return ret;
    355354} // build_fieldSel
    356355
     
    362361        return ret;
    363362} // build_pfieldSel
     363
     364Expression * build_addressOf( ExpressionNode * expr_node ) {
     365                return new AddressExpr( maybeMoveBuild< Expression >(expr_node) );
     366} // build_addressOf
     367
     368Expression * build_sizeOfexpr( ExpressionNode * expr_node ) {
     369        return new SizeofExpr( maybeMoveBuild< Expression >(expr_node) );
     370} // build_sizeOfexpr
     371
     372Expression * build_sizeOftype( DeclarationNode * decl_node ) {
     373        return new SizeofExpr( maybeMoveBuildType( decl_node ) );
     374} // build_sizeOftype
     375
     376Expression * build_alignOfexpr( ExpressionNode * expr_node ) {
     377        return new AlignofExpr( maybeMoveBuild< Expression >(expr_node) );
     378} // build_alignOfexpr
     379
     380Expression * build_alignOftype( DeclarationNode * decl_node ) {
     381        return new AlignofExpr( maybeMoveBuildType( decl_node) );
     382} // build_alignOftype
    364383
    365384Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member ) {
     
    403422} // build_cond
    404423
     424Expression * build_comma( ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
     425        return new CommaExpr( maybeMoveBuild< Expression >(expr_node1), maybeMoveBuild< Expression >(expr_node2) );
     426} // build_comma
     427
     428Expression * build_attrexpr( NameExpr * var, ExpressionNode * expr_node ) {
     429        return new AttrExpr( var, maybeMoveBuild< Expression >(expr_node) );
     430} // build_attrexpr
     431
     432Expression * build_attrtype( NameExpr * var, DeclarationNode * decl_node ) {
     433        return new AttrExpr( var, maybeMoveBuildType( decl_node ) );
     434} // build_attrtype
     435
    405436Expression * build_tuple( ExpressionNode * expr_node ) {
    406437        list< Expression * > exprs;
     
    414445        return new UntypedExpr( maybeMoveBuild< Expression >(function), args, nullptr );
    415446} // build_func
     447
     448Expression * build_range( ExpressionNode * low, ExpressionNode * high ) {
     449        return new RangeExpr( maybeMoveBuild< Expression >( low ), maybeMoveBuild< Expression >( high ) );
     450} // build_range
     451
     452Expression * build_asmexpr( ExpressionNode * inout, Expression * constraint, ExpressionNode * operand ) {
     453        return new AsmExpr( maybeMoveBuild< Expression >( inout ), constraint, maybeMoveBuild< Expression >(operand) );
     454} // build_asmexpr
     455
     456Expression * build_valexpr( StatementNode * s ) {
     457        return new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(s) ) );
     458} // build_valexpr
     459
     460Expression * build_typevalue( DeclarationNode * decl ) {
     461        return new TypeExpr( maybeMoveBuildType( decl ) );
     462} // build_typevalue
    416463
    417464Expression * build_compoundLiteral( DeclarationNode * decl_node, InitializerNode * kids ) {
Note: See TracChangeset for help on using the changeset viewer.