Flutter Engine
The Flutter Engine
SkSLAddConstToVarModifiers.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2022 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
14
15namespace SkSL {
16
17class Expression;
18
20 const Expression* initialValue,
21 const ProgramUsage* usage) {
22 // If the variable is already marked as `const`, keep our existing modifiers.
24 if (flags.isConst()) {
25 return flags;
26 }
27 // If the variable doesn't have a compile-time-constant initial value, we can't `const` it.
28 if (!initialValue || !Analysis::IsCompileTimeConstant(*initialValue)) {
29 return flags;
30 }
31 // This only works for variables that are written-to a single time.
33 if (counts.fWrite != 1) {
34 return flags;
35 }
36 // Add `const` to our variable's modifier flags, making it eligible for constant-folding.
38}
39
40} // namespace SkSL
ModifierFlags modifierFlags() const
Definition: SkSLVariable.h:89
FlutterSemanticsFlag flags
bool IsCompileTimeConstant(const Expression &expr)
ModifierFlags AddConstToVarModifiers(const Variable &var, const Expression *initialValue, const ProgramUsage *usage)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core counts
Definition: switches.h:239
static void usage(char *argv0)