summaryrefslogtreecommitdiff
path: root/src/ast/ast.cpp
diff options
context:
space:
mode:
authorJohn Hodge (sonata) <tpg@mutabah.net>2015-01-15 11:44:12 +0800
committerJohn Hodge (sonata) <tpg@mutabah.net>2015-01-15 11:44:12 +0800
commit3044ae80284fb958051ffd2926fcbff470ff8591 (patch)
treee09bd7461c76118926426acad388c315a86e4703 /src/ast/ast.cpp
parent801bce6026e86d32b6971463a3aefd38eb3b2f27 (diff)
downloadmrust-3044ae80284fb958051ffd2926fcbff470ff8591.tar.gz
Type alias bound to path, considering removing std hack and implementing AST read
Diffstat (limited to 'src/ast/ast.cpp')
-rw-r--r--src/ast/ast.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp
index 0c33dcb9..c2686787 100644
--- a/src/ast/ast.cpp
+++ b/src/ast/ast.cpp
@@ -116,16 +116,6 @@ ExternCrate ExternCrate_std()
}
));
std_mod.add_submod(true, ::std::move(option));
- // - io
- Module io(crate.crate(), "io");
- io.add_typealias(true, "IoResult", TypeAlias(
- { TypeParam(false, "T") },
- TypeRef( Path("std", {
- PathNode("result",{}),
- PathNode("Result", {TypeRef("T"),TypeRef(Path("std", {PathNode("io"), PathNode("IoError")}))})
- }) )
- ));
- std_mod.add_submod(true, ::std::move(io));
// - result
Module result(crate.crate(), "result");
result.add_enum(true, "Result", Enum(
@@ -139,13 +129,38 @@ ExternCrate ExternCrate_std()
}
));
std_mod.add_submod(true, ::std::move(result));
+ // - io
+ Module io(crate.crate(), "io");
+ io.add_typealias(true, "IoResult", TypeAlias(
+ { TypeParam(false, "T") },
+ TypeRef( Path("std", {
+ PathNode("result",{}),
+ PathNode("Result", {TypeRef("T"),TypeRef(Path("std", {PathNode("io"), PathNode("IoError")}))})
+ }) )
+ ));
+ std_mod.add_submod(true, ::std::move(io));
+ // - iter
+ {
+ Module iter(crate.crate(), "iter");
+ {
+ Trait iterator;
+ iterator.add_type("Item", TypeRef());
+ //iterator.add_function("next", Function({}, Function::CLASS_REFMETHOD, "Option<<Self as Iterator>::Item>", {}, Expr());
+ iter.add_trait(true, "Iterator", ::std::move(iterator));
+ }
+ std_mod.add_submod(true, ::std::move(iter));
+ }
+ // - prelude
Module prelude(crate.crate(), "prelude");
// Re-exports
- #define USE(mod, name, ...) do{ Path p({__VA_ARGS__}); p.set_crate("std"); mod.add_alias(true, ::std::move(p), name); } while(0)
+ #define USE(mod, name, ...) do{ Path p("std", {__VA_ARGS__}); mod.add_alias(true, ::std::move(p), name); } while(0)
USE(prelude, "Option", PathNode("option", {}), PathNode("Option",{}) );
USE(prelude, "Some", PathNode("option", {}), PathNode("Option",{}), PathNode("Some",{}) );
USE(prelude, "None", PathNode("option", {}), PathNode("Option",{}), PathNode("None",{}) );
+ USE(prelude, "Result", PathNode("result", {}), PathNode("Result",{}) );
+ USE(prelude, "Ok", PathNode("result", {}), PathNode("Result",{}), PathNode("Ok",{}) );
+ USE(prelude, "Err", PathNode("result", {}), PathNode("Result",{}), PathNode("Err",{}) );
std_mod.add_submod(true, prelude);
return crate;