ProgramBuilder: Add a WrapInStatement() overload for literals
Lets you pass AST literals to WrapInStatement() / WrapInFunction() Change-Id: I69d8918a61f0ea25193b64df38ed6cd606c7f044 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48047 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
49668bbe17
commit
169512e499
|
@ -131,8 +131,8 @@ ast::ConstructorExpression* ProgramBuilder::ConstructValueFilledWith(
|
||||||
|
|
||||||
ProgramBuilder::TypesBuilder::TypesBuilder(ProgramBuilder* pb) : builder(pb) {}
|
ProgramBuilder::TypesBuilder::TypesBuilder(ProgramBuilder* pb) : builder(pb) {}
|
||||||
|
|
||||||
ast::VariableDeclStatement* ProgramBuilder::WrapInStatement(ast::Variable* v) {
|
ast::Statement* ProgramBuilder::WrapInStatement(ast::Literal* lit) {
|
||||||
return create<ast::VariableDeclStatement>(v);
|
return WrapInStatement(create<ast::ScalarConstructorExpression>(lit));
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Statement* ProgramBuilder::WrapInStatement(ast::Expression* expr) {
|
ast::Statement* ProgramBuilder::WrapInStatement(ast::Expression* expr) {
|
||||||
|
@ -140,6 +140,10 @@ ast::Statement* ProgramBuilder::WrapInStatement(ast::Expression* expr) {
|
||||||
return Decl(Var(symbols_.New(), nullptr, ast::StorageClass::kFunction, expr));
|
return Decl(Var(symbols_.New(), nullptr, ast::StorageClass::kFunction, expr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ast::VariableDeclStatement* ProgramBuilder::WrapInStatement(ast::Variable* v) {
|
||||||
|
return create<ast::VariableDeclStatement>(v);
|
||||||
|
}
|
||||||
|
|
||||||
ast::Statement* ProgramBuilder::WrapInStatement(ast::Statement* stmt) {
|
ast::Statement* ProgramBuilder::WrapInStatement(ast::Statement* stmt) {
|
||||||
return stmt;
|
return stmt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1405,6 +1405,12 @@ class ProgramBuilder {
|
||||||
/// expression has no resolved type.
|
/// expression has no resolved type.
|
||||||
type::Type* TypeOf(ast::Expression* expr) const;
|
type::Type* TypeOf(ast::Expression* expr) const;
|
||||||
|
|
||||||
|
/// Wraps the ast::Literal in a statement. This is used by tests that
|
||||||
|
/// construct a partial AST and require the Resolver to reach these
|
||||||
|
/// nodes.
|
||||||
|
/// @param lit the ast::Literal to be wrapped by an ast::Statement
|
||||||
|
/// @return the ast::Statement that wraps the ast::Statement
|
||||||
|
ast::Statement* WrapInStatement(ast::Literal* lit);
|
||||||
/// Wraps the ast::Expression in a statement. This is used by tests that
|
/// Wraps the ast::Expression in a statement. This is used by tests that
|
||||||
/// construct a partial AST and require the Resolver to reach these
|
/// construct a partial AST and require the Resolver to reach these
|
||||||
/// nodes.
|
/// nodes.
|
||||||
|
|
Loading…
Reference in New Issue