2020-03-02 20:47:43 +00:00
|
|
|
// Copyright 2020 The Tint Authors.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "src/ast/statement.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "src/ast/assignment_statement.h"
|
2020-07-27 15:25:00 +00:00
|
|
|
#include "src/ast/block_statement.h"
|
2020-03-02 20:47:43 +00:00
|
|
|
#include "src/ast/break_statement.h"
|
2020-07-21 13:42:05 +00:00
|
|
|
#include "src/ast/call_statement.h"
|
2020-03-02 20:47:43 +00:00
|
|
|
#include "src/ast/case_statement.h"
|
|
|
|
#include "src/ast/continue_statement.h"
|
2020-07-25 03:34:33 +00:00
|
|
|
#include "src/ast/discard_statement.h"
|
2020-03-02 20:47:43 +00:00
|
|
|
#include "src/ast/else_statement.h"
|
|
|
|
#include "src/ast/fallthrough_statement.h"
|
|
|
|
#include "src/ast/if_statement.h"
|
|
|
|
#include "src/ast/loop_statement.h"
|
|
|
|
#include "src/ast/return_statement.h"
|
|
|
|
#include "src/ast/switch_statement.h"
|
2020-03-30 22:46:48 +00:00
|
|
|
#include "src/ast/variable_decl_statement.h"
|
2020-03-02 20:47:43 +00:00
|
|
|
|
|
|
|
namespace tint {
|
|
|
|
namespace ast {
|
|
|
|
|
|
|
|
Statement::Statement() = default;
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
Statement::Statement(const Source& source) : Base(source) {}
|
2020-03-02 20:47:43 +00:00
|
|
|
|
2020-04-09 18:52:06 +00:00
|
|
|
Statement::Statement(Statement&&) = default;
|
|
|
|
|
2020-03-02 20:47:43 +00:00
|
|
|
Statement::~Statement() = default;
|
|
|
|
|
2020-11-11 14:11:55 +00:00
|
|
|
const char* Statement::Name() const {
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<AssignmentStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "assignment statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<BlockStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "block statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<BreakStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "break statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<CaseStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "case statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<CallStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "function call";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<ContinueStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "continue statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<DiscardStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "discard statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<ElseStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "else statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<FallthroughStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "fallthrough statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<IfStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "if statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<LoopStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "loop statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<ReturnStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "return statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<SwitchStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "switch statement";
|
|
|
|
}
|
2020-11-30 23:30:58 +00:00
|
|
|
if (Is<VariableDeclStatement>()) {
|
2020-11-11 14:11:55 +00:00
|
|
|
return "variable declaration";
|
|
|
|
}
|
|
|
|
return "statement";
|
|
|
|
}
|
|
|
|
|
2020-03-02 20:47:43 +00:00
|
|
|
} // namespace ast
|
|
|
|
} // namespace tint
|