From c15006c15505ae785eb5447c055b8f9379e7fcde Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 3 Apr 2015 22:57:27 +0800 Subject: Added partial support for #[derive()] - Supports Debug on struct, and assumes compiling in libcore (for now) --- src/include/main_bindings.hpp | 11 +++++++++++ src/include/synext.hpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/include/synext.hpp (limited to 'src/include') diff --git a/src/include/main_bindings.hpp b/src/include/main_bindings.hpp index fef57184..91bac742 100644 --- a/src/include/main_bindings.hpp +++ b/src/include/main_bindings.hpp @@ -5,13 +5,24 @@ #include "../ast/ast.hpp" +/// Parse a crate from the given file extern AST::Crate Parse_Crate(::std::string mainfile); +/// Process #[] decorators +extern void Process_Decorators(AST::Crate& crate); +/// Resolve all in-text paths to absolute variants extern void ResolvePaths(AST::Crate& crate); +/// Check that generic bounds are valid extern void Typecheck_GenericBounds(AST::Crate& crate); +/// Check that parameters for generics are valid extern void Typecheck_GenericParams(AST::Crate& crate); +/// Type resolution (and hence checking) for expressions extern void Typecheck_Expr(AST::Crate& crate); + +/// Convert the AST to a flat tree extern AST::Flat Convert_Flatten(const AST::Crate& crate); + +/// Dump the crate as annotated rust extern void Dump_Rust(const char *Filename, const AST::Crate& crate); #endif diff --git a/src/include/synext.hpp b/src/include/synext.hpp new file mode 100644 index 00000000..6688c1c7 --- /dev/null +++ b/src/include/synext.hpp @@ -0,0 +1,33 @@ +/* + */ +#ifndef _SYNEXT_HPP_ +#define _SYNEXT_HPP_ + +#include "../common.hpp" // for mv$ and other things +#include +#include + +namespace AST { + class MetaItem; + class Path; + class Module; + class Struct; +} + +class CDecoratorHandler +{ +public: + virtual void handle_item(AST::Module& mod, const AST::MetaItem& attr, const AST::Path& path, AST::Struct& str) const = 0; +}; + +#define STATIC_SYNEXT(_type, ident, _typename) \ + struct register_##_typename##_c {\ + register_##_typename##_c() {\ + Register_Synext_##_type( ident, ::std::unique_ptr(new _typename()) ); \ + } \ + } s_register_##_typename; + +extern void Register_Synext_Decorator(::std::string name, ::std::unique_ptr handler); + +#endif + -- cgit v1.2.3