mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 23:56:16 +00:00
ast: Remove expression constructors that don't take a Source
Parsers need fixing up. Bug: tint:396 Bug: tint:390 Change-Id: I7f823e2489101b43c1b21a6b89c248695a3f35b7 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35160 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
5ed161b2d9
commit
1ff59cd0e2
@@ -50,6 +50,7 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &f32, 3.14f)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
@@ -84,11 +85,12 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
ast::CaseStatementList body;
|
||||
@@ -122,12 +124,13 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList default_csl_1;
|
||||
auto* block_default_1 = create<ast::BlockStatement>();
|
||||
@@ -172,12 +175,13 @@ TEST_F(ValidateControlBlockTest,
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::UintLiteral>(Source{}, &u32, 1));
|
||||
@@ -215,12 +219,13 @@ TEST_F(ValidateControlBlockTest,
|
||||
&u32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::UintLiteral>(Source{}, &u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, -1));
|
||||
@@ -257,12 +262,13 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
|
||||
&u32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::UintLiteral>(Source{}, &u32, 3)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::UintLiteral>(Source{}, &u32, 0));
|
||||
@@ -305,12 +311,13 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
|
||||
@@ -353,11 +360,12 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
block_default->append(
|
||||
@@ -390,11 +398,12 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
ast::CaseStatementList body;
|
||||
@@ -430,11 +439,12 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
|
||||
&my_int, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
ast::CaseStatementList body;
|
||||
|
||||
@@ -46,6 +46,7 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
@@ -94,6 +95,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
@@ -155,7 +157,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
|
||||
return_expr));
|
||||
@@ -179,7 +181,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
|
||||
return_expr));
|
||||
@@ -205,7 +207,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
|
||||
auto* func =
|
||||
@@ -215,7 +217,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>(Source{}, &i32, 2));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body_copy->append(create<ast::ReturnStatement>(Source{}, return_expr_copy));
|
||||
auto* func_copy = create<ast::Function>(
|
||||
@@ -237,7 +239,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
|
||||
ast::ExpressionList call_params;
|
||||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}},
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("func"), "func"),
|
||||
create<ast::IdentifierExpression>(Source{}, mod()->RegisterSymbol("func"),
|
||||
"func"),
|
||||
call_params);
|
||||
ast::VariableList params0;
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
@@ -259,7 +262,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
||||
ast::ExpressionList call_params;
|
||||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}},
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("func"), "func"),
|
||||
create<ast::IdentifierExpression>(Source{}, mod()->RegisterSymbol("func"),
|
||||
"func"),
|
||||
call_params);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, // source
|
||||
@@ -274,7 +278,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>(Source{}, &i32, 2));
|
||||
Source{}, 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 +297,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
|
||||
ast::type::I32 i32;
|
||||
ast::VariableList params;
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 0));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
|
||||
|
||||
@@ -65,9 +65,9 @@ TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
auto* rhs = create<ast::IdentifierExpression>(mod()->RegisterSymbol("my_var"),
|
||||
"my_var");
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
auto* rhs = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("my_var"), "my_var");
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
|
||||
// TODO(sarahM0): Invalidate assignment to scalar.
|
||||
@@ -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>(Source{}, &i32, 2));
|
||||
Source{}, 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>(Source{}, &i32, 2));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
@@ -123,13 +123,14 @@ TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
td()->RegisterVariableForTesting(var);
|
||||
@@ -154,13 +155,14 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
td()->RegisterVariableForTesting(var);
|
||||
@@ -188,13 +190,14 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
@@ -223,12 +226,13 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
|
||||
ast::BlockStatement block;
|
||||
block.append(create<ast::VariableDeclStatement>(var));
|
||||
@@ -324,6 +328,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
@@ -331,7 +336,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("not_global_var"),
|
||||
"not_global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
@@ -363,13 +368,14 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
mod()->RegisterSymbol("global_var"), "global_var");
|
||||
Source{}, mod()->RegisterSymbol("global_var"), "global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::VariableList params;
|
||||
|
||||
@@ -402,19 +408,20 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
Source{}, 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>(Source{}, &f32, 3.14f));
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
outer_body->append(
|
||||
@@ -442,17 +449,18 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
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>(Source{}, &f32, 3.14f));
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
Source{}, 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,6 +487,7 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var0);
|
||||
@@ -490,6 +499,7 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var1);
|
||||
@@ -510,6 +520,7 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var0);
|
||||
@@ -521,6 +532,7 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var1);
|
||||
@@ -543,13 +555,14 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
|
||||
&i32, // type
|
||||
true, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
@@ -580,6 +593,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(global_var);
|
||||
@@ -591,6 +605,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
ast::VariableList params;
|
||||
@@ -624,6 +639,7 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
@@ -634,6 +650,7 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
@@ -667,12 +684,13 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
@@ -683,6 +701,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
@@ -711,6 +730,7 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
@@ -721,12 +741,13 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var));
|
||||
@@ -753,6 +774,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
@@ -763,6 +785,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
&void_type, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
@@ -810,10 +833,10 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
td()->RegisterVariableForTesting(var);
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
Reference in New Issue
Block a user