Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r487845d7 rddb80bd  
    8383}
    8484
     85long long int ConstantExpr::intValue() const {
     86        if ( BasicType * basicType = dynamic_cast< BasicType * >( result ) ) {
     87                if ( basicType->isInteger() ) {
     88                        return get_constant()->get_ival();
     89                }
     90        } else if ( dynamic_cast< OneType * >( result ) ) {
     91                return 1;
     92        } else if ( dynamic_cast< ZeroType * >( result ) ) {
     93                return 0;
     94        }
     95        throw SemanticError( "Constant expression of non-integral type ", this );
     96}
     97
    8598VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {
    8699        assert( var );
     
    589602        if ( ! body.empty() ) {
    590603                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {
    591                         set_result( maybeClone( exprStmt->get_expr()->get_result() ) );
     604                        result = maybeClone( exprStmt->expr->result );
    592605                }
    593606        }
    594607        // ensure that StmtExpr has a result type
    595608        if ( ! result ) {
    596                 set_result( new VoidType( Type::Qualifiers() ) );
     609                result = new VoidType( Type::Qualifiers() );
    597610        }
    598611}
Note: See TracChangeset for help on using the changeset viewer.