summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2015-06-04 17:19:28 +0800
committerJohn Hodge <tpg@mutabah.net>2015-06-04 17:19:28 +0800
commit9f69517be928bf78b7d63c2937941d6d9c93b48c (patch)
tree91df9882aeb77a5c1e67f1f157ff81dbfd9180dd /src
parentf2c96d7c448934baec49c91b5cb2ac7c05562437 (diff)
downloadmrust-9f69517be928bf78b7d63c2937941d6d9c93b48c.tar.gz
Fix issues with printout, lexing, and pattern resolving
Diffstat (limited to 'src')
-rw-r--r--src/convert/resolve.cpp5
-rw-r--r--src/dump_as_rust.cpp3
-rw-r--r--src/parse/lex.cpp2
3 files changed, 7 insertions, 3 deletions
diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp
index 68633dc8..f3ba701f 100644
--- a/src/convert/resolve.cpp
+++ b/src/convert/resolve.cpp
@@ -276,10 +276,12 @@ CPathResolver::CPathResolver(const AST::Crate& crate):
void CPathResolver::start_scope()
{
DEBUG("");
+ m_scope_stack.push_back( {0, nullptr, AST::Path(), {}} );
m_locals.push_back( LocalItem() );
}
void CPathResolver::end_scope()
{
+ m_scope_stack.pop_back( );
DEBUG(m_locals.size() << " items");
for( auto it = m_locals.end(); it-- != m_locals.begin(); )
{
@@ -437,7 +439,8 @@ void CPathResolver::handle_path_int(AST::Path& path, CASTIterator::PathMode mode
// 1. function scopes (variables and local items)
// > Return values: name or path
{
- if( this->find_local_item(path, /*allow_variables=*/path.is_trivial()) ) {
+ bool allow_variables = (mode == CASTIterator::MODE_EXPR && path.is_trivial());
+ if( this->find_local_item(path, allow_variables) ) {
break ;
}
else {
diff --git a/src/dump_as_rust.cpp b/src/dump_as_rust.cpp
index 0aca6685..d760f4cd 100644
--- a/src/dump_as_rust.cpp
+++ b/src/dump_as_rust.cpp
@@ -334,7 +334,7 @@ public:
case CORETYPE_BOOL:
break;
case CORETYPE_CHAR:
- m_os << "'\\u" << ::std::hex << n.m_value << ::std::dec << "'";
+ m_os << "'\\u{" << ::std::hex << n.m_value << ::std::dec << "}'";
break;
case CORETYPE_F32:
case CORETYPE_F64:
@@ -364,6 +364,7 @@ public:
case CORETYPE_ANY:
case CORETYPE_F32:
case CORETYPE_F64:
+ m_os.precision(10);
m_os << n.m_value;
break;
default:
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp
index c246bbc0..419a04d5 100644
--- a/src/parse/lex.cpp
+++ b/src/parse/lex.cpp
@@ -536,7 +536,7 @@ double Lexer::parseFloat(uint64_t whole)
const int MAX_LEN = 63;
const int MAX_SIG = MAX_LEN - 1 - 4;
char buf[MAX_LEN+1];
- int ofs = snprintf(buf, MAX_LEN+1, "%llu", (unsigned long long)whole);
+ int ofs = snprintf(buf, MAX_LEN+1, "%llu.", (unsigned long long)whole);
char ch = this->getc_num();
#define PUTC(ch) do { if( ofs < MAX_SIG ) { buf[ofs] = ch; ofs ++; } else { throw ParseError::Generic("Oversized float"); } } while(0)