ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 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 | */ |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 7 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 8 | #ifndef SKSL_CONTEXT |
| 9 | #define SKSL_CONTEXT |
| 10 | |
John Stiles | 030b326 | 2024-01-06 16:18:04 -0500 | [diff] [blame] | 11 | #include "include/private/base/SkAssert.h" |
| 12 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 13 | namespace SkSL { |
| 14 | |
John Stiles | 6cec033 | 2022-08-23 13:15:47 -0400 | [diff] [blame] | 15 | class BuiltinTypes; |
John Stiles | 2dda4b6 | 2021-09-16 13:18:10 -0400 | [diff] [blame] | 16 | class ErrorReporter; |
John Stiles | 86aab38 | 2022-10-14 15:59:46 -0400 | [diff] [blame] | 17 | struct Module; |
John Stiles | 270cec2 | 2021-02-17 12:59:36 -0500 | [diff] [blame] | 18 | struct ProgramConfig; |
John Stiles | dc6a9d9 | 2023-05-04 16:36:04 -0400 | [diff] [blame] | 19 | class SymbolTable; |
John Stiles | dbd4e6f | 2021-02-16 13:29:15 -0500 | [diff] [blame] | 20 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 21 | /** |
John Stiles | dc6a9d9 | 2023-05-04 16:36:04 -0400 | [diff] [blame] | 22 | * Contains compiler-wide objects and state. |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 23 | */ |
| 24 | class Context { |
| 25 | public: |
John Stiles | 8060d6b | 2023-12-19 17:05:44 -0500 | [diff] [blame] | 26 | Context(const BuiltinTypes& types, ErrorReporter& errors); |
John Stiles | 2dda4b6 | 2021-09-16 13:18:10 -0400 | [diff] [blame] | 27 | ~Context(); |
Ethan Nicholas | 624a529f | 2021-04-16 14:54:43 -0400 | [diff] [blame] | 28 | |
John Stiles | 6cec033 | 2022-08-23 13:15:47 -0400 | [diff] [blame] | 29 | // The Context holds a reference to all of the built-in types. |
| 30 | const BuiltinTypes& fTypes; |
Brian Salomon | 2a51de8 | 2016-11-16 12:06:01 -0500 | [diff] [blame] | 31 | |
John Stiles | 270cec2 | 2021-02-17 12:59:36 -0500 | [diff] [blame] | 32 | // The Context holds a pointer to the configuration of the program being compiled. |
| 33 | ProgramConfig* fConfig = nullptr; |
Ethan Nicholas | 8d11654 | 2021-08-11 13:27:16 -0400 | [diff] [blame] | 34 | |
John Stiles | 2dda4b6 | 2021-09-16 13:18:10 -0400 | [diff] [blame] | 35 | // The Context holds a pointer to our error reporter. |
Ethan Nicholas | 313c948 | 2021-08-23 10:35:08 -0400 | [diff] [blame] | 36 | ErrorReporter* fErrors; |
John Stiles | 2dda4b6 | 2021-09-16 13:18:10 -0400 | [diff] [blame] | 37 | |
John Stiles | 030b326 | 2024-01-06 16:18:04 -0500 | [diff] [blame] | 38 | void setErrorReporter(ErrorReporter* e) { |
| 39 | SkASSERT(e); |
| 40 | fErrors = e; |
| 41 | } |
| 42 | |
John Stiles | 80313c3 | 2022-10-14 15:23:32 -0400 | [diff] [blame] | 43 | // The Context holds a pointer to our module with built-in declarations. |
John Stiles | 86aab38 | 2022-10-14 15:59:46 -0400 | [diff] [blame] | 44 | const Module* fModule = nullptr; |
John Stiles | dc6a9d9 | 2023-05-04 16:36:04 -0400 | [diff] [blame] | 45 | |
| 46 | // This is the current symbol table of the code we are processing, and therefore changes during |
| 47 | // compilation. |
John Stiles | e6386f3 | 2024-01-16 09:59:52 -0500 | [diff] [blame] | 48 | SymbolTable* fSymbolTable = nullptr; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame] | 51 | } // namespace SkSL |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 52 | |
| 53 | #endif |