1/*
2 * Copyright 2021 Google LLC.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "include/sksl/SkSLErrorReporter.h"
9
10#include "src/sksl/SkSLCompiler.h"
11#include "src/sksl/dsl/priv/DSLWriter.h"
12
13namespace SkSL {
14
15void ErrorReporter::error(skstd::string_view msg, PositionInfo position) {
16    if (msg.contains(Compiler::POISON_TAG)) {
17        // don't report errors on poison values
18        return;
19    }
20    ++fErrorCount;
21    this->handleError(msg, position);
22}
23
24void ErrorReporter::error(int line, skstd::string_view msg) {
25    if (msg.contains(Compiler::POISON_TAG)) {
26        // don't report errors on poison values
27        return;
28    }
29    if (line == -1) {
30        ++fErrorCount;
31        fPendingErrors.push_back(String(msg));
32    } else {
33        this->error(msg, PositionInfo(/*file=*/nullptr, line));
34    }
35}
36
37} // namespace SkSL
38