Tue, 06 Jan 2015 21:39:09 +0100
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) 2012 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 "DiagnosticsBase.h" |
michael@0 | 8 | |
michael@0 | 9 | #include <cassert> |
michael@0 | 10 | |
michael@0 | 11 | namespace pp |
michael@0 | 12 | { |
michael@0 | 13 | |
michael@0 | 14 | Diagnostics::~Diagnostics() |
michael@0 | 15 | { |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | void Diagnostics::report(ID id, |
michael@0 | 19 | const SourceLocation& loc, |
michael@0 | 20 | const std::string& text) |
michael@0 | 21 | { |
michael@0 | 22 | // TODO(alokp): Keep a count of errors and warnings. |
michael@0 | 23 | print(id, loc, text); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | Diagnostics::Severity Diagnostics::severity(ID id) |
michael@0 | 27 | { |
michael@0 | 28 | if ((id > ERROR_BEGIN) && (id < ERROR_END)) |
michael@0 | 29 | return ERROR; |
michael@0 | 30 | |
michael@0 | 31 | if ((id > WARNING_BEGIN) && (id < WARNING_END)) |
michael@0 | 32 | return WARNING; |
michael@0 | 33 | |
michael@0 | 34 | assert(false); |
michael@0 | 35 | return ERROR; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | std::string Diagnostics::message(ID id) |
michael@0 | 39 | { |
michael@0 | 40 | switch (id) |
michael@0 | 41 | { |
michael@0 | 42 | // Errors begin. |
michael@0 | 43 | case INTERNAL_ERROR: |
michael@0 | 44 | return "internal error"; |
michael@0 | 45 | case OUT_OF_MEMORY: |
michael@0 | 46 | return "out of memory"; |
michael@0 | 47 | case INVALID_CHARACTER: |
michael@0 | 48 | return "invalid character"; |
michael@0 | 49 | case INVALID_NUMBER: |
michael@0 | 50 | return "invalid number"; |
michael@0 | 51 | case INTEGER_OVERFLOW: |
michael@0 | 52 | return "integer overflow"; |
michael@0 | 53 | case FLOAT_OVERFLOW: |
michael@0 | 54 | return "float overflow"; |
michael@0 | 55 | case TOKEN_TOO_LONG: |
michael@0 | 56 | return "token too long"; |
michael@0 | 57 | case INVALID_EXPRESSION: |
michael@0 | 58 | return "invalid expression"; |
michael@0 | 59 | case DIVISION_BY_ZERO: |
michael@0 | 60 | return "division by zero"; |
michael@0 | 61 | case EOF_IN_COMMENT: |
michael@0 | 62 | return "unexpected end of file found in comment"; |
michael@0 | 63 | case UNEXPECTED_TOKEN: |
michael@0 | 64 | return "unexpected token"; |
michael@0 | 65 | case DIRECTIVE_INVALID_NAME: |
michael@0 | 66 | return "invalid directive name"; |
michael@0 | 67 | case MACRO_NAME_RESERVED: |
michael@0 | 68 | return "macro name is reserved"; |
michael@0 | 69 | case MACRO_REDEFINED: |
michael@0 | 70 | return "macro redefined"; |
michael@0 | 71 | case MACRO_PREDEFINED_REDEFINED: |
michael@0 | 72 | return "predefined macro redefined"; |
michael@0 | 73 | case MACRO_PREDEFINED_UNDEFINED: |
michael@0 | 74 | return "predefined macro undefined"; |
michael@0 | 75 | case MACRO_UNTERMINATED_INVOCATION: |
michael@0 | 76 | return "unterminated macro invocation"; |
michael@0 | 77 | case MACRO_TOO_FEW_ARGS: |
michael@0 | 78 | return "Not enough arguments for macro"; |
michael@0 | 79 | case MACRO_TOO_MANY_ARGS: |
michael@0 | 80 | return "Too many arguments for macro"; |
michael@0 | 81 | case CONDITIONAL_ENDIF_WITHOUT_IF: |
michael@0 | 82 | return "unexpected #endif found without a matching #if"; |
michael@0 | 83 | case CONDITIONAL_ELSE_WITHOUT_IF: |
michael@0 | 84 | return "unexpected #else found without a matching #if"; |
michael@0 | 85 | case CONDITIONAL_ELSE_AFTER_ELSE: |
michael@0 | 86 | return "unexpected #else found after another #else"; |
michael@0 | 87 | case CONDITIONAL_ELIF_WITHOUT_IF: |
michael@0 | 88 | return "unexpected #elif found without a matching #if"; |
michael@0 | 89 | case CONDITIONAL_ELIF_AFTER_ELSE: |
michael@0 | 90 | return "unexpected #elif found after #else"; |
michael@0 | 91 | case CONDITIONAL_UNTERMINATED: |
michael@0 | 92 | return "unexpected end of file found in conditional block"; |
michael@0 | 93 | case INVALID_EXTENSION_NAME: |
michael@0 | 94 | return "invalid extension name"; |
michael@0 | 95 | case INVALID_EXTENSION_BEHAVIOR: |
michael@0 | 96 | return "invalid extension behavior"; |
michael@0 | 97 | case INVALID_EXTENSION_DIRECTIVE: |
michael@0 | 98 | return "invalid extension directive"; |
michael@0 | 99 | case INVALID_VERSION_NUMBER: |
michael@0 | 100 | return "invalid version number"; |
michael@0 | 101 | case INVALID_VERSION_DIRECTIVE: |
michael@0 | 102 | return "invalid version directive"; |
michael@0 | 103 | case VERSION_NOT_FIRST_STATEMENT: |
michael@0 | 104 | return "#version directive must occur before anything else, " |
michael@0 | 105 | "except for comments and white space"; |
michael@0 | 106 | case INVALID_LINE_NUMBER: |
michael@0 | 107 | return "invalid line number"; |
michael@0 | 108 | case INVALID_FILE_NUMBER: |
michael@0 | 109 | return "invalid file number"; |
michael@0 | 110 | case INVALID_LINE_DIRECTIVE: |
michael@0 | 111 | return "invalid line directive"; |
michael@0 | 112 | // Errors end. |
michael@0 | 113 | // Warnings begin. |
michael@0 | 114 | case EOF_IN_DIRECTIVE: |
michael@0 | 115 | return "unexpected end of file found in directive"; |
michael@0 | 116 | case CONDITIONAL_UNEXPECTED_TOKEN: |
michael@0 | 117 | return "unexpected token after conditional expression"; |
michael@0 | 118 | case UNRECOGNIZED_PRAGMA: |
michael@0 | 119 | return "unrecognized pragma"; |
michael@0 | 120 | // Warnings end. |
michael@0 | 121 | default: |
michael@0 | 122 | assert(false); |
michael@0 | 123 | return ""; |
michael@0 | 124 | } |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | } // namespace pp |