1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2 * Use of this file is governed by the BSD 3-clause license that
3 * can be found in the LICENSE.txt file in the project root.
6 #include "misc/MurmurHash.h"
9 #include "atn/LexerChannelAction.h"
11 using namespace antlr4::atn;
12 using namespace antlr4::misc;
14 LexerChannelAction::LexerChannelAction(int channel) : _channel(channel) {
17 int LexerChannelAction::getChannel() const {
21 LexerActionType LexerChannelAction::getActionType() const {
22 return LexerActionType::CHANNEL;
25 bool LexerChannelAction::isPositionDependent() const {
29 void LexerChannelAction::execute(Lexer *lexer) {
30 lexer->setChannel(_channel);
33 size_t LexerChannelAction::hashCode() const {
34 size_t hash = MurmurHash::initialize();
35 hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
36 hash = MurmurHash::update(hash, _channel);
37 return MurmurHash::finish(hash, 2);
40 bool LexerChannelAction::operator == (const LexerAction &obj) const {
45 const LexerChannelAction *action = dynamic_cast<const LexerChannelAction *>(&obj);
46 if (action == nullptr) {
50 return _channel == action->_channel;
53 std::string LexerChannelAction::toString() const {
54 return "channel(" + std::to_string(_channel) + ")";