1cb93a386Sopenharmony_ci// Copyright 2020 The Tint Authors. 2cb93a386Sopenharmony_ci// 3cb93a386Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 4cb93a386Sopenharmony_ci// you may not use this file except in compliance with the License. 5cb93a386Sopenharmony_ci// You may obtain a copy of the License at 6cb93a386Sopenharmony_ci// 7cb93a386Sopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 8cb93a386Sopenharmony_ci// 9cb93a386Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 10cb93a386Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 11cb93a386Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12cb93a386Sopenharmony_ci// See the License for the specific language governing permissions and 13cb93a386Sopenharmony_ci// limitations under the License. 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_ci#include "src/ast/statement.h" 16cb93a386Sopenharmony_ci 17cb93a386Sopenharmony_ci#include "src/ast/assignment_statement.h" 18cb93a386Sopenharmony_ci#include "src/ast/break_statement.h" 19cb93a386Sopenharmony_ci#include "src/ast/call_statement.h" 20cb93a386Sopenharmony_ci#include "src/ast/continue_statement.h" 21cb93a386Sopenharmony_ci#include "src/ast/discard_statement.h" 22cb93a386Sopenharmony_ci#include "src/ast/fallthrough_statement.h" 23cb93a386Sopenharmony_ci#include "src/ast/if_statement.h" 24cb93a386Sopenharmony_ci#include "src/ast/loop_statement.h" 25cb93a386Sopenharmony_ci#include "src/ast/return_statement.h" 26cb93a386Sopenharmony_ci#include "src/ast/switch_statement.h" 27cb93a386Sopenharmony_ci#include "src/ast/variable_decl_statement.h" 28cb93a386Sopenharmony_ci 29cb93a386Sopenharmony_ciTINT_INSTANTIATE_TYPEINFO(tint::ast::Statement); 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_cinamespace tint { 32cb93a386Sopenharmony_cinamespace ast { 33cb93a386Sopenharmony_ci 34cb93a386Sopenharmony_ciStatement::Statement(ProgramID pid, const Source& src) : Base(pid, src) {} 35cb93a386Sopenharmony_ci 36cb93a386Sopenharmony_ciStatement::Statement(Statement&&) = default; 37cb93a386Sopenharmony_ci 38cb93a386Sopenharmony_ciStatement::~Statement() = default; 39cb93a386Sopenharmony_ci 40cb93a386Sopenharmony_ciconst char* Statement::Name() const { 41cb93a386Sopenharmony_ci if (Is<AssignmentStatement>()) { 42cb93a386Sopenharmony_ci return "assignment statement"; 43cb93a386Sopenharmony_ci } 44cb93a386Sopenharmony_ci if (Is<BlockStatement>()) { 45cb93a386Sopenharmony_ci return "block statement"; 46cb93a386Sopenharmony_ci } 47cb93a386Sopenharmony_ci if (Is<BreakStatement>()) { 48cb93a386Sopenharmony_ci return "break statement"; 49cb93a386Sopenharmony_ci } 50cb93a386Sopenharmony_ci if (Is<CaseStatement>()) { 51cb93a386Sopenharmony_ci return "case statement"; 52cb93a386Sopenharmony_ci } 53cb93a386Sopenharmony_ci if (Is<CallStatement>()) { 54cb93a386Sopenharmony_ci return "function call"; 55cb93a386Sopenharmony_ci } 56cb93a386Sopenharmony_ci if (Is<ContinueStatement>()) { 57cb93a386Sopenharmony_ci return "continue statement"; 58cb93a386Sopenharmony_ci } 59cb93a386Sopenharmony_ci if (Is<DiscardStatement>()) { 60cb93a386Sopenharmony_ci return "discard statement"; 61cb93a386Sopenharmony_ci } 62cb93a386Sopenharmony_ci if (Is<ElseStatement>()) { 63cb93a386Sopenharmony_ci return "else statement"; 64cb93a386Sopenharmony_ci } 65cb93a386Sopenharmony_ci if (Is<FallthroughStatement>()) { 66cb93a386Sopenharmony_ci return "fallthrough statement"; 67cb93a386Sopenharmony_ci } 68cb93a386Sopenharmony_ci if (Is<IfStatement>()) { 69cb93a386Sopenharmony_ci return "if statement"; 70cb93a386Sopenharmony_ci } 71cb93a386Sopenharmony_ci if (Is<LoopStatement>()) { 72cb93a386Sopenharmony_ci return "loop statement"; 73cb93a386Sopenharmony_ci } 74cb93a386Sopenharmony_ci if (Is<ReturnStatement>()) { 75cb93a386Sopenharmony_ci return "return statement"; 76cb93a386Sopenharmony_ci } 77cb93a386Sopenharmony_ci if (Is<SwitchStatement>()) { 78cb93a386Sopenharmony_ci return "switch statement"; 79cb93a386Sopenharmony_ci } 80cb93a386Sopenharmony_ci if (Is<VariableDeclStatement>()) { 81cb93a386Sopenharmony_ci return "variable declaration"; 82cb93a386Sopenharmony_ci } 83cb93a386Sopenharmony_ci return "statement"; 84cb93a386Sopenharmony_ci} 85cb93a386Sopenharmony_ci 86cb93a386Sopenharmony_ci} // namespace ast 87cb93a386Sopenharmony_ci} // namespace tint 88