From c16abd4fe1bda5ebcd50dbb22f30c6be43bb885f Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 7 May 2020 15:00:33 -0400 Subject: Enhanced C++ extractor (#1340) * Extractor builds without any reference to syntax (as it will be helping to produce this!). * Change macros to include the super class. * Added indexOf(const UnownedSubString& in) to UnownedSubString. Refactored extractor * Output a macro for each type with the extracted info - can be used during injection in class * Simplify the header file - as can get super type and last from macro now * Store the 'origin' of a definition * Some small tidy ups to the extractor. * Improve comments on the extractor options. * Made CPPExtractor own SourceOrigins * Small fixes around SourceOrigin. * Small tidy up around macroOrign --- source/slang/slang-syntax.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-syntax.cpp') diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp index 334273870..2055c2422 100644 --- a/source/slang/slang-syntax.cpp +++ b/source/slang/slang-syntax.cpp @@ -74,6 +74,7 @@ ABSTRACT_SYNTAX_CLASS(GlobalGenericParamSubstitution, Substitutions); #include "slang-val-defs.h" #include "slang-object-meta-end.h" + SyntaxClassBase::ClassInfo::ClassInfo(const char* name, CreateFunc createFunc, const ClassInfo* superClass): m_name(name), m_createFunc(createFunc), @@ -184,7 +185,48 @@ static bool _checkSubClassRange() return SLANG_OK; } - // Free functions +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!! DiagnosticSink impls !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +void printDiagnosticArg(StringBuilder& sb, Decl* decl) +{ + sb << getText(decl->getName()); +} + +void printDiagnosticArg(StringBuilder& sb, Type* type) +{ + sb << type->ToString(); +} + +void printDiagnosticArg(StringBuilder& sb, Val* val) +{ + sb << val->ToString(); +} + +void printDiagnosticArg(StringBuilder& sb, TypeExp const& type) +{ + sb << type.type->ToString(); +} + +void printDiagnosticArg(StringBuilder& sb, QualType const& type) +{ + if (type.type) + sb << type.type->ToString(); + else + sb << ""; +} + +SourceLoc const& getDiagnosticPos(SyntaxNode const* syntax) +{ + return syntax->loc; +} + +SourceLoc const& getDiagnosticPos(TypeExp const& typeExp) +{ + return typeExp.exp->loc; +} + + +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!! Free functions !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! const RefPtr* adjustFilterCursorImpl(const SyntaxClassBase::ClassInfo& clsInfo, MemberFilterStyle filterStyle, const RefPtr* ptr, const RefPtr* end) { -- cgit v1.2.3