summaryrefslogtreecommitdiff
path: root/source/slang/object-meta-begin.h
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-06-29 08:55:09 -0700
committerTim Foley <tfoley@nvidia.com>2017-06-30 12:22:33 -0700
commitcab694dcead92a554654d7fa3f08909d519425f0 (patch)
tree6c2c07c3930ff68b5518e562b0b507d5ec54d0bf /source/slang/object-meta-begin.h
parentb2b08679a32506d629df84730f36639dab9f9593 (diff)
Add meta-definitions for AST types
- The big change here is that all the definitions for syntax-node classes have been macro-ized, to that we can do light metaprogramming over them - The use of macros for this has big down-sides, but I'm not quite ready to do anything more heavy-weight right now - The macro-ized definitions can be included multiple times, to generate different declarations/code as needed - The first example of using this meta-programming facility is a new visitor system - The actual visitor base classes and the dispatch logic are all generated from the meta-files - There was only one visitor left in the code: the semantics checker, so that was ported to the new system. - All current test cases pass, so *of course* that means all is well.
Diffstat (limited to 'source/slang/object-meta-begin.h')
-rw-r--r--source/slang/object-meta-begin.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/source/slang/object-meta-begin.h b/source/slang/object-meta-begin.h
new file mode 100644
index 000000000..e4187a600
--- /dev/null
+++ b/source/slang/object-meta-begin.h
@@ -0,0 +1,36 @@
+// object-meta-begin.h
+
+#ifndef SYNTAX_CLASS
+#error The 'SYNTAX_CLASS' macro should be defined before including 'object-meta-begin.h'
+#endif
+
+#ifndef ABSTRACT_SYNTAX_CLASS
+#define ABSTRACT_SYNTAX_CLASS(NAME, BASE) SYNTAX_CLASS(NAME, BASE)
+#endif
+
+#ifndef END_SYNTAX_CLASS
+#define END_SYNTAX_CLASS() /* empty */
+#endif
+
+#ifndef DECL_FIELD
+#define DECL_FIELD(TYPE, NAME) SYNTAX_FIELD(TYPE, NAME)
+#endif
+
+#ifndef SYNTAX_FIELD
+#define SYNTAX_FIELD(TYPE, NAME) FIELD(TYPE, NAME)
+#endif
+
+#ifndef FIELD_INIT
+#define FIELD_INIT(TYPE, NAME, INIT) FIELD(TYPE, NAME)
+#endif
+
+#ifndef FIELD
+#define FIELD(...) /* empty */
+#endif
+
+#ifndef RAW
+#define RAW(...) /* empty */
+#endif
+
+#define SIMPLE_SYNTAX_CLASS(NAME, BASE) SYNTAX_CLASS(NAME, BASE) END_SYNTAX_CLASS()
+