Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/gfx/skia/skia/src/sksl/analysis/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  SkSLHasSideEffects.cpp

  Sprache: C
 

/*
 * Copyright 2022 Google LLC
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#include "include/core/SkTypes.h"
#include "src/sksl/SkSLAnalysis.h"
#include "src/sksl/SkSLOperator.h"
#include "src/sksl/analysis/SkSLProgramVisitor.h"
#include "src/sksl/ir/SkSLBinaryExpression.h"
#include "src/sksl/ir/SkSLExpression.h"
#include "src/sksl/ir/SkSLFunctionCall.h"
#include "src/sksl/ir/SkSLFunctionDeclaration.h"
#include "src/sksl/ir/SkSLIRNode.h"
#include "src/sksl/ir/SkSLModifierFlags.h"
#include "src/sksl/ir/SkSLPrefixExpression.h"

namespace SkSL {

bool Analysis::HasSideEffects(const Expression& expr) {
    class HasSideEffectsVisitor : public ProgramVisitor {
    public:
        bool visitExpression(const Expression& expr) override {
            switch (expr.kind()) {
                case Expression::Kind::kFunctionCall: {
                    const FunctionCall& call = expr.as<FunctionCall>();
                    if (!call.function().modifierFlags().isPure()) {
                        return true;
                    }
                    break;
                }
                case Expression::Kind::kPrefix: {
                    const PrefixExpression& prefix = expr.as<PrefixExpression>();
                    if (prefix.getOperator().kind() == Operator::Kind::PLUSPLUS ||
                        prefix.getOperator().kind() == Operator::Kind::MINUSMINUS) {
                        return true;
                    }
                    break;
                }
                case Expression::Kind::kBinary: {
                    const BinaryExpression& binary = expr.as<BinaryExpression>();
                    if (binary.getOperator().isAssignment()) {
                        return true;
                    }
                    break;
                }
                case Expression::Kind::kPostfix:
                    return true;

                default:
                    break;
            }
            return INHERITED::visitExpression(expr);
        }

        using INHERITED = ProgramVisitor;
    };

    HasSideEffectsVisitor visitor;
    return visitor.visitExpression(expr);
}

}  // namespace SkSL

Messung V0.5 in Prozent
C=97 H=95 G=95

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.