mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 23:56:16 +00:00
Add a symbol to the Identifier AST node
This CL adds a Symbol to the identifier to represent the name. The name still exists but will be removed in a future CL when the namers are in place. Change-Id: Ic3cc8ad0d99e3bea6eb1ff1ce212e7de67991aec Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35460 Commit-Queue: dan sinclair <dsinclair@chromium.org> Auto-Submit: dan sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
5b3c9f1c62
commit
6b59bf45aa
@@ -53,8 +53,8 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
|
||||
create<ast::SintLiteral>(&f32, 3.14f)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}}, "a");
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
ast::CaseStatementList body;
|
||||
@@ -87,7 +87,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) {
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond = create<ast::IdentifierExpression>("a");
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
ast::CaseStatementList body;
|
||||
@@ -125,7 +126,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond = create<ast::IdentifierExpression>("a");
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList default_csl_1;
|
||||
auto* block_default_1 = create<ast::BlockStatement>();
|
||||
@@ -174,7 +176,8 @@ TEST_F(ValidateControlBlockTest,
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond = create<ast::IdentifierExpression>("a");
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::UintLiteral>(&u32, 1));
|
||||
@@ -216,7 +219,8 @@ TEST_F(ValidateControlBlockTest,
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond = create<ast::IdentifierExpression>("a");
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(&i32, -1));
|
||||
@@ -257,7 +261,8 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond = create<ast::IdentifierExpression>("a");
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::UintLiteral>(&u32, 0));
|
||||
@@ -304,7 +309,8 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) {
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond = create<ast::IdentifierExpression>("a");
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::SintLiteral>(&i32, 10));
|
||||
@@ -350,7 +356,8 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond = create<ast::IdentifierExpression>("a");
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
block_default->append(
|
||||
@@ -386,7 +393,8 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond = create<ast::IdentifierExpression>("a");
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
ast::CaseStatementList body;
|
||||
@@ -425,7 +433,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
|
||||
create<ast::SintLiteral>(&u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond = create<ast::IdentifierExpression>("a");
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
ast::CaseStatementList body;
|
||||
|
||||
@@ -237,7 +237,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
|
||||
ast::ExpressionList call_params;
|
||||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}},
|
||||
create<ast::IdentifierExpression>("func"), call_params);
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("func"), "func"),
|
||||
call_params);
|
||||
ast::VariableList params0;
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
body0->append(create<ast::CallStatement>(call_expr));
|
||||
@@ -258,7 +259,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
||||
ast::ExpressionList call_params;
|
||||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}},
|
||||
create<ast::IdentifierExpression>("func"), call_params);
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("func"), "func"),
|
||||
call_params);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, // source
|
||||
"a", // name
|
||||
@@ -267,6 +269,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
||||
false, // is_const
|
||||
call_expr, // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params0;
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
body0->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
@@ -66,7 +66,8 @@ TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) {
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1));
|
||||
auto* rhs = create<ast::IdentifierExpression>("my_var");
|
||||
auto* rhs = create<ast::IdentifierExpression>(mod()->RegisterSymbol("my_var"),
|
||||
"my_var");
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
|
||||
// TODO(sarahM0): Invalidate assignment to scalar.
|
||||
@@ -79,8 +80,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariable_Fail) {
|
||||
// b = 2;
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}}, "b");
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
auto* assign = create<ast::AssignmentStatement>(
|
||||
@@ -97,8 +98,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) {
|
||||
// }
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}}, "b");
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
|
||||
@@ -125,7 +126,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) {
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>("a");
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
|
||||
@@ -155,7 +157,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) {
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>("a");
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.3f));
|
||||
|
||||
@@ -188,7 +191,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>("a");
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
|
||||
@@ -221,7 +225,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* lhs = create<ast::IdentifierExpression>("a");
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.3f));
|
||||
|
||||
@@ -323,7 +328,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, "not_global_var");
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("not_global_var"),
|
||||
"not_global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
|
||||
@@ -360,7 +366,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>("global_var");
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
mod()->RegisterSymbol("global_var"), "global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
|
||||
@@ -404,8 +411,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}}, "a");
|
||||
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));
|
||||
|
||||
@@ -438,8 +445,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}}, "a");
|
||||
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));
|
||||
|
||||
@@ -539,7 +546,8 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>("a");
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
|
||||
@@ -802,7 +810,8 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
td()->RegisterVariableForTesting(var);
|
||||
auto* lhs = create<ast::IdentifierExpression>("a");
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user