summaryrefslogtreecommitdiff
path: root/source/slang/compiler.h
diff options
context:
space:
mode:
authorTim Foley <tim.foley.is@gmail.com>2017-08-10 15:25:04 -0700
committerGitHub <noreply@github.com>2017-08-10 15:25:04 -0700
commitdb4079f7e3635a6a61b8725643b1d7ecf68b97d8 (patch)
tree224c16ad374c5ed533a497beeb75753e7ce2d771 /source/slang/compiler.h
parent6e4830f4d74adef0a47c6503d84dc114240fafa3 (diff)
parenta5a436c4783fb75a0d089a6483219c06db91f593 (diff)
Merge pull request #156 from tfoleyNV/source-file-cleanup
Make source location lightweight
Diffstat (limited to 'source/slang/compiler.h')
-rw-r--r--source/slang/compiler.h45
1 files changed, 27 insertions, 18 deletions
diff --git a/source/slang/compiler.h b/source/slang/compiler.h
index fd40a62f6..5a6cb5c19 100644
--- a/source/slang/compiler.h
+++ b/source/slang/compiler.h
@@ -122,17 +122,7 @@ namespace Slang
// GLSL, // pass through GLSL to `glslang` library
};
- // Represents a single source file (either an on-disk file, or a
- // "virtual" file passed in as a string)
- class SourceFile : public RefObject
- {
- public:
- // The file path for a real file, or the nominal path for a virtual file
- String path;
-
- // The actual contents of the file
- String content;
- };
+ class SourceFile;
// A single translation unit requested to be compiled.
//
@@ -228,6 +218,10 @@ namespace Slang
// Are we being driven by the command-line `slangc`, and should act accordingly?
bool isCommandLineCompile = false;
+ // Source manager to help track files loaded
+ SourceManager sourceManagerStorage;
+ SourceManager* sourceManager;
+
// Output stuff
DiagnosticSink mSink;
String mDiagnosticOutput;
@@ -250,12 +244,9 @@ namespace Slang
Dictionary<String, RefPtr<ModuleDecl>> mapNameToLoadedModules;
- CompileRequest(Session* session)
- : mSession(session)
- {}
+ CompileRequest(Session* session);
- ~CompileRequest()
- {}
+ ~CompileRequest();
void parseTranslationUnit(
TranslationUnitRequest* translationUnit);
@@ -267,6 +258,10 @@ namespace Slang
int addTranslationUnit(SourceLanguage language, String const& name);
+ void addTranslationUnitSourceFile(
+ int translationUnitIndex,
+ SourceFile* sourceFile);
+
void addTranslationUnitSourceString(
int translationUnitIndex,
String const& path,
@@ -285,7 +280,7 @@ namespace Slang
String const& name,
String const& path,
String const& source,
- CodePosition const& loc);
+ SourceLoc const& loc);
void handlePoundImport(
String const& path,
@@ -293,7 +288,18 @@ namespace Slang
RefPtr<ModuleDecl> findOrImportModule(
String const& name,
- CodePosition const& loc);
+ SourceLoc const& loc);
+
+ SourceManager* getSourceManager()
+ {
+ return sourceManager;
+ }
+
+ void setSourceManager(SourceManager* sm)
+ {
+ sourceManager = sm;
+ mSink.sourceManager = sm;
+ }
};
void generateOutput(
@@ -324,6 +330,9 @@ namespace Slang
List<RefPtr<ModuleDecl>> loadedModuleCode;
+ SourceManager builtinSourceManager;
+
+ SourceManager* getBuiltinSourceManager() { return &builtinSourceManager; }
//