From f99a99e79ff7946dcf7a283c87caf8f0a92c2c03 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Sat, 17 Jan 2015 11:46:17 +0800 Subject: Deserialise working, need to annotate loaded crates with crate ID --- src/ast/path.cpp | 2 ++ src/main.cpp | 4 ++-- src/parse/root.cpp | 1 + src/types.cpp | 17 +++++++++++------ 4 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ast/path.cpp b/src/ast/path.cpp index eab5d745..80c9bbdb 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -301,9 +301,11 @@ void operator>>(Deserialiser& s, Path::Class& pc) } SERIALISE_TYPE(Path::, "AST_Path", { s << m_class; + s << m_crate; s << m_nodes; },{ s >> m_class; + s.item(m_crate); s.item(m_nodes); }) diff --git a/src/main.cpp b/src/main.cpp index 9ba04dd7..ce1bd3e7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,11 +81,11 @@ int main(int argc, char *argv[]) { AST::Crate crate = Parse_Crate(infile); - s << crate; + //s << crate; // Resolve names to be absolute names (include references to the relevant struct/global/function) ResolvePaths(crate); - s << crate; + //s << crate; // Typecheck / type propagate module (type annotations of all values) diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 66b1d0fb..024860bf 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -745,6 +745,7 @@ void Parse_ModRoot(Preproc& lex, AST::Crate& crate, AST::Module& mod, const ::st AST::Path prelude_path = AST::Path(AST::Path::TagAbsolute()); prelude_path.append( AST::PathNode("std", {}) ); prelude_path.append( AST::PathNode("prelude", {}) ); + prelude_path.append( AST::PathNode("v1", {}) ); Parse_Use_Wildcard(prelude_path, [&mod](AST::Path p, std::string s) { mod.add_alias(false, p, s); diff --git a/src/types.cpp b/src/types.cpp index 7a2b21c6..b2dcd582 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -75,9 +75,10 @@ const char* coretype_name(const eCoreType ct ) { case CORETYPE_I32: return "i32"; case CORETYPE_U64: return "u64"; case CORETYPE_I64: return "i64"; - case CORETYPE_F32: return "f16"; - case CORETYPE_F64: return "f16"; + case CORETYPE_F32: return "f32"; + case CORETYPE_F64: return "f64"; } + DEBUG("Unknown core type?! " << ct); return "NFI"; } void operator% (::Serialiser& s, eCoreType ct) { @@ -129,16 +130,20 @@ void operator>>(::Deserialiser& d, TypeRef::Class& c) { } SERIALISE_TYPE(TypeRef::, "TypeRef", { s << class_name(m_class); - s << coretype_name(m_core_type); + if(m_class == PRIMITIVE) + s << coretype_name(m_core_type); s << m_inner_types; - s << m_is_inner_mutable; + if(m_class == REFERENCE || m_class == POINTER) + s << m_is_inner_mutable; s << m_size_expr; s << m_path; },{ s >> m_class; - s % m_core_type; + if(m_class == PRIMITIVE) + s % m_core_type; s.item( m_inner_types ); - s.item( m_is_inner_mutable ); + if(m_class == REFERENCE || m_class == POINTER) + s.item( m_is_inner_mutable ); bool size_expr_present; s.item(size_expr_present); if( size_expr_present ) -- cgit v1.2.3