| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/parser/qqmljsengine_p.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | #include "qqmljsengine_p.h" | - | ||||||||||||
| 41 | #include "qqmljsglobal_p.h" | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | #include <QtCore/private/qnumeric_p.h> | - | ||||||||||||
| 44 | #include <QtCore/qhash.h> | - | ||||||||||||
| 45 | #include <QtCore/qdebug.h> | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | QT_QML_BEGIN_NAMESPACE | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | namespace QQmlJS { | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | static inline int toDigit(char c) | - | ||||||||||||
| 52 | { | - | ||||||||||||
| 53 | if ((c >= '0') && (c <= '9'))
| 0 | ||||||||||||
| 54 | return c - '0'; never executed: return c - '0'; | 0 | ||||||||||||
| 55 | else if ((c >= 'a') && (c <= 'z'))
| 0 | ||||||||||||
| 56 | return 10 + c - 'a'; never executed: return 10 + c - 'a'; | 0 | ||||||||||||
| 57 | else if ((c >= 'A') && (c <= 'Z'))
| 0 | ||||||||||||
| 58 | return 10 + c - 'A'; never executed: return 10 + c - 'A'; | 0 | ||||||||||||
| 59 | return -1; never executed: return -1; | 0 | ||||||||||||
| 60 | } | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | double integerFromString(const char *buf, int size, int radix) | - | ||||||||||||
| 63 | { | - | ||||||||||||
| 64 | if (size == 0)
| 0 | ||||||||||||
| 65 | return qt_qnan(); never executed: return qt_qnan(); | 0 | ||||||||||||
| 66 | - | |||||||||||||
| 67 | double sign = 1.0; | - | ||||||||||||
| 68 | int i = 0; | - | ||||||||||||
| 69 | if (buf[0] == '+') {
| 0 | ||||||||||||
| 70 | ++i; | - | ||||||||||||
| 71 | } else if (buf[0] == '-') { never executed: end of block
| 0 | ||||||||||||
| 72 | sign = -1.0; | - | ||||||||||||
| 73 | ++i; | - | ||||||||||||
| 74 | } never executed: end of block | 0 | ||||||||||||
| 75 | - | |||||||||||||
| 76 | if (((size-i) >= 2) && (buf[i] == '0')) {
| 0 | ||||||||||||
| 77 | if (((buf[i+1] == 'x') || (buf[i+1] == 'X'))
| 0 | ||||||||||||
| 78 | && (radix < 34)) {
| 0 | ||||||||||||
| 79 | if ((radix != 0) && (radix != 16))
| 0 | ||||||||||||
| 80 | return 0; never executed: return 0; | 0 | ||||||||||||
| 81 | radix = 16; | - | ||||||||||||
| 82 | i += 2; | - | ||||||||||||
| 83 | } else { never executed: end of block | 0 | ||||||||||||
| 84 | if (radix == 0) {
| 0 | ||||||||||||
| 85 | radix = 8; | - | ||||||||||||
| 86 | ++i; | - | ||||||||||||
| 87 | } never executed: end of block | 0 | ||||||||||||
| 88 | } never executed: end of block | 0 | ||||||||||||
| 89 | } else if (radix == 0) {
| 0 | ||||||||||||
| 90 | radix = 10; | - | ||||||||||||
| 91 | } never executed: end of block | 0 | ||||||||||||
| 92 | - | |||||||||||||
| 93 | int j = i; | - | ||||||||||||
| 94 | for ( ; i < size; ++i) {
| 0 | ||||||||||||
| 95 | int d = toDigit(buf[i]); | - | ||||||||||||
| 96 | if ((d == -1) || (d >= radix))
| 0 | ||||||||||||
| 97 | break; never executed: break; | 0 | ||||||||||||
| 98 | } never executed: end of block | 0 | ||||||||||||
| 99 | double result; | - | ||||||||||||
| 100 | if (j == i) {
| 0 | ||||||||||||
| 101 | if (!qstrcmp(buf, "Infinity"))
| 0 | ||||||||||||
| 102 | result = qInf(); never executed: result = qInf(); | 0 | ||||||||||||
| 103 | else | - | ||||||||||||
| 104 | result = qt_qnan(); never executed: result = qt_qnan(); | 0 | ||||||||||||
| 105 | } else { | - | ||||||||||||
| 106 | result = 0; | - | ||||||||||||
| 107 | double multiplier = 1; | - | ||||||||||||
| 108 | for (--i ; i >= j; --i, multiplier *= radix)
| 0 | ||||||||||||
| 109 | result += toDigit(buf[i]) * multiplier; never executed: result += toDigit(buf[i]) * multiplier; | 0 | ||||||||||||
| 110 | } never executed: end of block | 0 | ||||||||||||
| 111 | result *= sign; | - | ||||||||||||
| 112 | return result; never executed: return result; | 0 | ||||||||||||
| 113 | } | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | Engine::Engine() | - | ||||||||||||
| 116 | : _lexer(nullptr), _directives(nullptr) | - | ||||||||||||
| 117 | { executed 2978571 times by 148 tests: }end of blockExecuted by:
executed 2978571 times by 148 tests: end of blockExecuted by:
| 2978571 | ||||||||||||
| 118 | - | |||||||||||||
| 119 | Engine::~Engine() | - | ||||||||||||
| 120 | { } | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | void Engine::setCode(const QString &code) | - | ||||||||||||
| 123 | { executed 2979904 times by 148 tests: _code = code; }end of blockExecuted by:
executed 2979904 times by 148 tests: end of blockExecuted by:
| 2979904 | ||||||||||||
| 124 | - | |||||||||||||
| 125 | void Engine::addComment(int pos, int len, int line, int col) | - | ||||||||||||
| 126 | { executed 2086837 times by 93 tests: end of blockExecuted by:
executed 2067346 times by 93 tests: _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col));Executed by:
executed 2086837 times by 93 tests: end of blockExecuted by:
executed 2067346 times by 93 tests: _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col));Executed by:
| 16410-2086837 | ||||||||||||
| 127 | - | |||||||||||||
| 128 | QList<QQmlJS::AST::SourceLocation> Engine::comments() const | - | ||||||||||||
| 129 | { never executed: return _comments; }return _comments;never executed: return _comments; | 0 | ||||||||||||
| 130 | - | |||||||||||||
| 131 | Lexer *Engine::lexer() const | - | ||||||||||||
| 132 | { executed 2938488 times by 147 tests: return _lexer; }return _lexer;Executed by:
executed 2938488 times by 147 tests: return _lexer;Executed by:
| 2938488 | ||||||||||||
| 133 | - | |||||||||||||
| 134 | void Engine::setLexer(Lexer *lexer) | - | ||||||||||||
| 135 | { executed 2978109 times by 148 tests: _lexer = lexer; }end of blockExecuted by:
executed 2978109 times by 148 tests: end of blockExecuted by:
| 2978109 | ||||||||||||
| 136 | - | |||||||||||||
| 137 | Directives *Engine::directives() const | - | ||||||||||||
| 138 | { executed 1768203 times by 26 tests: return _directives; }return _directives;Executed by:
executed 1768203 times by 26 tests: return _directives;Executed by:
| 1768203 | ||||||||||||
| 139 | - | |||||||||||||
| 140 | void Engine::setDirectives(Directives *directives) | - | ||||||||||||
| 141 | { executed 116 times by 12 tests: _directives = directives; }end of blockExecuted by:
executed 116 times by 12 tests: end of blockExecuted by:
| 116 | ||||||||||||
| 142 | - | |||||||||||||
| 143 | MemoryPool *Engine::pool() | - | ||||||||||||
| 144 | { executed 3143856 times by 147 tests: return &_pool; }return &_pool;Executed by:
executed 3143856 times by 147 tests: return &_pool;Executed by:
| 3143856 | ||||||||||||
| 145 | - | |||||||||||||
| 146 | QStringRef Engine::newStringRef(const QString &text) | - | ||||||||||||
| 147 | { | - | ||||||||||||
| 148 | const int pos = _extraCode.length(); | - | ||||||||||||
| 149 | _extraCode += text; | - | ||||||||||||
| 150 | return _extraCode.midRef(pos, text.length()); executed 1180168 times by 89 tests: return _extraCode.midRef(pos, text.length());Executed by:
| 1180168 | ||||||||||||
| 151 | } | - | ||||||||||||
| 152 | - | |||||||||||||
| 153 | QStringRef Engine::newStringRef(const QChar *chars, int size) | - | ||||||||||||
| 154 | { never executed: return newStringRef(QString(chars, size)); }return newStringRef(QString(chars, size));never executed: return newStringRef(QString(chars, size)); | 0 | ||||||||||||
| 155 | - | |||||||||||||
| 156 | } // end of namespace QQmlJS | - | ||||||||||||
| 157 | - | |||||||||||||
| 158 | QT_QML_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |