Path: blob/main_old/src/compiler/preprocessor/Token.cpp
1693 views
//1// Copyright 2011 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56#include "compiler/preprocessor/Token.h"78#include "common/debug.h"9#include "compiler/preprocessor/numeric_lex.h"1011namespace angle12{1314namespace pp15{1617void Token::reset()18{19type = 0;20flags = 0;21location = SourceLocation();22text.clear();23}2425bool Token::equals(const Token &other) const26{27return (type == other.type) && (flags == other.flags) && (location == other.location) &&28(text == other.text);29}3031void Token::setAtStartOfLine(bool start)32{33if (start)34flags |= AT_START_OF_LINE;35else36flags &= ~AT_START_OF_LINE;37}3839void Token::setHasLeadingSpace(bool space)40{41if (space)42flags |= HAS_LEADING_SPACE;43else44flags &= ~HAS_LEADING_SPACE;45}4647void Token::setExpansionDisabled(bool disable)48{49if (disable)50flags |= EXPANSION_DISABLED;51else52flags &= ~EXPANSION_DISABLED;53}5455bool Token::iValue(int *value) const56{57ASSERT(type == CONST_INT);58return numeric_lex_int(text, value);59}6061bool Token::uValue(unsigned int *value) const62{63ASSERT(type == CONST_INT);64return numeric_lex_int(text, value);65}6667std::ostream &operator<<(std::ostream &out, const Token &token)68{69if (token.hasLeadingSpace())70out << " ";7172out << token.text;73return out;74}7576} // namespace pp7778} // namespace angle798081