resolver: Refactor Statement handling

Break up Resolver::Statement() into multiple resolver functions.
Move simple statement validation out to resolver_validation.cc

Change-Id: Ifa29433af0a9afa39a66ac3e4f7ca376351adfbf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71102
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton
2021-11-26 16:26:42 +00:00
committed by Tint LUCI CQ
parent c5835eb4a0
commit 8c30d752a0
7 changed files with 358 additions and 214 deletions

View File

@@ -21,6 +21,9 @@ namespace tint {
namespace ast {
class ForLoopStatement;
} // namespace ast
namespace sem {
class Expression;
} // namespace sem
} // namespace tint
namespace tint {
@@ -39,6 +42,16 @@ class ForLoopStatement : public Castable<ForLoopStatement, CompoundStatement> {
/// Destructor
~ForLoopStatement() override;
/// @returns the for-loop condition expression
const Expression* Condition() const { return condition_; }
/// Sets the for-loop condition expression
/// @param condition the for-loop condition expression
void SetCondition(const Expression* condition) { condition_ = condition; }
private:
const Expression* condition_ = nullptr;
};
} // namespace sem

View File

@@ -23,6 +23,9 @@ namespace ast {
class IfStatement;
class ElseStatement;
} // namespace ast
namespace sem {
class Expression;
} // namespace sem
} // namespace tint
namespace tint {
@@ -41,6 +44,16 @@ class IfStatement : public Castable<IfStatement, CompoundStatement> {
/// Destructor
~IfStatement() override;
/// @returns the if-statement condition expression
const Expression* Condition() const { return condition_; }
/// Sets the if-statement condition expression
/// @param condition the if condition expression
void SetCondition(const Expression* condition) { condition_ = condition; }
private:
const Expression* condition_ = nullptr;
};
/// Holds semantic information about an else statement
@@ -56,6 +69,16 @@ class ElseStatement : public Castable<ElseStatement, CompoundStatement> {
/// Destructor
~ElseStatement() override;
/// @returns the else-statement condition expression
const Expression* Condition() const { return condition_; }
/// Sets the else-statement condition expression
/// @param condition the else condition expression
void SetCondition(const Expression* condition) { condition_ = condition; }
private:
const Expression* condition_ = nullptr;
};
} // namespace sem

View File

@@ -82,7 +82,7 @@ class Swizzle : public Castable<Swizzle, MemberAccessorExpression> {
/// Constructor
/// @param declaration the AST node
/// @param type the resolved type of the expression
/// @param statement the statement that
/// @param statement the statement that owns this expression
/// @param indices the swizzle indices
Swizzle(const ast::MemberAccessorExpression* declaration,
const sem::Type* type,

View File

@@ -234,7 +234,7 @@ class VariableUser : public Castable<VariableUser, Expression> {
const sem::Variable* Variable() const { return variable_; }
private:
sem::Variable const* const variable_;
const sem::Variable* const variable_;
};
} // namespace sem