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