From 327f2b7ec50a7480b458d6d3ba8e2ca7fcdb8498 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 20 Jun 2017 08:11:27 -0700 Subject: Overhaul handling of entry points and translation units. The main user-visible change here is that instead of `spAddTranslationUnitEntryPoint` we have `spAddEntryPoint`, to reflect that the list of entry points is "global" to a compile request. As a result, `spGetEntryPointSource` now only needs the entry point index, and not the translation unit index. There are a bunch more behind-the-scenes changes, though, reflecting a streamlining of the concepts related to compilation into a smaller number of classes. Now there is: - `Session` (unchanged) to manage the lifetimes of shared stuff like the stdlib - `CompileRequest` (merges in `CompileOptions`) to handle all the lifetime related to a single invocation of the compiler - `TranslationUnitRequest` (merges `TranslationUnitOptions`, `CompileUnit`) to represent a single translation unit ("module") that the user is trying to compile. This is a single file for HLSL/GLSL, but can be multiple files for Slang. - `EntryPointRequest` (merges `EntryPointOption` and a bit of `EntryPointResult`) to track a single entry point that the user is asking to compile (that entry point always comes from a single translation unit) A lot of functions used to take some combination of these and end up with really long signatures. I've given most of the objects "parent" pointers so that they can get back to all the context they need, so most functions don't need as many parameters. It may eventually be important to tease these apart again, in particular: - The code-generation side of things (the `*Result` types) might need to be pulled out in case we want to codegen multiple times from the same AST - Similarly, the layout stuff may also need to be pulled out, in case we want to lay things out multiple times with different rules. --- source/slang/check.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'source/slang/check.cpp') diff --git a/source/slang/check.cpp b/source/slang/check.cpp index f79df0c40..128afcefe 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -46,27 +46,25 @@ namespace Slang { ProgramSyntaxNode * program = nullptr; FunctionSyntaxNode * function = nullptr; - CompileOptions const* options = nullptr; - TranslationUnitOptions const* translationUnitOptions = nullptr; + CompileRequest* request = nullptr; + TranslationUnitRequest* translationUnit = nullptr; // lexical outer statements List outerStmts; public: SemanticsVisitor( DiagnosticSink * pErr, - CompileOptions const& options, - TranslationUnitOptions const& translationUnitOptions, - CompileRequest* request) + CompileRequest* request, + TranslationUnitRequest* translationUnit) : SyntaxVisitor(pErr) - , options(&options) - , translationUnitOptions(&translationUnitOptions) , request(request) + , translationUnit(translationUnit) { } - CompileOptions const& getOptions() { return *options; } - TranslationUnitOptions const& getTranslationUnitOptions() { return *translationUnitOptions; } + CompileRequest* getCompileRequest() { return request; } + TranslationUnitRequest* getTranslationUnit() { return translationUnit; } public: // Translate Types @@ -969,7 +967,7 @@ namespace Slang // expressions without a type, and we need to ignore them. if( !fromExpr->Type.type ) { - if(getTranslationUnitOptions().compileFlags & SLANG_COMPILE_FLAG_NO_CHECKING ) + if(getTranslationUnit()->compileFlags & SLANG_COMPILE_FLAG_NO_CHECKING ) return fromExpr; } @@ -981,7 +979,7 @@ namespace Slang fromExpr.Ptr(), nullptr)) { - if(!(getTranslationUnitOptions().compileFlags & SLANG_COMPILE_FLAG_NO_CHECKING)) + if(!(getTranslationUnit()->compileFlags & SLANG_COMPILE_FLAG_NO_CHECKING)) { getSink()->diagnose(fromExpr->Position, Diagnostics::typeMismatch, toType, fromExpr->Type); } @@ -4967,12 +4965,11 @@ namespace Slang }; SyntaxVisitor* CreateSemanticsVisitor( - DiagnosticSink* err, - CompileOptions const& options, - TranslationUnitOptions const& translationUnitOptions, - CompileRequest* request) + DiagnosticSink* err, + CompileRequest* request, + TranslationUnitRequest* translationUnit) { - return new SemanticsVisitor(err, options, translationUnitOptions, request); + return new SemanticsVisitor(err, request, translationUnit); } // -- cgit v1.2.3