From 3e74d39f24fdfaa547ce900be177863e2bfe2dea Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 16 Oct 2018 18:49:11 -0400 Subject: Feature/include refactor (#675) * Refactor of path handling. * Added PathInfo * Changed ISlangFileSystem - such that has separate concepts of reading a file, getting a relative path and getting a canonical path * Added support for getting a canonical path for windows/linux * Made maps/testing around canonicalPaths * User output remains around 'foundPath' - which is the same as before * Small improvements around PathInfo * Added a type and make constructors to make clear the different 'path' uses * Fixed bug in findViewRecursively * Checking and reporting for ignored #pragma once. * Removed SLANG_PATH_TYPE_NONE as doesn't serve any useful purpose. * Improve comments in slang.h aroung ISlangFileSystem * Remove the need for in slang-io.cpp * Ran premake5. * Improvements and fixes around PathInfo. * Fix typo on linix GetCanonical * Make the ISlangFileSystem the same as before, and ISlangFileSystem contain the new methods. Internally it always uses the ISlangFileSystemExt, and will wrap a ISlangFileSystem with WrapFileSystem, if it is determined (via queryInterface) that it doesn't implement the full interface. --- source/slang/emit.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source/slang/emit.cpp') diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index c306186fb..4961518f1 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -541,7 +541,7 @@ struct EmitVisitor emitRawText(buffer); // Only emit the path part of a `#line` directive if needed - if(sourceLocation.path != context->shared->loc.path) + if(sourceLocation.pathInfo.foundPath != context->shared->loc.pathInfo.foundPath) { emitRawText(" "); @@ -578,7 +578,7 @@ struct EmitVisitor if(shouldUseGLSLStyleLineDirective) { - auto path = sourceLocation.path; + auto path = sourceLocation.pathInfo.foundPath; // GLSL doesn't support the traditional form of a `#line` directive without // an extension. Rather than depend on that extension we will output @@ -609,7 +609,8 @@ struct EmitVisitor // in a module that tracks source files. emitRawText("\""); - for(auto c : sourceLocation.path) + const auto& path = sourceLocation.pathInfo.foundPath; + for(auto c : path) { char charBuffer[] = { c, 0 }; switch(c) @@ -673,7 +674,7 @@ struct EmitVisitor // a differnet file or line, *or* if the source location is // somehow later on the line than what we want to emit, // then we need to emit a new `#line` directive. - if(sourceLocation.path != context->shared->loc.path + if(sourceLocation.pathInfo.foundPath != context->shared->loc.pathInfo.foundPath || sourceLocation.line != context->shared->loc.line || sourceLocation.column < context->shared->loc.column) { @@ -682,7 +683,7 @@ struct EmitVisitor // to get us caught up. enum { kSmallLineCount = 3 }; auto lineDiff = sourceLocation.line - context->shared->loc.line; - if(sourceLocation.path == context->shared->loc.path + if(sourceLocation.pathInfo.foundPath == context->shared->loc.pathInfo.foundPath && sourceLocation.line > context->shared->loc.line && lineDiff <= kSmallLineCount) { -- cgit v1.2.3