diff options
author | John Hodge <tpg@mutabah.net> | 2015-11-03 12:25:42 +1100 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2015-11-03 12:25:42 +1100 |
commit | 20ee7442f280ced9e5258876f9fd2212797f868b (patch) | |
tree | 2bb4fd40727ad0402d6d17a6501d5bab05fb5e48 /src | |
parent | 01ec57f596f89d4b52b378975f941e2ed8d2e563 (diff) | |
download | mrust-20ee7442f280ced9e5258876f9fd2212797f868b.tar.gz |
Remove embedded spans (will move to wrapping spans)
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/path.cpp | 5 | ||||
-rw-r--r-- | src/ast/path.hpp | 11 | ||||
-rw-r--r-- | src/convert/resolve.cpp | 5 | ||||
-rw-r--r-- | src/include/span.hpp | 11 | ||||
-rw-r--r-- | src/parse/root.cpp | 4 | ||||
-rw-r--r-- | src/parse/types.cpp | 2 | ||||
-rw-r--r-- | src/types.cpp | 3 | ||||
-rw-r--r-- | src/types.hpp | 4 |
8 files changed, 21 insertions, 24 deletions
diff --git a/src/ast/path.cpp b/src/ast/path.cpp index 8668c386..797bb5b1 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -89,8 +89,7 @@ AST::Path::Path(TagUfcs, TypeRef type, TypeRef trait, ::std::vector<AST::PathNod } AST::Path::Path(const Path& x): m_crate(x.m_crate), - m_class(), - m_span(x.m_span) + m_class() //m_binding(x.m_binding) { TU_MATCH(Class, (x.m_class), (ent), @@ -516,7 +515,7 @@ void Path::print_pretty(::std::ostream& os) const os << "::" << n; ) ) - os << "/*" << path.m_binding << " [" << path.span().filename << ":" << path.span().start_line << "]*/"; + os << "/*" << path.m_binding << "*/"; #else switch(path.m_class) { diff --git a/src/ast/path.hpp b/src/ast/path.hpp index fd1cf5dc..743934fe 100644 --- a/src/ast/path.hpp +++ b/src/ast/path.hpp @@ -131,7 +131,6 @@ private: public: Class m_class; - Span m_span; private: PathBinding m_binding; @@ -144,7 +143,6 @@ public: Path& operator=(AST::Path&& x) { m_crate = mv$(x.m_crate); m_class = mv$(x.m_class); - //m_span = mv$(x.m_span); m_binding = mv$(x.m_binding); //DEBUG("Path, " << x); return *this; @@ -193,12 +191,6 @@ public: DEBUG("crate set to " << m_crate); } } - void set_span(Span sp) { - this->m_span = sp; - } - const Span& span() const { - return this->m_span; - } Class::Tag class_tag() const { @@ -330,6 +322,9 @@ public: void bind_function(const Function& ent, const ::std::vector<TypeRef>& args={}) { m_binding = PathBinding::make_Function({&ent}); } + void bind_type_alias(const TypeAlias& ent, const ::std::vector<TypeRef>& args={}) { + m_binding = PathBinding::make_TypeAlias({&ent}); + } }; } // namespace AST diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp index 70bfc080..3119ae37 100644 --- a/src/convert/resolve.cpp +++ b/src/convert/resolve.cpp @@ -607,7 +607,7 @@ void CPathResolver::handle_path_int(AST::Path& path, CASTIterator::PathMode mode {
if(path.size() > 1) {
auto ty = TypeRef(TypeRef::TagArg(), path[0].name());
- ty.set_span( path.span() );
+ //ty.set_span( path.span() );
// Repalce with UFCS
auto newpath = AST::Path(AST::Path::TagUfcs(), ty, TypeRef());
newpath.add_tailing(path);
@@ -1369,8 +1369,7 @@ void ResolvePaths_HandleModule_Use(const AST::Crate& crate, const AST::Path& mod mod = &crate.get_root_module(i);
),
(TypeAlias,
- throw ParseError::Todo("Bind to type alias in use resolution");
- //p.bind_type_alias(i);
+ p.bind_type_alias(i);
mod = nullptr;
),
(Function,
diff --git a/src/include/span.hpp b/src/include/span.hpp index 3df70b72..70d78205 100644 --- a/src/include/span.hpp +++ b/src/include/span.hpp @@ -52,6 +52,13 @@ struct Span void note(::std::function<void(::std::ostream&)> msg) const; }; -#define ERROR(span, code, msg) do { (span).error(code, [&](::std::ostream& os) { os << msg; }); throw ::std::runtime_error("Error fell through" #code); } while(0) -#define BUG(span, msg) do { (span).bug([&](::std::ostream& os) { os << msg; }); throw ::std::runtime_error("Bug fell through"); } while(0) +template<typename T> +struct Spanned +{ + Span m_span; + T m_item; +}; + +#define ERROR(span, code, msg) do { (Span()/*span*/).error(code, [&](::std::ostream& os) { os << msg; }); throw ::std::runtime_error("Error fell through" #code); } while(0) +#define BUG(span, msg) do { (Span()/*span*/).bug([&](::std::ostream& os) { os << msg; }); throw ::std::runtime_error("Bug fell through"); } while(0) diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 2931f492..462922d2 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -986,7 +986,7 @@ void Parse_Use(TokenStream& lex, ::std::function<void(AST::Path, ::std::string)> }
else
{
- path.set_span( lex.end_span(span_start) );
+ //path.set_span( lex.end_span(span_start) );
switch( tok.type() )
{
case TOK_BRACE_OPEN:
@@ -1003,7 +1003,7 @@ void Parse_Use(TokenStream& lex, ::std::function<void(AST::Path, ::std::string)> return ;
}
}
- path.set_span( lex.end_span(span_start) );
+ //path.set_span( lex.end_span(span_start) );
::std::string name;
// This should only be allowed if the last token was an ident
diff --git a/src/parse/types.cpp b/src/parse/types.cpp index 7777de79..d0ca6357 100644 --- a/src/parse/types.cpp +++ b/src/parse/types.cpp @@ -43,7 +43,7 @@ TypeRef Parse_Type(TokenStream& lex) { ProtoSpan ps = lex.start_span(); TypeRef rv = Parse_Type_Int(lex); - rv.set_span(lex.end_span(ps)); + //rv.set_span(lex.end_span(ps)); return rv; } diff --git a/src/types.cpp b/src/types.cpp index d25d3332..68347f55 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -576,7 +576,8 @@ Ordering TypeRef::ord(const TypeRef& x) const DEBUG(*this << " == " << x); if( ent.params ) DEBUG("- (L) " << *ent.params); if( x_ent.params ) DEBUG("- (R) " << *x_ent.params); - BUG(m_span, "Can't compare mismatched generic types"); + throw ::std::runtime_error("Can't compare mismatched generic types"); + //BUG(m_span, "Can't compare mismatched generic types"); } else { } diff --git a/src/types.hpp b/src/types.hpp index 90f9ee3b..9146d971 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -98,7 +98,6 @@ TAGGED_UNION(TypeData, None, class TypeRef:
public Serialisable
{
- Span m_span;
public:
TypeData m_data;
@@ -206,9 +205,6 @@ public: {}
- void set_span(Span sp) { this->m_span = sp; }
- const Span& span() { return this->m_span; }
-
/// Dereference the type (return the result of *type_instance)
bool deref(bool is_implicit);
/// Merge with another type (combines known aspects, conflitcs cause an exception)
|