ExprVar
| 740 | } |
| 741 | // ExprVar |
| 742 | virtual ExpressionPtr visit ( ExprVar * expr ) override { |
| 743 | if ( !expr->variable->access_ref && !expr->variable->access_extern ) { |
| 744 | if ( expr->r2v ) { |
| 745 | if ( expr->variable->init ) { |
| 746 | if ( expr->variable->init->constexpression ) { |
| 747 | if ( !expr->isGlobalVariable() || expr->variable->type->isConst() ) { |
| 748 | reportFolding(); |
| 749 | auto cle = expr->variable->init->clone(); |
| 750 | if ( !cle->type ) { |
| 751 | cle->type = new TypeDecl(*expr->variable->init->type); |
| 752 | } |
| 753 | return cle; |
| 754 | } |
| 755 | } |
| 756 | } else { |
| 757 | if ( expr->type->isFoldable() && !expr->variable->access_init && (expr->variable->type->constant || !expr->isGlobalVariable()) ) { |
| 758 | if ( expr->type->isEnumT() ) { |
| 759 | auto cfv = expr->type->enumType->find(0, ""); |
| 760 | if ( !cfv.empty() ) { |
| 761 | reportFolding(); |
| 762 | auto exprV = new ExprConstEnumeration(expr->at, cfv, new TypeDecl(*expr->type)); |
| 763 | exprV->type = expr->type->enumType->makeEnumType(); |
| 764 | exprV->type->constant = true; |
| 765 | exprV->value = v_zero(); |
| 766 | return exprV; |
| 767 | } |
| 768 | } else if ( expr->type->baseType==Type::tString ) { |
| 769 | reportFolding(); |
| 770 | auto exprV = new ExprConstString(expr->at); |
| 771 | exprV->type = new TypeDecl(Type::tString); |
| 772 | exprV->type->constant = true; |
| 773 | return exprV; |
| 774 | } else { |
| 775 | reportFolding(); |
| 776 | auto exprV = Program::makeConst(expr->at, expr->type, v_zero()); |
| 777 | exprV->type = new TypeDecl(*expr->type); |
| 778 | exprV->type->constant = true; |
| 779 | return exprV; |
| 780 | } |
| 781 | } |
| 782 | } |
| 783 | } |
| 784 | } |
| 785 | return Visitor::visit(expr); |
| 786 | } |
| 787 | // ExprFor |
| 788 | virtual ExpressionPtr visit ( ExprFor * expr ) override { |
| 789 | // TODO: how do we determine, if iteration count is not used? |