Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: src/sksl/SkSLCompiler.h

Issue 1984363002: initial checkin of SkSL compiler (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fixed CMake build Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sksl/SkSLCodeGenerator.h ('k') | src/sksl/SkSLCompiler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/sksl/SkSLCompiler.h
diff --git a/src/sksl/SkSLCompiler.h b/src/sksl/SkSLCompiler.h
new file mode 100644
index 0000000000000000000000000000000000000000..2209427eef058b17107d9ba302f6590a2ac1e0ab
--- /dev/null
+++ b/src/sksl/SkSLCompiler.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SKSL_COMPILER
+#define SKSL_COMPILER
+
+#include <vector>
+#include "ir/SkSLProgram.h"
+#include "ir/SkSLSymbolTable.h"
+#include "SkSLErrorReporter.h"
+
+namespace SkSL {
+
+class IRGenerator;
+
+/**
+ * Main compiler entry point. This is a traditional compiler design which first parses the .sksl
+ * file into an abstract syntax tree (a tree of ASTNodes), then performs semantic analysis to
+ * produce a Program (a tree of IRNodes), then feeds the Program into a CodeGenerator to produce
+ * compiled output.
+ */
+class Compiler : public ErrorReporter {
+public:
+ Compiler();
+
+ ~Compiler();
+
+ std::unique_ptr<Program> convertProgram(Program::Kind kind, std::string text);
+
+ bool toSPIRV(Program::Kind kind, std::string text, std::ostream& out);
+
+ bool toSPIRV(Program::Kind kind, std::string text, std::string* out);
+
+ void error(Position position, std::string msg) override;
+
+ std::string errorText();
+
+ void writeErrorCount();
+
+private:
+
+ void internalConvertProgram(std::string text,
+ std::vector<std::unique_ptr<ProgramElement>>* result);
+
+ std::shared_ptr<SymbolTable> fTypes;
+ IRGenerator* fIRGenerator;
+ std::string fSkiaVertText; // FIXME store parsed version instead
+
+ int fErrorCount;
+ std::string fErrorText;
+};
+
+} // namespace
+
+#endif
« no previous file with comments | « src/sksl/SkSLCodeGenerator.h ('k') | src/sksl/SkSLCompiler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698