aboutsummaryrefslogtreecommitdiff
path: root/src/comp/driver/rustc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/comp/driver/rustc.rs')
-rw-r--r--src/comp/driver/rustc.rs52
1 files changed, 46 insertions, 6 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index e5a614ba..42bd91c5 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -1,6 +1,23 @@
// -*- rust -*-
-fn main(vec[str] args) -> () {
+import std._str;
+import lib.llvm.llvm;
+import lib.llvm.builder;
+import fe.parser;
+import fe.token;
+
+fn write_module() {
+ auto llmod =
+ llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"),
+ llvm.LLVMGetGlobalContext());
+
+ auto b = builder(llvm.LLVMCreateBuilder());
+
+ llvm.LLVMWriteBitcodeToFile(llmod, _str.buf("rust_out.bc"));
+ llvm.LLVMDisposeModule(llmod);
+}
+
+fn main(vec[str] args) {
log "This is the rust 'self-hosted' compiler.";
log "The one written in rust.";
@@ -10,13 +27,36 @@ fn main(vec[str] args) -> () {
auto i = 0;
for (str filename in args) {
if (i > 0) {
- auto br = std._io.new_buf_reader(filename);
- log "opened file: " + filename;
- for (u8 b in br.read()) {
- log b;
- }
+ auto p = parser.new_parser(filename);
+ log "opened file: " + filename;
+ auto tok = p.peek();
+ while (true) {
+ alt (tok) {
+ case (token.EOF()) { ret; }
+ case (_) {
+ log token.to_str(tok);
+ p.bump();
+ tok = p.peek();
+ }
+ }
+ }
}
i += 1;
}
+ // Test LLVM module-writing. Nothing interesting yet.
+ write_module();
+
}
+
+
+//
+// Local Variables:
+// mode: rust
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
+//