// TODO: Create new `make_qualified_call` helper function
DeriveClone::DeriveClone (Location loc)
- : loc (loc), expanded (nullptr), builder (AstBuilder (loc))
+ : DeriveVisitor (loc), expanded (nullptr)
{}
std::unique_ptr<AST::Item>
#define RUST_DERIVE_CLONE_H
#include "rust-derive.h"
-#include "rust-ast-builder.h"
namespace Rust {
namespace AST {
std::unique_ptr<AST::Item> go (Item &item);
private:
- Location loc;
- std::unique_ptr<AST::Item> expanded;
- AstBuilder builder;
+ std::unique_ptr<Item> expanded;
/**
* Create a call to "clone". For now, this creates a call to
namespace Rust {
namespace AST {
-DeriveCopy::DeriveCopy (Location loc)
- : loc (loc), builder (AstBuilder (loc)), expanded (nullptr)
+DeriveCopy::DeriveCopy (Location loc) : DeriveVisitor (loc), expanded (nullptr)
{}
std::unique_ptr<AST::Item>
std::unique_ptr<Item> go (Item &);
private:
- Location loc;
- AstBuilder builder;
std::unique_ptr<Item> expanded;
/**
namespace Rust {
namespace AST {
+DeriveVisitor::DeriveVisitor (Location loc)
+ : loc (loc), builder (AstBuilder (loc))
+{}
+
std::unique_ptr<Item>
DeriveVisitor::derive (Item &item, const Attribute &attr,
BuiltinMacro to_derive)
#include "rust-ast-full.h"
#include "rust-ast-visitor.h"
+#include "rust-ast-builder.h"
#include "rust-macro-builtins.h"
namespace Rust {
static std::unique_ptr<Item> derive (Item &item, const Attribute &derive,
BuiltinMacro to_derive);
+protected:
+ DeriveVisitor (Location loc);
+
+ Location loc;
+ AstBuilder builder;
+
private:
// the 4 "allowed" visitors, which a derive-visitor can specify and override
virtual void visit_struct (StructStruct &struct_item) = 0;