Remove suppressing [chromium-style] errors
Lots of little style nits needed to be fixed for this work. BUG=tint:44 Change-Id: Ibb45d9e3f6795ee0c09f5eca994bb28e20979d97 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19221 Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
parent
1234633b32
commit
4d32be4f1b
40
BUILD.gn
40
BUILD.gn
|
@ -34,8 +34,8 @@ source_set("libtint") {
|
|||
"src/ast/binary_expression.h",
|
||||
"src/ast/binding_decoration.cc",
|
||||
"src/ast/binding_decoration.h",
|
||||
"src/ast/bool_literal.h",
|
||||
"src/ast/bool_literal.cc",
|
||||
"src/ast/bool_literal.h",
|
||||
"src/ast/break_statement.cc",
|
||||
"src/ast/break_statement.h",
|
||||
"src/ast/builtin.cc",
|
||||
|
@ -78,8 +78,8 @@ source_set("libtint") {
|
|||
"src/ast/int_literal.h",
|
||||
"src/ast/kill_statement.cc",
|
||||
"src/ast/kill_statement.h",
|
||||
"src/ast/literal.h",
|
||||
"src/ast/literal.cc",
|
||||
"src/ast/literal.h",
|
||||
"src/ast/location_decoration.cc",
|
||||
"src/ast/location_decoration.h",
|
||||
"src/ast/loop_statement.cc",
|
||||
|
@ -108,10 +108,10 @@ source_set("libtint") {
|
|||
"src/ast/statement_condition.h",
|
||||
"src/ast/storage_class.cc",
|
||||
"src/ast/storage_class.h",
|
||||
"src/ast/struct_decoration.cc",
|
||||
"src/ast/struct_decoration.h",
|
||||
"src/ast/struct.cc",
|
||||
"src/ast/struct.h",
|
||||
"src/ast/struct_decoration.cc",
|
||||
"src/ast/struct_decoration.h",
|
||||
"src/ast/struct_member.cc",
|
||||
"src/ast/struct_member.h",
|
||||
"src/ast/struct_member_decoration.cc",
|
||||
|
@ -120,8 +120,6 @@ source_set("libtint") {
|
|||
"src/ast/struct_member_offset_decoration.h",
|
||||
"src/ast/switch_statement.cc",
|
||||
"src/ast/switch_statement.h",
|
||||
"src/ast/type_constructor_expression.h",
|
||||
"src/ast/type_constructor_expression.cc",
|
||||
"src/ast/type/alias_type.cc",
|
||||
"src/ast/type/alias_type.h",
|
||||
"src/ast/type/array_type.cc",
|
||||
|
@ -146,6 +144,8 @@ source_set("libtint") {
|
|||
"src/ast/type/vector_type.h",
|
||||
"src/ast/type/void_type.cc",
|
||||
"src/ast/type/void_type.h",
|
||||
"src/ast/type_constructor_expression.cc",
|
||||
"src/ast/type_constructor_expression.h",
|
||||
"src/ast/uint_literal.cc",
|
||||
"src/ast/uint_literal.h",
|
||||
"src/ast/unary_derivative.cc",
|
||||
|
@ -164,12 +164,12 @@ source_set("libtint") {
|
|||
"src/ast/unless_statement.h",
|
||||
"src/ast/variable.cc",
|
||||
"src/ast/variable.h",
|
||||
"src/ast/variable_decoration.cc",
|
||||
"src/ast/variable_decoration.h",
|
||||
"src/ast/variable_decl_statement.cc",
|
||||
"src/ast/variable_decl_statement.h",
|
||||
"src/context.h",
|
||||
"src/ast/variable_decoration.cc",
|
||||
"src/ast/variable_decoration.h",
|
||||
"src/context.cc",
|
||||
"src/context.h",
|
||||
"src/reader/reader.cc",
|
||||
"src/reader/reader.h",
|
||||
"src/scope_stack.h",
|
||||
|
@ -186,34 +186,26 @@ source_set("libtint") {
|
|||
"src/writer/writer.h",
|
||||
]
|
||||
|
||||
configs += [ ":tint_common_config" ]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
|
||||
# Suppress warnings from the Chromium Clang plugin
|
||||
configs -= [ "//build/config/clang:find_bad_constructs" ]
|
||||
}
|
||||
|
||||
executable("tint") {
|
||||
sources = [
|
||||
"samples/main.cc",
|
||||
]
|
||||
deps = [
|
||||
":libtint",
|
||||
]
|
||||
sources = [ "samples/main.cc" ]
|
||||
deps = [ ":libtint" ]
|
||||
|
||||
configs += [ ":tint_common_config" ]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
|
||||
# Suppress warnings from the Chromium Clang plugin
|
||||
configs -= [ "//build/config/clang:find_bad_constructs" ]
|
||||
}
|
||||
|
||||
group("tint_all") {
|
||||
deps = [
|
||||
":tint",
|
||||
]
|
||||
deps = [ ":tint" ]
|
||||
}
|
||||
|
|
|
@ -32,8 +32,15 @@ ArrayAccessorExpression::ArrayAccessorExpression(
|
|||
array_(std::move(array)),
|
||||
idx_expr_(std::move(idx_expr)) {}
|
||||
|
||||
ArrayAccessorExpression::ArrayAccessorExpression(ArrayAccessorExpression&&) =
|
||||
default;
|
||||
|
||||
ArrayAccessorExpression::~ArrayAccessorExpression() = default;
|
||||
|
||||
bool ArrayAccessorExpression::IsArrayAccessor() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArrayAccessorExpression::IsValid() const {
|
||||
if (array_ == nullptr || !array_->IsValid())
|
||||
return false;
|
||||
|
|
|
@ -42,7 +42,7 @@ class ArrayAccessorExpression : public Expression {
|
|||
std::unique_ptr<Expression> array,
|
||||
std::unique_ptr<Expression> idx_expr);
|
||||
/// Move constructor
|
||||
ArrayAccessorExpression(ArrayAccessorExpression&&) = default;
|
||||
ArrayAccessorExpression(ArrayAccessorExpression&&);
|
||||
~ArrayAccessorExpression() override;
|
||||
|
||||
/// Sets the array
|
||||
|
@ -62,7 +62,7 @@ class ArrayAccessorExpression : public Expression {
|
|||
Expression* idx_expr() const { return idx_expr_.get(); }
|
||||
|
||||
/// @returns true if this is an array accessor expression
|
||||
bool IsArrayAccessor() const override { return true; }
|
||||
bool IsArrayAccessor() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -27,8 +27,13 @@ AsExpression::AsExpression(const Source& source,
|
|||
std::unique_ptr<Expression> expr)
|
||||
: Expression(source), type_(type), expr_(std::move(expr)) {}
|
||||
|
||||
AsExpression::AsExpression(AsExpression&&) = default;
|
||||
AsExpression::~AsExpression() = default;
|
||||
|
||||
bool AsExpression::IsAs() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AsExpression::IsValid() const {
|
||||
if (expr_ == nullptr || !expr_->IsValid())
|
||||
return false;
|
||||
|
|
|
@ -42,7 +42,7 @@ class AsExpression : public Expression {
|
|||
type::Type* type,
|
||||
std::unique_ptr<Expression> expr);
|
||||
/// Move constructor
|
||||
AsExpression(AsExpression&&) = default;
|
||||
AsExpression(AsExpression&&);
|
||||
~AsExpression() override;
|
||||
|
||||
/// Sets the type
|
||||
|
@ -58,7 +58,7 @@ class AsExpression : public Expression {
|
|||
Expression* expr() const { return expr_.get(); }
|
||||
|
||||
/// @returns true if this is an as expression
|
||||
bool IsAs() const override { return true; }
|
||||
bool IsAs() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -28,8 +28,14 @@ AssignmentStatement::AssignmentStatement(const Source& source,
|
|||
std::unique_ptr<Expression> rhs)
|
||||
: Statement(source), lhs_(std::move(lhs)), rhs_(std::move(rhs)) {}
|
||||
|
||||
AssignmentStatement::AssignmentStatement(AssignmentStatement&&) = default;
|
||||
|
||||
AssignmentStatement::~AssignmentStatement() = default;
|
||||
|
||||
bool AssignmentStatement::IsAssign() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssignmentStatement::IsValid() const {
|
||||
if (lhs_ == nullptr || !lhs_->IsValid())
|
||||
return false;
|
||||
|
|
|
@ -43,7 +43,7 @@ class AssignmentStatement : public Statement {
|
|||
std::unique_ptr<Expression> lhs,
|
||||
std::unique_ptr<Expression> rhs);
|
||||
/// Move constructor
|
||||
AssignmentStatement(AssignmentStatement&&) = default;
|
||||
AssignmentStatement(AssignmentStatement&&);
|
||||
~AssignmentStatement() override;
|
||||
|
||||
/// Sets the left side of the statement
|
||||
|
@ -59,7 +59,7 @@ class AssignmentStatement : public Statement {
|
|||
Expression* rhs() const { return rhs_.get(); }
|
||||
|
||||
/// @returns true if this is an assignment statement
|
||||
bool IsAssign() const override { return true; }
|
||||
bool IsAssign() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -30,8 +30,14 @@ BinaryExpression::BinaryExpression(const Source& source,
|
|||
std::unique_ptr<Expression> rhs)
|
||||
: Expression(source), op_(op), lhs_(std::move(lhs)), rhs_(std::move(rhs)) {}
|
||||
|
||||
BinaryExpression::BinaryExpression(BinaryExpression&&) = default;
|
||||
|
||||
BinaryExpression::~BinaryExpression() = default;
|
||||
|
||||
bool BinaryExpression::IsBinary() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BinaryExpression::IsValid() const {
|
||||
if (lhs_ == nullptr || !lhs_->IsValid()) {
|
||||
return false;
|
||||
|
|
|
@ -70,7 +70,7 @@ class BinaryExpression : public Expression {
|
|||
std::unique_ptr<Expression> lhs,
|
||||
std::unique_ptr<Expression> rhs);
|
||||
/// Move constructor
|
||||
BinaryExpression(BinaryExpression&&) = default;
|
||||
BinaryExpression(BinaryExpression&&);
|
||||
~BinaryExpression() override;
|
||||
|
||||
/// Sets the binary op type
|
||||
|
@ -131,7 +131,7 @@ class BinaryExpression : public Expression {
|
|||
Expression* rhs() const { return rhs_.get(); }
|
||||
|
||||
/// @returns true if this is a op expression
|
||||
bool IsBinary() const override { return true; }
|
||||
bool IsBinary() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -21,6 +21,10 @@ BindingDecoration::BindingDecoration(uint32_t val) : value_(val) {}
|
|||
|
||||
BindingDecoration::~BindingDecoration() = default;
|
||||
|
||||
bool BindingDecoration::IsBinding() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void BindingDecoration::to_str(std::ostream& out) const {
|
||||
out << "BindingDecoration{" << value_ << "}" << std::endl;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class BindingDecoration : public VariableDecoration {
|
|||
~BindingDecoration() override;
|
||||
|
||||
/// @returns true if this is a binding decoration
|
||||
bool IsBinding() const override { return true; }
|
||||
bool IsBinding() const override;
|
||||
|
||||
/// @returns the binding value
|
||||
uint32_t value() const { return value_; }
|
||||
|
|
|
@ -22,6 +22,10 @@ BoolLiteral::BoolLiteral(ast::type::Type* type, bool value)
|
|||
|
||||
BoolLiteral::~BoolLiteral() = default;
|
||||
|
||||
bool BoolLiteral::IsBool() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string BoolLiteral::to_str() const {
|
||||
return value_ ? "true" : "false";
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class BoolLiteral : public Literal {
|
|||
~BoolLiteral() override;
|
||||
|
||||
/// @returns true if this is a bool literal
|
||||
bool IsBool() const override { return true; }
|
||||
bool IsBool() const override;
|
||||
|
||||
/// @returns true if the bool literal is true
|
||||
bool IsTrue() const { return value_; }
|
||||
|
|
|
@ -34,8 +34,14 @@ BreakStatement::BreakStatement(const Source& source,
|
|||
condition_(condition),
|
||||
conditional_(std::move(conditional)) {}
|
||||
|
||||
BreakStatement::BreakStatement(BreakStatement&&) = default;
|
||||
|
||||
BreakStatement::~BreakStatement() = default;
|
||||
|
||||
bool BreakStatement::IsBreak() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BreakStatement::IsValid() const {
|
||||
if (condition_ == StatementCondition::kNone)
|
||||
return conditional_ == nullptr;
|
||||
|
|
|
@ -46,7 +46,7 @@ class BreakStatement : public Statement {
|
|||
StatementCondition condition,
|
||||
std::unique_ptr<Expression> conditional);
|
||||
/// Move constructor
|
||||
BreakStatement(BreakStatement&&) = default;
|
||||
BreakStatement(BreakStatement&&);
|
||||
~BreakStatement() override;
|
||||
|
||||
/// Sets the condition type
|
||||
|
@ -64,7 +64,7 @@ class BreakStatement : public Statement {
|
|||
Expression* conditional() const { return conditional_.get(); }
|
||||
|
||||
/// @returns true if this is an break statement
|
||||
bool IsBreak() const override { return true; }
|
||||
bool IsBreak() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -21,6 +21,10 @@ BuiltinDecoration::BuiltinDecoration(Builtin builtin) : builtin_(builtin) {}
|
|||
|
||||
BuiltinDecoration::~BuiltinDecoration() = default;
|
||||
|
||||
bool BuiltinDecoration::IsBuiltin() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void BuiltinDecoration::to_str(std::ostream& out) const {
|
||||
out << "BuiltinDecoration{" << builtin_ << "}" << std::endl;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class BuiltinDecoration : public VariableDecoration {
|
|||
~BuiltinDecoration() override;
|
||||
|
||||
/// @returns true if this is a builtin decoration
|
||||
bool IsBuiltin() const override { return true; }
|
||||
bool IsBuiltin() const override;
|
||||
|
||||
/// @returns the builtin value
|
||||
Builtin value() const { return builtin_; }
|
||||
|
|
|
@ -28,8 +28,14 @@ CallExpression::CallExpression(const Source& source,
|
|||
ExpressionList params)
|
||||
: Expression(source), func_(std::move(func)), params_(std::move(params)) {}
|
||||
|
||||
CallExpression::CallExpression(CallExpression&&) = default;
|
||||
|
||||
CallExpression::~CallExpression() = default;
|
||||
|
||||
bool CallExpression::IsCall() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CallExpression::IsValid() const {
|
||||
if (func_ == nullptr || !func_->IsValid())
|
||||
return false;
|
||||
|
|
|
@ -41,7 +41,7 @@ class CallExpression : public Expression {
|
|||
std::unique_ptr<Expression> func,
|
||||
ExpressionList params);
|
||||
/// Move constructor
|
||||
CallExpression(CallExpression&&) = default;
|
||||
CallExpression(CallExpression&&);
|
||||
~CallExpression() override;
|
||||
|
||||
/// Sets the func
|
||||
|
@ -57,7 +57,7 @@ class CallExpression : public Expression {
|
|||
const ExpressionList& params() const { return params_; }
|
||||
|
||||
/// @returns true if this is a call expression
|
||||
bool IsCall() const override { return true; }
|
||||
bool IsCall() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -30,8 +30,14 @@ CaseStatement::CaseStatement(const Source& source,
|
|||
condition_(std::move(condition)),
|
||||
body_(std::move(body)) {}
|
||||
|
||||
CaseStatement::CaseStatement(CaseStatement&&) = default;
|
||||
|
||||
CaseStatement::~CaseStatement() = default;
|
||||
|
||||
bool CaseStatement::IsCase() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CaseStatement::IsValid() const {
|
||||
for (const auto& stmt : body_) {
|
||||
if (stmt == nullptr || !stmt->IsValid())
|
||||
|
|
|
@ -44,7 +44,7 @@ class CaseStatement : public Statement {
|
|||
std::unique_ptr<Literal> condition,
|
||||
StatementList body);
|
||||
/// Move constructor
|
||||
CaseStatement(CaseStatement&&) = default;
|
||||
CaseStatement(CaseStatement&&);
|
||||
~CaseStatement() override;
|
||||
|
||||
/// Sets the condition for the case statement
|
||||
|
@ -64,7 +64,7 @@ class CaseStatement : public Statement {
|
|||
const StatementList& body() const { return body_; }
|
||||
|
||||
/// @returns true if this is a case statement
|
||||
bool IsCase() const override { return true; }
|
||||
bool IsCase() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -28,8 +28,14 @@ CastExpression::CastExpression(const Source& source,
|
|||
std::unique_ptr<Expression> expr)
|
||||
: Expression(source), type_(type), expr_(std::move(expr)) {}
|
||||
|
||||
CastExpression::CastExpression(CastExpression&&) = default;
|
||||
|
||||
CastExpression::~CastExpression() = default;
|
||||
|
||||
bool CastExpression::IsCast() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CastExpression::IsValid() const {
|
||||
if (expr_ == nullptr || !expr_->IsValid())
|
||||
return false;
|
||||
|
|
|
@ -42,7 +42,7 @@ class CastExpression : public Expression {
|
|||
type::Type* type,
|
||||
std::unique_ptr<Expression> expr);
|
||||
/// Move constructor
|
||||
CastExpression(CastExpression&&) = default;
|
||||
CastExpression(CastExpression&&);
|
||||
~CastExpression() override;
|
||||
|
||||
/// Sets the type
|
||||
|
@ -58,7 +58,7 @@ class CastExpression : public Expression {
|
|||
Expression* expr() const { return expr_.get(); }
|
||||
|
||||
/// @returns true if this is a cast expression
|
||||
bool IsCast() const override { return true; }
|
||||
bool IsCast() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -29,6 +29,18 @@ ConstructorExpression::~ConstructorExpression() = default;
|
|||
ConstructorExpression::ConstructorExpression(const Source& source)
|
||||
: Expression(source) {}
|
||||
|
||||
bool ConstructorExpression::IsConstructor() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConstructorExpression::IsScalarConstructor() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConstructorExpression::IsTypeConstructor() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
ScalarConstructorExpression* ConstructorExpression::AsScalarConstructor() {
|
||||
assert(IsScalarConstructor());
|
||||
return static_cast<ScalarConstructorExpression*>(this);
|
||||
|
|
|
@ -29,12 +29,12 @@ class ConstructorExpression : public Expression {
|
|||
~ConstructorExpression() override;
|
||||
|
||||
/// @returns true if this is an constructor expression
|
||||
bool IsConstructor() const override { return true; }
|
||||
bool IsConstructor() const override;
|
||||
|
||||
/// @returns true if this is a scalar constructor
|
||||
virtual bool IsScalarConstructor() const { return false; }
|
||||
virtual bool IsScalarConstructor() const;
|
||||
/// @returns true if this is a type constructor
|
||||
virtual bool IsTypeConstructor() const { return false; }
|
||||
virtual bool IsTypeConstructor() const;
|
||||
|
||||
/// @returns this as a scalar constructor expression
|
||||
ScalarConstructorExpression* AsScalarConstructor();
|
||||
|
|
|
@ -35,8 +35,14 @@ ContinueStatement::ContinueStatement(const Source& source,
|
|||
condition_(condition),
|
||||
conditional_(std::move(conditional)) {}
|
||||
|
||||
ContinueStatement::ContinueStatement(ContinueStatement&&) = default;
|
||||
|
||||
ContinueStatement::~ContinueStatement() = default;
|
||||
|
||||
bool ContinueStatement::IsContinue() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContinueStatement::IsValid() const {
|
||||
if (condition_ == StatementCondition::kNone)
|
||||
return conditional_ == nullptr;
|
||||
|
|
|
@ -46,7 +46,7 @@ class ContinueStatement : public Statement {
|
|||
StatementCondition condition,
|
||||
std::unique_ptr<Expression> conditional);
|
||||
/// Move constructor
|
||||
ContinueStatement(ContinueStatement&&) = default;
|
||||
ContinueStatement(ContinueStatement&&);
|
||||
~ContinueStatement() override;
|
||||
|
||||
/// Sets the condition type
|
||||
|
@ -64,7 +64,7 @@ class ContinueStatement : public Statement {
|
|||
Expression* conditional() const { return conditional_.get(); }
|
||||
|
||||
/// @returns true if this is an continue statement
|
||||
bool IsContinue() const override { return true; }
|
||||
bool IsContinue() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -26,6 +26,10 @@ DecoratedVariable::DecoratedVariable(DecoratedVariable&&) = default;
|
|||
|
||||
DecoratedVariable::~DecoratedVariable() = default;
|
||||
|
||||
bool DecoratedVariable::IsDecorated() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DecoratedVariable::IsValid() const {
|
||||
return Variable::IsValid();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class DecoratedVariable : public Variable {
|
|||
const VariableDecorationList& decorations() const { return decorations_; }
|
||||
|
||||
/// @returns true if this is a decorated variable
|
||||
bool IsDecorated() const override { return true; }
|
||||
bool IsDecorated() const override;
|
||||
|
||||
/// @returns true if the name and path are both present
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -36,8 +36,14 @@ ElseStatement::ElseStatement(const Source& source,
|
|||
condition_(std::move(condition)),
|
||||
body_(std::move(body)) {}
|
||||
|
||||
ElseStatement::ElseStatement(ElseStatement&&) = default;
|
||||
|
||||
ElseStatement::~ElseStatement() = default;
|
||||
|
||||
bool ElseStatement::IsElse() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ElseStatement::IsValid() const {
|
||||
for (const auto& stmt : body_) {
|
||||
if (stmt == nullptr || !stmt->IsValid())
|
||||
|
|
|
@ -49,7 +49,7 @@ class ElseStatement : public Statement {
|
|||
std::unique_ptr<Expression> condition,
|
||||
StatementList body);
|
||||
/// Move constructor
|
||||
ElseStatement(ElseStatement&&) = default;
|
||||
ElseStatement(ElseStatement&&);
|
||||
~ElseStatement() override;
|
||||
|
||||
/// Sets the condition for the else statement
|
||||
|
@ -69,7 +69,7 @@ class ElseStatement : public Statement {
|
|||
const StatementList& body() const { return body_; }
|
||||
|
||||
/// @returns true if this is a else statement
|
||||
bool IsElse() const override { return true; }
|
||||
bool IsElse() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -37,6 +37,50 @@ Expression::Expression(const Source& source) : Node(source) {}
|
|||
|
||||
Expression::~Expression() = default;
|
||||
|
||||
bool Expression::IsArrayAccessor() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsAs() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsCall() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsCast() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsIdentifier() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsConstructor() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsMemberAccessor() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsBinary() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsUnaryDerivative() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsUnaryMethod() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Expression::IsUnaryOp() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayAccessorExpression* Expression::AsArrayAccessor() {
|
||||
assert(IsArrayAccessor());
|
||||
return static_cast<ArrayAccessorExpression*>(this);
|
||||
|
|
|
@ -48,27 +48,27 @@ class Expression : public Node {
|
|||
type::Type* result_type() const { return result_type_; }
|
||||
|
||||
/// @returns true if this is an array accessor expression
|
||||
virtual bool IsArrayAccessor() const { return false; }
|
||||
virtual bool IsArrayAccessor() const;
|
||||
/// @returns true if this is an as expression
|
||||
virtual bool IsAs() const { return false; }
|
||||
virtual bool IsAs() const;
|
||||
/// @returns true if this is a call expression
|
||||
virtual bool IsCall() const { return false; }
|
||||
virtual bool IsCall() const;
|
||||
/// @returns true if this is a cast expression
|
||||
virtual bool IsCast() const { return false; }
|
||||
virtual bool IsCast() const;
|
||||
/// @returns true if this is an identifier expression
|
||||
virtual bool IsIdentifier() const { return false; }
|
||||
virtual bool IsIdentifier() const;
|
||||
/// @returns true if this is an constructor expression
|
||||
virtual bool IsConstructor() const { return false; }
|
||||
virtual bool IsConstructor() const;
|
||||
/// @returns true if this is a member accessor expression
|
||||
virtual bool IsMemberAccessor() const { return false; }
|
||||
virtual bool IsMemberAccessor() const;
|
||||
/// @returns true if this is a binary expression
|
||||
virtual bool IsBinary() const { return false; }
|
||||
virtual bool IsBinary() const;
|
||||
/// @returns true if this is a unary derivative expression
|
||||
virtual bool IsUnaryDerivative() const { return false; }
|
||||
virtual bool IsUnaryDerivative() const;
|
||||
/// @returns true if this is a unary method expression
|
||||
virtual bool IsUnaryMethod() const { return false; }
|
||||
virtual bool IsUnaryMethod() const;
|
||||
/// @returns true if this is a unary op expression
|
||||
virtual bool IsUnaryOp() const { return false; }
|
||||
virtual bool IsUnaryOp() const;
|
||||
|
||||
/// @returns the expression as an array accessor
|
||||
ArrayAccessorExpression* AsArrayAccessor();
|
||||
|
|
|
@ -24,6 +24,10 @@ FallthroughStatement::FallthroughStatement(const Source& source)
|
|||
|
||||
FallthroughStatement::~FallthroughStatement() = default;
|
||||
|
||||
bool FallthroughStatement::IsFallthrough() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FallthroughStatement::IsValid() const {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class FallthroughStatement : public Statement {
|
|||
~FallthroughStatement() override;
|
||||
|
||||
/// @returns true if this is an fallthrough statement
|
||||
bool IsFallthrough() const override { return true; }
|
||||
bool IsFallthrough() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -25,6 +25,10 @@ FloatLiteral::FloatLiteral(ast::type::Type* type, float value)
|
|||
|
||||
FloatLiteral::~FloatLiteral() = default;
|
||||
|
||||
bool FloatLiteral::IsFloat() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string FloatLiteral::to_str() const {
|
||||
return std::to_string(value_);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class FloatLiteral : public Literal {
|
|||
~FloatLiteral() override;
|
||||
|
||||
/// @returns true if this is a float literal
|
||||
bool IsFloat() const override { return true; }
|
||||
bool IsFloat() const override;
|
||||
|
||||
/// @returns the float literal value
|
||||
float value() const { return value_; }
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Function::Function() = default;
|
||||
|
||||
Function::Function(const std::string& name,
|
||||
VariableList params,
|
||||
type::Type* return_type)
|
||||
|
@ -36,6 +38,8 @@ Function::Function(const Source& source,
|
|||
params_(std::move(params)),
|
||||
return_type_(return_type) {}
|
||||
|
||||
Function::Function(Function&&) = default;
|
||||
|
||||
Function::~Function() = default;
|
||||
|
||||
bool Function::IsValid() const {
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace ast {
|
|||
class Function : public Node {
|
||||
public:
|
||||
/// Create a new empty function statement
|
||||
Function() = default;
|
||||
Function();
|
||||
/// Create a function
|
||||
/// @param name the function name
|
||||
/// @param params the function parameters
|
||||
|
@ -52,7 +52,7 @@ class Function : public Node {
|
|||
VariableList params,
|
||||
type::Type* return_type);
|
||||
/// Move constructor
|
||||
Function(Function&&) = default;
|
||||
Function(Function&&);
|
||||
|
||||
~Function() override;
|
||||
|
||||
|
|
|
@ -31,8 +31,14 @@ IdentifierExpression::IdentifierExpression(const Source& source,
|
|||
std::vector<std::string> name)
|
||||
: Expression(source), name_(std::move(name)) {}
|
||||
|
||||
IdentifierExpression::IdentifierExpression(IdentifierExpression&&) = default;
|
||||
|
||||
IdentifierExpression::~IdentifierExpression() = default;
|
||||
|
||||
bool IdentifierExpression::IsIdentifier() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IdentifierExpression::IsValid() const {
|
||||
if (name_.size() == 0)
|
||||
return false;
|
||||
|
|
|
@ -42,7 +42,7 @@ class IdentifierExpression : public Expression {
|
|||
/// @param name the name
|
||||
IdentifierExpression(const Source& source, std::vector<std::string> name);
|
||||
/// Move constructor
|
||||
IdentifierExpression(IdentifierExpression&&) = default;
|
||||
IdentifierExpression(IdentifierExpression&&);
|
||||
~IdentifierExpression() override;
|
||||
|
||||
/// Sets the name
|
||||
|
@ -52,7 +52,7 @@ class IdentifierExpression : public Expression {
|
|||
std::vector<std::string> name() const { return name_; }
|
||||
|
||||
/// @returns true if this is an identifier expression
|
||||
bool IsIdentifier() const override { return true; }
|
||||
bool IsIdentifier() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -32,8 +32,14 @@ IfStatement::IfStatement(const Source& source,
|
|||
condition_(std::move(condition)),
|
||||
body_(std::move(body)) {}
|
||||
|
||||
IfStatement::IfStatement(IfStatement&&) = default;
|
||||
|
||||
IfStatement::~IfStatement() = default;
|
||||
|
||||
bool IfStatement::IsIf() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfStatement::IsValid() const {
|
||||
if (condition_ == nullptr || !condition_->IsValid())
|
||||
return false;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020 The Tint Authors.
|
||||
// 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.
|
||||
|
@ -42,7 +42,7 @@ class IfStatement : public Statement {
|
|||
std::unique_ptr<Expression> condition,
|
||||
StatementList body);
|
||||
/// Move constructor
|
||||
IfStatement(IfStatement&&) = default;
|
||||
IfStatement(IfStatement&&);
|
||||
~IfStatement() override;
|
||||
|
||||
/// Sets the condition for the if statement
|
||||
|
@ -74,7 +74,7 @@ class IfStatement : public Statement {
|
|||
const StatementList& premerge() const { return premerge_; }
|
||||
|
||||
/// @returns true if this is a if statement
|
||||
bool IsIf() const override { return true; }
|
||||
bool IsIf() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -22,6 +22,10 @@ IntLiteral::IntLiteral(ast::type::Type* type, int32_t value)
|
|||
|
||||
IntLiteral::~IntLiteral() = default;
|
||||
|
||||
bool IntLiteral::IsInt() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string IntLiteral::to_str() const {
|
||||
return std::to_string(value_);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class IntLiteral : public Literal {
|
|||
~IntLiteral() override;
|
||||
|
||||
/// @returns true if this is a int literal
|
||||
bool IsInt() const override { return true; }
|
||||
bool IsInt() const override;
|
||||
|
||||
/// @returns the int literal value
|
||||
int32_t value() const { return value_; }
|
||||
|
|
|
@ -23,6 +23,10 @@ KillStatement::KillStatement(const Source& source) : Statement(source) {}
|
|||
|
||||
KillStatement::~KillStatement() = default;
|
||||
|
||||
bool KillStatement::IsKill() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KillStatement::IsValid() const {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class KillStatement : public Statement {
|
|||
~KillStatement() override;
|
||||
|
||||
/// @returns true if this is a kill statement
|
||||
bool IsKill() const override { return true; }
|
||||
bool IsKill() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -28,6 +28,22 @@ Literal::Literal(ast::type::Type* type) : type_(type) {}
|
|||
|
||||
Literal::~Literal() = default;
|
||||
|
||||
bool Literal::IsBool() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Literal::IsFloat() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Literal::IsInt() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Literal::IsUint() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
BoolLiteral* Literal::AsBool() {
|
||||
assert(IsBool());
|
||||
return static_cast<BoolLiteral*>(this);
|
||||
|
|
|
@ -33,13 +33,13 @@ class Literal {
|
|||
virtual ~Literal();
|
||||
|
||||
/// @returns true if this is a bool literal
|
||||
virtual bool IsBool() const { return false; }
|
||||
virtual bool IsBool() const;
|
||||
/// @returns true if this is a float literal
|
||||
virtual bool IsFloat() const { return false; }
|
||||
virtual bool IsFloat() const;
|
||||
/// @returns true if this is a signed int literal
|
||||
virtual bool IsInt() const { return false; }
|
||||
virtual bool IsInt() const;
|
||||
/// @returns true if this is a unsigned int literal
|
||||
virtual bool IsUint() const { return false; }
|
||||
virtual bool IsUint() const;
|
||||
|
||||
/// @returns the literal as a boolean literal
|
||||
BoolLiteral* AsBool();
|
||||
|
|
|
@ -21,6 +21,10 @@ LocationDecoration::LocationDecoration(uint32_t val) : value_(val) {}
|
|||
|
||||
LocationDecoration::~LocationDecoration() = default;
|
||||
|
||||
bool LocationDecoration::IsLocation() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void LocationDecoration::to_str(std::ostream& out) const {
|
||||
out << "LocationDecoration{" << value_ << "}" << std::endl;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class LocationDecoration : public VariableDecoration {
|
|||
~LocationDecoration() override;
|
||||
|
||||
/// @returns true if this is a location decoration
|
||||
bool IsLocation() const override { return true; }
|
||||
bool IsLocation() const override;
|
||||
|
||||
/// @returns the location value
|
||||
uint32_t value() const { return value_; }
|
||||
|
|
|
@ -29,8 +29,14 @@ LoopStatement::LoopStatement(const Source& source,
|
|||
body_(std::move(body)),
|
||||
continuing_(std::move(continuing)) {}
|
||||
|
||||
LoopStatement::LoopStatement(LoopStatement&&) = default;
|
||||
|
||||
LoopStatement::~LoopStatement() = default;
|
||||
|
||||
bool LoopStatement::IsLoop() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoopStatement::IsValid() const {
|
||||
for (const auto& stmt : body_) {
|
||||
if (stmt == nullptr || !stmt->IsValid())
|
||||
|
|
|
@ -39,7 +39,7 @@ class LoopStatement : public Statement {
|
|||
StatementList body,
|
||||
StatementList continuing);
|
||||
/// Move constructor
|
||||
LoopStatement(LoopStatement&&) = default;
|
||||
LoopStatement(LoopStatement&&);
|
||||
~LoopStatement() override;
|
||||
|
||||
/// Sets the body statements
|
||||
|
@ -59,7 +59,7 @@ class LoopStatement : public Statement {
|
|||
bool has_continuing() const { return !continuing_.empty(); }
|
||||
|
||||
/// @returns true if this is a loop statement
|
||||
bool IsLoop() const override { return true; }
|
||||
bool IsLoop() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -32,8 +32,15 @@ MemberAccessorExpression::MemberAccessorExpression(
|
|||
struct_(std::move(structure)),
|
||||
member_(std::move(member)) {}
|
||||
|
||||
MemberAccessorExpression::MemberAccessorExpression(MemberAccessorExpression&&) =
|
||||
default;
|
||||
|
||||
MemberAccessorExpression::~MemberAccessorExpression() = default;
|
||||
|
||||
bool MemberAccessorExpression::IsMemberAccessor() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MemberAccessorExpression::IsValid() const {
|
||||
if (struct_ == nullptr || !struct_->IsValid()) {
|
||||
return false;
|
||||
|
|
|
@ -44,7 +44,7 @@ class MemberAccessorExpression : public Expression {
|
|||
std::unique_ptr<Expression> structure,
|
||||
std::unique_ptr<IdentifierExpression> member);
|
||||
/// Move constructor
|
||||
MemberAccessorExpression(MemberAccessorExpression&&) = default;
|
||||
MemberAccessorExpression(MemberAccessorExpression&&);
|
||||
~MemberAccessorExpression() override;
|
||||
|
||||
/// Sets the structure
|
||||
|
@ -64,7 +64,7 @@ class MemberAccessorExpression : public Expression {
|
|||
IdentifierExpression* member() const { return member_.get(); }
|
||||
|
||||
/// @returns true if this is a member accessor expression
|
||||
bool IsMemberAccessor() const override { return true; }
|
||||
bool IsMemberAccessor() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Module::Module() = default;
|
||||
|
||||
Module::Module(Module&&) = default;
|
||||
|
||||
Module::~Module() = default;
|
||||
|
||||
const Import* Module::FindImportByName(const std::string& name) {
|
||||
for (const auto& import : imports_) {
|
||||
if (import->name() == name)
|
||||
|
@ -43,7 +49,7 @@ bool Module::IsValid() const {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
for (const auto& alias : alias_types_) {
|
||||
for (auto* const alias : alias_types_) {
|
||||
if (alias == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
@ -70,7 +76,7 @@ std::string Module::to_str() const {
|
|||
for (const auto& ep : entry_points_) {
|
||||
ep->to_str(out, indent);
|
||||
}
|
||||
for (const auto& alias : alias_types_) {
|
||||
for (auto* const alias : alias_types_) {
|
||||
out << alias->name() << " -> " << alias->type()->type_name() << std::endl;
|
||||
}
|
||||
for (const auto& func : functions_) {
|
||||
|
|
|
@ -32,10 +32,10 @@ namespace ast {
|
|||
/// Represents all the source in a given program.
|
||||
class Module {
|
||||
public:
|
||||
Module() = default;
|
||||
Module();
|
||||
/// Move constructor
|
||||
Module(Module&&) = default;
|
||||
~Module() = default;
|
||||
Module(Module&&);
|
||||
~Module();
|
||||
|
||||
/// Add the given import to the module
|
||||
/// @param import The import to add.
|
||||
|
|
|
@ -23,6 +23,10 @@ NopStatement::NopStatement(const Source& source) : Statement(source) {}
|
|||
|
||||
NopStatement::~NopStatement() = default;
|
||||
|
||||
bool NopStatement::IsNop() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NopStatement::IsValid() const {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class NopStatement : public Statement {
|
|||
~NopStatement() override;
|
||||
|
||||
/// @returns true if this is a nop statement
|
||||
bool IsNop() const override { return true; }
|
||||
bool IsNop() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -30,8 +30,13 @@ RegardlessStatement::RegardlessStatement(const Source& source,
|
|||
condition_(std::move(condition)),
|
||||
body_(std::move(body)) {}
|
||||
|
||||
RegardlessStatement::RegardlessStatement(RegardlessStatement&&) = default;
|
||||
RegardlessStatement::~RegardlessStatement() = default;
|
||||
|
||||
bool RegardlessStatement::IsRegardless() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RegardlessStatement::IsValid() const {
|
||||
if (condition_ == nullptr || !condition_->IsValid()) {
|
||||
return false;
|
||||
|
|
|
@ -42,7 +42,7 @@ class RegardlessStatement : public Statement {
|
|||
std::unique_ptr<Expression> condition,
|
||||
StatementList body);
|
||||
/// Move constructor
|
||||
RegardlessStatement(RegardlessStatement&&) = default;
|
||||
RegardlessStatement(RegardlessStatement&&);
|
||||
~RegardlessStatement() override;
|
||||
|
||||
/// Sets the condition expression
|
||||
|
@ -60,7 +60,7 @@ class RegardlessStatement : public Statement {
|
|||
const StatementList& body() const { return body_; }
|
||||
|
||||
/// @returns true if this is an regardless statement
|
||||
bool IsRegardless() const override { return true; }
|
||||
bool IsRegardless() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -28,8 +28,14 @@ ReturnStatement::ReturnStatement(const Source& source,
|
|||
std::unique_ptr<Expression> value)
|
||||
: Statement(source), value_(std::move(value)) {}
|
||||
|
||||
ReturnStatement::ReturnStatement(ReturnStatement&&) = default;
|
||||
|
||||
ReturnStatement::~ReturnStatement() = default;
|
||||
|
||||
bool ReturnStatement::IsReturn() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReturnStatement::IsValid() const {
|
||||
if (value_ != nullptr) {
|
||||
return value_->IsValid();
|
||||
|
|
|
@ -40,7 +40,7 @@ class ReturnStatement : public Statement {
|
|||
/// @param value the return value
|
||||
ReturnStatement(const Source& source, std::unique_ptr<Expression> value);
|
||||
/// Move constructor
|
||||
ReturnStatement(ReturnStatement&&) = default;
|
||||
ReturnStatement(ReturnStatement&&);
|
||||
~ReturnStatement() override;
|
||||
|
||||
/// Sets the value
|
||||
|
@ -54,7 +54,7 @@ class ReturnStatement : public Statement {
|
|||
bool has_value() const { return value_ != nullptr; }
|
||||
|
||||
/// @returns true if this is a return statement
|
||||
bool IsReturn() const override { return true; }
|
||||
bool IsReturn() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -29,8 +29,15 @@ ScalarConstructorExpression::ScalarConstructorExpression(
|
|||
std::unique_ptr<Literal> litearl)
|
||||
: ConstructorExpression(source), literal_(std::move(litearl)) {}
|
||||
|
||||
ScalarConstructorExpression::ScalarConstructorExpression(
|
||||
ScalarConstructorExpression&&) = default;
|
||||
|
||||
ScalarConstructorExpression::~ScalarConstructorExpression() = default;
|
||||
|
||||
bool ScalarConstructorExpression::IsScalarConstructor() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScalarConstructorExpression::IsValid() const {
|
||||
return literal_ != nullptr;
|
||||
}
|
||||
|
|
|
@ -38,11 +38,11 @@ class ScalarConstructorExpression : public ConstructorExpression {
|
|||
ScalarConstructorExpression(const Source& source,
|
||||
std::unique_ptr<Literal> literal);
|
||||
/// Move constructor
|
||||
ScalarConstructorExpression(ScalarConstructorExpression&&) = default;
|
||||
ScalarConstructorExpression(ScalarConstructorExpression&&);
|
||||
~ScalarConstructorExpression() override;
|
||||
|
||||
/// @returns true if this is a scalar constructor
|
||||
bool IsScalarConstructor() const override { return true; }
|
||||
bool IsScalarConstructor() const override;
|
||||
|
||||
/// Set the literal value
|
||||
/// @param literal the literal
|
||||
|
|
|
@ -21,6 +21,10 @@ SetDecoration::SetDecoration(uint32_t val) : value_(val) {}
|
|||
|
||||
SetDecoration::~SetDecoration() = default;
|
||||
|
||||
bool SetDecoration::IsSet() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetDecoration::to_str(std::ostream& out) const {
|
||||
out << "SetDecoration{" << value_ << "}" << std::endl;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class SetDecoration : public VariableDecoration {
|
|||
~SetDecoration() override;
|
||||
|
||||
/// @returns true if this is a set decoration
|
||||
bool IsSet() const override { return true; }
|
||||
bool IsSet() const override;
|
||||
|
||||
/// @returns the set value
|
||||
uint32_t value() const { return value_; }
|
||||
|
|
|
@ -39,8 +39,70 @@ Statement::Statement() = default;
|
|||
|
||||
Statement::Statement(const Source& source) : Node(source) {}
|
||||
|
||||
Statement::Statement(Statement&&) = default;
|
||||
|
||||
Statement::~Statement() = default;
|
||||
|
||||
bool Statement::IsAssign() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsBreak() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsCase() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsContinue() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsElse() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsFallthrough() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsIf() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsKill() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsLoop() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsNop() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsRegardless() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsReturn() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsSwitch() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsUnless() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statement::IsVariableDecl() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
AssignmentStatement* Statement::AsAssign() {
|
||||
assert(IsAssign());
|
||||
return static_cast<AssignmentStatement*>(this);
|
||||
|
|
|
@ -45,35 +45,35 @@ class Statement : public Node {
|
|||
~Statement() override;
|
||||
|
||||
/// @returns true if this is an assign statement
|
||||
virtual bool IsAssign() const { return false; }
|
||||
virtual bool IsAssign() const;
|
||||
/// @returns true if this is a break statement
|
||||
virtual bool IsBreak() const { return false; }
|
||||
virtual bool IsBreak() const;
|
||||
/// @returns true if this is a case statement
|
||||
virtual bool IsCase() const { return false; }
|
||||
virtual bool IsCase() const;
|
||||
/// @returns true if this is a continue statement
|
||||
virtual bool IsContinue() const { return false; }
|
||||
virtual bool IsContinue() const;
|
||||
/// @returns true if this is an else statement
|
||||
virtual bool IsElse() const { return false; }
|
||||
virtual bool IsElse() const;
|
||||
/// @returns true if this is a fallthrough statement
|
||||
virtual bool IsFallthrough() const { return false; }
|
||||
virtual bool IsFallthrough() const;
|
||||
/// @returns true if this is an if statement
|
||||
virtual bool IsIf() const { return false; }
|
||||
virtual bool IsIf() const;
|
||||
/// @returns true if this is a kill statement
|
||||
virtual bool IsKill() const { return false; }
|
||||
virtual bool IsKill() const;
|
||||
/// @returns true if this is a loop statement
|
||||
virtual bool IsLoop() const { return false; }
|
||||
virtual bool IsLoop() const;
|
||||
/// @returns true if this is a nop statement
|
||||
virtual bool IsNop() const { return false; }
|
||||
virtual bool IsNop() const;
|
||||
/// @returns true if this is an regardless statement
|
||||
virtual bool IsRegardless() const { return false; }
|
||||
virtual bool IsRegardless() const;
|
||||
/// @returns true if this is a return statement
|
||||
virtual bool IsReturn() const { return false; }
|
||||
virtual bool IsReturn() const;
|
||||
/// @returns true if this is a switch statement
|
||||
virtual bool IsSwitch() const { return false; }
|
||||
virtual bool IsSwitch() const;
|
||||
/// @returns true if this is an unless statement
|
||||
virtual bool IsUnless() const { return false; }
|
||||
virtual bool IsUnless() const;
|
||||
/// @returns true if this is an variable statement
|
||||
virtual bool IsVariableDecl() const { return false; }
|
||||
virtual bool IsVariableDecl() const;
|
||||
|
||||
/// @returns the statement as an assign statement
|
||||
AssignmentStatement* AsAssign();
|
||||
|
@ -113,7 +113,7 @@ class Statement : public Node {
|
|||
/// @param source the source of the expression
|
||||
explicit Statement(const Source& source);
|
||||
/// Move constructor
|
||||
Statement(Statement&&) = default;
|
||||
Statement(Statement&&);
|
||||
|
||||
private:
|
||||
Statement(const Statement&) = delete;
|
||||
|
|
|
@ -27,6 +27,8 @@ Struct::Struct(const Source& source,
|
|||
StructMemberList members)
|
||||
: Node(source), decoration_(decoration), members_(std::move(members)) {}
|
||||
|
||||
Struct::Struct(Struct&&) = default;
|
||||
|
||||
Struct::~Struct() = default;
|
||||
|
||||
bool Struct::IsValid() const {
|
||||
|
|
|
@ -43,7 +43,7 @@ class Struct : public Node {
|
|||
StructDecoration decoration,
|
||||
StructMemberList members);
|
||||
/// Move constructor
|
||||
Struct(Struct&&) = default;
|
||||
Struct(Struct&&);
|
||||
|
||||
~Struct() override;
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
StructMember::StructMember() = default;
|
||||
|
||||
StructMember::StructMember(const std::string& name,
|
||||
type::Type* type,
|
||||
StructMemberDecorationList decorations)
|
||||
|
@ -31,6 +33,8 @@ StructMember::StructMember(const Source& source,
|
|||
type_(type),
|
||||
decorations_(std::move(decorations)) {}
|
||||
|
||||
StructMember::StructMember(StructMember&&) = default;
|
||||
|
||||
StructMember::~StructMember() = default;
|
||||
|
||||
bool StructMember::IsValid() const {
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace ast {
|
|||
class StructMember : public Node {
|
||||
public:
|
||||
/// Create a new empty struct member statement
|
||||
StructMember() = default;
|
||||
StructMember();
|
||||
/// Create a new struct member statement
|
||||
/// @param name The struct member name
|
||||
/// @param type The struct member type
|
||||
|
@ -50,7 +50,7 @@ class StructMember : public Node {
|
|||
type::Type* type,
|
||||
StructMemberDecorationList decorations);
|
||||
/// Move constructor
|
||||
StructMember(StructMember&&) = default;
|
||||
StructMember(StructMember&&);
|
||||
|
||||
~StructMember() override;
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ StructMemberDecoration::StructMemberDecoration() = default;
|
|||
|
||||
StructMemberDecoration::~StructMemberDecoration() = default;
|
||||
|
||||
bool StructMemberDecoration::IsOffset() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
StructMemberOffsetDecoration* StructMemberDecoration::AsOffset() {
|
||||
assert(IsOffset());
|
||||
return static_cast<StructMemberOffsetDecoration*>(this);
|
||||
|
|
|
@ -30,7 +30,7 @@ class StructMemberDecoration {
|
|||
virtual ~StructMemberDecoration();
|
||||
|
||||
/// @returns true if this is an offset decoration
|
||||
virtual bool IsOffset() const { return false; }
|
||||
virtual bool IsOffset() const;
|
||||
|
||||
/// @returns the decoration as an offset decoration
|
||||
StructMemberOffsetDecoration* AsOffset();
|
||||
|
|
|
@ -20,6 +20,10 @@ namespace ast {
|
|||
StructMemberOffsetDecoration::StructMemberOffsetDecoration(uint32_t offset)
|
||||
: offset_(offset) {}
|
||||
|
||||
bool StructMemberOffsetDecoration::IsOffset() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
StructMemberOffsetDecoration::~StructMemberOffsetDecoration() = default;
|
||||
|
||||
std::string StructMemberOffsetDecoration::to_str() const {
|
||||
|
|
|
@ -33,7 +33,7 @@ class StructMemberOffsetDecoration : public StructMemberDecoration {
|
|||
~StructMemberOffsetDecoration() override;
|
||||
|
||||
/// @returns true if this is an offset decoration
|
||||
bool IsOffset() const override { return true; }
|
||||
bool IsOffset() const override;
|
||||
|
||||
/// @returns the offset value
|
||||
uint32_t offset() const { return offset_; }
|
||||
|
|
|
@ -32,6 +32,12 @@ SwitchStatement::SwitchStatement(const Source& source,
|
|||
condition_(std::move(condition)),
|
||||
body_(std::move(body)) {}
|
||||
|
||||
bool SwitchStatement::IsSwitch() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
SwitchStatement::SwitchStatement(SwitchStatement&&) = default;
|
||||
|
||||
SwitchStatement::~SwitchStatement() = default;
|
||||
|
||||
bool SwitchStatement::IsValid() const {
|
||||
|
|
|
@ -45,7 +45,7 @@ class SwitchStatement : public Statement {
|
|||
std::unique_ptr<Expression> condition,
|
||||
CaseStatementList body);
|
||||
/// Move constructor
|
||||
SwitchStatement(SwitchStatement&&) = default;
|
||||
SwitchStatement(SwitchStatement&&);
|
||||
~SwitchStatement() override;
|
||||
|
||||
/// Sets the condition for the switch statement
|
||||
|
@ -65,7 +65,7 @@ class SwitchStatement : public Statement {
|
|||
const CaseStatementList& body() const { return body_; }
|
||||
|
||||
/// @returns true if this is a switch statement
|
||||
bool IsSwitch() const override { return true; }
|
||||
bool IsSwitch() const override;
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
|
|
@ -27,6 +27,14 @@ AliasType::AliasType(const std::string& name, Type* subtype)
|
|||
|
||||
AliasType::~AliasType() = default;
|
||||
|
||||
bool AliasType::IsAlias() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AliasType::type_name() const {
|
||||
return "__alias_" + name_ + subtype_->type_name();
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -35,7 +35,7 @@ class AliasType : public Type {
|
|||
~AliasType() override;
|
||||
|
||||
/// @returns true if the type is an alias type
|
||||
bool IsAlias() const override { return true; }
|
||||
bool IsAlias() const override;
|
||||
|
||||
/// @returns the alias name
|
||||
const std::string& name() const { return name_; }
|
||||
|
@ -43,9 +43,7 @@ class AliasType : public Type {
|
|||
Type* type() const { return subtype_; }
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override {
|
||||
return "__alias_" + name_ + subtype_->type_name();
|
||||
}
|
||||
std::string type_name() const override;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
|
|
|
@ -23,8 +23,24 @@ ArrayType::ArrayType(Type* subtype) : subtype_(subtype) {}
|
|||
ArrayType::ArrayType(Type* subtype, uint32_t size)
|
||||
: subtype_(subtype), size_(size) {}
|
||||
|
||||
ArrayType::ArrayType(ArrayType&&) = default;
|
||||
|
||||
ArrayType::~ArrayType() = default;
|
||||
|
||||
bool ArrayType::IsArray() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ArrayType::type_name() const {
|
||||
assert(subtype_);
|
||||
|
||||
std::string type_name = "__array" + subtype_->type_name();
|
||||
if (!IsRuntimeArray())
|
||||
type_name += "_" + std::to_string(size_);
|
||||
|
||||
return type_name;
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -36,11 +36,11 @@ class ArrayType : public Type {
|
|||
/// @param size the number of elements in the array
|
||||
ArrayType(Type* subtype, uint32_t size);
|
||||
/// Move constructor
|
||||
ArrayType(ArrayType&&) = default;
|
||||
ArrayType(ArrayType&&);
|
||||
~ArrayType() override;
|
||||
|
||||
/// @returns true if the type is an array type
|
||||
bool IsArray() const override { return true; }
|
||||
bool IsArray() const override;
|
||||
/// @returns true if this is a runtime array.
|
||||
/// i.e. the size is determined at runtime
|
||||
bool IsRuntimeArray() const { return size_ == 0; }
|
||||
|
@ -51,15 +51,7 @@ class ArrayType : public Type {
|
|||
uint32_t size() const { return size_; }
|
||||
|
||||
/// @returns the name for the type
|
||||
std::string type_name() const override {
|
||||
assert(subtype_);
|
||||
|
||||
std::string type_name = "__array" + subtype_->type_name();
|
||||
if (!IsRuntimeArray())
|
||||
type_name += "_" + std::to_string(size_);
|
||||
|
||||
return type_name;
|
||||
}
|
||||
std::string type_name() const override;
|
||||
|
||||
private:
|
||||
Type* subtype_ = nullptr;
|
||||
|
|
|
@ -22,6 +22,14 @@ BoolType::BoolType() = default;
|
|||
|
||||
BoolType::~BoolType() = default;
|
||||
|
||||
bool BoolType::IsBool() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string BoolType::type_name() const {
|
||||
return "__bool";
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -33,10 +33,10 @@ class BoolType : public Type {
|
|||
~BoolType() override;
|
||||
|
||||
/// @returns true if the type is a bool type
|
||||
bool IsBool() const override { return true; }
|
||||
bool IsBool() const override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override { return "__bool"; }
|
||||
std::string type_name() const override;
|
||||
};
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -22,6 +22,14 @@ F32Type::F32Type() = default;
|
|||
|
||||
F32Type::~F32Type() = default;
|
||||
|
||||
bool F32Type::IsF32() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string F32Type::type_name() const {
|
||||
return "__f32";
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -33,10 +33,10 @@ class F32Type : public Type {
|
|||
~F32Type() override;
|
||||
|
||||
/// @returns true if the type is an f32 type
|
||||
bool IsF32() const override { return true; }
|
||||
bool IsF32() const override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override { return "__f32"; }
|
||||
std::string type_name() const override;
|
||||
};
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -22,6 +22,14 @@ I32Type::I32Type() = default;
|
|||
|
||||
I32Type::~I32Type() = default;
|
||||
|
||||
bool I32Type::IsI32() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string I32Type::type_name() const {
|
||||
return "__i32";
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -33,10 +33,10 @@ class I32Type : public Type {
|
|||
~I32Type() override;
|
||||
|
||||
/// @returns true if the type is an i32 type
|
||||
bool IsI32() const override { return true; }
|
||||
bool IsI32() const override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override { return "__i32"; }
|
||||
std::string type_name() const override;
|
||||
};
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -28,6 +28,15 @@ MatrixType::MatrixType(Type* subtype, uint32_t rows, uint32_t columns)
|
|||
assert(columns < 5);
|
||||
}
|
||||
|
||||
bool MatrixType::IsMatrix() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string MatrixType::type_name() const {
|
||||
return "__mat_" + std::to_string(rows_) + "_" + std::to_string(columns_) +
|
||||
subtype_->type_name();
|
||||
}
|
||||
|
||||
MatrixType::~MatrixType() = default;
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -36,7 +36,7 @@ class MatrixType : public Type {
|
|||
~MatrixType() override;
|
||||
|
||||
/// @returns true if the type is a matrix type
|
||||
bool IsMatrix() const override { return true; }
|
||||
bool IsMatrix() const override;
|
||||
|
||||
/// @returns the type of the matrix
|
||||
Type* type() const { return subtype_; }
|
||||
|
@ -46,10 +46,7 @@ class MatrixType : public Type {
|
|||
uint32_t columns() const { return columns_; }
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override {
|
||||
return "__mat_" + std::to_string(rows_) + "_" + std::to_string(columns_) +
|
||||
subtype_->type_name();
|
||||
}
|
||||
std::string type_name() const override;
|
||||
|
||||
private:
|
||||
Type* subtype_ = nullptr;
|
||||
|
|
|
@ -21,6 +21,16 @@ namespace type {
|
|||
PointerType::PointerType(Type* subtype, StorageClass storage_class)
|
||||
: subtype_(subtype), storage_class_(storage_class) {}
|
||||
|
||||
bool PointerType::IsPointer() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string PointerType::type_name() const {
|
||||
std::ostringstream out;
|
||||
out << "__ptr_" << storage_class_ << subtype_->type_name();
|
||||
return out.str();
|
||||
}
|
||||
|
||||
PointerType::~PointerType() = default;
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -37,7 +37,7 @@ class PointerType : public Type {
|
|||
~PointerType() override;
|
||||
|
||||
/// @returns true if the type is a pointer type
|
||||
bool IsPointer() const override { return true; }
|
||||
bool IsPointer() const override;
|
||||
|
||||
/// @returns the pointee type
|
||||
Type* type() const { return subtype_; }
|
||||
|
@ -45,11 +45,7 @@ class PointerType : public Type {
|
|||
StorageClass storage_class() const { return storage_class_; }
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override {
|
||||
std::ostringstream out;
|
||||
out << "__ptr_" << storage_class_ << subtype_->type_name();
|
||||
return out.str();
|
||||
}
|
||||
std::string type_name() const override;
|
||||
|
||||
private:
|
||||
Type* subtype_;
|
||||
|
|
|
@ -23,6 +23,16 @@ namespace type {
|
|||
StructType::StructType(std::unique_ptr<Struct> impl)
|
||||
: struct_(std::move(impl)) {}
|
||||
|
||||
StructType::StructType(StructType&&) = default;
|
||||
|
||||
bool StructType::IsStruct() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string StructType::type_name() const {
|
||||
return "__struct_" + name_;
|
||||
}
|
||||
|
||||
StructType::~StructType() = default;
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -32,7 +32,7 @@ class StructType : public Type {
|
|||
/// @param impl the struct data
|
||||
explicit StructType(std::unique_ptr<Struct> impl);
|
||||
/// Move constructor
|
||||
StructType(StructType&&) = default;
|
||||
StructType(StructType&&);
|
||||
~StructType() override;
|
||||
|
||||
/// Sets the name of the struct
|
||||
|
@ -42,13 +42,13 @@ class StructType : public Type {
|
|||
const std::string& name() const { return name_; }
|
||||
|
||||
/// @returns true if the type is a struct type
|
||||
bool IsStruct() const override { return true; }
|
||||
bool IsStruct() const override;
|
||||
|
||||
/// @returns the struct name
|
||||
Struct* impl() const { return struct_.get(); }
|
||||
|
||||
/// @returns the name for th type
|
||||
std::string type_name() const override { return "__struct_" + name_; }
|
||||
std::string type_name() const override;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
|
|
|
@ -36,6 +36,50 @@ Type::Type() = default;
|
|||
|
||||
Type::~Type() = default;
|
||||
|
||||
bool Type::IsAlias() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsArray() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsBool() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsF32() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsI32() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsMatrix() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsPointer() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsStruct() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsU32() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsVector() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsVoid() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
AliasType* Type::AsAlias() {
|
||||
assert(IsAlias());
|
||||
return static_cast<AliasType*>(this);
|
||||
|
|
|
@ -41,27 +41,27 @@ class Type {
|
|||
virtual ~Type();
|
||||
|
||||
/// @returns true if the type is an alias type
|
||||
virtual bool IsAlias() const { return false; }
|
||||
virtual bool IsAlias() const;
|
||||
/// @returns true if the type is an array type
|
||||
virtual bool IsArray() const { return false; }
|
||||
virtual bool IsArray() const;
|
||||
/// @returns true if the type is a bool type
|
||||
virtual bool IsBool() const { return false; }
|
||||
virtual bool IsBool() const;
|
||||
/// @returns true if the type is an f32 type
|
||||
virtual bool IsF32() const { return false; }
|
||||
virtual bool IsF32() const;
|
||||
/// @returns true if the type is an i32 type
|
||||
virtual bool IsI32() const { return false; }
|
||||
virtual bool IsI32() const;
|
||||
/// @returns true if the type is a matrix type
|
||||
virtual bool IsMatrix() const { return false; }
|
||||
virtual bool IsMatrix() const;
|
||||
/// @returns true if the type is a ptr type
|
||||
virtual bool IsPointer() const { return false; }
|
||||
virtual bool IsPointer() const;
|
||||
/// @returns true if the type is a struct type
|
||||
virtual bool IsStruct() const { return false; }
|
||||
virtual bool IsStruct() const;
|
||||
/// @returns true if the type is a u32 type
|
||||
virtual bool IsU32() const { return false; }
|
||||
virtual bool IsU32() const;
|
||||
/// @returns true if the type is a vec type
|
||||
virtual bool IsVector() const { return false; }
|
||||
virtual bool IsVector() const;
|
||||
/// @returns true if the type is a void type
|
||||
virtual bool IsVoid() const { return false; }
|
||||
virtual bool IsVoid() const;
|
||||
|
||||
/// @returns the name for this type. The |type_name| is unique over all types.
|
||||
virtual std::string type_name() const = 0;
|
||||
|
|
|
@ -22,6 +22,16 @@ U32Type::U32Type() = default;
|
|||
|
||||
U32Type::~U32Type() = default;
|
||||
|
||||
U32Type::U32Type(U32Type&&) = default;
|
||||
|
||||
bool U32Type::IsU32() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string U32Type::type_name() const {
|
||||
return "__u32";
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -29,14 +29,14 @@ class U32Type : public Type {
|
|||
/// Constructor
|
||||
U32Type();
|
||||
/// Move constructor
|
||||
U32Type(U32Type&&) = default;
|
||||
U32Type(U32Type&&);
|
||||
~U32Type() override;
|
||||
|
||||
/// @returns true if the type is a u32 type
|
||||
bool IsU32() const override { return true; }
|
||||
bool IsU32() const override;
|
||||
|
||||
/// @returns the name for th type
|
||||
std::string type_name() const override { return "__u32"; }
|
||||
std::string type_name() const override;
|
||||
};
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -26,8 +26,18 @@ VectorType::VectorType(Type* subtype, uint32_t size)
|
|||
assert(size_ < 5);
|
||||
}
|
||||
|
||||
VectorType::VectorType(VectorType&&) = default;
|
||||
|
||||
VectorType::~VectorType() = default;
|
||||
|
||||
bool VectorType::IsVector() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string VectorType::type_name() const {
|
||||
return "__vec_" + std::to_string(size_) + subtype_->type_name();
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue