summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast/ast.cpp222
-rw-r--r--src/ast/ast.hpp72
-rw-r--r--src/ast/attrs.hpp10
-rw-r--r--src/ast/crate.cpp54
-rw-r--r--src/ast/crate.hpp10
-rw-r--r--src/ast/expr.cpp278
-rw-r--r--src/ast/expr.hpp16
-rw-r--r--src/ast/generics.hpp19
-rw-r--r--src/ast/item.hpp8
-rw-r--r--src/ast/macro.hpp12
-rw-r--r--src/ast/path.cpp57
-rw-r--r--src/ast/path.hpp12
-rw-r--r--src/ast/types.cpp151
-rw-r--r--src/ast/types.hpp11
-rw-r--r--src/coretypes.hpp5
-rw-r--r--src/parse/lex.cpp4
-rw-r--r--src/parse/token.cpp8
-rw-r--r--src/parse/tokentree.hpp6
18 files changed, 53 insertions, 902 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp
index 8052a51e..b9394702 100644
--- a/src/ast/ast.cpp
+++ b/src/ast/ast.cpp
@@ -44,9 +44,6 @@ MetaItem* MetaItems::get(const char *name)
}
return 0;
}
-SERIALISE_TYPE_A(MetaItems::, "AST_MetaItems", {
- s.item(m_items);
-})
MetaItem::~MetaItem()
{
@@ -67,41 +64,10 @@ MetaItem MetaItem::clone() const
throw ::std::runtime_error("MetaItem::clone - Fell off end");
}
-
-SERIALISE_TYPE(MetaItem::, "AST_MetaItem", {
- s << m_name;
- //s << m_str_val;
- //s << m_sub_items;
-},{
- s.item(m_name);
- //s.item(m_str_val);
- //s.item(m_sub_items);
-})
-
-template<typename T>
-void operator<<(Serialiser& s, const Spanned<T>& x) {
- //s << x.sp;
- s << x.ent;
-}
-template<typename T>
-void operator>>(Deserialiser& s, Spanned<T>& x) {
- //s >> x.sp;
- s >> x.ent;
-}
-
::std::ostream& operator<<(::std::ostream& os, const ImplDef& impl)
{
return os << "impl<" << impl.m_params << "> " << impl.m_trait.ent << " for " << impl.m_type << "";
}
-SERIALISE_TYPE(ImplDef::, "AST_ImplDef", {
- s << m_params;
- s << m_trait;
- s << m_type;
-},{
- s.item(m_params);
- s >> m_trait;
- s.item(m_type);
-})
void Impl::add_function(bool is_public, bool is_specialisable, ::std::string name, Function fcn)
{
@@ -132,11 +98,6 @@ bool Impl::has_named_item(const ::std::string& name) const
{
return os << impl.m_def;
}
-SERIALISE_TYPE(Impl::, "AST_Impl", {
- s << m_def;
-},{
- s.item(m_def);
-})
::rust::option<char> ImplRef::find_named_item(const ::std::string& name) const
{
@@ -154,35 +115,13 @@ SERIALISE_TYPE(Impl::, "AST_Impl", {
return os;
}
-SERIALISE_TYPE_A(UseStmt::, "AST_UseStmt", {
- //s.item(sp);
- s.item(attrs);
- s.item(path);
-})
MacroInvocation MacroInvocation::clone() const
{
return MacroInvocation(m_span, m_attrs.clone(), m_macro_name, m_ident, m_input.clone());
}
-SERIALISE_TYPE_A(MacroInvocation::, "AST_MacroInvocation", {
- s.item(m_attrs);
- s.item(m_macro_name);
- s.item(m_ident);
- s.item(m_input);
-})
-SERIALISE_TYPE_A(Module::, "AST_Module", {
- s.item(m_my_path);
-
- s.item(m_items);
-
- s.item(m_macros);
-
- s.item(m_imports);
-
- s.item(m_impls);
-})
::std::unique_ptr<AST::Module> Module::add_anon() {
auto rv = box$( Module(m_my_path + FMT("#" << m_anon_modules.size())) );
@@ -362,69 +301,7 @@ Module::ItemRef Module::find_item(const ::std::string& needle, bool allow_leaves
return Module::ItemRef();
}
-SERIALISE_TYPE(Item::, "AST_Item", {
- s.item(attrs);
-},{
- s.item(attrs);
-})
-
-SERIALISE_TYPE(TypeAlias::, "AST_TypeAlias", {
- s << m_params;
- s << m_type;
-},{
- s.item(m_params);
- s.item(m_type);
-})
-
-::Serialiser& operator<<(::Serialiser& s, Static::Class fc)
-{
- switch(fc)
- {
- case Static::CONST: s << "CONST"; break;
- case Static::STATIC: s << "STATIC"; break;
- case Static::MUT: s << "MUT"; break;
- }
- return s;
-}
-void operator>>(::Deserialiser& s, Static::Class& fc)
-{
- ::std::string n;
- s.item(n);
- if(n == "CONST") fc = Static::CONST;
- else if(n == "STATIC") fc = Static::STATIC;
- else if(n == "MUT") fc = Static::MUT;
- else
- throw ::std::runtime_error("Deserialise Static::Class");
-}
-SERIALISE_TYPE(Static::, "AST_Static", {
- s << m_class;
- s << m_type;
- s << m_value;
-},{
- s >> m_class;
- s.item(m_type);
- s.item(m_value);
-})
-SERIALISE_TYPE(Function::, "AST_Function", {
- s << m_params;
- s << m_rettype;
- s << m_args;
- s << m_code;
-},{
- s.item(m_params);
- s.item(m_rettype);
- s.item(m_args);
- s.item(m_code);
-})
-
-SERIALISE_TYPE(Trait::, "AST_Trait", {
- s << m_params;
- s << m_items;
-},{
- s.item(m_params);
- s.item(m_items);
-})
void Trait::add_type(::std::string name, TypeRef type) {
m_items.push_back( Named<Item>(mv$(name), Item::make_Type({TypeAlias(GenericParams(), mv$(type))}), true) );
}
@@ -453,51 +330,6 @@ bool Trait::has_named_item(const ::std::string& name, bool& out_is_fcn) const
return false;
}
-SERIALISE_TYPE_A(EnumVariant::, "AST_EnumVariant", {
- s.item(m_attrs);
- s.item(m_name);
- s.item(m_data);
-})
-SERIALISE_TYPE(EnumVariantData::, "AST_EnumVariantData", {
- // TODO: Serialise AST::EnumVariantData
- (void)s;
-},{
- (void)s;
-})
-
-SERIALISE_TYPE(Enum::, "AST_Enum", {
- s << m_params;
- s << m_variants;
-},{
- s.item(m_params);
- s.item(m_variants);
-})
-
-SERIALISE_TYPE(Struct::, "AST_Struct", {
- s << m_params;
- s << m_data;
-},{
- s.item(m_params);
- s.item(m_data);
-})
-SERIALISE_TYPE(StructData::, "AST_StructData", {
- // TODO: AST::StructData serialise
- (void)s;
-},{
- (void)s;
-})
-SERIALISE_TYPE(StructItem::, "AST_StructItem", {
- // TODO: AST::StructItem serialise
- (void)s;
-},{
- (void)s;
-})
-SERIALISE_TYPE(TupleItem::, "AST_TupleItem", {
- // TODO: AST::TupleItem serialise
- (void)s;
-},{
- (void)s;
-})
::std::ostream& operator<<(::std::ostream& os, const TypeParam& tp)
{
@@ -508,13 +340,6 @@ SERIALISE_TYPE(TupleItem::, "AST_TupleItem", {
//os << ")";
return os;
}
-SERIALISE_TYPE(TypeParam::, "AST_TypeParam", {
- s << m_name;
- s << m_default;
-},{
- s.item(m_name);
- s.item(m_default);
-})
::std::ostream& operator<<(::std::ostream& os, const GenericBound& x)
{
@@ -548,46 +373,6 @@ SERIALISE_TYPE(TypeParam::, "AST_TypeParam", {
return os;
}
-#if 0
-#define SERIALISE_TU_ARM(CLASS, NAME, TAG, ...) case CLASS::TAG_##TAG: { *this = CLASS::make_##TAG({}); auto& NAME = this->as_##TAG(); (void)&NAME; __VA_ARGS__ } break;
-#define SERIALISE_TU_ARMS(CLASS, NAME, ...) TU_GMA(__VA_ARGS__)(SERIALISE_TU_ARM, (CLASS, NAME), __VA_ARGS__)
-#define SERIALISE_TU(PATH, TAG, NAME, ...) \
- void operator%(::Serialiser& s, PATH::Tag c) { s << PATH::tag_to_str(c); } \
- void operator%(::Deserialiser& s, PATH::Tag& c) { ::std::string n; s.item(n); c = PATH::tag_from_str(n); }\
- SERIALISE_TYPE(PATH::, TAG, {\
- s % this->tag(); TU_MATCH(PATH, ((*this)), (NAME), __VA_ARGS__)\
- }, {\
- PATH::Tag tag; s % tag; switch(tag) { case PATH::TAGDEAD: throw ""; SERIALISE_TU_ARMS(PATH, NAME, __VA_ARGS__) } \
- })
-#endif
-
-SERIALISE_TU(GenericBound, "GenericBound", ent,
- (Lifetime,
- s.item(ent.test);
- s.item(ent.bound);
- ),
- (TypeLifetime,
- s.item(ent.type);
- s.item(ent.bound);
- ),
- (IsTrait,
- s.item(ent.type);
- s.item(ent.hrls);
- s.item(ent.trait);
- ),
- (MaybeTrait,
- s.item(ent.type);
- s.item(ent.trait);
- ),
- (NotTrait,
- s.item(ent.type);
- s.item(ent.trait);
- ),
- (Equality,
- s.item(ent.type);
- s.item(ent.replacement);
- )
-)
int GenericParams::find_name(const char* name) const
{
@@ -604,10 +389,5 @@ int GenericParams::find_name(const char* name) const
{
return os << "<" << tps.m_lifetime_params << "," << tps.m_type_params << "> where {" << tps.m_bounds << "}";
}
-SERIALISE_TYPE_S(GenericParams, {
- s.item(m_type_params);
- s.item(m_lifetime_params);
- s.item(m_bounds);
-})
-}
+} // namespace AST
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp
index b14d7e46..93b68604 100644
--- a/src/ast/ast.hpp
+++ b/src/ast/ast.hpp
@@ -48,8 +48,7 @@ enum eItemType
ITEM_FN,
};
-struct StructItem:
- public Serialisable
+struct StructItem
{
::AST::MetaItems m_attrs;
bool m_is_public;
@@ -71,12 +70,9 @@ struct StructItem:
friend ::std::ostream& operator<<(::std::ostream& os, const StructItem& x) {
return os << (x.m_is_public ? "pub " : "") << x.m_name << ": " << x.m_type;
}
-
- SERIALISABLE_PROTOTYPES();
};
-struct TupleItem:
- public Serialisable
+struct TupleItem
{
::AST::MetaItems m_attrs;
bool m_is_public;
@@ -96,12 +92,9 @@ struct TupleItem:
friend ::std::ostream& operator<<(::std::ostream& os, const TupleItem& x) {
return os << (x.m_is_public ? "pub " : "") << x.m_type;
}
-
- SERIALISABLE_PROTOTYPES();
};
-class TypeAlias:
- public Serialisable
+class TypeAlias
{
GenericParams m_params;
TypeRef m_type;
@@ -117,12 +110,9 @@ public:
GenericParams& params() { return m_params; }
TypeRef& type() { return m_type; }
-
- SERIALISABLE_PROTOTYPES();
};
-class Static:
- public Serialisable
+class Static
{
public:
enum Class
@@ -151,12 +141,9 @@ public:
TypeRef& type() { return m_type; }
Expr& value() { return m_value; }
-
- SERIALISABLE_PROTOTYPES();
};
-class Function:
- public Serialisable
+class Function
{
public:
typedef ::std::vector< ::std::pair<AST::Pattern,TypeRef> > Arglist;
@@ -192,12 +179,9 @@ public:
Expr& code() { return m_code; }
TypeRef& rettype() { return m_rettype; }
Arglist& args() { return m_args; }
-
- SERIALISABLE_PROTOTYPES();
};
-class Trait:
- public Serialisable
+class Trait
{
GenericParams m_params;
::std::vector< Spanned<AST::Path> > m_supertraits;
@@ -231,11 +215,9 @@ public:
bool is_marker() const;
bool has_named_item(const ::std::string& name, bool& out_is_fcn) const;
-
- SERIALISABLE_PROTOTYPES();
};
-TAGGED_UNION_EX(EnumVariantData, (: public Serialisable), Value,
+TAGGED_UNION_EX(EnumVariantData, (), Value,
(
(Value, struct {
::AST::Expr m_value;
@@ -250,12 +232,10 @@ TAGGED_UNION_EX(EnumVariantData, (: public Serialisable), Value,
(), (),
(
public:
- SERIALISABLE_PROTOTYPES();
)
);
-struct EnumVariant:
- public Serialisable
+struct EnumVariant
{
MetaItems m_attrs;
::std::string m_name;
@@ -302,12 +282,9 @@ struct EnumVariant:
)
return os << ")";
}
-
- SERIALISABLE_PROTOTYPES();
};
-class Enum:
- public Serialisable
+class Enum
{
GenericParams m_params;
::std::vector<EnumVariant> m_variants;
@@ -323,11 +300,9 @@ public:
GenericParams& params() { return m_params; }
::std::vector<EnumVariant>& variants() { return m_variants; }
-
- SERIALISABLE_PROTOTYPES();
};
-TAGGED_UNION_EX(StructData, (: public Serialisable), Struct,
+TAGGED_UNION_EX(StructData, (), Struct,
(
(Tuple, struct {
::std::vector<TupleItem> ents;
@@ -339,12 +314,10 @@ TAGGED_UNION_EX(StructData, (: public Serialisable), Struct,
(),(),
(
public:
- SERIALISABLE_PROTOTYPES();
)
);
-class Struct:
- public Serialisable
+class Struct
{
GenericParams m_params;
public:
@@ -365,11 +338,9 @@ public:
TypeRef get_field_type(const char *name, const ::std::vector<TypeRef>& args);
- SERIALISABLE_PROTOTYPES();
};
-class ImplDef:
- public Serialisable
+class ImplDef
{
Span m_span;
MetaItems m_attrs;
@@ -401,11 +372,9 @@ public:
friend ::std::ostream& operator<<(::std::ostream& os, const ImplDef& impl);
- SERIALISABLE_PROTOTYPES();
};
-class Impl:
- public Serialisable
+class Impl
{
public:
struct ImplItem {
@@ -450,13 +419,11 @@ public:
bool has_named_item(const ::std::string& name) const;
friend ::std::ostream& operator<<(::std::ostream& os, const Impl& impl);
- SERIALISABLE_PROTOTYPES();
private:
};
-struct UseStmt:
- public Serialisable
+struct UseStmt
{
Span sp;
::AST::Path path;
@@ -471,13 +438,10 @@ struct UseStmt:
}
friend ::std::ostream& operator<<(::std::ostream& os, const UseStmt& x);
-
- SERIALISABLE_PROTOTYPES();
};
/// Representation of a parsed (and being converted) function
-class Module:
- public Serialisable
+class Module
{
public:
class ItemRef
@@ -651,14 +615,12 @@ public:
const NamedList<MacroRulesPtr>& macros() const { return m_macros; }
const ::std::vector<NamedNS<const MacroRules*> > macro_imports_res() const { return m_macro_import_res; }
-
- SERIALISABLE_PROTOTYPES();
private:
void resolve_macro_import(const Crate& crate, const ::std::string& modname, const ::std::string& macro_name);
};
-TAGGED_UNION_EX(Item, (: public Serialisable), None,
+TAGGED_UNION_EX(Item, (), None,
(
(None, struct {} ),
(MacroInv, MacroInvocation),
@@ -681,8 +643,6 @@ TAGGED_UNION_EX(Item, (: public Serialisable), None,
public:
MetaItems attrs;
Span span;
-
- SERIALISABLE_PROTOTYPES();
)
);
diff --git a/src/ast/attrs.hpp b/src/ast/attrs.hpp
index fbe63be4..aa892d6d 100644
--- a/src/ast/attrs.hpp
+++ b/src/ast/attrs.hpp
@@ -7,8 +7,7 @@ namespace AST {
//
class MetaItem;
-class MetaItems:
- public Serialisable
+class MetaItems
{
public:
Span m_span;
@@ -37,8 +36,6 @@ public:
friend ::std::ostream& operator<<(::std::ostream& os, const MetaItems& x) {
return os << "[" << x.m_items << "]";
}
-
- SERIALISABLE_PROTOTYPES();
};
@@ -52,8 +49,7 @@ TAGGED_UNION(MetaItemData, None,
})
);
-class MetaItem:
- public Serialisable
+class MetaItem
{
::std::string m_name;
MetaItemData m_data;
@@ -106,8 +102,6 @@ public:
)
return os;
}
-
- SERIALISABLE_PROTOTYPES();
};
} // namespace AST
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp
index 31cfe4a7..f71b6f65 100644
--- a/src/ast/crate.cpp
+++ b/src/ast/crate.cpp
@@ -66,26 +66,15 @@ void Crate::load_extern_crate(::std::string name)
{
throw ParseError::Generic("Can't open crate '" + name + "'");
}
- Deserialiser_TextTree ds(is);
- Deserialiser& d = ds;
+ //Deserialiser_TextTree ds(is);
+ //Deserialiser& d = ds;
ExternCrate ret;
- ret.deserialise( d );
+
+ // TODO: ...
m_extern_crates.insert( make_pair(::std::move(name), ::std::move(ret)) );
}
-SERIALISE_TYPE(Crate::, "AST_Crate", {
- unsigned ls = m_load_std;
- s.item(ls);
- s.item(m_extern_crates);
- s.item(m_root_module);
-},{
- unsigned ls = m_load_std;
- s.item(ls);
- m_load_std = (::AST::Crate::LoadStd)ls;
- s.item(m_extern_crates);
- s.item(m_root_module);
-})
ExternCrate::ExternCrate()
{
@@ -96,35 +85,6 @@ ExternCrate::ExternCrate(const char *path)
throw ParseError::Todo( FMT("Load extern crate from a file - '" << path << "'") );
}
-// Fill runtime-generated structures in the crate
-#if 0
-void ExternCrate::prescan()
-{
- TRACE_FUNCTION;
-
- Crate& cr = m_crate;
-
- cr.m_root_module.prescan();
-
- for( const auto& mi : cr.m_root_module.macro_imports_res() )
- {
- DEBUG("Macro (I) '"<<mi.name<<"' is_pub="<<mi.is_pub);
- if( mi.is_pub )
- {
- m_crate.m_exported_macros.insert( ::std::make_pair(mi.name, mi.data) );
- }
- }
- for( const auto& mi : cr.m_root_module.macros() )
- {
- DEBUG("Macro '"<<mi.name<<"' is_pub="<<mi.is_pub);
- if( mi.is_pub )
- {
- m_crate.m_exported_macros.insert( ::std::make_pair(mi.name, &mi.data) );
- }
- }
-}
-#endif
-
const MacroRules* ExternCrate::find_macro_rules(const ::std::string& name)
{
auto i = m_mr_macros.find(name);
@@ -133,12 +93,6 @@ const MacroRules* ExternCrate::find_macro_rules(const ::std::string& name)
return nullptr;
}
-SERIALISE_TYPE(ExternCrate::, "AST_ExternCrate", {
- (void)s;
-},{
- (void)s;
-})
-
} // namespace AST
diff --git a/src/ast/crate.hpp b/src/ast/crate.hpp
index 24106bfa..2ffd5582 100644
--- a/src/ast/crate.hpp
+++ b/src/ast/crate.hpp
@@ -9,8 +9,7 @@ namespace AST {
class ExternCrate;
-class Crate:
- public Serialisable
+class Crate
{
public:
::std::map< TypeRef, ::std::vector<Impl*> > m_impl_map;
@@ -47,14 +46,11 @@ public:
void load_externs();
void load_extern_crate(::std::string name);
-
- SERIALISABLE_PROTOTYPES();
};
/// Representation of an imported crate
/// - Functions are stored as resolved+typechecked ASTs
-class ExternCrate:
- public Serialisable
+class ExternCrate
{
::std::map< ::std::string, MacroRulesPtr > m_mr_macros;
@@ -73,8 +69,6 @@ public:
//const Crate& crate() const { return m_crate; }
//Module& root_module() { return m_crate.root_module(); }
//const Module& root_module() const { return m_crate.root_module(); }
-
- SERIALISABLE_PROTOTYPES();
};
} // namespace AST
diff --git a/src/ast/expr.cpp b/src/ast/expr.cpp
index ddb72beb..18f9ccae 100644
--- a/src/ast/expr.cpp
+++ b/src/ast/expr.cpp
@@ -28,16 +28,6 @@ void Expr::visit_nodes(NodeVisitor& v) const
else
return os << "/* null */";
}
-SERIALISE_TYPE(Expr::, "Expr", {
- s.item(m_node);
-},{
- bool tmp;
- s.item(tmp);
- if( tmp )
- m_node = ExprNode::from_deserialiser(s);
- else
- m_node.reset();
-});
::std::ostream& operator<<(::std::ostream& os, const ExprNode& node)
{
@@ -49,51 +39,13 @@ SERIALISE_TYPE(Expr::, "Expr", {
}
return os;
}
-::std::unique_ptr<ExprNode> ExprNode::from_deserialiser(Deserialiser& d) {
- ::std::string tag = d.start_object();
-
- DEBUG("tag = " << tag);
- ExprNode* ptr = nullptr;
- #define _(x) if(tag == #x) ptr = new x;
- _(ExprNode_Block)
- else _(ExprNode_Macro)
- else _(ExprNode_Flow)
- else _(ExprNode_LetBinding)
- else _(ExprNode_Assign)
- else _(ExprNode_CallPath)
- else _(ExprNode_CallMethod)
- else _(ExprNode_CallObject)
- else _(ExprNode_Match)
- else _(ExprNode_Loop)
- else _(ExprNode_If)
- else _(ExprNode_IfLet)
- else _(ExprNode_Integer)
- else _(ExprNode_Closure)
- else _(ExprNode_StructLiteral)
- else _(ExprNode_Array)
- else _(ExprNode_Tuple)
- else _(ExprNode_NamedValue)
- else _(ExprNode_Field)
- else _(ExprNode_Deref)
- else _(ExprNode_Cast)
- else _(ExprNode_BinOp)
- else _(ExprNode_UniOp)
- else
- throw ::std::runtime_error("Unknown node type " + tag);
- #undef _
-
- ptr->deserialise(d);
- d.end_object(tag.c_str());
- return ::std::unique_ptr<ExprNode>(ptr);
-}
ExprNode::~ExprNode() {
}
-#define NODE(class, serialise, _print, _clone)\
+#define NODE(class, _print, _clone)\
void class::visit(NodeVisitor& nv) { nv.visit(*this); } \
void class::print(::std::ostream& os) const _print \
- ::std::unique_ptr<ExprNode> class::clone() const _clone \
- SERIALISE_TYPE_S(class, serialise)
+ ::std::unique_ptr<ExprNode> class::clone() const _clone
#define OPT_CLONE(node) (node.get() ? node->clone() : ::AST::ExprNodeP())
namespace {
@@ -105,8 +57,6 @@ namespace {
}
NODE(ExprNode_Block, {
- s.item(m_nodes);
-},{
os << "{";
for(const auto& n : m_nodes)
os << *n << ";";
@@ -121,10 +71,6 @@ NODE(ExprNode_Block, {
})
NODE(ExprNode_Macro, {
- s.item(m_name);
- s.item(m_ident);
- s.item(m_tokens);
-},{
os << m_name << "!";
if( m_ident.size() > 0 )
{
@@ -135,33 +81,7 @@ NODE(ExprNode_Macro, {
return NEWNODE(ExprNode_Macro, m_name, m_ident, m_tokens.clone());
})
-void operator%(::Serialiser& s, const ExprNode_Flow::Type t) {
- switch(t)
- {
- #define _(v) case ExprNode_Flow::v: s << #v; return
- _(RETURN);
- _(BREAK);
- _(CONTINUE);
- #undef _
- }
-}
-void operator%(::Deserialiser& s, ExprNode_Flow::Type& t) {
- ::std::string n;
- s.item(n);
- if(0) ;
- #define _(v) else if(n == #v) t = ExprNode_Flow::v
- _(RETURN);
- _(BREAK);
- _(CONTINUE);
- #undef _
- else
- throw ::std::runtime_error("");
-}
NODE(ExprNode_Flow, {
- s % m_type;
- s.item(m_target);
- s.item(m_value);
-},{
switch(m_type)
{
case RETURN: os << "return"; break;
@@ -175,28 +95,18 @@ NODE(ExprNode_Flow, {
NODE(ExprNode_LetBinding, {
- s.item(m_pat);
- s.item(m_type);
- s.item(m_value);
-},{
os << "let " << m_pat << ": " << m_type << " = " << *m_value;
},{
return NEWNODE(ExprNode_LetBinding, m_pat.clone(), TypeRef(m_type), OPT_CLONE(m_value));
})
NODE(ExprNode_Assign, {
- s.item(m_slot);
- s.item(m_value);
-},{
os << *m_slot << " = " << *m_value;
},{
return NEWNODE(ExprNode_Assign, m_op, m_slot->clone(), m_value->clone());
})
NODE(ExprNode_CallPath, {
- s.item(m_path);
- s.item(m_args);
-},{
os << m_path << "(";
for(const auto& a : m_args) {
os << *a << ",";
@@ -211,10 +121,6 @@ NODE(ExprNode_CallPath, {
})
NODE(ExprNode_CallMethod, {
- s.item(m_val);
- s.item(m_method);
- s.item(m_args);
-},{
os << "(" << *m_val << ")." << m_method << "(";
for(const auto& a : m_args) {
os << *a << ",";
@@ -229,9 +135,6 @@ NODE(ExprNode_CallMethod, {
})
NODE(ExprNode_CallObject, {
- s.item(m_val);
- s.item(m_args);
-},{
os << "(" << *m_val << ")(";
for(const auto& a : m_args) {
os << *a << ",";
@@ -245,51 +148,13 @@ NODE(ExprNode_CallObject, {
return NEWNODE(ExprNode_CallObject, m_val->clone(), mv$(args));
})
-void operator%(::Serialiser& s, const ExprNode_Loop::Type t) {
- switch(t)
- {
- #define _(v) case ExprNode_Loop::v: s << #v; return
- _(LOOP);
- _(WHILE);
- _(WHILELET);
- _(FOR);
- #undef _
- }
-}
-void operator%(::Deserialiser& s, ExprNode_Loop::Type& t) {
- ::std::string n;
- s.item(n);
- if(0) ;
- #define _(v) else if(n == #v) t = ExprNode_Loop::v
- _(LOOP);
- _(WHILE);
- _(WHILELET);
- _(FOR);
- #undef _
- else
- throw ::std::runtime_error("");
-}
NODE(ExprNode_Loop, {
- s % m_type;
- s.item(m_label);
- s.item(m_pattern);
- s.item(m_cond);
- s.item(m_code);
-},{
os << "LOOP [" << m_label << "] " << m_pattern << " in/= " << *m_cond << " " << *m_code;
},{
return NEWNODE(ExprNode_Loop, m_label, m_type, m_pattern.clone(), OPT_CLONE(m_cond), m_code->clone());
})
-SERIALISE_TYPE_A(ExprNode_Match_Arm::, "ExprNode_Match_Arm", {
- s.item(m_patterns);
- s.item(m_cond);
- s.item(m_code);
-});
NODE(ExprNode_Match, {
- s.item(m_val);
- s.item(m_arms);
-},{
os << "match ("<<*m_val<<") {";
for(const auto& arm : m_arms)
{
@@ -314,68 +179,43 @@ NODE(ExprNode_Match, {
})
NODE(ExprNode_If, {
- s.item(m_cond);
- s.item(m_true);
- s.item(m_false);
-},{
os << "if " << *m_cond << " { " << *m_true << " } else { " << *m_false << " }";
},{
return NEWNODE(ExprNode_If, m_cond->clone(), m_true->clone(), OPT_CLONE(m_false));
})
NODE(ExprNode_IfLet, {
- s.item(m_pattern);
- s.item(m_value);
- s.item(m_true);
- s.item(m_false);
-},{
os << "if let " << m_pattern << " = (" << *m_value << ") { " << *m_true << " } else { " << *m_false << " }";
},{
return NEWNODE(ExprNode_IfLet, m_pattern.clone(), m_value->clone(), m_true->clone(), OPT_CLONE(m_false));
})
NODE(ExprNode_Integer, {
- s % m_datatype;
- s.item(m_value);
-},{
os << m_value;
},{
return NEWNODE(ExprNode_Integer, m_value, m_datatype);
})
NODE(ExprNode_Float, {
- s % m_datatype;
- s.item(m_value);
-},{
os << m_value;
},{
return NEWNODE(ExprNode_Float, m_value, m_datatype);
})
NODE(ExprNode_Bool, {
- s.item(m_value);
-},{
os << m_value;
},{
return NEWNODE(ExprNode_Bool, m_value);
})
NODE(ExprNode_String, {
- s.item(m_value);
-},{
os << "\"" << m_value << "\"";
},{
return NEWNODE(ExprNode_String, m_value);
})
NODE(ExprNode_ByteString, {
- s.item(m_value);
-},{
os << "b\"" << m_value << "\"";
},{
return NEWNODE(ExprNode_ByteString, m_value);
})
NODE(ExprNode_Closure, {
- s.item(m_args);
- s.item(m_return);
- s.item(m_code);
-},{
os << "/* todo: closure */";
},{
ExprNode_Closure::args_t args;
@@ -386,10 +226,6 @@ NODE(ExprNode_Closure, {
});
NODE(ExprNode_StructLiteral, {
- s.item(m_path);
- s.item(m_base_value);
- s.item(m_values);
-},{
os << "/* todo: sl */";
},{
ExprNode_StructLiteral::t_values vals;
@@ -402,9 +238,6 @@ NODE(ExprNode_StructLiteral, {
})
NODE(ExprNode_Array, {
- s.item(m_size);
- s.item(m_values);
-},{
os << "[";
if( m_size.get() )
os << *m_values[0] << "; " << *m_size;
@@ -427,8 +260,6 @@ NODE(ExprNode_Array, {
})
NODE(ExprNode_Tuple, {
- s.item(m_values);
-},{
os << "(";
for(const auto& a : m_values) {
os << *a << ",";
@@ -442,110 +273,36 @@ NODE(ExprNode_Tuple, {
})
NODE(ExprNode_NamedValue, {
- s.item(m_path);
-},{
os << m_path;
},{
return NEWNODE(ExprNode_NamedValue, AST::Path(m_path));
})
NODE(ExprNode_Field, {
- s.item(m_obj);
- s.item(m_name);
-},{
os << "(" << *m_obj << ")." << m_name;
},{
return NEWNODE(ExprNode_Field, m_obj->clone(), m_name);
})
NODE(ExprNode_Index, {
- s.item(m_obj);
- s.item(m_idx);
-},{
os << "(" << *m_obj << ")[" << *m_idx << "]";
},{
return NEWNODE(ExprNode_Index, m_obj->clone(), m_idx->clone());
})
NODE(ExprNode_Deref, {
- s.item(m_value);
-},{
os << "*(" << *m_value << ")";
},{
return NEWNODE(ExprNode_Deref, m_value->clone());
});
NODE(ExprNode_Cast, {
- s.item(m_value);
- s.item(m_type);
-},{
os << "(" << *m_value << " as " << m_type << ")";
},{
return NEWNODE(ExprNode_Cast, m_value->clone(), TypeRef(m_type));
})
-void operator%(::Serialiser& s, const ExprNode_BinOp::Type& t) {
- switch(t)
- {
- #define _(v) case ExprNode_BinOp::v: s << #v; return
- _(CMPEQU);
- _(CMPNEQU);
- _(CMPLT);
- _(CMPLTE);
- _(CMPGT);
- _(CMPGTE);
- _(RANGE);
- _(RANGE_INC);
- _(BOOLAND);
- _(BOOLOR);
- _(BITAND);
- _(BITOR);
- _(BITXOR);
- _(SHL);
- _(SHR);
- _(MULTIPLY);
- _(DIVIDE);
- _(MODULO);
- _(ADD);
- _(SUB);
- _(PLACE_IN);
- #undef _
- }
-}
-void operator%(::Deserialiser& s, ExprNode_BinOp::Type& t) {
- ::std::string n;
- s.item(n);
- if(0) ;
- #define _(v) else if(n == #v) t = ExprNode_BinOp::v
- _(CMPEQU);
- _(CMPNEQU);
- _(CMPLT);
- _(CMPLTE);
- _(CMPGT);
- _(CMPGTE);
- _(RANGE);
- _(RANGE_INC);
- _(BOOLAND);
- _(BOOLOR);
- _(BITAND);
- _(BITOR);
- _(BITXOR);
- _(SHL);
- _(SHR);
- _(MULTIPLY);
- _(DIVIDE);
- _(MODULO);
- _(ADD);
- _(SUB);
- #undef _
- else
- throw ::std::runtime_error("");
-}
NODE(ExprNode_BinOp, {
- s % m_type;
- s.item(m_left);
- s.item(m_right);
-},{
os << "(" << *m_left << " ";
switch(m_type)
{
@@ -576,38 +333,7 @@ NODE(ExprNode_BinOp, {
return NEWNODE(ExprNode_BinOp, m_type, OPT_CLONE(m_left), OPT_CLONE(m_right));
})
-void operator%(::Serialiser& s, const ExprNode_UniOp::Type t) {
- switch(t)
- {
- #define _(v) case ExprNode_UniOp::v: s << #v; return;
- _(NEGATE)
- _(INVERT)
- _(BOX)
- _(REF)
- _(REFMUT)
- _(QMARK)
- #undef _
- }
-}
-void operator%(::Deserialiser& s, enum ExprNode_UniOp::Type& t) {
- ::std::string n;
- s.item(n);
- if(1) ;
- #define _(v) else if(n == #v) t = ExprNode_UniOp::v;
- _(NEGATE)
- _(INVERT)
- _(BOX)
- _(REF)
- _(REFMUT)
- _(QMARK)
- #undef _
- else
- throw ::std::runtime_error( FMT("No uniop type for '" << n << "'") );
-}
NODE(ExprNode_UniOp, {
- s % m_type;
- s.item(m_value);
-},{
switch(m_type)
{
case NEGATE: os << "(-"; break;
diff --git a/src/ast/expr.hpp b/src/ast/expr.hpp
index 98314824..e7f6750d 100644
--- a/src/ast/expr.hpp
+++ b/src/ast/expr.hpp
@@ -18,8 +18,7 @@ using ::std::unique_ptr;
class NodeVisitor;
-class ExprNode:
- public Serialisable
+class ExprNode
{
TypeRef m_res_type;
MetaItems m_attrs;
@@ -49,8 +48,7 @@ public:
#define NODE_METHODS() \
void visit(NodeVisitor& nv) override;\
void print(::std::ostream& os) const override; \
- ::std::unique_ptr<ExprNode> clone() const override; \
- SERIALISABLE_PROTOTYPES();
+ ::std::unique_ptr<ExprNode> clone() const override;
struct ExprNode_Block:
public ExprNode
@@ -237,8 +235,7 @@ struct ExprNode_Loop:
NODE_METHODS();
};
-struct ExprNode_Match_Arm:
- public Serialisable
+struct ExprNode_Match_Arm
{
MetaItems m_attrs;
::std::vector<Pattern> m_patterns;
@@ -254,8 +251,6 @@ struct ExprNode_Match_Arm:
m_cond( mv$(cond) ),
m_code( mv$(code) )
{}
-
- SERIALISABLE_PROTOTYPES();
};
struct ExprNode_Match:
@@ -686,8 +681,7 @@ public:
#undef NT
};
-class Expr:
- public Serialisable
+class Expr
{
::std::shared_ptr<ExprNode> m_node;
public:
@@ -712,8 +706,6 @@ public:
void visit_nodes(NodeVisitor& v) const;
friend ::std::ostream& operator<<(::std::ostream& os, const Expr& pat);
-
- SERIALISABLE_PROTOTYPES();
};
typedef ::std::unique_ptr<AST::ExprNode> ExprNodeP;
diff --git a/src/ast/generics.hpp b/src/ast/generics.hpp
index d3c1ba18..0209ccbb 100644
--- a/src/ast/generics.hpp
+++ b/src/ast/generics.hpp
@@ -6,8 +6,7 @@
namespace AST {
-class TypeParam:
- public Serialisable
+class TypeParam
{
::std::string m_name;
TypeRef m_default;
@@ -22,15 +21,14 @@ public:
}
const ::std::string& name() const { return m_name; }
- const TypeRef& get_default() const { return m_default; }
- TypeRef& get_default() { return m_default; }
+ const TypeRef& get_default() const { return m_default; }
+ TypeRef& get_default() { return m_default; }
friend ::std::ostream& operator<<(::std::ostream& os, const TypeParam& tp);
- SERIALISABLE_PROTOTYPES();
};
-TAGGED_UNION_EX( GenericBound, (: public Serialisable), Lifetime,
+TAGGED_UNION_EX( GenericBound, (), Lifetime,
(
// Lifetime bound: 'test must be valid for 'bound
(Lifetime, struct {
@@ -68,7 +66,6 @@ TAGGED_UNION_EX( GenericBound, (: public Serialisable), Lifetime,
(, span(x.span) ), ( span = x.span; ),
(
public:
- SERIALISABLE_PROTOTYPES();
Span span;
@@ -88,8 +85,7 @@ TAGGED_UNION_EX( GenericBound, (: public Serialisable), Lifetime,
::std::ostream& operator<<(::std::ostream& os, const GenericBound& x);
-class GenericParams:
- public Serialisable
+class GenericParams
{
::std::vector<TypeParam> m_type_params;
::std::vector< ::std::string > m_lifetime_params;
@@ -118,10 +114,10 @@ public:
}
const ::std::vector<TypeParam>& ty_params() const { return m_type_params; }
+ ::std::vector<TypeParam>& ty_params() { return m_type_params; }
const ::std::vector< ::std::string>& lft_params() const { return m_lifetime_params; }
const ::std::vector<GenericBound>& bounds() const { return m_bounds; }
- ::std::vector<TypeParam>& ty_params() { return m_type_params; }
- ::std::vector<GenericBound>& bounds() { return m_bounds; }
+ ::std::vector<GenericBound>& bounds() { return m_bounds; }
void add_ty_param(TypeParam param) { m_type_params.push_back( ::std::move(param) ); }
void add_lft_param(::std::string name) { m_lifetime_params.push_back( ::std::move(name) ); }
@@ -134,7 +130,6 @@ public:
bool check_params(Crate& crate, ::std::vector<TypeRef>& types, bool allow_infer) const;
friend ::std::ostream& operator<<(::std::ostream& os, const GenericParams& tp);
- SERIALISABLE_PROTOTYPES();
};
diff --git a/src/ast/item.hpp b/src/ast/item.hpp
index 22fd44c9..07abb39b 100644
--- a/src/ast/item.hpp
+++ b/src/ast/item.hpp
@@ -32,8 +32,7 @@ struct NamedNS
template <typename T>
struct Named:
- public NamedNS<T>,
- public Serialisable
+ public NamedNS<T>
{
Named():
NamedNS<T>()
@@ -43,11 +42,6 @@ struct Named:
Named(::std::string name, T data, bool is_pub):
NamedNS<T>( ::std::move(name), ::std::move(data), is_pub )
{}
- SERIALISE_TYPE_A(, "Named", {
- s.item(this->name);
- s.item(this->data);
- s.item(this->is_pub);
- })
};
template <typename T>
diff --git a/src/ast/macro.hpp b/src/ast/macro.hpp
index 5cd53e1f..2798ad4a 100644
--- a/src/ast/macro.hpp
+++ b/src/ast/macro.hpp
@@ -8,8 +8,7 @@
namespace AST {
-class MacroInvocation:
- public Serialisable
+class MacroInvocation
{
Span m_span;
@@ -38,12 +37,6 @@ public:
MacroInvocation clone() const;
- static ::std::unique_ptr<MacroInvocation> from_deserialiser(Deserialiser& s) {
- auto i = new MacroInvocation;
- s.item( *i );
- return ::std::unique_ptr<MacroInvocation>(i);
- }
-
void clear() {
m_macro_name = "";
m_ident = "";
@@ -59,9 +52,6 @@ public:
const ::std::string& input_ident() const { return m_ident; }
const TokenTree& input_tt() const { return m_input; }
-
- SERIALISABLE_PROTOTYPES();
-
friend ::std::ostream& operator<<(::std::ostream& os, const MacroInvocation& x) {
os << x.m_attrs;
if(x.m_attrs.m_items.size() > 0)
diff --git a/src/ast/path.cpp b/src/ast/path.cpp
index 01eed8c7..92fdc4fe 100644
--- a/src/ast/path.cpp
+++ b/src/ast/path.cpp
@@ -115,13 +115,6 @@ void PathNode::print_pretty(::std::ostream& os, bool is_type_context) const
pn.print_pretty(os, false);
return os;
}
-SERIALISE_TYPE(PathNode::, "PathNode", {
- s << m_name;
- //s << m_params;
-},{
- s.item(m_name);
- //s.item(m_params);
-})
/// Return an iterator to the named item
template<typename T>
@@ -420,55 +413,5 @@ void Path::print_pretty(::std::ostream& os, bool is_type_context) const
path.print_pretty(os, false);
return os;
}
-void operator%(Serialiser& s, Path::Class::Tag c) {
- s << Path::Class::tag_to_str(c);
-}
-void operator%(::Deserialiser& s, Path::Class::Tag& c) {
- ::std::string n;
- s.item(n);
- c = Path::Class::tag_from_str(n);
-}
-#define _D(VAR, ...) case Class::TAG_##VAR: { m_class = Class::make_##VAR({}); auto& ent = m_class.as_##VAR(); (void)&ent; __VA_ARGS__ } break;
-::std::unique_ptr<Path> Path::from_deserialiser(Deserialiser& s) {
- Path p;
- s.item(p);
- return ::std::unique_ptr<Path>( new Path( mv$(p) ) );
-}
-SERIALISE_TYPE(Path::, "AST_Path", {
- s % m_class.tag();
- TU_MATCH(Path::Class, (m_class), (ent),
- (Invalid),
- (Local, s << ent.name; ),
- (Relative, s.item(ent.nodes); ),
- (Absolute, s.item(ent.nodes); ),
- (Self , s.item(ent.nodes); ),
- (Super , s.item(ent.nodes); ),
- (UFCS,
- s.item( ent.type );
- s.item( ent.trait );
- s.item( ent.nodes );
- )
- )
-},{
- Class::Tag tag;
- s % tag;
- switch(tag)
- {
- case Class::TAGDEAD: throw "";
- _D(Invalid)
- _D(Local , s.item( ent.name ); )
-
- _D(Relative, s.item(ent.nodes); )
- _D(Absolute, s.item(ent.nodes); )
- _D(Self , s.item(ent.nodes); )
- _D(Super , s.item(ent.nodes); )
- _D(UFCS,
- s.item( ent.type );
- s.item( ent.trait );
- s.item( ent.nodes );
- )
- }
-})
-#undef _D
}
diff --git a/src/ast/path.hpp b/src/ast/path.hpp
index efd367b1..809486b0 100644
--- a/src/ast/path.hpp
+++ b/src/ast/path.hpp
@@ -97,8 +97,7 @@ struct PathParams
friend ::std::ostream& operator<<(::std::ostream& os, const PathParams& x);
};
-class PathNode:
- public ::Serialisable
+class PathNode
{
::std::string m_name;
PathParams m_params;
@@ -115,12 +114,9 @@ public:
bool operator==(const PathNode& x) const { return ord(x) == OrdEqual; }
friend ::std::ostream& operator<<(::std::ostream& os, const PathNode& pn);
-
- SERIALISABLE_PROTOTYPES();
};
-class Path:
- public ::Serialisable
+class Path
{
public:
TAGGED_UNION(Class, Invalid,
@@ -301,12 +297,8 @@ public:
bool operator!=(const Path& x) const { return ord(x) != OrdEqual; }
bool operator<(const Path& x) const { return ord(x) != OrdLess; }
- static ::std::unique_ptr<Path> from_deserialiser(Deserialiser& s);
- SERIALISABLE_PROTOTYPES();
void print_pretty(::std::ostream& os, bool is_type_context) const;
friend ::std::ostream& operator<<(::std::ostream& os, const Path& path);
- friend ::Serialiser& operator<<(Serialiser& s, Path::Class pc);
- friend void operator>>(Deserialiser& s, Path::Class& pc);
private:
static void resolve_args_nl(::std::vector<PathNode>& nodes, ::std::function<TypeRef(const char*)> fcn);
diff --git a/src/ast/types.cpp b/src/ast/types.cpp
index ba2c12f2..293d9db0 100644
--- a/src/ast/types.cpp
+++ b/src/ast/types.cpp
@@ -80,12 +80,6 @@ Type_Function::Type_Function(const Type_Function& other):
m_arg_types(other.m_arg_types)
{
}
-SERIALISE_TYPE_A(Type_Function::, "Type_Function", {
- s.item( is_unsafe );
- s.item( m_abi );
- s.item( m_rettype );
- s.item( m_arg_types );
- })
Ordering Type_Function::ord(const Type_Function& x) const
{
@@ -260,151 +254,6 @@ Ordering TypeRef::ord(const TypeRef& x) const
return os;
}
-void operator% (::Serialiser& s, eCoreType ct) {
- s << coretype_name(ct);
-}
-void operator% (::Deserialiser& d, eCoreType& ct) {
- ::std::string n;
- d.item(n);
- /* */if(n == "-") ct = CORETYPE_INVAL;
- else if(n == "_") ct = CORETYPE_ANY;
- else if(n == "bool") ct = CORETYPE_BOOL;
- else if(n == "char") ct = CORETYPE_CHAR;
- else if(n == "usize") ct = CORETYPE_UINT;
- else if(n == "isize") ct = CORETYPE_INT;
- else if(n == "u8") ct = CORETYPE_U8;
- else if(n == "i8") ct = CORETYPE_I8;
- else if(n == "u16") ct = CORETYPE_U16;
- else if(n == "i16") ct = CORETYPE_I16;
- else if(n == "u32") ct = CORETYPE_U32;
- else if(n == "i32") ct = CORETYPE_I32;
- else if(n == "u64") ct = CORETYPE_U64;
- else if(n == "i64") ct = CORETYPE_I64;
- else if(n == "f32") ct = CORETYPE_F32;
- else if(n == "f64") ct = CORETYPE_F64;
- else
- throw ::std::runtime_error("Deserialise failure - coretype " + n);
-}
-void operator%(Serialiser& s, TypeData::Tag c) {
- s << TypeData::tag_to_str(c);
-}
-void operator%(::Deserialiser& s, TypeData::Tag& c) {
- ::std::string n;
- s.item(n);
- c = TypeData::tag_from_str(n);
-}
-
-::std::unique_ptr<TypeRef> TypeRef::from_deserialiser(Deserialiser& s) {
- TypeRef n;
- n.deserialise(s);
- return box$(n);
-}
-
-#define _S(VAR, ...) case TypeData::TAG_##VAR: { const auto& ent = m_data.as_##VAR(); (void)&ent; __VA_ARGS__ } break;
-#define _D(VAR, ...) case TypeData::TAG_##VAR: { m_data = TypeData::make_##VAR({}); auto& ent = m_data.as_##VAR(); (void)&ent; __VA_ARGS__ } break;
-SERIALISE_TYPE(TypeRef::, "TypeRef", {
- s % m_data.tag();
- switch(m_data.tag())
- {
- case TypeData::TAGDEAD: throw "";
- _S(None)
- _S(Macro,
- s.item( ent.inv );
- )
- _S(Any)
- _S(Bang)
- _S(Unit)
- _S(Primitive,
- s << coretype_name(ent.core_type);
- )
- _S(Function,
- s.item( ent.info );
- )
- _S(Tuple,
- s.item( ent.inner_types );
- )
- _S(Borrow,
- s.item( ent.is_mut );
- s.item( ent.inner );
- )
- _S(Pointer,
- s.item( ent.is_mut );
- s.item( ent.inner );
- )
- _S(Generic,
- s.item( ent.name );
- s.item( ent.index );
- )
- _S(Array,
- s.item( ent.inner );
- bool size_present = (ent.size.get() != 0);
- s.item( size_present );
- if(ent.size.get()) {
- s.item( ent.size );
- }
- )
- _S(Path,
- s.item( ent.path );
- )
- _S(TraitObject,
- s.item( ent.traits );
- )
- }
-},{
- TypeData::Tag tag;
- s % tag;
- switch(tag)
- {
- case TypeData::TAGDEAD: throw "";
- _D(None)
- _D(Any)
- _D(Unit)
- _D(Bang)
- _D(Macro,
- m_data = TypeData::make_Macro({});
- s.item( ent.inv );
- )
- _D(Primitive,
- s % ent.core_type;
- )
- _D(Function,
- s.item( ent.info );
- )
- _D(Tuple,
- s.item( ent.inner_types );
- )
- _D(Borrow,
- s.item( ent.is_mut );
- s.item( ent.inner );
- )
- _D(Pointer,
- s.item( ent.is_mut );
- s.item( ent.inner );
- )
- _D(Generic,
- s.item( ent.name );
- s.item( ent.index );
- )
- _D(Array,
- s.item( ent.inner );
- bool size_present;
- s.item( size_present );
- if( size_present )
- ent.size = AST::ExprNode::from_deserialiser(s);
- else
- ent.size.reset();
- )
- _D(Path,
- s.item( ent.path );
- )
- _D(TraitObject,
- s.item( ent.traits );
- )
- }
-})
-#undef _D
-#undef _S
-
void PrettyPrintType::print(::std::ostream& os) const
{
diff --git a/src/ast/types.hpp b/src/ast/types.hpp
index 1710fceb..e35c178f 100644
--- a/src/ast/types.hpp
+++ b/src/ast/types.hpp
@@ -35,8 +35,7 @@ struct TypeArgRef
const AST::GenericParams* params;
};
-struct Type_Function:
- public Serialisable
+struct Type_Function
{
bool is_unsafe;
::std::string m_abi;
@@ -54,8 +53,6 @@ struct Type_Function:
Type_Function(const Type_Function& other);
Ordering ord(const Type_Function& x) const;
-
- SERIALISABLE_PROTOTYPES();
};
TAGGED_UNION(TypeData, None,
@@ -101,8 +98,7 @@ TAGGED_UNION(TypeData, None,
);
/// A type
-class TypeRef:
- public Serialisable
+class TypeRef
{
Span m_span;
public:
@@ -282,9 +278,6 @@ public:
friend class PrettyPrintType;
friend ::std::ostream& operator<<(::std::ostream& os, const TypeRef& tr);
-
- static ::std::unique_ptr<TypeRef> from_deserialiser(Deserialiser& s);
- SERIALISABLE_PROTOTYPES();
};
#endif // TYPES_HPP_INCLUDED
diff --git a/src/coretypes.hpp b/src/coretypes.hpp
index bdf161e1..f78b1ff2 100644
--- a/src/coretypes.hpp
+++ b/src/coretypes.hpp
@@ -1,9 +1,6 @@
#ifndef CORETYPES_HPP_INCLUDED
#define CORETYPES_HPP_INCLUDED
-class Serialiser;
-class Deserialiser;
-
enum eCoreType
{
CORETYPE_INVAL,
@@ -21,7 +18,5 @@ enum eCoreType
extern enum eCoreType coretype_fromstring(const ::std::string& name);
extern const char* coretype_name(const eCoreType ct);
-extern void operator% (::Serialiser& d, eCoreType ct);
-extern void operator% (::Deserialiser& d, eCoreType& ct);
#endif // CORETYPES_HPP_INCLUDED
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp
index ee453579..f9d81f08 100644
--- a/src/parse/lex.cpp
+++ b/src/parse/lex.cpp
@@ -1161,10 +1161,6 @@ TokenTree TokenTree::clone() const
return TokenTree( mv$(ents) );
}
}
-SERIALISE_TYPE_A(TokenTree::, "TokenTree", {
- s.item(m_tok);
- s.item(m_subtrees);
-})
bool Codepoint::isspace() const {
switch(this->v)
diff --git a/src/parse/token.cpp b/src/parse/token.cpp
index 6380992e..3f95d9fd 100644
--- a/src/parse/token.cpp
+++ b/src/parse/token.cpp
@@ -372,6 +372,14 @@ void operator%(::Deserialiser& s, enum eTokenType& c) {
s.item(n);
c = Token::typefromstr(n);
}
+void operator%(::Serialiser& s, enum eCoreType t) {
+ s << coretype_name(t);
+}
+void operator%(::Deserialiser& s, enum eCoreType& t) {
+ ::std::string n;
+ s.item(n);
+ t = coretype_fromstring(n);
+}
SERIALISE_TYPE(Token::, "Token", {
s % m_type;
s << Token::Data::tag_to_str(m_data.tag());
diff --git a/src/parse/tokentree.hpp b/src/parse/tokentree.hpp
index 7f8810a7..833b39dc 100644
--- a/src/parse/tokentree.hpp
+++ b/src/parse/tokentree.hpp
@@ -2,10 +2,8 @@
#define TOKENTREE_HPP_INCLUDED
#include "lex.hpp"
-#include "../include/serialise.hpp"
-class TokenTree:
- public Serialisable
+class TokenTree
{
Token m_tok;
::std::vector<TokenTree> m_subtrees;
@@ -54,8 +52,6 @@ public:
return os;
}
}
-
- SERIALISABLE_PROTOTYPES();
};
class TTStream: