blob: 3ecb4ba50e7e3c60c2099e870646b383270c7a56 [file] [log] [blame]
ethannicholasd598f792016-07-25 10:08:54 -07001/*
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 Nicholas0df1b042017-03-31 13:56:23 -04007
ethannicholasd598f792016-07-25 10:08:54 -07008#ifndef SKSL_CONTEXT
9#define SKSL_CONTEXT
10
John Stiles030b3262024-01-06 16:18:04 -050011#include "include/private/base/SkAssert.h"
12
ethannicholasd598f792016-07-25 10:08:54 -070013namespace SkSL {
14
John Stiles6cec0332022-08-23 13:15:47 -040015class BuiltinTypes;
John Stiles2dda4b62021-09-16 13:18:10 -040016class ErrorReporter;
John Stiles86aab382022-10-14 15:59:46 -040017struct Module;
John Stiles270cec22021-02-17 12:59:36 -050018struct ProgramConfig;
John Stilesdc6a9d92023-05-04 16:36:04 -040019class SymbolTable;
John Stilesdbd4e6f2021-02-16 13:29:15 -050020
ethannicholasd598f792016-07-25 10:08:54 -070021/**
John Stilesdc6a9d92023-05-04 16:36:04 -040022 * Contains compiler-wide objects and state.
ethannicholasd598f792016-07-25 10:08:54 -070023 */
24class Context {
25public:
John Stiles8060d6b2023-12-19 17:05:44 -050026 Context(const BuiltinTypes& types, ErrorReporter& errors);
John Stiles2dda4b62021-09-16 13:18:10 -040027 ~Context();
Ethan Nicholas624a529f2021-04-16 14:54:43 -040028
John Stiles6cec0332022-08-23 13:15:47 -040029 // The Context holds a reference to all of the built-in types.
30 const BuiltinTypes& fTypes;
Brian Salomon2a51de82016-11-16 12:06:01 -050031
John Stiles270cec22021-02-17 12:59:36 -050032 // The Context holds a pointer to the configuration of the program being compiled.
33 ProgramConfig* fConfig = nullptr;
Ethan Nicholas8d116542021-08-11 13:27:16 -040034
John Stiles2dda4b62021-09-16 13:18:10 -040035 // The Context holds a pointer to our error reporter.
Ethan Nicholas313c9482021-08-23 10:35:08 -040036 ErrorReporter* fErrors;
John Stiles2dda4b62021-09-16 13:18:10 -040037
John Stiles030b3262024-01-06 16:18:04 -050038 void setErrorReporter(ErrorReporter* e) {
39 SkASSERT(e);
40 fErrors = e;
41 }
42
John Stiles80313c32022-10-14 15:23:32 -040043 // The Context holds a pointer to our module with built-in declarations.
John Stiles86aab382022-10-14 15:59:46 -040044 const Module* fModule = nullptr;
John Stilesdc6a9d92023-05-04 16:36:04 -040045
46 // This is the current symbol table of the code we are processing, and therefore changes during
47 // compilation.
John Stilese6386f32024-01-16 09:59:52 -050048 SymbolTable* fSymbolTable = nullptr;
ethannicholasd598f792016-07-25 10:08:54 -070049};
50
John Stilesa6841be2020-08-06 14:11:56 -040051} // namespace SkSL
ethannicholasd598f792016-07-25 10:08:54 -070052
53#endif