blob: 6be9dd05c4510709840c6ab94d444ac1f7400f0a [file] [log] [blame]
Ethan Nicholas4a5e22a2021-08-13 17:29:51 -04001/*
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
Ethan Nicholas6f20b8d2021-08-31 07:40:24 -040010#include "src/sksl/SkSLCompiler.h"
Ethan Nicholas4a5e22a2021-08-13 17:29:51 -040011#include "src/sksl/dsl/priv/DSLWriter.h"
12
13namespace SkSL {
14
Ethan Nicholas32724122021-09-07 13:49:07 -040015void ErrorReporter::error(skstd::string_view msg, PositionInfo position) {
16 if (msg.contains(Compiler::POISON_TAG)) {
Ethan Nicholas6f20b8d2021-08-31 07:40:24 -040017 // don't report errors on poison values
18 return;
19 }
Ethan Nicholas4a5e22a2021-08-13 17:29:51 -040020 ++fErrorCount;
21 this->handleError(msg, position);
22}
23
Ethan Nicholas5fad2b82021-09-27 10:39:18 -040024void ErrorReporter::error(int line, skstd::string_view msg) {
Ethan Nicholas32724122021-09-07 13:49:07 -040025 if (msg.contains(Compiler::POISON_TAG)) {
Ethan Nicholas6f20b8d2021-08-31 07:40:24 -040026 // don't report errors on poison values
27 return;
28 }
Ethan Nicholas5fad2b82021-09-27 10:39:18 -040029 if (line == -1) {
Ethan Nicholas4a5e22a2021-08-13 17:29:51 -040030 ++fErrorCount;
Ethan Nicholas32724122021-09-07 13:49:07 -040031 fPendingErrors.push_back(String(msg));
Ethan Nicholas4a5e22a2021-08-13 17:29:51 -040032 } else {
Ethan Nicholas5fad2b82021-09-27 10:39:18 -040033 this->error(msg, PositionInfo(/*file=*/nullptr, line));
Ethan Nicholas4a5e22a2021-08-13 17:29:51 -040034 }
35}
36
37} // namespace SkSL