Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
sksl
ir
SkSLDoStatement.cpp
Go to the documentation of this file.
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 "
src/sksl/ir/SkSLDoStatement.h
"
9
10
#include "
include/core/SkTypes.h
"
11
#include "
src/sksl/SkSLAnalysis.h
"
12
#include "
src/sksl/SkSLBuiltinTypes.h
"
13
#include "
src/sksl/SkSLContext.h
"
14
#include "
src/sksl/SkSLErrorReporter.h
"
15
#include "
src/sksl/SkSLProgramSettings.h
"
16
#include "
src/sksl/ir/SkSLType.h
"
17
18
namespace
SkSL
{
19
20
std::unique_ptr<Statement>
DoStatement::Convert
(
const
Context
& context,
21
Position
pos
,
22
std::unique_ptr<Statement> stmt,
23
std::unique_ptr<Expression>
test
) {
24
if
(context.
fConfig
->
strictES2Mode
()) {
25
context.
fErrors
->
error
(
pos
,
"do-while loops are not supported"
);
26
return
nullptr
;
27
}
28
test
= context.
fTypes
.
fBool
->coerceExpression(std::move(
test
), context);
29
if
(!
test
) {
30
return
nullptr
;
31
}
32
if
(
Analysis::DetectVarDeclarationWithoutScope
(*stmt, context.
fErrors
)) {
33
return
nullptr
;
34
}
35
return
DoStatement::Make
(context,
pos
, std::move(stmt), std::move(
test
));
36
}
37
38
std::unique_ptr<Statement>
DoStatement::Make
(
const
Context
& context,
39
Position
pos
,
40
std::unique_ptr<Statement> stmt,
41
std::unique_ptr<Expression>
test
) {
42
SkASSERT
(!context.
fConfig
->
strictES2Mode
());
43
SkASSERT
(
test
->type().matches(*context.
fTypes
.
fBool
));
44
SkASSERT
(!
Analysis::DetectVarDeclarationWithoutScope
(*stmt));
45
return
std::make_unique<DoStatement>(
pos
, std::move(stmt), std::move(
test
));
46
}
47
48
std::string
DoStatement::description
()
const
{
49
return
"do "
+ this->
statement
()->description() +
50
" while ("
+ this->
test
()->description() +
");"
;
51
}
52
53
}
// namespace SkSL
54
pos
SkPoint pos
Definition
ImageShaderTest.cpp:27
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
SkSLAnalysis.h
SkSLBuiltinTypes.h
SkSLContext.h
SkSLDoStatement.h
SkSLErrorReporter.h
SkSLProgramSettings.h
SkSLType.h
SkTypes.h
SkSL::BuiltinTypes::fBool
const std::unique_ptr< Type > fBool
Definition
SkSLBuiltinTypes.h:54
SkSL::Context
Definition
SkSLContext.h:24
SkSL::Context::fTypes
const BuiltinTypes & fTypes
Definition
SkSLContext.h:30
SkSL::Context::fErrors
ErrorReporter * fErrors
Definition
SkSLContext.h:36
SkSL::Context::fConfig
ProgramConfig * fConfig
Definition
SkSLContext.h:33
SkSL::DoStatement::test
std::unique_ptr< Expression > & test()
Definition
SkSLDoStatement.h:57
SkSL::DoStatement::Make
static std::unique_ptr< Statement > Make(const Context &context, Position pos, std::unique_ptr< Statement > stmt, std::unique_ptr< Expression > test)
Definition
SkSLDoStatement.cpp:38
SkSL::DoStatement::Convert
static std::unique_ptr< Statement > Convert(const Context &context, Position pos, std::unique_ptr< Statement > stmt, std::unique_ptr< Expression > test)
Definition
SkSLDoStatement.cpp:20
SkSL::DoStatement::description
std::string description() const override
Definition
SkSLDoStatement.cpp:48
SkSL::DoStatement::statement
std::unique_ptr< Statement > & statement()
Definition
SkSLDoStatement.h:49
SkSL::ErrorReporter::error
void error(Position position, std::string_view msg)
Definition
SkSLErrorReporter.cpp:16
SkSL::Position
Definition
SkSLPosition.h:18
SkSL::Analysis::DetectVarDeclarationWithoutScope
bool DetectVarDeclarationWithoutScope(const Statement &stmt, ErrorReporter *errors=nullptr)
Definition
SkSLAnalysis.cpp:466
SkSL
Definition
SkCapabilities.h:15
test
SkSL::ProgramConfig::strictES2Mode
bool strictES2Mode() const
Definition
SkSLProgramSettings.h:95
Generated on Fri Apr 26 2024 06:17:31 for Flutter Engine by
1.9.8