forked from thepowersgang/mrustc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1a5155
commit 8977122
Showing
6 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
*/ | ||
#include "../ast/ast.hpp" | ||
|
||
AST::Flat Convert_Flattern(const AST::Crate& crate) | ||
{ | ||
throw ParseError::Todo("Flatten"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
*/ | ||
#include "../ast/ast.hpp" | ||
|
||
void Render_Type(::std::ostream& os, const TypeRef& type, const char *name) | ||
{ | ||
/* | ||
swicth(type.class()) | ||
{ | ||
case TYPECLASS_STRUCT: | ||
os << "struct " << type.struct().mangled_name() << " " << name; | ||
break; | ||
} | ||
*/ | ||
} | ||
|
||
void Render_CStruct(::std::ostream& os, const AST::CStruct& str) | ||
{ | ||
os << "struct " << str.name() << "{\n"; | ||
FOREACH(::std::vector<std::pair<std::string,TypeRef> >, f, str.fields()) | ||
{ | ||
os << "\t"; | ||
Render_Type(os, f->second(), f->first().c_str()); | ||
os << ";\n"; | ||
} | ||
os << "}\n" | ||
} | ||
|
||
void Render_Crate(::std::ostream& os, const AST::Flat& crate) | ||
{ | ||
// First off, print forward declarations of all structs + enums | ||
FOREACH(::std::vector<AST::CStruct>, s, crate.structs()) | ||
os << "struct " << s->mangled_name() << ";\n"; | ||
|
||
FOREACH(::std::vector<AST::Function>, fcn, crate.functions()) | ||
{ | ||
Render_Type(os, fcn->rettype(), nullptr); | ||
os << " " << fcn->name() << "("; | ||
bool is_first = true; | ||
FOREACH(::std::vector<std::pair<std::string,TypeRef> >, f, fcn.args()) | ||
{ | ||
if( !is_first ) | ||
os << ", "; | ||
is_first = false; | ||
Render_Type(os, f->second(), f->first().c_str()); | ||
} | ||
os << ")\n{\n"; | ||
// Dump expression AST | ||
os << "}\n"; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters