summaryrefslogtreecommitdiff
path: root/src/ast/provided_module.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/provided_module.cpp')
-rw-r--r--src/ast/provided_module.cpp53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/ast/provided_module.cpp b/src/ast/provided_module.cpp
index a72869a6..f8e53bdf 100644
--- a/src/ast/provided_module.cpp
+++ b/src/ast/provided_module.cpp
@@ -7,35 +7,38 @@ AST::Module g_compiler_module;
void AST_InitProvidedModule()
{
// "struct str([u8])"
- g_compiler_module.add_struct(true, "str", AST::TypeParams(), ::std::vector<AST::StructItem> {
- AST::StructItem("", TypeRef(TypeRef::TagUnsizedArray(), TypeRef(CORETYPE_U8)), false),
- });
+ g_compiler_module.add_struct(true, "str",
+ AST::Struct( AST::MetaItems(), AST::TypeParams(), ::std::vector<AST::StructItem> {
+ AST::StructItem("", TypeRef(TypeRef::TagUnsizedArray(), TypeRef(CORETYPE_U8)), false),
+ }));
AST::Path copy_marker_path({AST::PathNode("marker"),AST::PathNode("Copy")});
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_U8), copy_marker_path));
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_U16), copy_marker_path));
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_U32), copy_marker_path));
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_U64), copy_marker_path));
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_UINT), copy_marker_path));
-
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_I8), copy_marker_path));
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_I16), copy_marker_path));
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_I32), copy_marker_path));
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_I64), copy_marker_path));
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_INT), copy_marker_path));
-
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_F32), copy_marker_path));
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(CORETYPE_F64), copy_marker_path));
+ #define impl(trait, type) \
+ g_compiler_module.add_impl(AST::Impl(AST::MetaItems(), AST::TypeParams(), type, trait))
+ impl(copy_marker_path, TypeRef(CORETYPE_U8));
+ impl(copy_marker_path, TypeRef(CORETYPE_U16));
+ impl(copy_marker_path, TypeRef(CORETYPE_U32));
+ impl(copy_marker_path, TypeRef(CORETYPE_U64));
+ impl(copy_marker_path, TypeRef(CORETYPE_UINT));
+ impl(copy_marker_path, TypeRef(CORETYPE_I8));
+ impl(copy_marker_path, TypeRef(CORETYPE_I16));
+ impl(copy_marker_path, TypeRef(CORETYPE_I32));
+ impl(copy_marker_path, TypeRef(CORETYPE_I64));
+ impl(copy_marker_path, TypeRef(CORETYPE_INT));
+ impl(copy_marker_path, TypeRef(CORETYPE_F32));
+ impl(copy_marker_path, TypeRef(CORETYPE_F64));
// A hacky default impl of 'Sized', with a negative impl on [T]
AST::Path sized_marker_path({AST::PathNode("marker"),AST::PathNode("Sized")});
- g_compiler_module.add_impl(AST::Impl(AST::TypeParams(), TypeRef(), sized_marker_path));
- AST::TypeParams tps;
- tps.add_ty_param( AST::TypeParam("T") );
- g_compiler_module.add_neg_impl(AST::ImplDef(
- ::std::move(tps),
- sized_marker_path,
- TypeRef(TypeRef::TagUnsizedArray(), TypeRef(TypeRef::TagArg(), "T"))
- ));
+ impl(sized_marker_path, TypeRef());
+ {
+ AST::TypeParams tps;
+ tps.add_ty_param( AST::TypeParam("T") );
+ g_compiler_module.add_neg_impl(AST::ImplDef(
+ AST::MetaItems(), ::std::move(tps),
+ sized_marker_path,
+ TypeRef(TypeRef::TagUnsizedArray(), TypeRef(TypeRef::TagArg(), "T"))
+ ));
+ }
}