mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 23:56:16 +00:00
ast: Add Source argument to literals
Bug: tint:396 Bug: tint:390 Change-Id: Ib78c19533dc65c85e2381bf1ce0d0966dd7babe9 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35019 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
604bc72dd9
commit
5ed161b2d9
@@ -50,8 +50,8 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&f32, 3.14f)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &f32, 3.14f)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
@@ -84,13 +84,13 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
ast::CaseStatementList body;
|
||||
body.push_back(
|
||||
create<ast::CaseStatement>(csl, create<ast::BlockStatement>()));
|
||||
@@ -122,8 +122,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
@@ -135,7 +135,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
||||
create<ast::CaseStatement>(default_csl_1, block_default_1));
|
||||
|
||||
ast::CaseSelectorList csl_case_1;
|
||||
csl_case_1.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
csl_case_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
auto* block_case_1 = create<ast::BlockStatement>();
|
||||
switch_body.push_back(create<ast::CaseStatement>(csl_case_1, block_case_1));
|
||||
|
||||
@@ -172,15 +172,15 @@ TEST_F(ValidateControlBlockTest,
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::UintLiteral>(&u32, 1));
|
||||
csl.push_back(create<ast::UintLiteral>(Source{}, &u32, 1));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl, create<ast::BlockStatement>()));
|
||||
|
||||
@@ -215,15 +215,15 @@ TEST_F(ValidateControlBlockTest,
|
||||
&u32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::UintLiteral>(Source{}, &u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(&i32, -1));
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, -1));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl, create<ast::BlockStatement>()));
|
||||
|
||||
@@ -257,21 +257,21 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
|
||||
&u32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 3)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::UintLiteral>(Source{}, &u32, 3)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::UintLiteral>(&u32, 0));
|
||||
csl_1.push_back(create<ast::UintLiteral>(Source{}, &u32, 0));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(csl_1, create<ast::BlockStatement>()));
|
||||
|
||||
ast::CaseSelectorList csl_2;
|
||||
csl_2.push_back(create<ast::UintLiteral>(&u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(&u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(Source{}, &u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(Source{}, &u32, 2));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl_2, create<ast::BlockStatement>()));
|
||||
|
||||
@@ -305,23 +305,23 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::SintLiteral>(&i32, 10));
|
||||
csl_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(csl_1, create<ast::BlockStatement>()));
|
||||
|
||||
ast::CaseSelectorList csl_2;
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 0));
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 2));
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 10));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 0));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl_2, create<ast::BlockStatement>()));
|
||||
|
||||
@@ -353,8 +353,8 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
@@ -390,8 +390,8 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
@@ -401,7 +401,7 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
||||
body.push_back(create<ast::CaseStatement>(Source{Source::Location{12, 34}},
|
||||
default_csl, block_default));
|
||||
ast::CaseSelectorList case_csl;
|
||||
case_csl.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
case_csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
auto* block_case = create<ast::BlockStatement>();
|
||||
body.push_back(create<ast::CaseStatement>(case_csl, block_case));
|
||||
|
||||
@@ -430,8 +430,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
|
||||
&my_int, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
@@ -46,8 +46,8 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params;
|
||||
ast::type::Void void_type;
|
||||
@@ -94,8 +94,8 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params;
|
||||
ast::type::Void void_type;
|
||||
@@ -155,7 +155,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
|
||||
return_expr));
|
||||
@@ -179,7 +179,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
|
||||
return_expr));
|
||||
@@ -205,7 +205,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
|
||||
auto* func =
|
||||
@@ -215,7 +215,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
||||
ast::VariableList params_copy;
|
||||
auto* body_copy = create<ast::BlockStatement>();
|
||||
auto* return_expr_copy = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body_copy->append(create<ast::ReturnStatement>(Source{}, return_expr_copy));
|
||||
auto* func_copy = create<ast::Function>(
|
||||
@@ -274,7 +274,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
body0->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body0->append(create<ast::ReturnStatement>(Source{}, return_expr));
|
||||
auto* func0 = create<ast::Function>(Source{}, mod()->RegisterSymbol("func"),
|
||||
@@ -293,7 +293,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
|
||||
ast::type::I32 i32;
|
||||
ast::VariableList params;
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 0));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
|
||||
|
||||
@@ -65,7 +65,7 @@ TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
auto* rhs = create<ast::IdentifierExpression>(mod()->RegisterSymbol("my_var"),
|
||||
"my_var");
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
@@ -83,7 +83,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariable_Fail) {
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
auto* assign = create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
|
||||
@@ -101,7 +101,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) {
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
@@ -123,13 +123,13 @@ TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
td()->RegisterVariableForTesting(var);
|
||||
@@ -154,13 +154,13 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.3f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
td()->RegisterVariableForTesting(var);
|
||||
@@ -188,13 +188,13 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
@@ -223,12 +223,12 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.3f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
|
||||
ast::BlockStatement block;
|
||||
block.append(create<ast::VariableDeclStatement>(var));
|
||||
@@ -324,14 +324,14 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("not_global_var"),
|
||||
"not_global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
@@ -363,13 +363,13 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
mod()->RegisterSymbol("global_var"), "global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::VariableList params;
|
||||
|
||||
@@ -402,19 +402,19 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
outer_body->append(
|
||||
@@ -442,17 +442,17 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
@@ -479,8 +479,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var0);
|
||||
|
||||
auto* var1 = create<ast::Variable>(
|
||||
@@ -490,8 +490,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var1);
|
||||
|
||||
EXPECT_TRUE(v()->ValidateGlobalVariables(mod()->global_variables()))
|
||||
@@ -510,8 +510,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var0);
|
||||
|
||||
auto* var1 = create<ast::Variable>(
|
||||
@@ -521,8 +521,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var1);
|
||||
|
||||
EXPECT_FALSE(v()->ValidateGlobalVariables(mod()->global_variables()));
|
||||
@@ -543,13 +543,13 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
|
||||
&i32, // type
|
||||
true, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
@@ -580,8 +580,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(global_var);
|
||||
|
||||
auto* var = create<ast::Variable>(
|
||||
@@ -591,8 +591,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
@@ -624,8 +624,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* var_a_float = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
@@ -634,8 +634,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
@@ -667,12 +667,12 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
@@ -683,8 +683,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
outer_body->append(
|
||||
@@ -711,8 +711,8 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* var = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
@@ -721,12 +721,12 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var));
|
||||
@@ -753,8 +753,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* var1 = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
@@ -763,8 +763,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
&void_type, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params0;
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
@@ -813,7 +813,7 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
Reference in New Issue
Block a user