Changes in src/SynTree/Expression.cc [487845d7:ddb80bd]
- File:
-
- 1 edited
-
src/SynTree/Expression.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r487845d7 rddb80bd 83 83 } 84 84 85 long 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 85 98 VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) { 86 99 assert( var ); … … 589 602 if ( ! body.empty() ) { 590 603 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) { 591 set_result( maybeClone( exprStmt->get_expr()->get_result() ));604 result = maybeClone( exprStmt->expr->result ); 592 605 } 593 606 } 594 607 // ensure that StmtExpr has a result type 595 608 if ( ! result ) { 596 set_result( new VoidType( Type::Qualifiers()) );609 result = new VoidType( Type::Qualifiers() ); 597 610 } 598 611 }
Note:
See TracChangeset
for help on using the changeset viewer.