MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / visit

Method visit

src/ast/ast_unused.cpp:742–786  ·  view source on GitHub ↗

ExprVar

Source from the content-addressed store, hash-verified

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?

Callers 2

MarkSideEffectsMethod · 0.45
getSideEffectsMethod · 0.45

Calls 13

isConstMethod · 0.80
isFoldableMethod · 0.80
isEnumTMethod · 0.80
v_zeroFunction · 0.50
visitFunction · 0.50
cloneMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
makeEnumTypeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected