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