diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-07 19:09:40 -0500 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-11-07 16:09:40 -0800 |
| commit | 6e591ada0eb652c320bba4bd8a46cd579946df01 (patch) | |
| tree | 768229fb26204b6b0a89201d9b14c32e9203c098 /source/slang/slang.cpp | |
| parent | 939688e963fde7a0485f210ef2674c27692021a4 (diff) | |
Support generic interface methods (#251)
* improve diagnostic messages and prevent fatal errors from crashing the compiler.
* fix top level exception catching.
* spelling fix
* change wording of invalidSwizzleExpr diagnostic
* add speculative GenericsApp expr parsing
* add new test case of cascading generics call.
* Fixing bugs in compiling cascaded generic function calls.
Add implementation of DeclaredSubTypeWitness::SubstituteImpl()
This is not needed by the type checker, but needed by IR specialization. When input source contains cascading generic function call, the arguments to `specialize` instruction is currently represented as a substitution. The arg values of this subsittution can be a `DeclaredSubTypeWitness` when a generic function uses one of its generic parameter to specialize another generic function. When the top level generics function is being specialized, this substitution argument, which is a `DeclaredSubTypeWitness`, needs to be substituted with the witness that used to specialize the top level function in the specialized specialize instruction as well.
* add a test case for cascading generic function call.
* parser bug fix
* fixes #255
* add test case for issue #255
* Generate missing `specialize` instruction when calling a generic method from an interface constraint.
When calling a generic method via an interface, we should be generating the following ir:
...
f = lookup_interface_method(...)
f_s = specailize(f, declRef)
...
This commit fixes this `emitFuncRef` function to emit the needed `specialize` instruction.
* fixes #260
This fix follows the second apporach in the disucssion. It generated mangled name for specialized functions by appending new substitution type names to the original mangled name.
* Disabling removing and re-inserting specailized functions in getSpecalizeFunc()
I am not sure why it is needed, it seems HLSL and GLSL backends are generating forward declarations anyways, so the order of functions in IRModule shouldn't matter.
* cleanup and complete test cases.
* fix warnings
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 1cda8e7d0..fe24fbd19 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -246,13 +246,13 @@ int CompileRequest::executeActionsInner() // Do some cleanup on settings specified by user. // In particular, we want to propagate flags from the overall request down to // each translation unit. - for( auto& translationUnit : translationUnits ) + for (auto& translationUnit : translationUnits) { translationUnit->compileFlags |= compileFlags; // However, the "no checking" flag shouldn't be applied to // any translation unit that is native Slang code. - if( translationUnit->sourceLanguage == SourceLanguage::Slang ) + if (translationUnit->sourceLanguage == SourceLanguage::Slang) { translationUnit->compileFlags &= ~SLANG_COMPILE_FLAG_NO_CHECKING; } @@ -282,7 +282,7 @@ int CompileRequest::executeActionsInner() // a pass-through compilation. // // Note that we *do* perform output generation as normal in pass-through mode. - if( passThrough == PassThroughMode::None ) + if (passThrough == PassThroughMode::None) { // Parse everything from the input files requested for (auto& translationUnit : translationUnits) @@ -316,7 +316,7 @@ int CompileRequest::executeActionsInner() return 1; } } - + // If command line specifies to skip codegen, we exit here. // Note: this is a debugging option. if (shouldSkipCodegen) @@ -901,7 +901,7 @@ SLANG_API int spCompile( { auto req = REQ(request); -#if 0 +#if !defined(SLANG_DEBUG_INTERNAL_ERROR) // By default we'd like to catch as many internal errors as possible, // and report them to the user nicely (rather than just crash their // application). Internally Slang currently uses exceptions for this. |
