gfx/angle/src/compiler/preprocessor/Token.cpp

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

     1 //
     2 // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
     3 // Use of this source code is governed by a BSD-style license that can be
     4 // found in the LICENSE file.
     5 //
     7 #include "Token.h"
     9 #include <cassert>
    11 #include "numeric_lex.h"
    13 namespace pp
    14 {
    16 void Token::reset()
    17 {
    18     type = 0;
    19     flags = 0;
    20     location = SourceLocation();
    21     text.clear();
    22 }
    24 bool Token::equals(const Token& other) const
    25 {
    26     return (type == other.type) &&
    27            (flags == other.flags) &&
    28            (location == other.location) &&
    29            (text == other.text);
    30 }
    32 void Token::setAtStartOfLine(bool start)
    33 {
    34     if (start)
    35         flags |= AT_START_OF_LINE;
    36     else
    37         flags &= ~AT_START_OF_LINE;
    38 }
    40 void Token::setHasLeadingSpace(bool space)
    41 {
    42     if (space)
    43         flags |= HAS_LEADING_SPACE;
    44     else
    45         flags &= ~HAS_LEADING_SPACE;
    46 }
    48 void Token::setExpansionDisabled(bool disable)
    49 {
    50     if (disable)
    51         flags |= EXPANSION_DISABLED;
    52     else
    53         flags &= ~EXPANSION_DISABLED;
    54 }
    56 bool Token::iValue(int* value) const
    57 {
    58     assert(type == CONST_INT);
    59     return numeric_lex_int(text, value);
    60 }
    62 bool Token::uValue(unsigned int* value) const
    63 {
    64     assert(type == CONST_INT);
    65     return numeric_lex_int(text, value);
    66 }
    68 bool Token::fValue(float* value) const
    69 {
    70     assert(type == CONST_FLOAT);
    71     return numeric_lex_float(text, value);
    72 }
    74 std::ostream& operator<<(std::ostream& out, const Token& token)
    75 {
    76     if (token.hasLeadingSpace())
    77         out << " ";
    79     out << token.text;
    80     return out;
    81 }
    83 }  // namespace pp

mercurial