mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 05:57:51 +00:00
Add list helpers
This CL adds various using statements for the std::vector<std::unique_ptr<CLASS>> constructs found in the AST. Change-Id: Ic9a2357cd73b2aafd99e961a38727f2f9874cde5 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18920 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
dan sinclair
parent
a71e1a50c8
commit
3ffec80c63
@@ -51,7 +51,7 @@ TEST_F(BuilderTest, Constructor_Type) {
|
||||
ast::type::F32Type f32;
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
@@ -77,7 +77,7 @@ TEST_F(BuilderTest, Constructor_Type_Dedups) {
|
||||
ast::type::F32Type f32;
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
@@ -103,7 +103,7 @@ TEST_F(BuilderTest, Constructor_NonConst_Type_Fails) {
|
||||
std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::move(rel));
|
||||
|
||||
@@ -62,7 +62,7 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
|
||||
ast::type::F32Type f32;
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
@@ -109,7 +109,7 @@ TEST_F(BuilderTest, DISABLED_FunctionVar_WithNonConstantConstructor) {
|
||||
std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::move(rel));
|
||||
@@ -147,7 +147,7 @@ TEST_F(BuilderTest, FunctionVar_Const) {
|
||||
ast::type::F32Type f32;
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
|
||||
@@ -71,7 +71,7 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) {
|
||||
ast::type::F32Type f32;
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
@@ -105,7 +105,7 @@ TEST_F(BuilderTest, GlobalVar_Const) {
|
||||
ast::type::F32Type f32;
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
@@ -136,7 +136,7 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) {
|
||||
ast::type::F32Type f32;
|
||||
auto v =
|
||||
std::make_unique<ast::Variable>("var", ast::StorageClass::kOutput, &f32);
|
||||
std::vector<std::unique_ptr<ast::VariableDecoration>> decos;
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(std::make_unique<ast::LocationDecoration>(5));
|
||||
|
||||
ast::DecoratedVariable dv(std::move(v));
|
||||
@@ -157,7 +157,7 @@ TEST_F(BuilderTest, GlobalVar_WithBindingAndSet) {
|
||||
ast::type::F32Type f32;
|
||||
auto v =
|
||||
std::make_unique<ast::Variable>("var", ast::StorageClass::kOutput, &f32);
|
||||
std::vector<std::unique_ptr<ast::VariableDecoration>> decos;
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(std::make_unique<ast::BindingDecoration>(2));
|
||||
decos.push_back(std::make_unique<ast::SetDecoration>(3));
|
||||
|
||||
@@ -180,7 +180,7 @@ TEST_F(BuilderTest, GlobalVar_WithBuiltin) {
|
||||
ast::type::F32Type f32;
|
||||
auto v =
|
||||
std::make_unique<ast::Variable>("var", ast::StorageClass::kOutput, &f32);
|
||||
std::vector<std::unique_ptr<ast::VariableDecoration>> decos;
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(
|
||||
std::make_unique<ast::BuiltinDecoration>(ast::Builtin::kPosition));
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
|
||||
ast::type::F32Type f32;
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
@@ -87,7 +87,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
|
||||
ast::type::F32Type f32;
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST_F(BuilderTest, Return_WithValue) {
|
||||
ast::type::F32Type f32;
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> vals;
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
|
||||
|
||||
@@ -277,8 +277,8 @@ TEST_F(BuilderTest_Type, GenerateStruct_Empty) {
|
||||
TEST_F(BuilderTest_Type, GenerateStruct) {
|
||||
ast::type::F32Type f32;
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMemberDecoration>> decos;
|
||||
std::vector<std::unique_ptr<ast::StructMember>> members;
|
||||
ast::StructMemberDecorationList decos;
|
||||
ast::StructMemberList members;
|
||||
members.push_back(
|
||||
std::make_unique<ast::StructMember>("a", &f32, std::move(decos)));
|
||||
|
||||
@@ -303,8 +303,8 @@ OpMemberName %1 0 "a"
|
||||
TEST_F(BuilderTest_Type, GenerateStruct_Decorated) {
|
||||
ast::type::F32Type f32;
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMemberDecoration>> decos;
|
||||
std::vector<std::unique_ptr<ast::StructMember>> members;
|
||||
ast::StructMemberDecorationList decos;
|
||||
ast::StructMemberList members;
|
||||
members.push_back(
|
||||
std::make_unique<ast::StructMember>("a", &f32, std::move(decos)));
|
||||
|
||||
@@ -331,12 +331,12 @@ OpMemberName %1 0 "a"
|
||||
TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) {
|
||||
ast::type::F32Type f32;
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMemberDecoration>> a_decos;
|
||||
ast::StructMemberDecorationList a_decos;
|
||||
a_decos.push_back(std::make_unique<ast::StructMemberOffsetDecoration>(0));
|
||||
std::vector<std::unique_ptr<ast::StructMemberDecoration>> b_decos;
|
||||
ast::StructMemberDecorationList b_decos;
|
||||
b_decos.push_back(std::make_unique<ast::StructMemberOffsetDecoration>(8));
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMember>> members;
|
||||
ast::StructMemberList members;
|
||||
members.push_back(
|
||||
std::make_unique<ast::StructMember>("a", &f32, std::move(a_decos)));
|
||||
members.push_back(
|
||||
|
||||
@@ -690,8 +690,7 @@ bool GeneratorImpl::EmitUnaryOp(ast::UnaryOpExpression* expr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeneratorImpl::EmitStatementBlock(
|
||||
const std::vector<std::unique_ptr<ast::Statement>>& statements) {
|
||||
bool GeneratorImpl::EmitStatementBlock(const ast::StatementList& statements) {
|
||||
out_ << " {" << std::endl;
|
||||
|
||||
increment_indent();
|
||||
@@ -710,7 +709,7 @@ bool GeneratorImpl::EmitStatementBlock(
|
||||
}
|
||||
|
||||
bool GeneratorImpl::EmitStatementBlockAndNewline(
|
||||
const std::vector<std::unique_ptr<ast::Statement>>& statements) {
|
||||
const ast::StatementList& statements) {
|
||||
const bool result = EmitStatementBlock(statements);
|
||||
if (result) {
|
||||
out_ << std::endl;
|
||||
|
||||
@@ -15,10 +15,8 @@
|
||||
#ifndef SRC_WRITER_WGSL_GENERATOR_IMPL_H_
|
||||
#define SRC_WRITER_WGSL_GENERATOR_IMPL_H_
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "src/ast/array_accessor_expression.h"
|
||||
#include "src/ast/constructor_expression.h"
|
||||
@@ -179,13 +177,11 @@ class GeneratorImpl {
|
||||
/// Handles a brace-enclosed list of statements.
|
||||
/// @param statements the statements to output
|
||||
/// @returns true if the statements were emitted
|
||||
bool EmitStatementBlock(
|
||||
const std::vector<std::unique_ptr<ast::Statement>>& statements);
|
||||
bool EmitStatementBlock(const ast::StatementList& statements);
|
||||
/// Handles a brace-enclosed list of statements and trailing newline.
|
||||
/// @param statements the statements to output
|
||||
/// @returns true if the statements were emitted
|
||||
bool EmitStatementBlockAndNewline(
|
||||
const std::vector<std::unique_ptr<ast::Statement>>& statements);
|
||||
bool EmitStatementBlockAndNewline(const ast::StatementList& statements);
|
||||
/// Handles statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted
|
||||
|
||||
@@ -43,11 +43,11 @@ TEST_F(GeneratorImplTest, EmitAliasType_Struct) {
|
||||
ast::type::I32Type i32;
|
||||
ast::type::F32Type f32;
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMember>> members;
|
||||
ast::StructMemberList members;
|
||||
members.push_back(std::make_unique<ast::StructMember>(
|
||||
"a", &f32, std::vector<std::unique_ptr<ast::StructMemberDecoration>>{}));
|
||||
"a", &f32, ast::StructMemberDecorationList{}));
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMemberDecoration>> b_deco;
|
||||
ast::StructMemberDecorationList b_deco;
|
||||
b_deco.push_back(std::make_unique<ast::StructMemberOffsetDecoration>(4));
|
||||
members.push_back(
|
||||
std::make_unique<ast::StructMember>("b", &i32, std::move(b_deco)));
|
||||
|
||||
@@ -37,7 +37,7 @@ TEST_F(GeneratorImplTest, EmitExpression_Call_WithoutParams) {
|
||||
|
||||
TEST_F(GeneratorImplTest, EmitExpression_Call_WithParams) {
|
||||
auto id = std::make_unique<ast::IdentifierExpression>("my_func");
|
||||
std::vector<std::unique_ptr<ast::Expression>> params;
|
||||
ast::ExpressionList params;
|
||||
params.push_back(std::make_unique<ast::IdentifierExpression>("param1"));
|
||||
params.push_back(std::make_unique<ast::IdentifierExpression>("param2"));
|
||||
ast::CallExpression call(std::move(id), std::move(params));
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/break_statement.h"
|
||||
@@ -34,7 +33,7 @@ TEST_F(GeneratorImplTest, Emit_Case) {
|
||||
ast::type::I32Type i32;
|
||||
auto cond = std::make_unique<ast::IntLiteral>(&i32, 5);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::BreakStatement>());
|
||||
|
||||
ast::CaseStatement c(std::move(cond), std::move(body));
|
||||
@@ -52,7 +51,7 @@ TEST_F(GeneratorImplTest, Emit_Case) {
|
||||
TEST_F(GeneratorImplTest, Emit_Case_Default) {
|
||||
ast::CaseStatement c;
|
||||
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::BreakStatement>());
|
||||
|
||||
c.set_body(std::move(body));
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/bool_literal.h"
|
||||
#include "src/ast/float_literal.h"
|
||||
@@ -81,7 +78,7 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Float) {
|
||||
ast::type::F32Type f32;
|
||||
|
||||
auto lit = std::make_unique<ast::FloatLiteral>(&f32, -1.2e-5);
|
||||
std::vector<std::unique_ptr<ast::Expression>> values;
|
||||
ast::ExpressionList values;
|
||||
values.push_back(
|
||||
std::make_unique<ast::ScalarConstructorExpression>(std::move(lit)));
|
||||
|
||||
@@ -96,7 +93,7 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Bool) {
|
||||
ast::type::BoolType b;
|
||||
|
||||
auto lit = std::make_unique<ast::BoolLiteral>(&b, true);
|
||||
std::vector<std::unique_ptr<ast::Expression>> values;
|
||||
ast::ExpressionList values;
|
||||
values.push_back(
|
||||
std::make_unique<ast::ScalarConstructorExpression>(std::move(lit)));
|
||||
|
||||
@@ -111,7 +108,7 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Int) {
|
||||
ast::type::I32Type i32;
|
||||
|
||||
auto lit = std::make_unique<ast::IntLiteral>(&i32, -12345);
|
||||
std::vector<std::unique_ptr<ast::Expression>> values;
|
||||
ast::ExpressionList values;
|
||||
values.push_back(
|
||||
std::make_unique<ast::ScalarConstructorExpression>(std::move(lit)));
|
||||
|
||||
@@ -126,7 +123,7 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Uint) {
|
||||
ast::type::U32Type u32;
|
||||
|
||||
auto lit = std::make_unique<ast::UintLiteral>(&u32, 12345);
|
||||
std::vector<std::unique_ptr<ast::Expression>> values;
|
||||
ast::ExpressionList values;
|
||||
values.push_back(
|
||||
std::make_unique<ast::ScalarConstructorExpression>(std::move(lit)));
|
||||
|
||||
@@ -144,7 +141,7 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Vec) {
|
||||
auto lit1 = std::make_unique<ast::FloatLiteral>(&f32, 1.f);
|
||||
auto lit2 = std::make_unique<ast::FloatLiteral>(&f32, 2.f);
|
||||
auto lit3 = std::make_unique<ast::FloatLiteral>(&f32, 3.f);
|
||||
std::vector<std::unique_ptr<ast::Expression>> values;
|
||||
ast::ExpressionList values;
|
||||
values.push_back(
|
||||
std::make_unique<ast::ScalarConstructorExpression>(std::move(lit1)));
|
||||
values.push_back(
|
||||
@@ -165,13 +162,13 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Mat) {
|
||||
|
||||
ast::type::VectorType vec(&f32, 2);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> mat_values;
|
||||
ast::ExpressionList mat_values;
|
||||
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
auto lit1 = std::make_unique<ast::FloatLiteral>(&f32, 1.f + (i * 2));
|
||||
auto lit2 = std::make_unique<ast::FloatLiteral>(&f32, 2.f + (i * 2));
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> values;
|
||||
ast::ExpressionList values;
|
||||
values.push_back(
|
||||
std::make_unique<ast::ScalarConstructorExpression>(std::move(lit1)));
|
||||
values.push_back(
|
||||
@@ -196,14 +193,14 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Array) {
|
||||
ast::type::VectorType vec(&f32, 3);
|
||||
ast::type::ArrayType ary(&vec, 3);
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> ary_values;
|
||||
ast::ExpressionList ary_values;
|
||||
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
auto lit1 = std::make_unique<ast::FloatLiteral>(&f32, 1.f + (i * 3));
|
||||
auto lit2 = std::make_unique<ast::FloatLiteral>(&f32, 2.f + (i * 3));
|
||||
auto lit3 = std::make_unique<ast::FloatLiteral>(&f32, 3.f + (i * 3));
|
||||
|
||||
std::vector<std::unique_ptr<ast::Expression>> values;
|
||||
ast::ExpressionList values;
|
||||
values.push_back(
|
||||
std::make_unique<ast::ScalarConstructorExpression>(std::move(lit1)));
|
||||
values.push_back(
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/else_statement.h"
|
||||
@@ -29,7 +28,7 @@ namespace {
|
||||
using GeneratorImplTest = testing::Test;
|
||||
|
||||
TEST_F(GeneratorImplTest, Emit_Else) {
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
ast::ElseStatement e(std::move(body));
|
||||
@@ -46,7 +45,7 @@ TEST_F(GeneratorImplTest, Emit_Else) {
|
||||
TEST_F(GeneratorImplTest, Emit_ElseWithCondition) {
|
||||
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
|
||||
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
ast::ElseStatement e(std::move(cond), std::move(body));
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace {
|
||||
using GeneratorImplTest = testing::Test;
|
||||
|
||||
TEST_F(GeneratorImplTest, Emit_Function) {
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
body.push_back(std::make_unique<ast::ReturnStatement>());
|
||||
|
||||
@@ -50,13 +50,13 @@ TEST_F(GeneratorImplTest, Emit_Function) {
|
||||
}
|
||||
|
||||
TEST_F(GeneratorImplTest, Emit_Function_WithParams) {
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
body.push_back(std::make_unique<ast::ReturnStatement>());
|
||||
|
||||
ast::type::F32Type f32;
|
||||
ast::type::I32Type i32;
|
||||
std::vector<std::unique_ptr<ast::Variable>> params;
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
std::make_unique<ast::Variable>("a", ast::StorageClass::kNone, &f32));
|
||||
params.push_back(
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/else_statement.h"
|
||||
#include "src/ast/identifier_expression.h"
|
||||
@@ -31,7 +28,7 @@ using GeneratorImplTest = testing::Test;
|
||||
|
||||
TEST_F(GeneratorImplTest, Emit_If) {
|
||||
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
ast::IfStatement i(std::move(cond), std::move(body));
|
||||
@@ -49,15 +46,15 @@ TEST_F(GeneratorImplTest, Emit_If) {
|
||||
TEST_F(GeneratorImplTest, Emit_IfWithElseIf) {
|
||||
auto else_cond = std::make_unique<ast::IdentifierExpression>("else_cond");
|
||||
|
||||
std::vector<std::unique_ptr<ast::Statement>> else_body;
|
||||
ast::StatementList else_body;
|
||||
else_body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
std::vector<std::unique_ptr<ast::ElseStatement>> elses;
|
||||
ast::ElseStatementList elses;
|
||||
elses.push_back(std::make_unique<ast::ElseStatement>(std::move(else_cond),
|
||||
std::move(else_body)));
|
||||
|
||||
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
ast::IfStatement i(std::move(cond), std::move(body));
|
||||
@@ -76,14 +73,14 @@ TEST_F(GeneratorImplTest, Emit_IfWithElseIf) {
|
||||
}
|
||||
|
||||
TEST_F(GeneratorImplTest, Emit_IfWithElse) {
|
||||
std::vector<std::unique_ptr<ast::Statement>> else_body;
|
||||
ast::StatementList else_body;
|
||||
else_body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
std::vector<std::unique_ptr<ast::ElseStatement>> elses;
|
||||
ast::ElseStatementList elses;
|
||||
elses.push_back(std::make_unique<ast::ElseStatement>(std::move(else_body)));
|
||||
|
||||
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
ast::IfStatement i(std::move(cond), std::move(body));
|
||||
@@ -104,19 +101,19 @@ TEST_F(GeneratorImplTest, Emit_IfWithElse) {
|
||||
TEST_F(GeneratorImplTest, Emit_IfWithMultiple) {
|
||||
auto else_cond = std::make_unique<ast::IdentifierExpression>("else_cond");
|
||||
|
||||
std::vector<std::unique_ptr<ast::Statement>> else_body;
|
||||
ast::StatementList else_body;
|
||||
else_body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
std::vector<std::unique_ptr<ast::Statement>> else_body_2;
|
||||
ast::StatementList else_body_2;
|
||||
else_body_2.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
std::vector<std::unique_ptr<ast::ElseStatement>> elses;
|
||||
ast::ElseStatementList elses;
|
||||
elses.push_back(std::make_unique<ast::ElseStatement>(std::move(else_cond),
|
||||
std::move(else_body)));
|
||||
elses.push_back(std::make_unique<ast::ElseStatement>(std::move(else_body_2)));
|
||||
|
||||
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
ast::IfStatement i(std::move(cond), std::move(body));
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/kill_statement.h"
|
||||
@@ -29,7 +28,7 @@ namespace {
|
||||
using GeneratorImplTest = testing::Test;
|
||||
|
||||
TEST_F(GeneratorImplTest, Emit_Loop) {
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
ast::LoopStatement l(std::move(body), {});
|
||||
@@ -45,10 +44,10 @@ TEST_F(GeneratorImplTest, Emit_Loop) {
|
||||
}
|
||||
|
||||
TEST_F(GeneratorImplTest, Emit_LoopWithContinuing) {
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
std::vector<std::unique_ptr<ast::Statement>> continuing;
|
||||
ast::StatementList continuing;
|
||||
continuing.push_back(std::make_unique<ast::NopStatement>());
|
||||
|
||||
ast::LoopStatement l(std::move(body), std::move(continuing));
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/identifier_expression.h"
|
||||
@@ -32,7 +31,7 @@ using GeneratorImplTest = testing::Test;
|
||||
TEST_F(GeneratorImplTest, Emit_Regardless) {
|
||||
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
|
||||
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::NopStatement>());
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/break_statement.h"
|
||||
@@ -33,19 +32,19 @@ using GeneratorImplTest = testing::Test;
|
||||
|
||||
TEST_F(GeneratorImplTest, Emit_Switch) {
|
||||
auto def = std::make_unique<ast::CaseStatement>();
|
||||
std::vector<std::unique_ptr<ast::Statement>> def_body;
|
||||
ast::StatementList def_body;
|
||||
def_body.push_back(std::make_unique<ast::BreakStatement>());
|
||||
def->set_body(std::move(def_body));
|
||||
|
||||
ast::type::I32Type i32;
|
||||
auto case_val = std::make_unique<ast::IntLiteral>(&i32, 5);
|
||||
std::vector<std::unique_ptr<ast::Statement>> case_body;
|
||||
ast::StatementList case_body;
|
||||
case_body.push_back(std::make_unique<ast::BreakStatement>());
|
||||
|
||||
auto case_stmt = std::make_unique<ast::CaseStatement>(std::move(case_val),
|
||||
std::move(case_body));
|
||||
|
||||
std::vector<std::unique_ptr<ast::CaseStatement>> body;
|
||||
ast::CaseStatementList body;
|
||||
body.push_back(std::move(case_stmt));
|
||||
body.push_back(std::move(def));
|
||||
|
||||
|
||||
@@ -110,11 +110,11 @@ TEST_F(GeneratorImplTest, EmitType_Struct) {
|
||||
ast::type::I32Type i32;
|
||||
ast::type::F32Type f32;
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMember>> members;
|
||||
ast::StructMemberList members;
|
||||
members.push_back(std::make_unique<ast::StructMember>(
|
||||
"a", &i32, std::vector<std::unique_ptr<ast::StructMemberDecoration>>{}));
|
||||
"a", &i32, ast::StructMemberDecorationList{}));
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMemberDecoration>> b_deco;
|
||||
ast::StructMemberDecorationList b_deco;
|
||||
b_deco.push_back(std::make_unique<ast::StructMemberOffsetDecoration>(4));
|
||||
members.push_back(
|
||||
std::make_unique<ast::StructMember>("b", &f32, std::move(b_deco)));
|
||||
@@ -136,11 +136,11 @@ TEST_F(GeneratorImplTest, EmitType_Struct_WithDecoration) {
|
||||
ast::type::I32Type i32;
|
||||
ast::type::F32Type f32;
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMember>> members;
|
||||
ast::StructMemberList members;
|
||||
members.push_back(std::make_unique<ast::StructMember>(
|
||||
"a", &i32, std::vector<std::unique_ptr<ast::StructMemberDecoration>>{}));
|
||||
"a", &i32, ast::StructMemberDecorationList{}));
|
||||
|
||||
std::vector<std::unique_ptr<ast::StructMemberDecoration>> b_deco;
|
||||
ast::StructMemberDecorationList b_deco;
|
||||
b_deco.push_back(std::make_unique<ast::StructMemberOffsetDecoration>(4));
|
||||
members.push_back(
|
||||
std::make_unique<ast::StructMember>("b", &f32, std::move(b_deco)));
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/identifier_expression.h"
|
||||
@@ -38,7 +37,7 @@ TEST_P(UnaryMethodTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto expr = std::make_unique<ast::IdentifierExpression>("expr");
|
||||
std::vector<std::unique_ptr<ast::Expression>> ops;
|
||||
ast::ExpressionList ops;
|
||||
ops.push_back(std::move(expr));
|
||||
|
||||
ast::UnaryMethodExpression method(params.method, std::move(ops));
|
||||
@@ -62,7 +61,7 @@ TEST_P(UnaryMethodTest_MultiParam, Emit) {
|
||||
|
||||
auto expr1 = std::make_unique<ast::IdentifierExpression>("expr1");
|
||||
auto expr2 = std::make_unique<ast::IdentifierExpression>("expr2");
|
||||
std::vector<std::unique_ptr<ast::Expression>> ops;
|
||||
ast::ExpressionList ops;
|
||||
ops.push_back(std::move(expr1));
|
||||
ops.push_back(std::move(expr2));
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/identifier_expression.h"
|
||||
@@ -32,7 +31,7 @@ using GeneratorImplTest = testing::Test;
|
||||
TEST_F(GeneratorImplTest, Emit_Unless) {
|
||||
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
|
||||
|
||||
std::vector<std::unique_ptr<ast::Statement>> body;
|
||||
ast::StatementList body;
|
||||
body.push_back(std::make_unique<ast::NopStatement>());
|
||||
body.push_back(std::make_unique<ast::KillStatement>());
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/binding_decoration.h"
|
||||
@@ -55,7 +54,7 @@ TEST_F(GeneratorImplTest, EmitVariable_StorageClass) {
|
||||
TEST_F(GeneratorImplTest, EmitVariable_Decorated) {
|
||||
ast::type::F32Type f32;
|
||||
|
||||
std::vector<std::unique_ptr<ast::VariableDecoration>> decos;
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(std::make_unique<ast::LocationDecoration>(2));
|
||||
|
||||
ast::DecoratedVariable dv;
|
||||
@@ -72,7 +71,7 @@ TEST_F(GeneratorImplTest, EmitVariable_Decorated) {
|
||||
TEST_F(GeneratorImplTest, EmitVariable_Decorated_Multiple) {
|
||||
ast::type::F32Type f32;
|
||||
|
||||
std::vector<std::unique_ptr<ast::VariableDecoration>> decos;
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(
|
||||
std::make_unique<ast::BuiltinDecoration>(ast::Builtin::kPosition));
|
||||
decos.push_back(std::make_unique<ast::BindingDecoration>(0));
|
||||
|
||||
Reference in New Issue
Block a user