xref: /aosp_15_r20/external/skia/src/sksl/SkSLContext.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2016 Google Inc.
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 #ifndef SKSL_CONTEXT
9 #define SKSL_CONTEXT
10 
11 #include "include/private/base/SkAssert.h"
12 
13 namespace SkSL {
14 
15 class BuiltinTypes;
16 class ErrorReporter;
17 struct Module;
18 struct ProgramConfig;
19 class SymbolTable;
20 
21 /**
22  * Contains compiler-wide objects and state.
23  */
24 class Context {
25 public:
26     Context(const BuiltinTypes& types, ErrorReporter& errors);
27     ~Context();
28 
29     // The Context holds a reference to all of the built-in types.
30     const BuiltinTypes& fTypes;
31 
32     // The Context holds a pointer to the configuration of the program being compiled.
33     ProgramConfig* fConfig = nullptr;
34 
35     // The Context holds a pointer to our error reporter.
36     ErrorReporter* fErrors;
37 
setErrorReporter(ErrorReporter * e)38     void setErrorReporter(ErrorReporter* e) {
39         SkASSERT(e);
40         fErrors = e;
41     }
42 
43     // The Context holds a pointer to our module with built-in declarations.
44     const Module* fModule = nullptr;
45 
46     // This is the current symbol table of the code we are processing, and therefore changes during
47     // compilation.
48     SymbolTable* fSymbolTable = nullptr;
49 };
50 
51 }  // namespace SkSL
52 
53 #endif
54