From 879ec1b385d290a4375682ec613a9e7a1967fc7d Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 10 Oct 2018 13:56:25 -0400 Subject: Feature/source loc refactor (#668) * * Remove the need for IRHighLevelDecoration in Emit * Use the IRLayoutDecoration for GeometryShaderPrimitiveTypeModifier * Initial look at at variable byte encoding, and simple unit test. * Fixing problems with comparison due to naming differences with slang/fxc. * * More tests and perf improvements for byte encoding. * Mechanism to detect processor and processor features in main slang header. * Split out cpu based defines into slang-cpu-defines.h so do not polute slang.h * Support for variable byte encoding on serialization. * Removed unused flag. * Fix warning. * Fix calcMsByte32 for 0 values without using intrinsic. * Fix a mistake in calculating maximum instruction size. * Introduced the idea of SourceUnit. * Small improvements around naming. Add more functionality - including getting the HumaneLoc. * Add support for #line default * Compiling with new SourceLoc handling. * Fix off by one on #line directives. * Can use 32bits for SourceLoc. Fix serialize to use that. * Small fixes and comment on usage. * Premake run. * Fix signed warning. * Fix typo on StringSlicePool::has found in review. --- source/slang/lexer.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'source/slang/lexer.h') diff --git a/source/slang/lexer.h b/source/slang/lexer.h index 1f2954d27..46d2aa227 100644 --- a/source/slang/lexer.h +++ b/source/slang/lexer.h @@ -73,7 +73,7 @@ namespace Slang struct Lexer { void initialize( - SourceFile* sourceFile, + SourceUnit* sourceUnit, DiagnosticSink* sink, NamePool* namePool); @@ -83,15 +83,7 @@ namespace Slang TokenList lexAllTokens(); - // Begin overriding the reported locations of tokens, - // based on a `#line` directives - void startOverridingSourceLocations(SourceLoc loc); - - // Stop overriding source locations, and go back - // to reporting source locations in the original file - void stopOverridingSourceLocations(); - - SourceFile* sourceFile; + SourceUnit* sourceUnit; DiagnosticSink* sink; NamePool* namePool; @@ -100,13 +92,16 @@ namespace Slang char const* begin; char const* end; + /// The starting sourceLoc (same as first location of SourceUnit) + SourceLoc startLoc; + // The starting source location for the code as written, // which cannot be overridden. - SourceLoc spellingStartLoc; + //SourceLoc spellingStartLoc; // The nominal starting location for the file, taking // any active `#line` directive into account. - SourceLoc presumedStartLoc; + //SourceLoc presumedStartLoc; TokenFlags tokenFlags; LexerFlags lexerFlags; -- cgit v1.2.3