diff options
Diffstat (limited to 'src/ast/types.cpp')
-rw-r--r-- | src/ast/types.cpp | 151 |
1 files changed, 0 insertions, 151 deletions
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 { |