diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-10-20 09:44:48 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-20 09:44:48 -0400 |
| commit | 624809ab356a54dad6cda9ce4d8f881e392d6e97 (patch) | |
| tree | 6286ecc86f8c6e4343aa61cdb646bc019691a4a0 | |
| parent | 9b25d4aa0b6219ce4e4429f9749c7c493531a3cd (diff) | |
Small improvement in AST serialization (#1582)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Make AST serialization types, marker include _AST_. Ie SLANG_CLASS -> SLANG_AST_CLASS and SLANG_ABSTRACT_CLASS -> SLANG_ABSTRACT_AST_CLASS
| -rw-r--r-- | premake5.lua | 2 | ||||
| -rw-r--r-- | source/slang/run-generators.vcxproj | 8 | ||||
| -rw-r--r-- | source/slang/slang-ast-base.h | 30 | ||||
| -rw-r--r-- | source/slang/slang-ast-decl.h | 94 | ||||
| -rw-r--r-- | source/slang/slang-ast-expr.h | 76 | ||||
| -rw-r--r-- | source/slang/slang-ast-modifier.h | 262 | ||||
| -rw-r--r-- | source/slang/slang-ast-reflect.h | 6 | ||||
| -rw-r--r-- | source/slang/slang-ast-stmt.h | 52 | ||||
| -rw-r--r-- | source/slang/slang-ast-type.h | 130 | ||||
| -rw-r--r-- | source/slang/slang-ast-val.h | 26 |
10 files changed, 343 insertions, 343 deletions
diff --git a/premake5.lua b/premake5.lua index 0d3887986..23d7d3e60 100644 --- a/premake5.lua +++ b/premake5.lua @@ -870,7 +870,7 @@ generatorProject("run-generators", "source/slang/") filter "files:**/slang-ast-reflect.h" do local inputFiles = { "slang-ast-base.h", "slang-ast-decl.h", "slang-ast-expr.h", "slang-ast-modifier.h", "slang-ast-stmt.h", "slang-ast-type.h", "slang-ast-val.h" } - runCPPExtractor(sourcePath, "ast", inputFiles, "slang-ast", "ASTNode", "_CLASS") + runCPPExtractor(sourcePath, "ast", inputFiles, "slang-ast", "ASTNode", "_AST_CLASS") end end diff --git a/source/slang/run-generators.vcxproj b/source/slang/run-generators.vcxproj index 56924b0d5..599f221b1 100644 --- a/source/slang/run-generators.vcxproj +++ b/source/slang/run-generators.vcxproj @@ -231,16 +231,16 @@ <FileType>Document</FileType> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"../../bin/windows-x86/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h -strip-prefix slang- -reflect-type Value -o slang-value-generated -output-fields -mark-suffix _VALUE_CLASS "../../bin/windows-x86/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h -strip-prefix slang- -reflect-type RefObject -o slang-ref-object-generated -output-fields -mark-suffix _OBJ_CLASS -"../../bin/windows-x86/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast -reflect-type ASTNode -o slang-ast-generated -output-fields -mark-suffix _CLASS</Command> +"../../bin/windows-x86/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast -reflect-type ASTNode -o slang-ast-generated -output-fields -mark-suffix _AST_CLASS</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"../../bin/windows-x64/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h -strip-prefix slang- -reflect-type Value -o slang-value-generated -output-fields -mark-suffix _VALUE_CLASS "../../bin/windows-x64/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h -strip-prefix slang- -reflect-type RefObject -o slang-ref-object-generated -output-fields -mark-suffix _OBJ_CLASS -"../../bin/windows-x64/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast -reflect-type ASTNode -o slang-ast-generated -output-fields -mark-suffix _CLASS</Command> +"../../bin/windows-x64/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast -reflect-type ASTNode -o slang-ast-generated -output-fields -mark-suffix _AST_CLASS</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"../../bin/windows-x86/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h -strip-prefix slang- -reflect-type Value -o slang-value-generated -output-fields -mark-suffix _VALUE_CLASS "../../bin/windows-x86/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h -strip-prefix slang- -reflect-type RefObject -o slang-ref-object-generated -output-fields -mark-suffix _OBJ_CLASS -"../../bin/windows-x86/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast -reflect-type ASTNode -o slang-ast-generated -output-fields -mark-suffix _CLASS</Command> +"../../bin/windows-x86/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast -reflect-type ASTNode -o slang-ast-generated -output-fields -mark-suffix _AST_CLASS</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"../../bin/windows-x64/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h -strip-prefix slang- -reflect-type Value -o slang-value-generated -output-fields -mark-suffix _VALUE_CLASS "../../bin/windows-x64/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h -strip-prefix slang- -reflect-type RefObject -o slang-ref-object-generated -output-fields -mark-suffix _OBJ_CLASS -"../../bin/windows-x64/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast -reflect-type ASTNode -o slang-ast-generated -output-fields -mark-suffix _CLASS</Command> +"../../bin/windows-x64/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast -reflect-type ASTNode -o slang-ast-generated -output-fields -mark-suffix _AST_CLASS</Command> <Outputs>../slangslang-value-generated.h;../slangslang-value-generated-macro.h;../slangslang-ref-object-generated.h;../slangslang-ref-object-generated-macro.h;../slangslang-ast-generated.h;../slangslang-ast-generated-macro.h</Outputs> <Message>slang-cpp-extractor ref-object %(Identity)</Message> <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">slang-ast-support-types.h;../../bin/windows-x86/debug/slang-cpp-extractor.exe;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h</AdditionalInputs> diff --git a/source/slang/slang-ast-base.h b/source/slang/slang-ast-base.h index 66b7d7c9e..5cbfd1e45 100644 --- a/source/slang/slang-ast-base.h +++ b/source/slang/slang-ast-base.h @@ -18,7 +18,7 @@ namespace Slang class NodeBase { - SLANG_ABSTRACT_CLASS(NodeBase) + SLANG_ABSTRACT_AST_CLASS(NodeBase) // MUST be called before used. Called automatically via the ASTBuilder. // Note that the astBuilder is not stored in the NodeBase derived types by default. @@ -67,7 +67,7 @@ SLANG_FORCE_INLINE const T* as(const NodeBase* node) // (thus having a location in the source code) class SyntaxNodeBase : public NodeBase { - SLANG_ABSTRACT_CLASS(SyntaxNodeBase) + SLANG_ABSTRACT_AST_CLASS(SyntaxNodeBase) // The primary source location associated with this AST node SourceLoc loc; @@ -80,7 +80,7 @@ class SyntaxNodeBase : public NodeBase class Val : public NodeBase { - SLANG_ABSTRACT_CLASS(Val) + SLANG_ABSTRACT_AST_CLASS(Val) typedef IValVisitor Visitor; @@ -132,7 +132,7 @@ SLANG_FORCE_INLINE const T* as(const Type* obj); // operate on the raw representation when needed. class Type: public Val { - SLANG_ABSTRACT_CLASS(Type) + SLANG_ABSTRACT_AST_CLASS(Type) friend struct ASTDumpAccess; @@ -176,7 +176,7 @@ SLANG_FORCE_INLINE const T* as(const Type* obj) { return obj ? dynamicCast<T>(co // type-level variables to concrete argument values class Substitutions: public NodeBase { - SLANG_ABSTRACT_CLASS(Substitutions) + SLANG_ABSTRACT_AST_CLASS(Substitutions) // The next outer that this one refines. Substitutions* outer = nullptr; @@ -196,7 +196,7 @@ class Substitutions: public NodeBase class GenericSubstitution : public Substitutions { - SLANG_CLASS(GenericSubstitution) + SLANG_AST_CLASS(GenericSubstitution) // The generic declaration that defines the // parameters we are binding to arguments @@ -213,7 +213,7 @@ class GenericSubstitution : public Substitutions class ThisTypeSubstitution : public Substitutions { - SLANG_CLASS(ThisTypeSubstitution) + SLANG_AST_CLASS(ThisTypeSubstitution) // The declaration of the interface that we are specializing InterfaceDecl* interfaceDecl = nullptr; @@ -231,7 +231,7 @@ class ThisTypeSubstitution : public Substitutions class GlobalGenericParamSubstitution : public Substitutions { - SLANG_CLASS(GlobalGenericParamSubstitution) + SLANG_AST_CLASS(GlobalGenericParamSubstitution) // the type_param decl to be substituted GlobalGenericParamDecl* paramDecl = nullptr; @@ -255,7 +255,7 @@ class GlobalGenericParamSubstitution : public Substitutions class SyntaxNode : public SyntaxNodeBase { - SLANG_ABSTRACT_CLASS(SyntaxNode); + SLANG_ABSTRACT_AST_CLASS(SyntaxNode); }; // @@ -265,7 +265,7 @@ class SyntaxNode : public SyntaxNodeBase // class Modifier : public SyntaxNode { - SLANG_ABSTRACT_CLASS(Modifier) + SLANG_ABSTRACT_AST_CLASS(Modifier) typedef IModifierVisitor Visitor; void accept(IModifierVisitor* visitor, void* extra); @@ -283,7 +283,7 @@ class Modifier : public SyntaxNode // A syntax node which can have modifiers applied class ModifiableSyntaxNode : public SyntaxNode { - SLANG_ABSTRACT_CLASS(ModifiableSyntaxNode) + SLANG_ABSTRACT_AST_CLASS(ModifiableSyntaxNode) Modifiers modifiers; @@ -305,7 +305,7 @@ class ModifiableSyntaxNode : public SyntaxNode // An intermediate type to represent either a single declaration, or a group of declarations class DeclBase : public ModifiableSyntaxNode { - SLANG_ABSTRACT_CLASS(DeclBase) + SLANG_ABSTRACT_AST_CLASS(DeclBase) typedef IDeclVisitor Visitor; @@ -315,7 +315,7 @@ class DeclBase : public ModifiableSyntaxNode class Decl : public DeclBase { public: - SLANG_ABSTRACT_CLASS(Decl) + SLANG_ABSTRACT_AST_CLASS(Decl) ContainerDecl* parentDecl = nullptr; @@ -341,7 +341,7 @@ public: class Expr : public SyntaxNode { - SLANG_ABSTRACT_CLASS(Expr) + SLANG_ABSTRACT_AST_CLASS(Expr) typedef IExprVisitor Visitor; @@ -352,7 +352,7 @@ class Expr : public SyntaxNode class Stmt : public ModifiableSyntaxNode { - SLANG_ABSTRACT_CLASS(Stmt) + SLANG_ABSTRACT_AST_CLASS(Stmt) typedef IStmtVisitor Visitor; diff --git a/source/slang/slang-ast-decl.h b/source/slang/slang-ast-decl.h index bd7d3a4f1..4210318dc 100644 --- a/source/slang/slang-ast-decl.h +++ b/source/slang/slang-ast-decl.h @@ -11,7 +11,7 @@ namespace Slang { // A group of declarations that should be treated as a unit class DeclGroup: public DeclBase { - SLANG_CLASS(DeclGroup) + SLANG_AST_CLASS(DeclGroup) List<Decl*> decls; }; @@ -20,7 +20,7 @@ class DeclGroup: public DeclBase // A "container" decl is a parent to other declarations class ContainerDecl: public Decl { - SLANG_ABSTRACT_CLASS(ContainerDecl) + SLANG_ABSTRACT_AST_CLASS(ContainerDecl) List<Decl*> members; @@ -54,7 +54,7 @@ class ContainerDecl: public Decl // Base class for all variable declarations class VarDeclBase : public Decl { - SLANG_ABSTRACT_CLASS(VarDeclBase) + SLANG_ABSTRACT_AST_CLASS(VarDeclBase) // type of the variable TypeExp type; @@ -68,13 +68,13 @@ class VarDeclBase : public Decl // Ordinary potentially-mutable variables (locals, globals, and member variables) class VarDecl : public VarDeclBase { - SLANG_CLASS(VarDecl) + SLANG_AST_CLASS(VarDecl) }; // A variable declaration that is always immutable (whether local, global, or member variable) class LetDecl : public VarDecl { - SLANG_CLASS(LetDecl) + SLANG_AST_CLASS(LetDecl) }; // An `AggTypeDeclBase` captures the shared functionality @@ -87,13 +87,13 @@ class LetDecl : public VarDecl // class AggTypeDeclBase : public ContainerDecl { - SLANG_ABSTRACT_CLASS(AggTypeDeclBase); + SLANG_ABSTRACT_AST_CLASS(AggTypeDeclBase); }; // An extension to apply to an existing type class ExtensionDecl : public AggTypeDeclBase { - SLANG_CLASS(ExtensionDecl) + SLANG_AST_CLASS(ExtensionDecl) TypeExp targetType; }; @@ -101,7 +101,7 @@ class ExtensionDecl : public AggTypeDeclBase // Declaration of a type that represents some sort of aggregate class AggTypeDecl : public AggTypeDeclBase { - SLANG_ABSTRACT_CLASS(AggTypeDecl) + SLANG_ABSTRACT_AST_CLASS(AggTypeDecl) FilteredMemberList<VarDecl> getFields() { @@ -111,12 +111,12 @@ class AggTypeDecl : public AggTypeDeclBase class StructDecl: public AggTypeDecl { - SLANG_CLASS(StructDecl); + SLANG_AST_CLASS(StructDecl); }; class ClassDecl : public AggTypeDecl { - SLANG_CLASS(ClassDecl) + SLANG_AST_CLASS(ClassDecl) }; @@ -127,7 +127,7 @@ class ClassDecl : public AggTypeDecl // class EnumDecl : public AggTypeDecl { - SLANG_CLASS(EnumDecl) + SLANG_AST_CLASS(EnumDecl) Type* tagType = nullptr; }; @@ -144,7 +144,7 @@ class EnumDecl : public AggTypeDecl // class EnumCaseDecl : public Decl { - SLANG_CLASS(EnumCaseDecl) + SLANG_AST_CLASS(EnumCaseDecl) // type of the parent `enum` TypeExp type; @@ -158,13 +158,13 @@ class EnumCaseDecl : public Decl // An interface which other types can conform to class InterfaceDecl : public AggTypeDecl { - SLANG_CLASS(InterfaceDecl) + SLANG_AST_CLASS(InterfaceDecl) }; class TypeConstraintDecl : public Decl { - SLANG_ABSTRACT_CLASS(TypeConstraintDecl) + SLANG_ABSTRACT_AST_CLASS(TypeConstraintDecl) const TypeExp& getSup() const; // Overrides should be public so base classes can access @@ -177,7 +177,7 @@ class TypeConstraintDecl : public Decl // class InheritanceDecl : public TypeConstraintDecl { - SLANG_CLASS(InheritanceDecl) + SLANG_AST_CLASS(InheritanceDecl) // The type expression as written TypeExp base; @@ -201,64 +201,64 @@ class InheritanceDecl : public TypeConstraintDecl // so that we can easily store conformances/constraints on type variables class SimpleTypeDecl : public Decl { - SLANG_ABSTRACT_CLASS(SimpleTypeDecl) + SLANG_ABSTRACT_AST_CLASS(SimpleTypeDecl) }; // A `typedef` declaration class TypeDefDecl : public SimpleTypeDecl { - SLANG_CLASS(TypeDefDecl) + SLANG_AST_CLASS(TypeDefDecl) TypeExp type; }; class TypeAliasDecl : public TypeDefDecl { - SLANG_CLASS(TypeAliasDecl) + SLANG_AST_CLASS(TypeAliasDecl) }; // An 'assoctype' declaration, it is a container of inheritance clauses class AssocTypeDecl : public AggTypeDecl { - SLANG_CLASS(AssocTypeDecl) + SLANG_AST_CLASS(AssocTypeDecl) }; // A 'type_param' declaration, which defines a generic // entry-point parameter. Is a container of GenericTypeConstraintDecl class GlobalGenericParamDecl : public AggTypeDecl { - SLANG_CLASS(GlobalGenericParamDecl) + SLANG_AST_CLASS(GlobalGenericParamDecl) }; // A `__generic_value_param` declaration, which defines an existential // value parameter (not a type parameter. class GlobalGenericValueParamDecl : public VarDeclBase { - SLANG_CLASS(GlobalGenericValueParamDecl) + SLANG_AST_CLASS(GlobalGenericValueParamDecl) }; // A scope for local declarations (e.g., as part of a statement) class ScopeDecl : public ContainerDecl { - SLANG_CLASS(ScopeDecl) + SLANG_AST_CLASS(ScopeDecl) }; // A function/initializer/subscript parameter (potentially mutable) class ParamDecl : public VarDeclBase { - SLANG_CLASS(ParamDecl) + SLANG_AST_CLASS(ParamDecl) }; // A parameter of a function declared in "modern" types (immutable unless explicitly `out` or `inout`) class ModernParamDecl : public ParamDecl { - SLANG_CLASS(ModernParamDecl) + SLANG_AST_CLASS(ModernParamDecl) }; // Base class for things that have parameter lists and can thus be applied to arguments ("called") class CallableDecl : public ContainerDecl { - SLANG_ABSTRACT_CLASS(CallableDecl) + SLANG_ABSTRACT_AST_CLASS(CallableDecl) FilteredMemberList<ParamDecl> getParameters() { @@ -286,7 +286,7 @@ class CallableDecl : public ContainerDecl // Base class for callable things that may also have a body that is evaluated to produce their result class FunctionDeclBase : public CallableDecl { - SLANG_ABSTRACT_CLASS(FunctionDeclBase) + SLANG_ABSTRACT_AST_CLASS(FunctionDeclBase) Stmt* body = nullptr; }; @@ -294,19 +294,19 @@ class FunctionDeclBase : public CallableDecl // A constructor/initializer to create instances of a type class ConstructorDecl : public FunctionDeclBase { - SLANG_CLASS(ConstructorDecl) + SLANG_AST_CLASS(ConstructorDecl) }; // A subscript operation used to index instances of a type class SubscriptDecl : public CallableDecl { - SLANG_CLASS(SubscriptDecl) + SLANG_AST_CLASS(SubscriptDecl) }; /// A property declaration that abstracts over storage with a getter/setter/etc. class PropertyDecl : public ContainerDecl { - SLANG_CLASS(PropertyDecl) + SLANG_AST_CLASS(PropertyDecl) TypeExp type; }; @@ -314,30 +314,30 @@ class PropertyDecl : public ContainerDecl // An "accessor" for a subscript or property class AccessorDecl : public FunctionDeclBase { - SLANG_CLASS(AccessorDecl) + SLANG_AST_CLASS(AccessorDecl) }; class GetterDecl : public AccessorDecl { - SLANG_CLASS(GetterDecl) + SLANG_AST_CLASS(GetterDecl) }; class SetterDecl : public AccessorDecl { - SLANG_CLASS(SetterDecl) + SLANG_AST_CLASS(SetterDecl) }; class RefAccessorDecl : public AccessorDecl { - SLANG_CLASS(RefAccessorDecl) + SLANG_AST_CLASS(RefAccessorDecl) }; class FuncDecl : public FunctionDeclBase { - SLANG_CLASS(FuncDecl) + SLANG_AST_CLASS(FuncDecl) }; class NamespaceDeclBase : public ContainerDecl { - SLANG_CLASS(NamespaceDeclBase) + SLANG_AST_CLASS(NamespaceDeclBase) }; // A `namespace` declaration inside some module, that provides @@ -350,14 +350,14 @@ class NamespaceDeclBase : public ContainerDecl // class NamespaceDecl : public NamespaceDeclBase { - SLANG_CLASS(NamespaceDecl) + SLANG_AST_CLASS(NamespaceDecl) }; // A "module" of code (essentially, a single translation unit) // that provides a scope for some number of declarations. class ModuleDecl : public NamespaceDeclBase { - SLANG_CLASS(ModuleDecl) + SLANG_AST_CLASS(ModuleDecl) // The API-level module that this declaration belong to. // // This field allows lookup of the `Module` based on a @@ -378,7 +378,7 @@ class ModuleDecl : public NamespaceDeclBase /// A declaration that brings members of another declaration or namespace into scope class UsingDecl : public Decl { - SLANG_CLASS(UsingDecl) + SLANG_AST_CLASS(UsingDecl) /// An expression that identifies the entity (e.g., a namespace) to be brought into `scope` Expr* arg; @@ -389,7 +389,7 @@ class UsingDecl : public Decl class ImportDecl : public Decl { - SLANG_CLASS(ImportDecl) + SLANG_AST_CLASS(ImportDecl) // The name of the module we are trying to import NameLoc moduleNameAndLoc; @@ -404,14 +404,14 @@ class ImportDecl : public Decl // A generic declaration, parameterized on types/values class GenericDecl : public ContainerDecl { - SLANG_CLASS(GenericDecl) + SLANG_AST_CLASS(GenericDecl) // The decl that is genericized... Decl* inner = nullptr; }; class GenericTypeParamDecl : public SimpleTypeDecl { - SLANG_CLASS(GenericTypeParamDecl) + SLANG_AST_CLASS(GenericTypeParamDecl) // The bound for the type parameter represents a trait that any // type used as this parameter must conform to // TypeExp bound; @@ -423,7 +423,7 @@ class GenericTypeParamDecl : public SimpleTypeDecl // A constraint placed as part of a generic declaration class GenericTypeConstraintDecl : public TypeConstraintDecl { - SLANG_CLASS(GenericTypeConstraintDecl) + SLANG_AST_CLASS(GenericTypeConstraintDecl) // A type constraint like `T : U` is constraining `T` to be "below" `U` // on a lattice of types. This may not be a subtyping relationship @@ -438,7 +438,7 @@ class GenericTypeConstraintDecl : public TypeConstraintDecl class GenericValueParamDecl : public VarDeclBase { - SLANG_CLASS(GenericValueParamDecl) + SLANG_AST_CLASS(GenericValueParamDecl) }; // An empty declaration (which might still have modifiers attached). @@ -452,7 +452,7 @@ class GenericValueParamDecl : public VarDeclBase // class EmptyDecl : public Decl { - SLANG_CLASS(EmptyDecl) + SLANG_AST_CLASS(EmptyDecl) }; // A declaration used by the implementation to put syntax keywords @@ -460,7 +460,7 @@ class EmptyDecl : public Decl // class SyntaxDecl : public Decl { - SLANG_CLASS(SyntaxDecl) + SLANG_AST_CLASS(SyntaxDecl) // What type of syntax node will be produced when parsing with this keyword? SyntaxClass<NodeBase> syntaxClass; @@ -476,7 +476,7 @@ class SyntaxDecl : public Decl // class AttributeDecl : public ContainerDecl { - SLANG_CLASS(AttributeDecl) + SLANG_AST_CLASS(AttributeDecl) // What type of syntax node will be produced to represent this attribute. SyntaxClass<NodeBase> syntaxClass; }; @@ -488,7 +488,7 @@ class AttributeDecl : public ContainerDecl // declaration in another module. class ImportExternalDecl : public DeclBase { - SLANG_CLASS(ImportExternalDecl) + SLANG_AST_CLASS(ImportExternalDecl) String mangledName; }; diff --git a/source/slang/slang-ast-expr.h b/source/slang/slang-ast-expr.h index 364bbe2d1..e2e64e2a2 100644 --- a/source/slang/slang-ast-expr.h +++ b/source/slang/slang-ast-expr.h @@ -11,7 +11,7 @@ namespace Slang { // Base class for expressions that will reference declarations class DeclRefExpr: public Expr { - SLANG_ABSTRACT_CLASS(DeclRefExpr) + SLANG_ABSTRACT_AST_CLASS(DeclRefExpr) // The scope in which to perform lookup RefPtr<Scope> scope; @@ -25,14 +25,14 @@ class DeclRefExpr: public Expr class VarExpr : public DeclRefExpr { - SLANG_CLASS(VarExpr) + SLANG_AST_CLASS(VarExpr) }; // An expression that references an overloaded set of declarations // having the same name. class OverloadedExpr : public Expr { - SLANG_CLASS(OverloadedExpr) + SLANG_AST_CLASS(OverloadedExpr) // The name that was looked up and found to be overloaded Name* name; @@ -49,7 +49,7 @@ class OverloadedExpr : public Expr // having the same name. class OverloadedExpr2: public Expr { - SLANG_CLASS(OverloadedExpr2) + SLANG_AST_CLASS(OverloadedExpr2) // Optional: the base expression is this overloaded result // arose from a member-reference expression. @@ -61,7 +61,7 @@ class OverloadedExpr2: public Expr class LiteralExpr : public Expr { - SLANG_ABSTRACT_CLASS(LiteralExpr) + SLANG_ABSTRACT_AST_CLASS(LiteralExpr) // The token that was used to express the literal. This can be // used to get the raw text of the literal, including any suffix. Token token; @@ -69,26 +69,26 @@ class LiteralExpr : public Expr class IntegerLiteralExpr : public LiteralExpr { - SLANG_CLASS(IntegerLiteralExpr) + SLANG_AST_CLASS(IntegerLiteralExpr) IntegerLiteralValue value; }; class FloatingPointLiteralExpr: public LiteralExpr { - SLANG_CLASS(FloatingPointLiteralExpr) + SLANG_AST_CLASS(FloatingPointLiteralExpr) FloatingPointLiteralValue value; }; class BoolLiteralExpr : public LiteralExpr { - SLANG_CLASS(BoolLiteralExpr) + SLANG_AST_CLASS(BoolLiteralExpr) bool value; }; class StringLiteralExpr : public LiteralExpr { - SLANG_CLASS(StringLiteralExpr) + SLANG_AST_CLASS(StringLiteralExpr) // TODO: consider storing the "segments" of the string // literal, in the case where multiple literals were @@ -102,14 +102,14 @@ class StringLiteralExpr : public LiteralExpr // An initializer list, e.g. `{ 1, 2, 3 }` class InitializerListExpr : public Expr { - SLANG_CLASS(InitializerListExpr) + SLANG_AST_CLASS(InitializerListExpr) List<Expr*> args; }; // A base class for expressions with arguments class ExprWithArgsBase : public Expr { - SLANG_ABSTRACT_CLASS(ExprWithArgsBase) + SLANG_ABSTRACT_AST_CLASS(ExprWithArgsBase) List<Expr*> arguments; }; @@ -117,7 +117,7 @@ class ExprWithArgsBase : public Expr // An aggregate type constructor class AggTypeCtorExpr : public ExprWithArgsBase { - SLANG_CLASS(AggTypeCtorExpr) + SLANG_AST_CLASS(AggTypeCtorExpr) TypeExp base; }; @@ -127,37 +127,37 @@ class AggTypeCtorExpr : public ExprWithArgsBase // both ordinary `()` function calls and `<>` generic application class AppExprBase : public ExprWithArgsBase { - SLANG_ABSTRACT_CLASS(AppExprBase) + SLANG_ABSTRACT_AST_CLASS(AppExprBase) Expr* functionExpr = nullptr; }; class InvokeExpr: public AppExprBase { - SLANG_CLASS(InvokeExpr) + SLANG_AST_CLASS(InvokeExpr) }; class OperatorExpr: public InvokeExpr { - SLANG_CLASS(OperatorExpr) + SLANG_AST_CLASS(OperatorExpr) }; class InfixExpr: public OperatorExpr { - SLANG_CLASS(InfixExpr) + SLANG_AST_CLASS(InfixExpr) }; class PrefixExpr: public OperatorExpr { - SLANG_CLASS(PrefixExpr) + SLANG_AST_CLASS(PrefixExpr) }; class PostfixExpr: public OperatorExpr { - SLANG_CLASS(PostfixExpr) + SLANG_AST_CLASS(PostfixExpr) }; class IndexExpr: public Expr { - SLANG_CLASS(IndexExpr) + SLANG_AST_CLASS(IndexExpr) Expr* baseExpression = nullptr; Expr* indexExpression = nullptr; @@ -165,14 +165,14 @@ class IndexExpr: public Expr class MemberExpr: public DeclRefExpr { - SLANG_CLASS(MemberExpr) + SLANG_AST_CLASS(MemberExpr) Expr* baseExpression = nullptr; }; // Member looked up on a type, rather than a value class StaticMemberExpr: public DeclRefExpr { - SLANG_CLASS(StaticMemberExpr) + SLANG_AST_CLASS(StaticMemberExpr) Expr* baseExpression = nullptr; }; @@ -187,7 +187,7 @@ struct MatrixCoord class MatrixSwizzleExpr : public Expr { - SLANG_CLASS(MatrixSwizzleExpr) + SLANG_AST_CLASS(MatrixSwizzleExpr) Expr* base = nullptr; int elementCount; MatrixCoord elementCoords[4]; @@ -195,7 +195,7 @@ class MatrixSwizzleExpr : public Expr class SwizzleExpr: public Expr { - SLANG_CLASS(SwizzleExpr) + SLANG_AST_CLASS(SwizzleExpr) Expr* base = nullptr; int elementCount; int elementIndices[4]; @@ -204,14 +204,14 @@ class SwizzleExpr: public Expr // A dereference of a pointer or pointer-like type class DerefExpr: public Expr { - SLANG_CLASS(DerefExpr) + SLANG_AST_CLASS(DerefExpr) Expr* base = nullptr; }; // Any operation that performs type-casting class TypeCastExpr: public InvokeExpr { - SLANG_CLASS(TypeCastExpr) + SLANG_AST_CLASS(TypeCastExpr) // TypeExp TargetType; // Expr* Expression = nullptr; }; @@ -219,13 +219,13 @@ class TypeCastExpr: public InvokeExpr // An explicit type-cast that appear in the user's code with `(type) expr` syntax class ExplicitCastExpr: public TypeCastExpr { - SLANG_CLASS(ExplicitCastExpr) + SLANG_AST_CLASS(ExplicitCastExpr) }; // An implicit type-cast inserted during semantic checking class ImplicitCastExpr : public TypeCastExpr { - SLANG_CLASS(ImplicitCastExpr) + SLANG_AST_CLASS(ImplicitCastExpr) }; /// A cast of a value to a super-type of its type. @@ -234,7 +234,7 @@ class ImplicitCastExpr : public TypeCastExpr /// class CastToSuperTypeExpr: public Expr { - SLANG_CLASS(CastToSuperTypeExpr) + SLANG_AST_CLASS(CastToSuperTypeExpr) /// The value being cast to a super type /// @@ -248,26 +248,26 @@ class CastToSuperTypeExpr: public Expr class SelectExpr: public OperatorExpr { - SLANG_CLASS(SelectExpr) + SLANG_AST_CLASS(SelectExpr) }; class GenericAppExpr: public AppExprBase { - SLANG_CLASS(GenericAppExpr) + SLANG_AST_CLASS(GenericAppExpr) }; // An expression representing re-use of the syntax for a type in more // than once conceptually-distinct declaration class SharedTypeExpr: public Expr { - SLANG_CLASS(SharedTypeExpr) + SLANG_AST_CLASS(SharedTypeExpr) // The underlying type expression that we want to share TypeExp base; }; class AssignExpr: public Expr { - SLANG_CLASS(AssignExpr) + SLANG_AST_CLASS(AssignExpr) Expr* left = nullptr; Expr* right = nullptr; }; @@ -278,7 +278,7 @@ class AssignExpr: public Expr // when we do rewriter stuff. class ParenExpr: public Expr { - SLANG_CLASS(ParenExpr) + SLANG_AST_CLASS(ParenExpr) Expr* base = nullptr; }; @@ -286,21 +286,21 @@ class ParenExpr: public Expr // refer to the current instance of an enclosing type. class ThisExpr: public Expr { - SLANG_CLASS(ThisExpr) + SLANG_AST_CLASS(ThisExpr) RefPtr<Scope> scope; }; // An expression that binds a temporary variable in a local expression context class LetExpr: public Expr { - SLANG_CLASS(LetExpr) + SLANG_AST_CLASS(LetExpr) VarDecl* decl = nullptr; Expr* body = nullptr; }; class ExtractExistentialValueExpr: public Expr { - SLANG_CLASS(ExtractExistentialValueExpr) + SLANG_AST_CLASS(ExtractExistentialValueExpr) DeclRef<VarDeclBase> declRef; }; @@ -311,7 +311,7 @@ class ExtractExistentialValueExpr: public Expr /// class TaggedUnionTypeExpr: public Expr { - SLANG_CLASS(TaggedUnionTypeExpr) + SLANG_AST_CLASS(TaggedUnionTypeExpr) List<TypeExp> caseTypes; }; @@ -321,7 +321,7 @@ class TaggedUnionTypeExpr: public Expr /// class ThisTypeExpr: public Expr { - SLANG_CLASS(ThisTypeExpr) + SLANG_AST_CLASS(ThisTypeExpr) RefPtr<Scope> scope; }; diff --git a/source/slang/slang-ast-modifier.h b/source/slang/slang-ast-modifier.h index cbdca6ab7..d707e9771 100644 --- a/source/slang/slang-ast-modifier.h +++ b/source/slang/slang-ast-modifier.h @@ -10,27 +10,27 @@ namespace Slang { // Simple modifiers have no state beyond their identity -class InModifier : public Modifier { SLANG_CLASS(InModifier)}; -class OutModifier : public Modifier { SLANG_CLASS(OutModifier)}; -class ConstModifier : public Modifier { SLANG_CLASS(ConstModifier)}; -class InstanceModifier : public Modifier { SLANG_CLASS(InstanceModifier)}; -class BuiltinModifier : public Modifier { SLANG_CLASS(BuiltinModifier)}; -class InlineModifier : public Modifier { SLANG_CLASS(InlineModifier)}; -class PublicModifier : public Modifier { SLANG_CLASS(PublicModifier)}; -class RequireModifier : public Modifier { SLANG_CLASS(RequireModifier)}; -class ParamModifier : public Modifier { SLANG_CLASS(ParamModifier)}; -class ExternModifier : public Modifier { SLANG_CLASS(ExternModifier)}; -class InputModifier : public Modifier { SLANG_CLASS(InputModifier)}; -class TransparentModifier : public Modifier { SLANG_CLASS(TransparentModifier)}; -class FromStdLibModifier : public Modifier { SLANG_CLASS(FromStdLibModifier)}; -class PrefixModifier : public Modifier { SLANG_CLASS(PrefixModifier)}; -class PostfixModifier : public Modifier { SLANG_CLASS(PostfixModifier)}; -class ExportedModifier : public Modifier { SLANG_CLASS(ExportedModifier)}; -class ConstExprModifier : public Modifier { SLANG_CLASS(ConstExprModifier)}; -class GloballyCoherentModifier : public Modifier { SLANG_CLASS(GloballyCoherentModifier)}; +class InModifier : public Modifier { SLANG_AST_CLASS(InModifier)}; +class OutModifier : public Modifier { SLANG_AST_CLASS(OutModifier)}; +class ConstModifier : public Modifier { SLANG_AST_CLASS(ConstModifier)}; +class InstanceModifier : public Modifier { SLANG_AST_CLASS(InstanceModifier)}; +class BuiltinModifier : public Modifier { SLANG_AST_CLASS(BuiltinModifier)}; +class InlineModifier : public Modifier { SLANG_AST_CLASS(InlineModifier)}; +class PublicModifier : public Modifier { SLANG_AST_CLASS(PublicModifier)}; +class RequireModifier : public Modifier { SLANG_AST_CLASS(RequireModifier)}; +class ParamModifier : public Modifier { SLANG_AST_CLASS(ParamModifier)}; +class ExternModifier : public Modifier { SLANG_AST_CLASS(ExternModifier)}; +class InputModifier : public Modifier { SLANG_AST_CLASS(InputModifier)}; +class TransparentModifier : public Modifier { SLANG_AST_CLASS(TransparentModifier)}; +class FromStdLibModifier : public Modifier { SLANG_AST_CLASS(FromStdLibModifier)}; +class PrefixModifier : public Modifier { SLANG_AST_CLASS(PrefixModifier)}; +class PostfixModifier : public Modifier { SLANG_AST_CLASS(PostfixModifier)}; +class ExportedModifier : public Modifier { SLANG_AST_CLASS(ExportedModifier)}; +class ConstExprModifier : public Modifier { SLANG_AST_CLASS(ConstExprModifier)}; +class GloballyCoherentModifier : public Modifier { SLANG_AST_CLASS(GloballyCoherentModifier)}; /// A modifier that indicates an `InheritanceDecl` should be ignored during name lookup (and related checks). -class IgnoreForLookupModifier : public Modifier { SLANG_CLASS(IgnoreForLookupModifier) }; +class IgnoreForLookupModifier : public Modifier { SLANG_AST_CLASS(IgnoreForLookupModifier) }; // A modifier that marks something as an operation that // has a one-to-one translation to the IR, and thus @@ -38,7 +38,7 @@ class IgnoreForLookupModifier : public Modifier { SLANG_CLASS(IgnoreForLookupMod // class IntrinsicOpModifier : public Modifier { - SLANG_CLASS(IntrinsicOpModifier) + SLANG_AST_CLASS(IntrinsicOpModifier) // Token that names the intrinsic op. Token opToken; @@ -52,7 +52,7 @@ class IntrinsicOpModifier : public Modifier // for some subset of targets. class TargetIntrinsicModifier : public Modifier { - SLANG_CLASS(TargetIntrinsicModifier) + SLANG_AST_CLASS(TargetIntrinsicModifier) // Token that names the target that the operation // is an intrisic for. @@ -67,7 +67,7 @@ class TargetIntrinsicModifier : public Modifier // target. class SpecializedForTargetModifier : public Modifier { - SLANG_CLASS(SpecializedForTargetModifier) + SLANG_AST_CLASS(SpecializedForTargetModifier) // Token that names the target that the operation // has been specialized for. @@ -78,7 +78,7 @@ class SpecializedForTargetModifier : public Modifier // a certain GLSL extension to be enabled when used class RequiredGLSLExtensionModifier : public Modifier { - SLANG_CLASS(RequiredGLSLExtensionModifier) + SLANG_AST_CLASS(RequiredGLSLExtensionModifier) Token extensionNameToken; }; @@ -87,7 +87,7 @@ class RequiredGLSLExtensionModifier : public Modifier // a certain GLSL version to be enabled when used class RequiredGLSLVersionModifier : public Modifier { - SLANG_CLASS(RequiredGLSLVersionModifier) + SLANG_AST_CLASS(RequiredGLSLVersionModifier) Token versionNumberToken; }; @@ -97,7 +97,7 @@ class RequiredGLSLVersionModifier : public Modifier // a certain SPIRV version to be enabled when used. Specified as "major.minor" class RequiredSPIRVVersionModifier : public Modifier { - SLANG_CLASS(RequiredSPIRVVersionModifier) + SLANG_AST_CLASS(RequiredSPIRVVersionModifier) SemanticVersion version; }; @@ -106,21 +106,21 @@ class RequiredSPIRVVersionModifier : public Modifier // a certain CUDA SM version to be enabled when used. Specified as "major.minor" class RequiredCUDASMVersionModifier : public Modifier { - SLANG_CLASS(RequiredCUDASMVersionModifier) + SLANG_AST_CLASS(RequiredCUDASMVersionModifier) SemanticVersion version; }; class InOutModifier : public OutModifier { - SLANG_CLASS(InOutModifier) + SLANG_AST_CLASS(InOutModifier) }; // `__ref` modifier for by-reference parameter passing class RefModifier : public Modifier { - SLANG_CLASS(RefModifier) + SLANG_AST_CLASS(RefModifier) }; @@ -140,7 +140,7 @@ class RefModifier : public Modifier // class SharedModifiers : public Modifier { - SLANG_CLASS(SharedModifiers) + SLANG_AST_CLASS(SharedModifiers) }; @@ -156,7 +156,7 @@ class SharedModifiers : public Modifier // different constructs. class GLSLLayoutModifier : public Modifier { - SLANG_ABSTRACT_CLASS(GLSLLayoutModifier) + SLANG_ABSTRACT_AST_CLASS(GLSLLayoutModifier) // The token used to introduce the modifier is stored @@ -169,17 +169,17 @@ class GLSLLayoutModifier : public Modifier // AST nodes to represent the begin/end of a `layout` modifier group class GLSLLayoutModifierGroupMarker : public Modifier { - SLANG_ABSTRACT_CLASS(GLSLLayoutModifierGroupMarker) + SLANG_ABSTRACT_AST_CLASS(GLSLLayoutModifierGroupMarker) }; class GLSLLayoutModifierGroupBegin : public GLSLLayoutModifierGroupMarker { - SLANG_CLASS(GLSLLayoutModifierGroupBegin) + SLANG_AST_CLASS(GLSLLayoutModifierGroupBegin) }; class GLSLLayoutModifierGroupEnd : public GLSLLayoutModifierGroupMarker { - SLANG_CLASS(GLSLLayoutModifierGroupEnd) + SLANG_AST_CLASS(GLSLLayoutModifierGroupEnd) }; @@ -188,53 +188,53 @@ class GLSLLayoutModifierGroupEnd : public GLSLLayoutModifierGroupMarker // those we have not. class GLSLParsedLayoutModifier : public GLSLLayoutModifier { - SLANG_ABSTRACT_CLASS(GLSLParsedLayoutModifier) + SLANG_ABSTRACT_AST_CLASS(GLSLParsedLayoutModifier) }; class GLSLUnparsedLayoutModifier : public GLSLLayoutModifier { - SLANG_CLASS(GLSLUnparsedLayoutModifier) + SLANG_AST_CLASS(GLSLUnparsedLayoutModifier) }; // Specific cases for known GLSL `layout` modifiers that we need to work with class GLSLConstantIDLayoutModifier : public GLSLParsedLayoutModifier { - SLANG_CLASS(GLSLConstantIDLayoutModifier) + SLANG_AST_CLASS(GLSLConstantIDLayoutModifier) }; class GLSLLocationLayoutModifier : public GLSLParsedLayoutModifier { - SLANG_CLASS(GLSLLocationLayoutModifier) + SLANG_AST_CLASS(GLSLLocationLayoutModifier) }; // A catch-all for single-keyword modifiers class SimpleModifier : public Modifier { - SLANG_CLASS(SimpleModifier) + SLANG_AST_CLASS(SimpleModifier) }; // Some GLSL-specific modifiers class GLSLBufferModifier : public SimpleModifier { - SLANG_CLASS(GLSLBufferModifier) + SLANG_AST_CLASS(GLSLBufferModifier) }; class GLSLWriteOnlyModifier : public SimpleModifier { - SLANG_CLASS(GLSLWriteOnlyModifier) + SLANG_AST_CLASS(GLSLWriteOnlyModifier) }; class GLSLReadOnlyModifier : public SimpleModifier { - SLANG_CLASS(GLSLReadOnlyModifier) + SLANG_AST_CLASS(GLSLReadOnlyModifier) }; class GLSLPatchModifier : public SimpleModifier { - SLANG_CLASS(GLSLPatchModifier) + SLANG_AST_CLASS(GLSLPatchModifier) }; @@ -242,7 +242,7 @@ class GLSLPatchModifier : public SimpleModifier // a parameter block declaration in the source program. class ImplicitParameterGroupVariableModifier : public Modifier { - SLANG_CLASS(ImplicitParameterGroupVariableModifier) + SLANG_AST_CLASS(ImplicitParameterGroupVariableModifier) }; @@ -250,14 +250,14 @@ class ImplicitParameterGroupVariableModifier : public Modifier // type of a parameter block declaration in the source program. class ImplicitParameterGroupElementTypeModifier : public Modifier { - SLANG_CLASS(ImplicitParameterGroupElementTypeModifier) + SLANG_AST_CLASS(ImplicitParameterGroupElementTypeModifier) }; // An HLSL semantic class HLSLSemantic : public Modifier { - SLANG_ABSTRACT_CLASS(HLSLSemantic) + SLANG_ABSTRACT_AST_CLASS(HLSLSemantic) Token name; }; @@ -265,7 +265,7 @@ class HLSLSemantic : public Modifier // An HLSL semantic that affects layout class HLSLLayoutSemantic : public HLSLSemantic { - SLANG_CLASS(HLSLLayoutSemantic) + SLANG_AST_CLASS(HLSLLayoutSemantic) Token registerName; Token componentMask; @@ -274,7 +274,7 @@ class HLSLLayoutSemantic : public HLSLSemantic // An HLSL `register` semantic class HLSLRegisterSemantic : public HLSLLayoutSemantic { - SLANG_CLASS(HLSLRegisterSemantic) + SLANG_AST_CLASS(HLSLRegisterSemantic) Token spaceName; }; @@ -282,14 +282,14 @@ class HLSLRegisterSemantic : public HLSLLayoutSemantic // TODO(tfoley): `packoffset` class HLSLPackOffsetSemantic : public HLSLLayoutSemantic { - SLANG_CLASS(HLSLPackOffsetSemantic) + SLANG_AST_CLASS(HLSLPackOffsetSemantic) }; // An HLSL semantic that just associated a declaration with a semantic name class HLSLSimpleSemantic : public HLSLSemantic { - SLANG_CLASS(HLSLSimpleSemantic) + SLANG_AST_CLASS(HLSLSimpleSemantic) }; @@ -299,14 +299,14 @@ class HLSLSimpleSemantic : public HLSLSemantic // that we need to keep around for later steps class GLSLPreprocessorDirective : public Modifier { - SLANG_CLASS(GLSLPreprocessorDirective) + SLANG_AST_CLASS(GLSLPreprocessorDirective) }; // A GLSL `#version` directive class GLSLVersionDirective : public GLSLPreprocessorDirective { - SLANG_CLASS(GLSLVersionDirective) + SLANG_AST_CLASS(GLSLVersionDirective) // Token giving the version number to use @@ -319,7 +319,7 @@ class GLSLVersionDirective : public GLSLPreprocessorDirective // A GLSL `#extension` directive class GLSLExtensionDirective : public GLSLPreprocessorDirective { - SLANG_CLASS(GLSLExtensionDirective) + SLANG_AST_CLASS(GLSLExtensionDirective) // Token giving the version number to use @@ -331,7 +331,7 @@ class GLSLExtensionDirective : public GLSLPreprocessorDirective class ParameterGroupReflectionName : public Modifier { - SLANG_CLASS(ParameterGroupReflectionName) + SLANG_AST_CLASS(ParameterGroupReflectionName) NameLoc nameAndLoc; }; @@ -339,7 +339,7 @@ class ParameterGroupReflectionName : public Modifier // A modifier that indicates a built-in base type (e.g., `float`) class BuiltinTypeModifier : public Modifier { - SLANG_CLASS(BuiltinTypeModifier) + SLANG_AST_CLASS(BuiltinTypeModifier) BaseType tag; }; @@ -349,7 +349,7 @@ class BuiltinTypeModifier : public Modifier // TODO(tfoley): This deserves a better name than "magic" class MagicTypeModifier : public Modifier { - SLANG_CLASS(MagicTypeModifier) + SLANG_AST_CLASS(MagicTypeModifier) String name; uint32_t tag; @@ -362,7 +362,7 @@ class MagicTypeModifier : public Modifier // `MagicTypeModifier` so that we don't have to apply all of them. class IntrinsicTypeModifier : public Modifier { - SLANG_CLASS(IntrinsicTypeModifier) + SLANG_AST_CLASS(IntrinsicTypeModifier) // The IR opcode to use when constructing a type uint32_t irOp; @@ -375,31 +375,31 @@ class IntrinsicTypeModifier : public Modifier // Modifiers that affect the storage layout for matrices class MatrixLayoutModifier : public Modifier { - SLANG_CLASS(MatrixLayoutModifier) + SLANG_AST_CLASS(MatrixLayoutModifier) }; // Modifiers that specify row- and column-major layout, respectively class RowMajorLayoutModifier : public MatrixLayoutModifier { - SLANG_CLASS(RowMajorLayoutModifier) + SLANG_AST_CLASS(RowMajorLayoutModifier) }; class ColumnMajorLayoutModifier : public MatrixLayoutModifier { - SLANG_CLASS(ColumnMajorLayoutModifier) + SLANG_AST_CLASS(ColumnMajorLayoutModifier) }; // The HLSL flavor of those modifiers class HLSLRowMajorLayoutModifier : public RowMajorLayoutModifier { - SLANG_CLASS(HLSLRowMajorLayoutModifier) + SLANG_AST_CLASS(HLSLRowMajorLayoutModifier) }; class HLSLColumnMajorLayoutModifier : public ColumnMajorLayoutModifier { - SLANG_CLASS(HLSLColumnMajorLayoutModifier) + SLANG_AST_CLASS(HLSLColumnMajorLayoutModifier) }; @@ -412,12 +412,12 @@ class HLSLColumnMajorLayoutModifier : public ColumnMajorLayoutModifier // GLSL specifies them. class GLSLRowMajorLayoutModifier : public ColumnMajorLayoutModifier { - SLANG_CLASS(GLSLRowMajorLayoutModifier) + SLANG_AST_CLASS(GLSLRowMajorLayoutModifier) }; class GLSLColumnMajorLayoutModifier : public RowMajorLayoutModifier { - SLANG_CLASS(GLSLColumnMajorLayoutModifier) + SLANG_AST_CLASS(GLSLColumnMajorLayoutModifier) }; @@ -425,49 +425,49 @@ class GLSLColumnMajorLayoutModifier : public RowMajorLayoutModifier class InterpolationModeModifier : public Modifier { - SLANG_ABSTRACT_CLASS(InterpolationModeModifier) + SLANG_ABSTRACT_AST_CLASS(InterpolationModeModifier) }; // HLSL `nointerpolation` modifier class HLSLNoInterpolationModifier : public InterpolationModeModifier { - SLANG_CLASS(HLSLNoInterpolationModifier) + SLANG_AST_CLASS(HLSLNoInterpolationModifier) }; // HLSL `noperspective` modifier class HLSLNoPerspectiveModifier : public InterpolationModeModifier { - SLANG_CLASS(HLSLNoPerspectiveModifier) + SLANG_AST_CLASS(HLSLNoPerspectiveModifier) }; // HLSL `linear` modifier class HLSLLinearModifier : public InterpolationModeModifier { - SLANG_CLASS(HLSLLinearModifier) + SLANG_AST_CLASS(HLSLLinearModifier) }; // HLSL `sample` modifier class HLSLSampleModifier : public InterpolationModeModifier { - SLANG_CLASS(HLSLSampleModifier) + SLANG_AST_CLASS(HLSLSampleModifier) }; // HLSL `centroid` modifier class HLSLCentroidModifier : public InterpolationModeModifier { - SLANG_CLASS(HLSLCentroidModifier) + SLANG_AST_CLASS(HLSLCentroidModifier) }; // HLSL `precise` modifier class PreciseModifier : public Modifier { - SLANG_CLASS(PreciseModifier) + SLANG_AST_CLASS(PreciseModifier) }; @@ -475,14 +475,14 @@ class PreciseModifier : public Modifier // and shouldn't be confused with `groupshared`) class HLSLEffectSharedModifier : public Modifier { - SLANG_CLASS(HLSLEffectSharedModifier) + SLANG_AST_CLASS(HLSLEffectSharedModifier) }; // HLSL `groupshared` modifier class HLSLGroupSharedModifier : public Modifier { - SLANG_CLASS(HLSLGroupSharedModifier) + SLANG_AST_CLASS(HLSLGroupSharedModifier) }; @@ -490,7 +490,7 @@ class HLSLGroupSharedModifier : public Modifier // treated as HLSL-specific) class HLSLStaticModifier : public Modifier { - SLANG_CLASS(HLSLStaticModifier) + SLANG_AST_CLASS(HLSLStaticModifier) }; @@ -498,20 +498,20 @@ class HLSLStaticModifier : public Modifier // use of the keyword) class HLSLUniformModifier : public Modifier { - SLANG_CLASS(HLSLUniformModifier) + SLANG_AST_CLASS(HLSLUniformModifier) }; // HLSL `volatile` modifier (ignored) class HLSLVolatileModifier : public Modifier { - SLANG_CLASS(HLSLVolatileModifier) + SLANG_AST_CLASS(HLSLVolatileModifier) }; class AttributeTargetModifier : public Modifier { - SLANG_CLASS(AttributeTargetModifier) + SLANG_AST_CLASS(AttributeTargetModifier) // A class to which the declared attribute type is applicable SyntaxClass<NodeBase> syntaxClass; @@ -520,7 +520,7 @@ class AttributeTargetModifier : public Modifier // Base class for checked and unchecked `[name(arg0, ...)]` style attribute. class AttributeBase : public Modifier { - SLANG_CLASS(AttributeBase) + SLANG_AST_CLASS(AttributeBase) List<Expr*> args; }; @@ -529,7 +529,7 @@ class AttributeBase : public Modifier // After analysis, this will be transformed into a more specific case. class UncheckedAttribute : public AttributeBase { - SLANG_CLASS(UncheckedAttribute) + SLANG_AST_CLASS(UncheckedAttribute) RefPtr<Scope> scope; }; @@ -537,20 +537,20 @@ class UncheckedAttribute : public AttributeBase // A `[name(arg0, ...)]` style attribute that has been validated. class Attribute : public AttributeBase { - SLANG_CLASS(Attribute) + SLANG_AST_CLASS(Attribute) AttributeArgumentValueDict intArgVals; }; class UserDefinedAttribute : public Attribute { - SLANG_CLASS(UserDefinedAttribute) + SLANG_AST_CLASS(UserDefinedAttribute) }; class AttributeUsageAttribute : public Attribute { - SLANG_CLASS(AttributeUsageAttribute) + SLANG_AST_CLASS(AttributeUsageAttribute) SyntaxClass<NodeBase> targetSyntaxClass; }; @@ -558,44 +558,44 @@ class AttributeUsageAttribute : public Attribute // An `[unroll]` or `[unroll(count)]` attribute class UnrollAttribute : public Attribute { - SLANG_CLASS(UnrollAttribute) + SLANG_AST_CLASS(UnrollAttribute) IntegerLiteralValue getCount(); }; class LoopAttribute : public Attribute { - SLANG_CLASS(LoopAttribute) + SLANG_AST_CLASS(LoopAttribute) }; // `[loop]` class FastOptAttribute : public Attribute { - SLANG_CLASS(FastOptAttribute) + SLANG_AST_CLASS(FastOptAttribute) }; // `[fastopt]` class AllowUAVConditionAttribute : public Attribute { - SLANG_CLASS(AllowUAVConditionAttribute) + SLANG_AST_CLASS(AllowUAVConditionAttribute) }; // `[allow_uav_condition]` class BranchAttribute : public Attribute { - SLANG_CLASS(BranchAttribute) + SLANG_AST_CLASS(BranchAttribute) }; // `[branch]` class FlattenAttribute : public Attribute { - SLANG_CLASS(FlattenAttribute) + SLANG_AST_CLASS(FlattenAttribute) }; // `[flatten]` class ForceCaseAttribute : public Attribute { - SLANG_CLASS(ForceCaseAttribute) + SLANG_AST_CLASS(ForceCaseAttribute) }; // `[forcecase]` class CallAttribute : public Attribute { - SLANG_CLASS(CallAttribute) + SLANG_AST_CLASS(CallAttribute) }; // `[call]` @@ -603,21 +603,21 @@ class CallAttribute : public Attribute // [[vk_push_constant]] [[push_constant]] class PushConstantAttribute : public Attribute { - SLANG_CLASS(PushConstantAttribute) + SLANG_AST_CLASS(PushConstantAttribute) }; // [[vk_shader_record]] [[shader_record]] class ShaderRecordAttribute : public Attribute { - SLANG_CLASS(ShaderRecordAttribute) + SLANG_AST_CLASS(ShaderRecordAttribute) }; // [[vk_binding]] class GLSLBindingAttribute : public Attribute { - SLANG_CLASS(GLSLBindingAttribute) + SLANG_AST_CLASS(GLSLBindingAttribute) int32_t binding = 0; int32_t set = 0; @@ -625,7 +625,7 @@ class GLSLBindingAttribute : public Attribute class GLSLSimpleIntegerLayoutAttribute : public Attribute { - SLANG_CLASS(GLSLSimpleIntegerLayoutAttribute) + SLANG_AST_CLASS(GLSLSimpleIntegerLayoutAttribute) int32_t value = 0; }; @@ -633,14 +633,14 @@ class GLSLSimpleIntegerLayoutAttribute : public Attribute // [[vk_location]] class GLSLLocationAttribute : public GLSLSimpleIntegerLayoutAttribute { - SLANG_CLASS(GLSLLocationAttribute) + SLANG_AST_CLASS(GLSLLocationAttribute) }; // [[vk_index]] class GLSLIndexAttribute : public GLSLSimpleIntegerLayoutAttribute { - SLANG_CLASS(GLSLIndexAttribute) + SLANG_AST_CLASS(GLSLIndexAttribute) }; @@ -649,46 +649,46 @@ class GLSLIndexAttribute : public GLSLSimpleIntegerLayoutAttribute class MaxTessFactorAttribute : public Attribute { - SLANG_CLASS(MaxTessFactorAttribute) + SLANG_AST_CLASS(MaxTessFactorAttribute) }; class OutputControlPointsAttribute : public Attribute { - SLANG_CLASS(OutputControlPointsAttribute) + SLANG_AST_CLASS(OutputControlPointsAttribute) }; class OutputTopologyAttribute : public Attribute { - SLANG_CLASS(OutputTopologyAttribute) + SLANG_AST_CLASS(OutputTopologyAttribute) }; class PartitioningAttribute : public Attribute { - SLANG_CLASS(PartitioningAttribute) + SLANG_AST_CLASS(PartitioningAttribute) }; class PatchConstantFuncAttribute : public Attribute { - SLANG_CLASS(PatchConstantFuncAttribute) + SLANG_AST_CLASS(PatchConstantFuncAttribute) FuncDecl* patchConstantFuncDecl = nullptr; }; class DomainAttribute : public Attribute { - SLANG_CLASS(DomainAttribute) + SLANG_AST_CLASS(DomainAttribute) }; class EarlyDepthStencilAttribute : public Attribute { - SLANG_CLASS(EarlyDepthStencilAttribute) + SLANG_AST_CLASS(EarlyDepthStencilAttribute) }; // `[earlydepthstencil]` // An HLSL `[numthreads(x,y,z)]` attribute class NumThreadsAttribute : public Attribute { - SLANG_CLASS(NumThreadsAttribute) + SLANG_AST_CLASS(NumThreadsAttribute) // The number of threads to use along each axis // @@ -701,7 +701,7 @@ class NumThreadsAttribute : public Attribute class MaxVertexCountAttribute : public Attribute { - SLANG_CLASS(MaxVertexCountAttribute) + SLANG_AST_CLASS(MaxVertexCountAttribute) // The number of max vertex count for geometry shader // @@ -712,7 +712,7 @@ class MaxVertexCountAttribute : public Attribute class InstanceAttribute : public Attribute { - SLANG_CLASS(InstanceAttribute) + SLANG_AST_CLASS(InstanceAttribute) // The number of instances to run for geometry shader // @@ -725,7 +725,7 @@ class InstanceAttribute : public Attribute // to be compiled, and specifies the stage for that entry point class EntryPointAttribute : public Attribute { - SLANG_CLASS(EntryPointAttribute) + SLANG_AST_CLASS(EntryPointAttribute) // The resolved stage that the entry point is targetting. // @@ -740,7 +740,7 @@ class EntryPointAttribute : public Attribute // ray tracing shader to pass per-ray payload information. class VulkanRayPayloadAttribute : public Attribute { - SLANG_CLASS(VulkanRayPayloadAttribute) + SLANG_AST_CLASS(VulkanRayPayloadAttribute) }; @@ -750,7 +750,7 @@ class VulkanRayPayloadAttribute : public Attribute // ray tracing shader to pass payload information to/from a callee. class VulkanCallablePayloadAttribute : public Attribute { - SLANG_CLASS(VulkanCallablePayloadAttribute) + SLANG_AST_CLASS(VulkanCallablePayloadAttribute) }; @@ -760,7 +760,7 @@ class VulkanCallablePayloadAttribute : public Attribute // intersection shader to pass hit attribute information. class VulkanHitAttributesAttribute : public Attribute { - SLANG_CLASS(VulkanHitAttributesAttribute) + SLANG_AST_CLASS(VulkanHitAttributesAttribute) }; @@ -770,7 +770,7 @@ class VulkanHitAttributesAttribute : public Attribute // class MutatingAttribute : public Attribute { - SLANG_CLASS(MutatingAttribute) + SLANG_AST_CLASS(MutatingAttribute) }; // A `[nonmutating]` attribute, which indicates that a @@ -779,7 +779,7 @@ class MutatingAttribute : public Attribute // class NonmutatingAttribute : public Attribute { - SLANG_CLASS(NonmutatingAttribute) + SLANG_AST_CLASS(NonmutatingAttribute) }; @@ -790,7 +790,7 @@ class NonmutatingAttribute : public Attribute // class ReadNoneAttribute : public Attribute { - SLANG_CLASS(ReadNoneAttribute) + SLANG_AST_CLASS(ReadNoneAttribute) }; @@ -798,32 +798,32 @@ class ReadNoneAttribute : public Attribute // HLSL modifiers for geometry shader input topology class HLSLGeometryShaderInputPrimitiveTypeModifier : public Modifier { - SLANG_CLASS(HLSLGeometryShaderInputPrimitiveTypeModifier) + SLANG_AST_CLASS(HLSLGeometryShaderInputPrimitiveTypeModifier) }; class HLSLPointModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier { - SLANG_CLASS(HLSLPointModifier) + SLANG_AST_CLASS(HLSLPointModifier) }; class HLSLLineModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier { - SLANG_CLASS(HLSLLineModifier) + SLANG_AST_CLASS(HLSLLineModifier) }; class HLSLTriangleModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier { - SLANG_CLASS(HLSLTriangleModifier) + SLANG_AST_CLASS(HLSLTriangleModifier) }; class HLSLLineAdjModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier { - SLANG_CLASS(HLSLLineAdjModifier) + SLANG_AST_CLASS(HLSLLineAdjModifier) }; class HLSLTriangleAdjModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier { - SLANG_CLASS(HLSLTriangleAdjModifier) + SLANG_AST_CLASS(HLSLTriangleAdjModifier) }; // A modifier to indicate that a constructor/initializer can be used @@ -831,7 +831,7 @@ class HLSLTriangleAdjModifier : public HLSLGeometryShaderInputPrimitiveTypeModif // the conversion, if applied. class ImplicitConversionModifier : public Modifier { - SLANG_CLASS(ImplicitConversionModifier) + SLANG_AST_CLASS(ImplicitConversionModifier) // The conversion cost, used to rank conversions ConversionCost cost; @@ -839,14 +839,14 @@ class ImplicitConversionModifier : public Modifier class FormatAttribute : public Attribute { - SLANG_CLASS(FormatAttribute) + SLANG_AST_CLASS(FormatAttribute) ImageFormat format; }; class AllowAttribute : public Attribute { - SLANG_CLASS(AllowAttribute) + SLANG_AST_CLASS(AllowAttribute) DiagnosticInfo const* diagnostic = nullptr; }; @@ -856,7 +856,7 @@ class AllowAttribute : public Attribute // class ExternAttribute : public Attribute { - SLANG_CLASS(ExternAttribute) + SLANG_AST_CLASS(ExternAttribute) }; @@ -865,30 +865,30 @@ class ExternAttribute : public Attribute // class UnsafeForceInlineEarlyAttribute : public Attribute { - SLANG_CLASS(UnsafeForceInlineEarlyAttribute) + SLANG_AST_CLASS(UnsafeForceInlineEarlyAttribute) }; /// An attribute that marks a type declaration as either allowing or /// disallowing the type to be inherited from in other modules. -class InheritanceControlAttribute : public Attribute { SLANG_CLASS(InheritanceControlAttribute) }; +class InheritanceControlAttribute : public Attribute { SLANG_AST_CLASS(InheritanceControlAttribute) }; /// An attribute that marks a type declaration as allowing the type to be inherited from in other modules. -class OpenAttribute : public InheritanceControlAttribute { SLANG_CLASS(OpenAttribute) }; +class OpenAttribute : public InheritanceControlAttribute { SLANG_AST_CLASS(OpenAttribute) }; /// An attribute that marks a type declaration as disallowing the type to be inherited from in other modules. -class SealedAttribute : public InheritanceControlAttribute { SLANG_CLASS(SealedAttribute) }; +class SealedAttribute : public InheritanceControlAttribute { SLANG_AST_CLASS(SealedAttribute) }; /// An attribute that marks a decl as a compiler built-in object. class BuiltinAttribute : public Attribute { - SLANG_CLASS(BuiltinAttribute) + SLANG_AST_CLASS(BuiltinAttribute) }; /// An attribute that defines the size of `AnyValue` type to represent a polymoprhic value that conforms to /// the decorated interface type. class AnyValueSizeAttribute : public Attribute { - SLANG_CLASS(AnyValueSizeAttribute) + SLANG_AST_CLASS(AnyValueSizeAttribute) int32_t size; }; @@ -897,7 +897,7 @@ class AnyValueSizeAttribute : public Attribute /// requires NVAPI operations for its implementation on D3D. class RequiresNVAPIAttribute : public Attribute { - SLANG_CLASS(RequiresNVAPIAttribute) + SLANG_AST_CLASS(RequiresNVAPIAttribute) }; /// Indicates that the modified declaration is one of the "magic" declarations @@ -906,7 +906,7 @@ class RequiresNVAPIAttribute : public Attribute /// will not be emitted, instead allowing the versions from the prelude to be used. class NVAPIMagicModifier : public Modifier { - SLANG_CLASS(NVAPIMagicModifier) + SLANG_AST_CLASS(NVAPIMagicModifier) }; /// A modifier that attaches to a `ModuleDecl` to indicate the register/space binding @@ -914,7 +914,7 @@ class NVAPIMagicModifier : public Modifier /// `NV_SHADER_EXTN_REGISTER_SPACE` preprocessor definitions. class NVAPISlotModifier : public Modifier { - SLANG_CLASS(NVAPISlotModifier) + SLANG_AST_CLASS(NVAPISlotModifier) /// The name of the register that is to be used (e.g., `"u3"`) /// diff --git a/source/slang/slang-ast-reflect.h b/source/slang/slang-ast-reflect.h index 63bd889b8..6ba895f71 100644 --- a/source/slang/slang-ast-reflect.h +++ b/source/slang/slang-ast-reflect.h @@ -8,7 +8,7 @@ #include "slang-ast-generated.h" // Implementation for SLANG_ABSTRACT_CLASS(x) using reflection from C++ extractor in slang-ast-generated.h -#define SLANG_CLASS_REFLECT_IMPL(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) \ +#define SLANG_AST_CLASS_REFLECT_IMPL(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) \ protected: \ NAME() = default; \ public: \ @@ -23,8 +23,8 @@ // Macro definitions - use the SLANG_ASTNode_ definitions to invoke the IMPL to produce the code // injected into AST classes -#define SLANG_ABSTRACT_CLASS(NAME) SLANG_ASTNode_##NAME(SLANG_CLASS_REFLECT_IMPL, _) -#define SLANG_CLASS(NAME) SLANG_ASTNode_##NAME(SLANG_CLASS_REFLECT_IMPL, _) +#define SLANG_ABSTRACT_AST_CLASS(NAME) SLANG_ASTNode_##NAME(SLANG_AST_CLASS_REFLECT_IMPL, _) +#define SLANG_AST_CLASS(NAME) SLANG_ASTNode_##NAME(SLANG_AST_CLASS_REFLECT_IMPL, _) // Macros for simulating virtual methods without virtual methods diff --git a/source/slang/slang-ast-stmt.h b/source/slang/slang-ast-stmt.h index 2fb10db1f..07fc9eeb5 100644 --- a/source/slang/slang-ast-stmt.h +++ b/source/slang/slang-ast-stmt.h @@ -10,7 +10,7 @@ namespace Slang { class ScopeStmt : public Stmt { - SLANG_ABSTRACT_CLASS(ScopeStmt) + SLANG_ABSTRACT_AST_CLASS(ScopeStmt) ScopeDecl* scopeDecl = nullptr; }; @@ -18,7 +18,7 @@ class ScopeStmt : public Stmt // A sequence of statements, treated as a single statement class SeqStmt : public Stmt { - SLANG_CLASS(SeqStmt) + SLANG_AST_CLASS(SeqStmt) List<Stmt*> stmts; }; @@ -26,7 +26,7 @@ class SeqStmt : public Stmt // The simplest kind of scope statement: just a `{...}` block class BlockStmt : public ScopeStmt { - SLANG_CLASS(BlockStmt) + SLANG_AST_CLASS(BlockStmt) Stmt* body = nullptr; }; @@ -35,7 +35,7 @@ class BlockStmt : public ScopeStmt // we want to let a downstream compiler handle any issues class UnparsedStmt : public Stmt { - SLANG_CLASS(UnparsedStmt) + SLANG_AST_CLASS(UnparsedStmt) // The tokens that were contained between `{` and `}` List<Token> tokens; @@ -43,24 +43,24 @@ class UnparsedStmt : public Stmt class EmptyStmt : public Stmt { - SLANG_CLASS(EmptyStmt) + SLANG_AST_CLASS(EmptyStmt) }; class DiscardStmt : public Stmt { - SLANG_CLASS(DiscardStmt) + SLANG_AST_CLASS(DiscardStmt) }; class DeclStmt : public Stmt { - SLANG_CLASS(DeclStmt) + SLANG_AST_CLASS(DeclStmt) DeclBase* decl = nullptr; }; class IfStmt : public Stmt { - SLANG_CLASS(IfStmt) + SLANG_AST_CLASS(IfStmt) Expr* predicate = nullptr; Stmt* positiveStatement = nullptr; @@ -70,13 +70,13 @@ class IfStmt : public Stmt // A statement that can be escaped with a `break` class BreakableStmt : public ScopeStmt { - SLANG_ABSTRACT_CLASS(BreakableStmt) + SLANG_ABSTRACT_AST_CLASS(BreakableStmt) }; class SwitchStmt : public BreakableStmt { - SLANG_CLASS(SwitchStmt) + SLANG_AST_CLASS(SwitchStmt) Expr* condition = nullptr; Stmt* body = nullptr; @@ -87,7 +87,7 @@ class SwitchStmt : public BreakableStmt // outer statement that it is associated with... class ChildStmt : public Stmt { - SLANG_ABSTRACT_CLASS(ChildStmt) + SLANG_ABSTRACT_AST_CLASS(ChildStmt) Stmt* parentStmt = nullptr; }; @@ -99,14 +99,14 @@ class ChildStmt : public Stmt // sub-statement. I'm leaving that out for now for simplicity. class CaseStmtBase : public ChildStmt { - SLANG_ABSTRACT_CLASS(CaseStmtBase) + SLANG_ABSTRACT_AST_CLASS(CaseStmtBase) }; // a `case` statement inside a `switch` class CaseStmt : public CaseStmtBase { - SLANG_CLASS(CaseStmt) + SLANG_AST_CLASS(CaseStmt) Expr* expr = nullptr; }; @@ -114,13 +114,13 @@ class CaseStmt : public CaseStmtBase // a `default` statement inside a `switch` class DefaultStmt : public CaseStmtBase { - SLANG_CLASS(DefaultStmt) + SLANG_AST_CLASS(DefaultStmt) }; // a `default` statement inside a `switch` class GpuForeachStmt : public ScopeStmt { - SLANG_CLASS(GpuForeachStmt) + SLANG_AST_CLASS(GpuForeachStmt) Expr* renderer = nullptr; Expr* gridDims = nullptr; @@ -131,14 +131,14 @@ class GpuForeachStmt : public ScopeStmt // A statement that represents a loop, and can thus be escaped with a `continue` class LoopStmt : public BreakableStmt { - SLANG_ABSTRACT_CLASS(LoopStmt) + SLANG_ABSTRACT_AST_CLASS(LoopStmt) }; // A `for` statement class ForStmt : public LoopStmt { - SLANG_CLASS(ForStmt) + SLANG_AST_CLASS(ForStmt) Stmt* initialStatement = nullptr; Expr* sideEffectExpression = nullptr; @@ -150,13 +150,13 @@ class ForStmt : public LoopStmt // of the loop variable to the body. class UnscopedForStmt : public ForStmt { - SLANG_CLASS(UnscopedForStmt) + SLANG_AST_CLASS(UnscopedForStmt) ; }; class WhileStmt : public LoopStmt { - SLANG_CLASS(WhileStmt) + SLANG_AST_CLASS(WhileStmt) Expr* predicate = nullptr; Stmt* statement = nullptr; @@ -164,7 +164,7 @@ class WhileStmt : public LoopStmt class DoWhileStmt : public LoopStmt { - SLANG_CLASS(DoWhileStmt) + SLANG_AST_CLASS(DoWhileStmt) Stmt* statement = nullptr; Expr* predicate = nullptr; @@ -173,7 +173,7 @@ class DoWhileStmt : public LoopStmt // A compile-time, range-based `for` loop, which will not appear in the output code class CompileTimeForStmt : public ScopeStmt { - SLANG_CLASS(CompileTimeForStmt) + SLANG_AST_CLASS(CompileTimeForStmt) VarDecl* varDecl = nullptr; Expr* rangeBeginExpr = nullptr; @@ -187,29 +187,29 @@ class CompileTimeForStmt : public ScopeStmt // to their parent statement. class JumpStmt : public ChildStmt { - SLANG_ABSTRACT_CLASS(JumpStmt) + SLANG_ABSTRACT_AST_CLASS(JumpStmt) }; class BreakStmt : public JumpStmt { - SLANG_CLASS(BreakStmt) + SLANG_AST_CLASS(BreakStmt) }; class ContinueStmt : public JumpStmt { - SLANG_CLASS(ContinueStmt) + SLANG_AST_CLASS(ContinueStmt) }; class ReturnStmt : public Stmt { - SLANG_CLASS(ReturnStmt) + SLANG_AST_CLASS(ReturnStmt) Expr* expression = nullptr; }; class ExpressionStmt : public Stmt { - SLANG_CLASS(ExpressionStmt) + SLANG_AST_CLASS(ExpressionStmt) Expr* expression = nullptr; }; diff --git a/source/slang/slang-ast-type.h b/source/slang/slang-ast-type.h index b2e43a507..4c2242794 100644 --- a/source/slang/slang-ast-type.h +++ b/source/slang/slang-ast-type.h @@ -11,7 +11,7 @@ namespace Slang { // The type of a reference to an overloaded name class OverloadGroupType : public Type { - SLANG_CLASS(OverloadGroupType) + SLANG_AST_CLASS(OverloadGroupType) // Overrides should be public so base classes can access String _toStringOverride(); @@ -24,7 +24,7 @@ class OverloadGroupType : public Type // been coerced to some other type) class InitializerListType : public Type { - SLANG_CLASS(InitializerListType) + SLANG_AST_CLASS(InitializerListType) // Overrides should be public so base classes can access @@ -37,7 +37,7 @@ class InitializerListType : public Type // The type of an expression that was erroneous class ErrorType : public Type { - SLANG_CLASS(ErrorType) + SLANG_AST_CLASS(ErrorType) // Overrides should be public so base classes can access String _toStringOverride(); @@ -50,7 +50,7 @@ class ErrorType : public Type // A type that takes the form of a reference to some declaration class DeclRefType : public Type { - SLANG_CLASS(DeclRefType) + SLANG_AST_CLASS(DeclRefType) DeclRef<Decl> declRef; @@ -73,7 +73,7 @@ protected: // Base class for types that can be used in arithmetic expressions class ArithmeticExpressionType : public DeclRefType { - SLANG_ABSTRACT_CLASS(ArithmeticExpressionType) + SLANG_ABSTRACT_AST_CLASS(ArithmeticExpressionType) BasicExpressionType* getScalarType(); @@ -83,7 +83,7 @@ class ArithmeticExpressionType : public DeclRefType class BasicExpressionType : public ArithmeticExpressionType { - SLANG_CLASS(BasicExpressionType) + SLANG_AST_CLASS(BasicExpressionType) BaseType baseType; @@ -104,12 +104,12 @@ protected: // mapping to the IR level. class BuiltinType : public DeclRefType { - SLANG_ABSTRACT_CLASS(BuiltinType) + SLANG_ABSTRACT_AST_CLASS(BuiltinType) }; class FeedbackType : public BuiltinType { - SLANG_CLASS(FeedbackType) + SLANG_AST_CLASS(FeedbackType) enum class Kind : uint8_t { @@ -123,7 +123,7 @@ class FeedbackType : public BuiltinType // Resources that contain "elements" that can be fetched class ResourceType : public BuiltinType { - SLANG_ABSTRACT_CLASS(ResourceType) + SLANG_ABSTRACT_AST_CLASS(ResourceType) // The type that results from fetching an element from this resource Type* elementType = nullptr; @@ -143,7 +143,7 @@ class ResourceType : public BuiltinType class TextureTypeBase : public ResourceType { - SLANG_ABSTRACT_CLASS(TextureTypeBase) + SLANG_ABSTRACT_AST_CLASS(TextureTypeBase) protected: TextureTypeBase(TextureFlavor inFlavor, Type* inElementType) @@ -157,7 +157,7 @@ protected: class TextureType : public TextureTypeBase { - SLANG_CLASS(TextureType) + SLANG_AST_CLASS(TextureType) protected: TextureType(TextureFlavor flavor, Type* elementType) @@ -170,7 +170,7 @@ protected: // as they exist in, e.g., GLSL class TextureSamplerType : public TextureTypeBase { - SLANG_CLASS(TextureSamplerType) + SLANG_AST_CLASS(TextureSamplerType) protected: TextureSamplerType(TextureFlavor flavor, Type* elementType) @@ -181,7 +181,7 @@ protected: // This is a base type for `image*` types, as they exist in GLSL class GLSLImageType : public TextureTypeBase { - SLANG_CLASS(GLSLImageType) + SLANG_AST_CLASS(GLSLImageType) protected: GLSLImageType( @@ -193,7 +193,7 @@ protected: class SamplerStateType : public BuiltinType { - SLANG_CLASS(SamplerStateType) + SLANG_AST_CLASS(SamplerStateType) // What flavor of sampler state is this SamplerStateFlavor flavor; @@ -202,7 +202,7 @@ class SamplerStateType : public BuiltinType // Other cases of generic types known to the compiler class BuiltinGenericType : public BuiltinType { - SLANG_CLASS(BuiltinGenericType) + SLANG_AST_CLASS(BuiltinGenericType) Type* elementType = nullptr; @@ -214,7 +214,7 @@ class BuiltinGenericType : public BuiltinType // in the element type. class PointerLikeType : public BuiltinGenericType { - SLANG_CLASS(PointerLikeType) + SLANG_AST_CLASS(PointerLikeType) }; @@ -222,65 +222,65 @@ class PointerLikeType : public BuiltinGenericType class HLSLStructuredBufferTypeBase : public BuiltinGenericType { - SLANG_CLASS(HLSLStructuredBufferTypeBase) + SLANG_AST_CLASS(HLSLStructuredBufferTypeBase) }; class HLSLStructuredBufferType : public HLSLStructuredBufferTypeBase { - SLANG_CLASS(HLSLStructuredBufferType) + SLANG_AST_CLASS(HLSLStructuredBufferType) }; class HLSLRWStructuredBufferType : public HLSLStructuredBufferTypeBase { - SLANG_CLASS(HLSLRWStructuredBufferType) + SLANG_AST_CLASS(HLSLRWStructuredBufferType) }; class HLSLRasterizerOrderedStructuredBufferType : public HLSLStructuredBufferTypeBase { - SLANG_CLASS(HLSLRasterizerOrderedStructuredBufferType) + SLANG_AST_CLASS(HLSLRasterizerOrderedStructuredBufferType) }; class UntypedBufferResourceType : public BuiltinType { - SLANG_CLASS(UntypedBufferResourceType) + SLANG_AST_CLASS(UntypedBufferResourceType) }; class HLSLByteAddressBufferType : public UntypedBufferResourceType { - SLANG_CLASS(HLSLByteAddressBufferType) + SLANG_AST_CLASS(HLSLByteAddressBufferType) }; class HLSLRWByteAddressBufferType : public UntypedBufferResourceType { - SLANG_CLASS(HLSLRWByteAddressBufferType) + SLANG_AST_CLASS(HLSLRWByteAddressBufferType) }; class HLSLRasterizerOrderedByteAddressBufferType : public UntypedBufferResourceType { - SLANG_CLASS(HLSLRasterizerOrderedByteAddressBufferType) + SLANG_AST_CLASS(HLSLRasterizerOrderedByteAddressBufferType) }; class RaytracingAccelerationStructureType : public UntypedBufferResourceType { - SLANG_CLASS(RaytracingAccelerationStructureType) + SLANG_AST_CLASS(RaytracingAccelerationStructureType) }; class HLSLAppendStructuredBufferType : public HLSLStructuredBufferTypeBase { - SLANG_CLASS(HLSLAppendStructuredBufferType) + SLANG_AST_CLASS(HLSLAppendStructuredBufferType) }; class HLSLConsumeStructuredBufferType : public HLSLStructuredBufferTypeBase { - SLANG_CLASS(HLSLConsumeStructuredBufferType) + SLANG_AST_CLASS(HLSLConsumeStructuredBufferType) }; class HLSLPatchType : public BuiltinType { - SLANG_CLASS(HLSLPatchType) + SLANG_AST_CLASS(HLSLPatchType) Type* getElementType(); IntVal* getElementCount(); @@ -288,12 +288,12 @@ class HLSLPatchType : public BuiltinType class HLSLInputPatchType : public HLSLPatchType { - SLANG_CLASS(HLSLInputPatchType) + SLANG_AST_CLASS(HLSLInputPatchType) }; class HLSLOutputPatchType : public HLSLPatchType { - SLANG_CLASS(HLSLOutputPatchType) + SLANG_AST_CLASS(HLSLOutputPatchType) }; @@ -301,29 +301,29 @@ class HLSLOutputPatchType : public HLSLPatchType class HLSLStreamOutputType : public BuiltinGenericType { - SLANG_CLASS(HLSLStreamOutputType) + SLANG_AST_CLASS(HLSLStreamOutputType) }; class HLSLPointStreamType : public HLSLStreamOutputType { - SLANG_CLASS(HLSLPointStreamType) + SLANG_AST_CLASS(HLSLPointStreamType) }; class HLSLLineStreamType : public HLSLStreamOutputType { - SLANG_CLASS(HLSLLineStreamType) + SLANG_AST_CLASS(HLSLLineStreamType) }; class HLSLTriangleStreamType : public HLSLStreamOutputType { - SLANG_CLASS(HLSLTriangleStreamType) + SLANG_AST_CLASS(HLSLTriangleStreamType) }; // class GLSLInputAttachmentType : public BuiltinType { - SLANG_CLASS(GLSLInputAttachmentType) + SLANG_AST_CLASS(GLSLInputAttachmentType) }; @@ -331,17 +331,17 @@ class GLSLInputAttachmentType : public BuiltinType // declarations, includeing HLSL `cbuffer` or GLSL `uniform` blocks. class ParameterGroupType : public PointerLikeType { - SLANG_CLASS(ParameterGroupType) + SLANG_AST_CLASS(ParameterGroupType) }; class UniformParameterGroupType : public ParameterGroupType { - SLANG_CLASS(UniformParameterGroupType) + SLANG_AST_CLASS(UniformParameterGroupType) }; class VaryingParameterGroupType : public ParameterGroupType { - SLANG_CLASS(VaryingParameterGroupType) + SLANG_AST_CLASS(VaryingParameterGroupType) }; @@ -349,45 +349,45 @@ class VaryingParameterGroupType : public ParameterGroupType // ALso used for GLSL `uniform` blocks. class ConstantBufferType : public UniformParameterGroupType { - SLANG_CLASS(ConstantBufferType) + SLANG_AST_CLASS(ConstantBufferType) }; // type for HLSL `tbuffer` declarations, and `TextureBuffer<T>` class TextureBufferType : public UniformParameterGroupType { - SLANG_CLASS(TextureBufferType) + SLANG_AST_CLASS(TextureBufferType) }; // type for GLSL `in` and `out` blocks class GLSLInputParameterGroupType : public VaryingParameterGroupType { - SLANG_CLASS(GLSLInputParameterGroupType) + SLANG_AST_CLASS(GLSLInputParameterGroupType) }; class GLSLOutputParameterGroupType : public VaryingParameterGroupType { - SLANG_CLASS(GLSLOutputParameterGroupType) + SLANG_AST_CLASS(GLSLOutputParameterGroupType) }; // type for GLLSL `buffer` blocks class GLSLShaderStorageBufferType : public UniformParameterGroupType { - SLANG_CLASS(GLSLShaderStorageBufferType) + SLANG_AST_CLASS(GLSLShaderStorageBufferType) }; // type for Slang `ParameterBlock<T>` type class ParameterBlockType : public UniformParameterGroupType { - SLANG_CLASS(ParameterBlockType) + SLANG_AST_CLASS(ParameterBlockType) }; class ArrayExpressionType : public Type { - SLANG_CLASS(ArrayExpressionType) + SLANG_AST_CLASS(ArrayExpressionType) Type* baseType = nullptr; IntVal* arrayLength = nullptr; @@ -405,7 +405,7 @@ class ArrayExpressionType : public Type // `float` would have the type `TypeType(float)`. class TypeType : public Type { - SLANG_CLASS(TypeType) + SLANG_AST_CLASS(TypeType) // The type that this is the type of... Type* type = nullptr; @@ -427,7 +427,7 @@ protected: // A vector type, e.g., `vector<T,N>` class VectorExpressionType : public ArithmeticExpressionType { - SLANG_CLASS(VectorExpressionType) + SLANG_AST_CLASS(VectorExpressionType) // The type of vector elements. // As an invariant, this should be a basic type or an alias. @@ -444,7 +444,7 @@ class VectorExpressionType : public ArithmeticExpressionType // A matrix type, e.g., `matrix<T,R,C>` class MatrixExpressionType : public ArithmeticExpressionType { - SLANG_CLASS(MatrixExpressionType) + SLANG_AST_CLASS(MatrixExpressionType) Type* getElementType(); IntVal* getRowCount(); @@ -463,19 +463,19 @@ private: // The built-in `String` type class StringType : public BuiltinType { - SLANG_CLASS(StringType) + SLANG_AST_CLASS(StringType) }; // The built-in `__Dynamic` type class DynamicType : public BuiltinType { - SLANG_CLASS(DynamicType) + SLANG_AST_CLASS(DynamicType) }; // Type built-in `__EnumType` type class EnumTypeType : public BuiltinType { - SLANG_CLASS(EnumTypeType) + SLANG_AST_CLASS(EnumTypeType) // TODO: provide accessors for the declaration, the "tag" type, etc. }; @@ -483,7 +483,7 @@ class EnumTypeType : public BuiltinType // simple pointers as part of code generation. class PtrTypeBase : public BuiltinType { - SLANG_CLASS(PtrTypeBase) + SLANG_AST_CLASS(PtrTypeBase) // Get the type of the pointed-to value. Type* getValueType(); @@ -492,7 +492,7 @@ class PtrTypeBase : public BuiltinType // A true (user-visible) pointer type, e.g., `T*` class PtrType : public PtrTypeBase { - SLANG_CLASS(PtrType) + SLANG_AST_CLASS(PtrType) }; // A type that represents the behind-the-scenes @@ -500,31 +500,31 @@ class PtrType : public PtrTypeBase // or `in out` parameter class OutTypeBase : public PtrTypeBase { - SLANG_CLASS(OutTypeBase) + SLANG_AST_CLASS(OutTypeBase) }; // The type for an `out` parameter, e.g., `out T` class OutType : public OutTypeBase { - SLANG_CLASS(OutType) + SLANG_AST_CLASS(OutType) }; // The type for an `in out` parameter, e.g., `in out T` class InOutType : public OutTypeBase { - SLANG_CLASS(InOutType) + SLANG_AST_CLASS(InOutType) }; // The type for an `ref` parameter, e.g., `ref T` class RefType : public PtrTypeBase { - SLANG_CLASS(RefType) + SLANG_AST_CLASS(RefType) }; // A type alias of some kind (e.g., via `typedef`) class NamedExpressionType : public Type { - SLANG_CLASS(NamedExpressionType) + SLANG_AST_CLASS(NamedExpressionType) DeclRef<TypeDefDecl> declRef; Type* innerType = nullptr; @@ -548,7 +548,7 @@ protected: // and its result type. class FuncType : public Type { - SLANG_CLASS(FuncType) + SLANG_AST_CLASS(FuncType) // TODO: We may want to preserve parameter names // in the list here, just so that we can print @@ -574,7 +574,7 @@ class FuncType : public Type // The "type" of an expression that names a generic declaration. class GenericDeclRefType : public Type { - SLANG_CLASS(GenericDeclRefType) + SLANG_AST_CLASS(GenericDeclRefType) DeclRef<GenericDecl> declRef; @@ -596,7 +596,7 @@ protected: // The "type" of a reference to a module or namespace class NamespaceType : public Type { - SLANG_CLASS(NamespaceType) + SLANG_AST_CLASS(NamespaceType) DeclRef<NamespaceDeclBase> declRef; @@ -613,7 +613,7 @@ class NamespaceType : public Type // when the existential is "opened" in some context. class ExtractExistentialType : public Type { - SLANG_CLASS(ExtractExistentialType) + SLANG_AST_CLASS(ExtractExistentialType) DeclRef<VarDeclBase> declRef; DeclRef<InterfaceDecl> interfaceDeclRef; @@ -629,7 +629,7 @@ class ExtractExistentialType : public Type /// A tagged union of zero or more other types. class TaggedUnionType : public Type { - SLANG_CLASS(TaggedUnionType) + SLANG_AST_CLASS(TaggedUnionType) /// The distinct "cases" the tagged union can store. /// @@ -648,7 +648,7 @@ class TaggedUnionType : public Type class ExistentialSpecializedType : public Type { - SLANG_CLASS(ExistentialSpecializedType) + SLANG_AST_CLASS(ExistentialSpecializedType) Type* baseType = nullptr; ExpandedSpecializationArgs args; @@ -664,7 +664,7 @@ class ExistentialSpecializedType : public Type /// The type of `this` within a polymorphic declaration class ThisType : public Type { - SLANG_CLASS(ThisType) + SLANG_AST_CLASS(ThisType) DeclRef<InterfaceDecl> interfaceDeclRef; diff --git a/source/slang/slang-ast-val.h b/source/slang/slang-ast-val.h index 6bc86e805..af137395b 100644 --- a/source/slang/slang-ast-val.h +++ b/source/slang/slang-ast-val.h @@ -11,13 +11,13 @@ namespace Slang { // A compile-time integer (may not have a specific concrete value) class IntVal : public Val { - SLANG_ABSTRACT_CLASS(IntVal) + SLANG_ABSTRACT_AST_CLASS(IntVal) }; // Trivial case of a value that is just a constant integer class ConstantIntVal : public IntVal { - SLANG_CLASS(ConstantIntVal) + SLANG_AST_CLASS(ConstantIntVal) IntegerLiteralValue value; @@ -36,7 +36,7 @@ protected: // The logical "value" of a reference to a generic value parameter class GenericParamIntVal : public IntVal { - SLANG_CLASS(GenericParamIntVal) + SLANG_AST_CLASS(GenericParamIntVal) DeclRef<VarDeclBase> declRef; @@ -55,7 +55,7 @@ protected: /// An unknown integer value indicating an erroneous sub-expression class ErrorIntVal : public IntVal { - SLANG_CLASS(ErrorIntVal) + SLANG_AST_CLASS(ErrorIntVal) // TODO: We should probably eventually just have an `ErrorVal` here // and have all `Val`s that represent ordinary values hold their @@ -103,7 +103,7 @@ class ErrorIntVal : public IntVal // class Witness : public Val { - SLANG_ABSTRACT_CLASS(Witness) + SLANG_ABSTRACT_AST_CLASS(Witness) }; // A witness that one type is a subtype of another @@ -113,7 +113,7 @@ class Witness : public Val // TODO: we may need to tease those apart. class SubtypeWitness : public Witness { - SLANG_ABSTRACT_CLASS(SubtypeWitness) + SLANG_ABSTRACT_AST_CLASS(SubtypeWitness) Type* sub = nullptr; Type* sup = nullptr; @@ -121,7 +121,7 @@ class SubtypeWitness : public Witness class TypeEqualityWitness : public SubtypeWitness { - SLANG_CLASS(TypeEqualityWitness) + SLANG_AST_CLASS(TypeEqualityWitness) // Overrides should be public so base classes can access bool _equalsValOverride(Val* val); @@ -134,7 +134,7 @@ class TypeEqualityWitness : public SubtypeWitness // because some in-scope declaration says so class DeclaredSubtypeWitness : public SubtypeWitness { - SLANG_CLASS(DeclaredSubtypeWitness) + SLANG_AST_CLASS(DeclaredSubtypeWitness) DeclRef<Decl> declRef; @@ -148,7 +148,7 @@ class DeclaredSubtypeWitness : public SubtypeWitness // A witness that `sub : sup` because `sub : mid` and `mid : sup` class TransitiveSubtypeWitness : public SubtypeWitness { - SLANG_CLASS(TransitiveSubtypeWitness) + SLANG_AST_CLASS(TransitiveSubtypeWitness) // Witness that `sub : mid` SubtypeWitness* subToMid = nullptr; @@ -167,7 +167,7 @@ class TransitiveSubtypeWitness : public SubtypeWitness // an existential of type `sup`. class ExtractExistentialSubtypeWitness : public SubtypeWitness { - SLANG_CLASS(ExtractExistentialSubtypeWitness) + SLANG_AST_CLASS(ExtractExistentialSubtypeWitness) // The declaration of the existential value that has been opened DeclRef<VarDeclBase> declRef; @@ -185,7 +185,7 @@ class ExtractExistentialSubtypeWitness : public SubtypeWitness // class TaggedUnionSubtypeWitness : public SubtypeWitness { - SLANG_CLASS(TaggedUnionSubtypeWitness) + SLANG_AST_CLASS(TaggedUnionSubtypeWitness) // Witnesses that each of the "case" types in the union // is a subtype of `sup`. @@ -203,14 +203,14 @@ class TaggedUnionSubtypeWitness : public SubtypeWitness /// A witness of the fact that `ThisType(someInterface) : someInterface` class ThisTypeSubtypeWitness : public SubtypeWitness { - SLANG_CLASS(ThisTypeSubtypeWitness) + SLANG_AST_CLASS(ThisTypeSubtypeWitness) }; /// A witness of the fact that a user provided "__Dynamic" type argument is a /// subtype to the existential type parameter. class DynamicSubtypeWitness : public SubtypeWitness { - SLANG_CLASS(DynamicSubtypeWitness) + SLANG_AST_CLASS(DynamicSubtypeWitness) }; } // namespace Slang |
