summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-11-05 13:43:00 -0500
committerGitHub <noreply@github.com>2020-11-05 13:43:00 -0500
commitc985f5f2f95dc95998fdfb8400baa0a04760ada2 (patch)
treef79ba0576dd4f85c284f3c300a42d79964413796 /tools
parent8d4c0ea875b186648ff75b4f04891ba8f1286aac (diff)
Standard library save/loadable (#1592)
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix handling of access modifiers inside type definition. * Fix access problem for AST node. Make dumping produce a single function with switch, to potentially make available without Dump specific access. * WIP on serialization design doc. * Remove project references to previously generated files. * More docs on serialization design. * Improve serialization documentation. Remove unused function from IRSerialReader. * Small fixes around naming. Remove long comment from slang-serialize.h - as covered in serialization.md * Remove long comment in slang-serialize.h as covered in serialization.md * More information about doing replacements on read for AST and problems surrounding. * Typo fix. * Spelling fixes. * Value serialize. * Value types with inheritence. * Use value reflection serial conversion for more AST types * Use automatic serialization on more of AST. * Get the types via decltype, simplifies what the extractor has to do. * Update the serialization.md for the value serialization. * Small doc improvements. * Update project. * Remove ImportExternalDecl type Added addImportSymbol and ImportSymbol type Fixed bug in container which meant it wouldn't read back AST module * Because of change of how imports and handled, store objects as SerialPointers. * First pass symbol lookup from mangled names. * Cache current module looked up from mangled name. * Fix SourceLoc bug. Improve comments. * Added diagnostic on mangled symbol not being found * Fix typo. * WIP serializing stdlib. * WIP serializing stdlib in. * Fix problem serializing arrays that hold data that is already serialized. * Remove clash of names in MagicTypeModifier. * Make conversion from char to String explicit. Fix reference count issue with SerialReader. * Add code to save/load stdlib. * Use return code to avoid warning - SerialContainerUtil::write(module, options, &stream)) * Make all String numeric ctors explicit. Added isChar to UnownedStringSlice. Added operator== for UnownedStringSlice to String to avoid need to convert to String and allocate. * Add error check to readAllText. * tabs -> spaces on String.h * tab -> spaces String.cpp * Remove msg for StringBuilder, just build inplace for exceptions. * Check SerialClasses - for name clashes. Renamed Modifier::name as Modifier::keywordName * Handling of extensions when deserializing AST - updating the moduleDecl->mapTypeToCandidateExtensions Co-authored-by: Tim Foley <tim.foley.is@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/render-test/shader-input-layout.cpp18
-rw-r--r--tools/slang-generate/main.cpp22
2 files changed, 22 insertions, 18 deletions
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index 6ded388e8..6c6f67c86 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -273,17 +273,17 @@ namespace renderer_test
SlangScalarType scalarType = _getScalarType(type.getUnownedSlice());
if (scalarType == SLANG_SCALAR_TYPE_NONE)
{
- StringBuilder builder;
+ StringBuilder scalarTypeNames;
for (const auto& info : g_scalarTypeInfos)
{
- if (builder.getLength() != 0)
+ if (scalarTypeNames.getLength() != 0)
{
- builder << ", ";
+ scalarTypeNames << ", ";
}
- builder << info.name;
+ scalarTypeNames << info.name;
}
- throw TextFormatException("Expecting " + builder + " " + parser.NextToken().Position.Line);
+ throw TextFormatException(StringBuilder() << "Expecting " << scalarTypeNames << " " << parser.NextToken().Position.Line);
}
parser.Read(",");
@@ -549,7 +549,7 @@ namespace renderer_test
Token nameToken = parser.ReadToken();
if (nameToken.Type != TokenType::Identifier)
{
- throw TextFormatException(String("Invalid input syntax at line ") + parser.NextToken().Position.Line);
+ throw TextFormatException(StringBuilder() << "Invalid input syntax at line " << parser.NextToken().Position.Line);
}
builder << nameToken.Content;
@@ -580,7 +580,7 @@ namespace renderer_test
}
else
{
- throw TextFormatException(String("Invalid input syntax at line ") + parser.NextToken().Position.Line);
+ throw TextFormatException(StringBuilder() << "Invalid input syntax at line " << parser.NextToken().Position.Line);
}
}
@@ -606,7 +606,9 @@ namespace renderer_test
}
catch (const TextFormatException&)
{
- throw TextFormatException(String("Invalid input syntax at line ") + parser.NextToken().Position.Line);
+ StringBuilder msg;
+ msg << "Invalid input syntax at line " << parser.NextToken().Position.Line;
+ throw TextFormatException(msg);
}
}
}
diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp
index 700c1bb21..796bbd59d 100644
--- a/tools/slang-generate/main.cpp
+++ b/tools/slang-generate/main.cpp
@@ -690,37 +690,39 @@ void usage(char const* appName)
fprintf(stderr, "usage: %s <input>\n", appName);
}
-SlangResult readAllText(char const * fileName, String& stringOut)
+SlangResult readAllText(char const * fileName, String& outString)
{
- FILE * f;
+ FILE* f;
fopen_s(&f, fileName, "rb");
if (!f)
{
- stringOut = "";
+ outString = "";
return SLANG_FAIL;
}
else
{
- stringOut =
fseek(f, 0, SEEK_END);
auto size = ftell(f);
StringRepresentation* stringRep = StringRepresentation::createWithCapacityAndLength(size, size);
- stringOut = String(stringRep);
+ outString = String(stringRep);
+
+ char* buffer = stringRep->getData();
+
+ // Seems unnecessary
+ //memset(buffer, 0, size);
- char * buffer = stringRep->getData();
- memset(buffer, 0, size);
fseek(f, 0, SEEK_SET);
- fread(buffer, sizeof(char), size, f);
+ size_t readCount = fread(buffer, sizeof(char), size, f);
fclose(f);
- return SLANG_OK;
+ return (readCount == size) ? SLANG_OK : SLANG_FAIL;
}
}
void writeAllText(char const *srcFileName, char const* fileName, const char* content)
{
- FILE * f = nullptr;
+ FILE* f = nullptr;
fopen_s(&f, fileName, "wb");
if (!f)
{