summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2017-01-01 21:20:01 +0800
committerJohn Hodge <tpg@mutabah.net>2017-01-01 21:20:01 +0800
commitb5a559c4b80ceb697212c98badea2e0192710e0c (patch)
tree6cb05f6dc89c54c2eff4b0cd57d0b66dfb13d1da
parentfa59ba5317f83d7bbb38aa7668360fa7e2bad7fc (diff)
downloadmrust-b5a559c4b80ceb697212c98badea2e0192710e0c.tar.gz
Trans - Tweaks to forward declarations
-rw-r--r--Makefile2
-rw-r--r--src/trans/codegen_c.cpp4
-rw-r--r--src/trans/enumerate.cpp17
3 files changed, 18 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index d6b91e73..ea5c2c58 100644
--- a/Makefile
+++ b/Makefile
@@ -242,7 +242,7 @@ output/rust/%: $(RUST_TESTS_DIR)%.rs $(RUSTCSRC) $(BIN) output/libstd.hir output
@$(BIN) $< -o $@.c --stop-after $(RUST_TESTS_FINAL_STAGE) $(TEST_ARGS_$*) > $@.txt 2>&1 || (tail -n 1 $@.txt; false)
@echo "--- [CC] -o $@"
$(TARGET_CC) $@.c -pthread -g -o $@
- @echo "000 [$@]"
+ @echo "--- [$@]"
@./$@
output/rust/run-pass/allocator-default.o: output/libstd.hir output/liballoc_jemalloc.hir
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index b73b4d37..ef64ebcd 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -77,7 +77,7 @@ namespace {
{
TRACE_FUNCTION_F(ty);
TU_IFLET( ::HIR::TypeRef::Data, ty.m_data, Tuple, te,
- // TODO: Pre-define tuple name
+ m_of << "typedef struct "; emit_ctype(ty); m_of << " "; emit_ctype(ty); m_of << ";\n";
)
else TU_IFLET( ::HIR::TypeRef::Data, ty.m_data, Function, te,
// TODO: Pre-define function type name
@@ -116,7 +116,7 @@ namespace {
TU_IFLET( ::HIR::TypeRef::Data, ty.m_data, Tuple, te,
if( te.size() > 0 )
{
- m_of << "typedef struct {\n";
+ m_of << "typedef struct "; emit_ctype(ty); m_of << " {\n";
for(unsigned int i = 0; i < te.size(); i++)
{
m_of << "\t";
diff --git a/src/trans/enumerate.cpp b/src/trans/enumerate.cpp
index 25513c17..4de920db 100644
--- a/src/trans/enumerate.cpp
+++ b/src/trans/enumerate.cpp
@@ -268,11 +268,24 @@ namespace {
}
TRACE_FUNCTION_F(ty << " - " << (mode == Mode::Shallow ? "Shallow" : (mode == Mode::Normal ? "Normal" : "Deep")));
- if( mode != Mode::Shallow )
+ if( mode == Mode::Shallow )
+ {
+ TU_MATCH_DEF(::HIR::TypeRef::Data, (ty.m_data), (te),
+ (
+ ),
+ (Pointer,
+ visit_type(*te.inner, Mode::Shallow);
+ ),
+ (Borrow,
+ visit_type(*te.inner, Mode::Shallow);
+ )
+ )
+ }
+ else
{
if( active_set.find(&ty) != active_set.end() ) {
// TODO: Handle recursion
- DEBUG("- Type recursion with " << ty);
+ BUG(Span(), "- Type recursion with " << ty);
return ;
}
active_set.insert( &ty );