Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 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 | |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 10 | #include "src/sksl/SkSLCompiler.h" |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 11 | #include "src/sksl/dsl/priv/DSLWriter.h" |
| 12 | |
| 13 | namespace SkSL { |
| 14 | |
Ethan Nicholas | 3272412 | 2021-09-07 13:49:07 -0400 | [diff] [blame] | 15 | void ErrorReporter::error(skstd::string_view msg, PositionInfo position) { |
| 16 | if (msg.contains(Compiler::POISON_TAG)) { |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 17 | // don't report errors on poison values |
| 18 | return; |
| 19 | } |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 20 | ++fErrorCount; |
| 21 | this->handleError(msg, position); |
| 22 | } |
| 23 | |
Ethan Nicholas | 5fad2b8 | 2021-09-27 10:39:18 -0400 | [diff] [blame^] | 24 | void ErrorReporter::error(int line, skstd::string_view msg) { |
Ethan Nicholas | 3272412 | 2021-09-07 13:49:07 -0400 | [diff] [blame] | 25 | if (msg.contains(Compiler::POISON_TAG)) { |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 26 | // don't report errors on poison values |
| 27 | return; |
| 28 | } |
Ethan Nicholas | 5fad2b8 | 2021-09-27 10:39:18 -0400 | [diff] [blame^] | 29 | if (line == -1) { |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 30 | ++fErrorCount; |
Ethan Nicholas | 3272412 | 2021-09-07 13:49:07 -0400 | [diff] [blame] | 31 | fPendingErrors.push_back(String(msg)); |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 32 | } else { |
Ethan Nicholas | 5fad2b8 | 2021-09-27 10:39:18 -0400 | [diff] [blame^] | 33 | this->error(msg, PositionInfo(/*file=*/nullptr, line)); |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 34 | } |
| 35 | } |
| 36 | |
| 37 | } // namespace SkSL |