yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
eaa8dcfcc
master
1#pragma once 2 3#include "compiler-core/slang-lexer.h" 4#include "diagnostics.h" 5#include "identifier-lookup.h" 6#include "node.h" 7 8namespace CppParse 9{ 10using namespace Slang ; 11 12class TypeSet :public RefObject 13{ 14public : 15/// This is the looked up name. 16UnownedStringSlice 17m_macroName ;///< The name extracted from the macro SLANG_ABSTRACT_AST_CLASS -> AST 18 19String m_typeName ;///< The enum type name associated with this type for AST it is ASTNode 20String m_fileMark ;///< This 'mark' becomes of the output filename 21 22List < ClassLikeNode *> m_baseTypes ;///< The base types for this type set 23}; 24 25class SourceOrigin :public RefObject 26{ 27public : 28void addNode (Node * node ) 29 { 30if (auto classLike = as < ClassLikeNode > (node )) 31 { 32SLANG_ASSERT (classLike -> m_origin == nullptr ); 33classLike -> m_origin = this ; 34 } 35 36m_nodes .add (node ); 37 } 38 39SourceOrigin (SourceFile * sourceFile ,const String & macroOrigin ) 40 :m_sourceFile (sourceFile ),m_macroOrigin (macroOrigin ) 41 { 42 } 43 44String m_macroOrigin ;///< The macro text is inserted into the macro to identify the origin. It 45///< is based on the filename 46SourceFile * m_sourceFile ;///< The source file - also holds the path information 47 48/// All of the nodes defined in this file in the order they were defined 49/// Note that the same namespace may be listed multiple times. 50List < RefPtr < Node >>m_nodes ; 51}; 52 53struct Options ; 54class IdentifierLookup ; 55 56/* NodeTree holds nodes that have been parsed into a tree rooted on the 'rootNode'. 57Also contains other state associated with or useful to a node tree */ 58class NodeTree 59{ 60public : 61friend class Parser ; 62/// Get all of the parsed source origins 63const List < RefPtr < SourceOrigin >>& getSourceOrigins ()const {return m_sourceOrigins ; } 64 65TypeSet * getTypeSet (const UnownedStringSlice & slice ); 66TypeSet * getOrAddTypeSet (const UnownedStringSlice & slice ); 67 68SourceOrigin * addSourceOrigin (SourceFile * sourceFile ,const Options & options ); 69 70/// Get all of the type sets 71const List < RefPtr < TypeSet >>& getTypeSets ()const {return m_typeSets ; } 72 73/// Get the root node 74Node * getRootNode ()const {return m_rootNode ; } 75 76/// When parsing we don't lookup all up super types/add derived types. This is because 77/// we allow files to be processed in any order, so we have to do the type lookup as a separate 78/// operation 79SlangResult calcDerivedTypes (DiagnosticSink * sink ); 80 81NodeTree (StringSlicePool * typePool ,NamePool * namePool ,IdentifierLookup * identifierLookup ); 82 83static String calcMacroOrigin (const String & filePath ,const Options & options ); 84 85protected : 86SlangResult _calcDerivedTypesRec (ScopeNode * node ,DiagnosticSink * sink ); 87 88StringSlicePool m_typeSetPool ;///< Pool for type set names 89List < RefPtr < TypeSet >>m_typeSets ;///< The type sets 90 91IdentifierLookup * m_identifierLookup ; 92StringSlicePool * m_typePool ;///< Pool for just types 93 94NamePool * m_namePool ; 95 96RefPtr < ScopeNode > m_rootNode ;///< The root scope 97 98List < RefPtr < SourceOrigin >>m_sourceOrigins ; 99}; 100 101}// namespace CppParse