mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-11 14:39:13 +00:00
This CL adds tests for decorated variable and updates the API to be slightly nicer. Bug: tint:11 Change-Id: I0bd5b8b6e6f682dc9d405e02e51d5dbcaeccc5f3 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16465 Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com> Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
71 lines
2.2 KiB
C++
71 lines
2.2 KiB
C++
// Copyright 2020 The Tint Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#ifndef SRC_AST_DECORATED_VARIABLE_H_
|
|
#define SRC_AST_DECORATED_VARIABLE_H_
|
|
|
|
#include <memory>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include "src/ast/variable.h"
|
|
#include "src/ast/variable_decoration.h"
|
|
|
|
namespace tint {
|
|
namespace ast {
|
|
|
|
/// A Decorated Variable statement.
|
|
class DecoratedVariable : public Variable {
|
|
public:
|
|
/// Create a new empty decorated variable statement
|
|
DecoratedVariable();
|
|
/// Create a decorated variable from an existing variable
|
|
/// @param var the variable to initialize from
|
|
explicit DecoratedVariable(std::unique_ptr<Variable> var);
|
|
/// Move constructor
|
|
DecoratedVariable(DecoratedVariable&&);
|
|
|
|
~DecoratedVariable() override;
|
|
|
|
/// Sets a decoration to the variable
|
|
/// @param decos the decorations to set
|
|
void set_decorations(std::vector<std::unique_ptr<VariableDecoration>> decos) {
|
|
decorations_ = std::move(decos);
|
|
}
|
|
/// @returns the decorations attached to this variable
|
|
const std::vector<std::unique_ptr<VariableDecoration>>& decorations() const {
|
|
return decorations_;
|
|
}
|
|
|
|
/// @returns true if this is a decorated variable
|
|
bool IsDecorated() const override { return true; }
|
|
|
|
/// @returns true if the name and path are both present
|
|
bool IsValid() const override;
|
|
|
|
/// @param out the stream to write to
|
|
/// @param indent number of spaces to indent the node when writing
|
|
void to_str(std::ostream& out, size_t indent) const override;
|
|
|
|
private:
|
|
DecoratedVariable(const DecoratedVariable&) = delete;
|
|
|
|
std::vector<std::unique_ptr<VariableDecoration>> decorations_;
|
|
};
|
|
|
|
} // namespace ast
|
|
} // namespace tint
|
|
|
|
#endif // SRC_AST_DECORATED_VARIABLE_H_
|