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

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial