Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/gfx/skia/skia/src/sksl/ir/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  SkSLSwitchStatement.h   Sprache: C

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


#ifndef SKSL_SWITCHSTATEMENT
#define SKSL_SWITCHSTATEMENT

#include "src/sksl/SkSLDefines.h"
#include "src/sksl/SkSLPosition.h"
#include "src/sksl/ir/SkSLBlock.h"
#include "src/sksl/ir/SkSLExpression.h"
#include "src/sksl/ir/SkSLIRNode.h"
#include "src/sksl/ir/SkSLStatement.h"

#include <memory>
#include <string>
#include <utility>

namespace SkSL {

class Context;
class SymbolTable;

/**
 * A 'switch' statement.
 */

class SwitchStatement final : public Statement {
public:
    inline static constexpr Kind kIRNodeKind = Kind::kSwitch;

    SwitchStatement(Position pos,
                    std::unique_ptr<Expression> value,
                    std::unique_ptr<Statement> caseBlock)
            : INHERITED(pos, kIRNodeKind)
            , fValue(std::move(value))
            , fCaseBlock(std::move(caseBlock)) {}

    // Create a `switch` statement with an array of case-values and case-statements.
    // Coerces case values to the proper type and reports an error if cases are duplicated.
    // Reports errors via the ErrorReporter.
    static std::unique_ptr<Statement> Convert(const Context& context,
                                              Position pos,
                                              std::unique_ptr<Expression> value,
                                              ExpressionArray caseValues,
                                              StatementArray caseStatements,
                                              std::unique_ptr<SymbolTable> symbolTable);

    // Create a `switch` statement with a Block containing only SwitchCases. The SwitchCase block
    // must already contain non-overlapping, correctly-typed case values. Reports errors via ASSERT.
    static std::unique_ptr<Statement> Make(const Context& context,
                                           Position pos,
                                           std::unique_ptr<Expression> value,
                                           std::unique_ptr<Statement> caseBlock);

    std::unique_ptr<Expression>& value() {
        return fValue;
    }

    const std::unique_ptr<Expression>& value() const {
        return fValue;
    }

    std::unique_ptr<Statement>& caseBlock() {
        return fCaseBlock;
    }

    const std::unique_ptr<Statement>& caseBlock() const {
        return fCaseBlock;
    }

    StatementArray& cases() {
        return fCaseBlock->as<Block>().children();
    }

    const StatementArray& cases() const {
        return fCaseBlock->as<Block>().children();
    }

    std::string description() const override;

private:
    std::unique_ptr<Expression> fValue;
    std::unique_ptr<Statement> fCaseBlock; // must be a Block containing only SwitchCase statements

    using INHERITED = Statement;
};

}  // namespace SkSL

#endif

Messung V0.5
C=98 H=95 G=96

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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.