diff options
Diffstat (limited to 'source/slang/syntax-base-defs.h')
| -rw-r--r-- | source/slang/syntax-base-defs.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/syntax-base-defs.h b/source/slang/syntax-base-defs.h index eda554988..bcb37de09 100644 --- a/source/slang/syntax-base-defs.h +++ b/source/slang/syntax-base-defs.h @@ -10,6 +10,16 @@ ABSTRACT_SYNTAX_CLASS(SyntaxNodeBase, RefObject) // The primary source location associated with this AST node FIELD(CodePosition, Position) + + RAW( + // Allow dynamic casting with a convenient syntax + template<typename T> + T* As() + { + return dynamic_cast<T*>(this); + } + ) + END_SYNTAX_CLASS() // Base class for compile-time values (most often a type). |
