summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-06-04 13:21:22 +0800
committerJohn Hodge <tpg@mutabah.net>2018-06-04 13:21:22 +0800
commit42bdc18d4ba8f9fd19109050eb83bb6615539a75 (patch)
tree88501e01485038ad879160383b60c2e02b97f96e
parent8d99deade68a9c995101fd5944f9011fcf3dccc7 (diff)
downloadmrust-42bdc18d4ba8f9fd19109050eb83bb6615539a75.tar.gz
All - Ensure that all files have a header comment, remove some dead code
-rw-r--r--Makefile2
-rw-r--r--src/ast/ast.cpp17
-rw-r--r--src/ast/ast.hpp18
-rw-r--r--src/ast/crate.cpp5
-rw-r--r--src/ast/crate.hpp8
-rw-r--r--src/ast/expr.cpp5
-rw-r--r--src/ast/expr_ptr.hpp5
-rw-r--r--src/ast/item.hpp35
-rw-r--r--src/ast/macro.hpp8
-rw-r--r--src/ast/path.cpp5
-rw-r--r--src/ast/path.hpp5
-rw-r--r--src/ast/types.hpp7
-rw-r--r--src/common.hpp6
-rw-r--r--src/coretypes.hpp7
-rw-r--r--src/debug.cpp8
-rw-r--r--src/expand/cfg.hpp7
-rw-r--r--src/expand/macro_rules.cpp1
-rw-r--r--src/expand/macro_rules.hpp14
-rw-r--r--src/expand/mod.cpp1
-rw-r--r--src/expand/std_prelude.cpp5
-rw-r--r--src/hir/crate_ptr.cpp5
-rw-r--r--src/hir/crate_ptr.hpp6
-rw-r--r--src/hir/expr.hpp5
-rw-r--r--src/hir/generic_params.cpp5
-rw-r--r--src/hir/generic_params.hpp5
-rw-r--r--src/hir/path.hpp2
-rw-r--r--src/hir/type_ptr.cpp18
-rw-r--r--src/hir/type_ptr.hpp16
-rw-r--r--src/hir_conv/main_bindings.hpp5
-rw-r--r--src/hir_typeck/expr_visit.cpp5
-rw-r--r--src/hir_typeck/expr_visit.hpp7
-rw-r--r--src/hir_typeck/impl_ref.hpp5
-rw-r--r--src/hir_typeck/main_bindings.hpp5
-rw-r--r--src/include/compile_error.hpp5
-rw-r--r--src/include/cpp_unpack.h8
-rw-r--r--src/include/main_bindings.hpp16
-rw-r--r--src/include/rc_string.hpp5
-rw-r--r--src/include/rustic.hpp152
-rw-r--r--src/include/stdspan.hpp78
-rw-r--r--src/include/synext.hpp5
-rw-r--r--src/include/synext_decorator.hpp5
-rw-r--r--src/include/synext_macro.hpp5
-rw-r--r--src/include/tagged_union.hpp17
-rw-r--r--src/macro_rules/mod.cpp5
-rw-r--r--src/macro_rules/pattern_checks.hpp5
-rw-r--r--src/parse/eTokenType.enum.h7
-rw-r--r--src/parse/interpolated_fragment.cpp5
-rw-r--r--src/parse/interpolated_fragment.hpp5
-rw-r--r--src/parse/parseerror.hpp7
-rw-r--r--src/rc_string.cpp5
-rw-r--r--src/resolve/absolute.cpp9
-rw-r--r--src/resolve/index.cpp6
-rw-r--r--src/resolve/main_bindings.hpp6
-rw-r--r--src/resolve/use.cpp13
-rw-r--r--src/trans/allocator.cpp8
-rw-r--r--src/trans/allocator.hpp5
-rw-r--r--src/trans/codegen_c.hpp5
-rw-r--r--src/trans/codegen_mmir.cpp12
-rw-r--r--tools/common/debug.h7
-rw-r--r--tools/common/helpers.h8
-rw-r--r--tools/common/path.cpp5
-rw-r--r--tools/common/path.h7
-rw-r--r--tools/common/toml.cpp10
-rw-r--r--tools/common/toml.h16
-rw-r--r--tools/minicargo/build.h9
-rw-r--r--tools/minicargo/main.cpp3
-rw-r--r--tools/minicargo/manifest.cpp7
-rw-r--r--tools/minicargo/manifest.h7
-rw-r--r--tools/minicargo/repository.cpp5
-rw-r--r--tools/minicargo/repository.h7
-rw-r--r--tools/standalone_miri/hir/type.hpp9
-rw-r--r--tools/standalone_miri/hir_sim.hpp10
-rw-r--r--tools/standalone_miri/lex.cpp10
-rw-r--r--tools/standalone_miri/lex.hpp10
-rw-r--r--tools/standalone_miri/miri.hpp16
-rw-r--r--tools/standalone_miri/module_tree.cpp13
-rw-r--r--tools/standalone_miri/module_tree.hpp11
-rw-r--r--tools/testrunner/main.cpp13
78 files changed, 520 insertions, 320 deletions
diff --git a/Makefile b/Makefile
index 1aafecc3..0d34be43 100644
--- a/Makefile
+++ b/Makefile
@@ -95,7 +95,7 @@ OBJ += resolve/use.o resolve/index.o resolve/absolute.o
OBJ += hir/from_ast.o hir/from_ast_expr.o
OBJ += hir/dump.o
OBJ += hir/hir.o hir/generic_params.o
-OBJ += hir/crate_ptr.o hir/type_ptr.o hir/expr_ptr.o
+OBJ += hir/crate_ptr.o hir/expr_ptr.o
OBJ += hir/type.o hir/path.o hir/expr.o hir/pattern.o
OBJ += hir/visitor.o hir/crate_post_load.o
OBJ += hir_conv/expand_type.o hir_conv/constant_evaluation.o hir_conv/resolve_ufcs.o hir_conv/bind.o hir_conv/markings.o
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp
index 4fdf8f9d..e4fe49da 100644
--- a/src/ast/ast.cpp
+++ b/src/ast/ast.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/ast.cpp
+ * - Implementation of the various AST classes
*/
#include "ast.hpp"
#include "crate.hpp"
@@ -236,16 +241,6 @@ bool Impl::has_named_item(const ::std::string& name) const
return os << impl.m_def;
}
-::rust::option<char> ImplRef::find_named_item(const ::std::string& name) const
-{
- if( this->impl.has_named_item(name) ) {
- return ::rust::Some(' ');
- }
- else {
- return ::rust::None<char>();
- }
-}
-
::std::ostream& operator<<(::std::ostream& os, const UseStmt& x)
{
os << "Use(" << x.path << ")";
@@ -311,7 +306,7 @@ void Module::add_macro(bool is_exported, ::std::string name, MacroRulesPtr macro
m_macros.push_back( Named<MacroRulesPtr>( mv$(name), mv$(macro), is_exported ) );
}
void Module::add_macro_import(::std::string name, const MacroRules& mr) {
- m_macro_import_res.push_back( NamedNS<const MacroRules*>( mv$(name), &mr, false ) );
+ m_macro_import_res.push_back( Named<const MacroRules*>( mv$(name), &mr, false ) );
}
Item Item::clone() const
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp
index 241b51d7..0a43cc71 100644
--- a/src/ast/ast.hpp
+++ b/src/ast/ast.hpp
@@ -505,7 +505,7 @@ class Module
// --- Runtime caches and state ---
::std::vector< ::std::shared_ptr<Module> > m_anon_modules;
- ::std::vector< NamedNS<const MacroRules*> > m_macro_import_res; // Vec of imported macros (not serialised)
+ ::std::vector< Named<const MacroRules*> > m_macro_import_res;
::std::vector< Named<MacroRulesPtr> > m_macros;
public:
@@ -570,7 +570,7 @@ public:
NamedList<MacroRulesPtr>& macros() { return m_macros; }
const NamedList<MacroRulesPtr>& macros() const { return m_macros; }
- const ::std::vector<NamedNS<const MacroRules*> > macro_imports_res() const { return m_macro_import_res; }
+ const ::std::vector<Named<const MacroRules*> > macro_imports_res() const { return m_macro_import_res; }
private:
void resolve_macro_import(const Crate& crate, const ::std::string& modname, const ::std::string& macro_name);
@@ -612,20 +612,6 @@ TAGGED_UNION_EX(Item, (), None,
)
);
-
-struct ImplRef
-{
- const Impl& impl;
- ::std::vector<TypeRef> params;
-
- ImplRef(const Impl& impl, ::std::vector<TypeRef> params):
- impl(impl),
- params( mv$(params) )
- {}
-
- ::rust::option<char> find_named_item(const ::std::string& name) const;
-};
-
} // namespace AST
class GenericResolveClosure
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp
index 9e4ed2ad..3db09f1b 100644
--- a/src/ast/crate.cpp
+++ b/src/ast/crate.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/crate.cpp
+ * - Helper functions for the AST::Crate type (includes loading `extern crate`s)
*/
#include "crate.hpp"
#include "ast.hpp"
diff --git a/src/ast/crate.hpp b/src/ast/crate.hpp
index bf1758d7..87a9f867 100644
--- a/src/ast/crate.hpp
+++ b/src/ast/crate.hpp
@@ -1,4 +1,10 @@
-
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/crate.hpp
+ * - AST::Crate type, and other top-level AST definitions
+ */
#pragma once
#include "ast.hpp"
diff --git a/src/ast/expr.cpp b/src/ast/expr.cpp
index 1142b763..32295c8e 100644
--- a/src/ast/expr.cpp
+++ b/src/ast/expr.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/expr.cpp
+ * - AST Expression nodes
*/
#include "expr.hpp"
#include "ast.hpp"
diff --git a/src/ast/expr_ptr.hpp b/src/ast/expr_ptr.hpp
index 1d68af15..cae519cc 100644
--- a/src/ast/expr_ptr.hpp
+++ b/src/ast/expr_ptr.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/expr_ptr.hpp
+ * - Pointer type wrapping AST::ExprNode (prevents need to know the full definition)
*/
#include <memory>
diff --git a/src/ast/item.hpp b/src/ast/item.hpp
index 2137090d..0074ce9a 100644
--- a/src/ast/item.hpp
+++ b/src/ast/item.hpp
@@ -1,4 +1,10 @@
-
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/item.hpp
+ * - AST named item wrapper
+ */
#pragma once
#include <string>
@@ -7,19 +13,19 @@
namespace AST {
template <typename T>
-struct NamedNS
+struct Named
{
::std::string name;
T data;
bool is_pub;
- NamedNS():
+ Named():
is_pub(false)
{}
- NamedNS(NamedNS&&) = default;
- NamedNS(const NamedNS&) = default;
- NamedNS& operator=(NamedNS&&) = default;
- NamedNS(::std::string name, T data, bool is_pub):
+ Named(Named&&) = default;
+ Named(const Named&) = default;
+ Named& operator=(Named&&) = default;
+ Named(::std::string name, T data, bool is_pub):
name( ::std::move(name) ),
data( ::std::move(data) ),
is_pub( is_pub )
@@ -28,21 +34,6 @@ struct NamedNS
};
template <typename T>
-struct Named:
- public NamedNS<T>
-{
- Named():
- NamedNS<T>()
- {}
- Named(Named&&) = default;
- Named(const Named&) = default;
- Named& operator=(Named&&) = default;
- Named(::std::string name, T data, bool is_pub):
- NamedNS<T>( ::std::move(name), ::std::move(data), is_pub )
- {}
-};
-
-template <typename T>
using NamedList = ::std::vector<Named<T> >;
} // namespace AST
diff --git a/src/ast/macro.hpp b/src/ast/macro.hpp
index 84baa5a3..5b2223ce 100644
--- a/src/ast/macro.hpp
+++ b/src/ast/macro.hpp
@@ -1,4 +1,10 @@
-
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/macro.hpp
+ * - AST representation of a macro invocation
+ */
#ifndef _AST_MACRO_HPP_
#define _AST_MACRO_HPP_
diff --git a/src/ast/path.cpp b/src/ast/path.cpp
index 690bc9eb..6fdf1e40 100644
--- a/src/ast/path.cpp
+++ b/src/ast/path.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/path.cpp
+ * - AST::Path and friends
*/
#include "path.hpp"
#include "ast.hpp"
diff --git a/src/ast/path.hpp b/src/ast/path.hpp
index 0cb6fcc8..c2d13d73 100644
--- a/src/ast/path.hpp
+++ b/src/ast/path.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/path.hpp
+ * - AST::Path and helper types
*/
#ifndef AST_PATH_HPP_INCLUDED
#define AST_PATH_HPP_INCLUDED
diff --git a/src/ast/types.hpp b/src/ast/types.hpp
index b6d9d6f5..af07ba2d 100644
--- a/src/ast/types.hpp
+++ b/src/ast/types.hpp
@@ -1,3 +1,10 @@
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/types.hpp
+ * - AST Type reference (and helpers)
+ */
#ifndef TYPES_HPP_INCLUDED
#define TYPES_HPP_INCLUDED
diff --git a/src/common.hpp b/src/common.hpp
index 3c99e57b..f46f93fd 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * common.hpp
+ * - Compiler-global common header
*/
#ifndef COMMON_HPP_INCLUDED
#define COMMON_HPP_INCLUDED
@@ -22,7 +27,6 @@
#define rc_new$(...) ::make_shared_ptr(::std::move(__VA_ARGS__))
#include "include/debug.hpp"
-#include "include/rustic.hpp" // slice and option
#include "include/compile_error.hpp"
template<typename T>
diff --git a/src/coretypes.hpp b/src/coretypes.hpp
index 67e32f79..7665f5ba 100644
--- a/src/coretypes.hpp
+++ b/src/coretypes.hpp
@@ -1,3 +1,10 @@
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * coretypes.hpp
+ * - AST-level builtin types
+ */
#ifndef CORETYPES_HPP_INCLUDED
#define CORETYPES_HPP_INCLUDED
diff --git a/src/debug.cpp b/src/debug.cpp
index d460c3cb..43e2795e 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -1,4 +1,10 @@
-
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * debug.cpp
+ * - Debug printing (with indenting)
+ */
#include <debug.hpp>
TraceLog::TraceLog(const char* tag, ::std::function<void(::std::ostream&)> info_cb, ::std::function<void(::std::ostream&)> ret):
diff --git a/src/expand/cfg.hpp b/src/expand/cfg.hpp
index 7c7785bb..5050a229 100644
--- a/src/expand/cfg.hpp
+++ b/src/expand/cfg.hpp
@@ -1,3 +1,10 @@
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * expand/cfg.hpp
+ * - Handling of `#[cfg]` and `cfg!` conditions
+ */
#pragma once
diff --git a/src/expand/macro_rules.cpp b/src/expand/macro_rules.cpp
index 5aa15a46..89f394e1 100644
--- a/src/expand/macro_rules.cpp
+++ b/src/expand/macro_rules.cpp
@@ -15,7 +15,6 @@
#include "../parse/common.hpp"
#include "../parse/ttstream.hpp"
#include <ast/crate.hpp>
-#include "macro_rules.hpp"
#include <macro_rules/macro_rules.hpp>
#include <hir/hir.hpp> // for HIR::Crate
diff --git a/src/expand/macro_rules.hpp b/src/expand/macro_rules.hpp
deleted file mode 100644
index 00332dd5..00000000
--- a/src/expand/macro_rules.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Binding header for the macro_rules syntax extension
- */
-#pragma once
-
-#include <synext.hpp>
-
-namespace AST {
- class Expr;
- class Module;
-}
-class TokenTree;
-class TokenStream;
-class MacroRules;
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp
index 8e052dfe..5d6d3234 100644
--- a/src/expand/mod.cpp
+++ b/src/expand/mod.cpp
@@ -10,7 +10,6 @@
#include <main_bindings.hpp>
#include <synext.hpp>
#include <map>
-#include "macro_rules.hpp"
#include "../macro_rules/macro_rules.hpp"
#include "../parse/common.hpp" // For reparse from macros
#include <ast/expr.hpp>
diff --git a/src/expand/std_prelude.cpp b/src/expand/std_prelude.cpp
index 6b81b71e..d6022959 100644
--- a/src/expand/std_prelude.cpp
+++ b/src/expand/std_prelude.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * expand/std_prelude.cpp
+ * - Handling of no_std/no_core/no_prelude
*/
#include <synext.hpp>
#include <ast/crate.hpp>
diff --git a/src/hir/crate_ptr.cpp b/src/hir/crate_ptr.cpp
index bc0287b3..e5cb8bf1 100644
--- a/src/hir/crate_ptr.cpp
+++ b/src/hir/crate_ptr.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir/crate_ptr.cpp
+ * - Implementation of HIR::CratePtr
*/
#include "crate_ptr.hpp"
#include "hir.hpp"
diff --git a/src/hir/crate_ptr.hpp b/src/hir/crate_ptr.hpp
index c870b1ea..bdbff1b2 100644
--- a/src/hir/crate_ptr.hpp
+++ b/src/hir/crate_ptr.hpp
@@ -1,5 +1,9 @@
/*
- * High-level intermediate representation
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir/crate_ptr.hpp
+ * - Pointer type to the HIR version of a crate
*/
#pragma once
diff --git a/src/hir/expr.hpp b/src/hir/expr.hpp
index 33726093..37efac31 100644
--- a/src/hir/expr.hpp
+++ b/src/hir/expr.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir/expr.hpp
+ * - HIR Expression nodes
*/
#pragma once
diff --git a/src/hir/generic_params.cpp b/src/hir/generic_params.cpp
index 984d8a3a..381277fc 100644
--- a/src/hir/generic_params.cpp
+++ b/src/hir/generic_params.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir/generic_params.hpp
+ * - HIR version of generic definition blocks
*/
#include "generic_params.hpp"
diff --git a/src/hir/generic_params.hpp b/src/hir/generic_params.hpp
index 8753ae7e..ef83bda7 100644
--- a/src/hir/generic_params.hpp
+++ b/src/hir/generic_params.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir/generic_params.hpp
+ * - HIR version of generic definition blocks
*/
#pragma once
#include <string>
diff --git a/src/hir/path.hpp b/src/hir/path.hpp
index 206b5d5b..f2bec6ee 100644
--- a/src/hir/path.hpp
+++ b/src/hir/path.hpp
@@ -11,11 +11,11 @@
#include <common.hpp>
#include <tagged_union.hpp>
-#include <hir/type_ptr.hpp>
#include <span.hpp>
namespace HIR {
+class TypeRef;
class Trait;
enum Compare {
diff --git a/src/hir/type_ptr.cpp b/src/hir/type_ptr.cpp
deleted file mode 100644
index b4814e41..00000000
--- a/src/hir/type_ptr.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#include <hir/type_ptr.hpp>
-#include <hir/type.hpp>
-
-::HIR::TypeRefPtr::TypeRefPtr(TypeRef tr):
- m_ptr( new TypeRef(mv$(tr)) )
-{
-}
-::HIR::TypeRefPtr::TypeRefPtr(TypeRefPtr&& other):
- m_ptr( other.m_ptr )
-{
- other.m_ptr = nullptr;
-}
-::HIR::TypeRefPtr::~TypeRefPtr()
-{
- delete m_ptr, m_ptr = nullptr;
-}
-
diff --git a/src/hir/type_ptr.hpp b/src/hir/type_ptr.hpp
deleted file mode 100644
index b3e1bcc7..00000000
--- a/src/hir/type_ptr.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- */
-#pragma once
-
-namespace HIR {
-
-class TypeRef;
-class TypeRefPtr {
- TypeRef* m_ptr;
-public:
- TypeRefPtr(TypeRef _);
- TypeRefPtr(TypeRefPtr&& _);
- ~TypeRefPtr();
-};
-
-} // namespace HIR
diff --git a/src/hir_conv/main_bindings.hpp b/src/hir_conv/main_bindings.hpp
index fe99b859..37488dae 100644
--- a/src/hir_conv/main_bindings.hpp
+++ b/src/hir_conv/main_bindings.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir_conv/main_bindings.hpp
+ * - Functions in the "HIR Conversion" group called by main
*/
#pragma once
diff --git a/src/hir_typeck/expr_visit.cpp b/src/hir_typeck/expr_visit.cpp
index b82e8f23..123f51b3 100644
--- a/src/hir_typeck/expr_visit.cpp
+++ b/src/hir_typeck/expr_visit.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir_typeck/expr_visit.cpp
+ * - Wrapper around HIR typecheck that visits all expressions
*/
#include <hir/hir.hpp>
#include <hir/expr.hpp>
diff --git a/src/hir_typeck/expr_visit.hpp b/src/hir_typeck/expr_visit.hpp
index 3fe601e4..2263a66f 100644
--- a/src/hir_typeck/expr_visit.hpp
+++ b/src/hir_typeck/expr_visit.hpp
@@ -1,3 +1,10 @@
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir_typeck/expr_visit.hpp
+ * - Helpers for the HIR typecheck expression visiting
+ */
namespace typeck {
struct ModuleState
diff --git a/src/hir_typeck/impl_ref.hpp b/src/hir_typeck/impl_ref.hpp
index 126daeda..b1190c61 100644
--- a/src/hir_typeck/impl_ref.hpp
+++ b/src/hir_typeck/impl_ref.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir_typeck/impl_ref.hpp
+ * - Reference to a specific impl block (or the concept of one)
*/
#pragma once
diff --git a/src/hir_typeck/main_bindings.hpp b/src/hir_typeck/main_bindings.hpp
index fe2920b9..12872fe6 100644
--- a/src/hir_typeck/main_bindings.hpp
+++ b/src/hir_typeck/main_bindings.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * hir_typeck/main_bindings.hpp
+ * - Functions in HIR typecheck called by main
*/
#pragma once
diff --git a/src/include/compile_error.hpp b/src/include/compile_error.hpp
index f88cbe58..d813d83a 100644
--- a/src/include/compile_error.hpp
+++ b/src/include/compile_error.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/compile_error.hpp
+ * - Front-end compiler error exception classes
*/
#ifndef _COMPILE_ERROR_H_
#define _COMPILE_ERROR_H_
diff --git a/src/include/cpp_unpack.h b/src/include/cpp_unpack.h
index 69417589..801d5619 100644
--- a/src/include/cpp_unpack.h
+++ b/src/include/cpp_unpack.h
@@ -1,4 +1,10 @@
-
+/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/cpp_unpack.hpp
+ * - Macro that performs variadic unpacking and calls a function/macro with the unpacked values
+ */
#ifndef _CPP_UNAPCK_H_
#define _CPP_UNAPCK_H_
diff --git a/src/include/main_bindings.hpp b/src/include/main_bindings.hpp
index ee8f4c54..c9e573d4 100644
--- a/src/include/main_bindings.hpp
+++ b/src/include/main_bindings.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/main_bindings.hpp
+ * - General bindings of AST passes for main to call
*/
#ifndef _MAIN_BINDINGS_HPP_
#define _MAIN_BINDINGS_HPP_
@@ -8,25 +13,16 @@
namespace AST {
class Crate;
- class Flat;
}
/// Parse a crate from the given file
extern AST::Crate Parse_Crate(::std::string mainfile);
-
extern void Expand(::AST::Crate& crate);
extern void Expand_TestHarness(::AST::Crate& crate);
extern void Expand_ProcMacro(::AST::Crate& crate);
-/// Process #[] decorators
-extern void Process_Decorators(AST::Crate& crate);
-
-/// Convert the AST to a flat tree
-extern AST::Flat Convert_Flatten(const AST::Crate& crate);
-
-
-/// Dump the crate as annotated rust
+/// Dump the crate AST as annotated rust
extern void Dump_Rust(const char *Filename, const AST::Crate& crate);
#endif
diff --git a/src/include/rc_string.hpp b/src/include/rc_string.hpp
index fd230062..eec47d80 100644
--- a/src/include/rc_string.hpp
+++ b/src/include/rc_string.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/rc_string.hpp
+ * - Reference-counted string (used for spans)
*/
#pragma once
diff --git a/src/include/rustic.hpp b/src/include/rustic.hpp
deleted file mode 100644
index 93992f61..00000000
--- a/src/include/rustic.hpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- */
-#pragma once
-
-template<typename T>
-class slice
-{
- T* m_first;
- unsigned int m_len;
-public:
- slice():
- m_first(nullptr),
- m_len(0)
- {}
- slice(const ::std::vector<T>& v):
- m_first(&v[0]),
- m_len(v.size())
- {}
- slice(::std::vector<T>& v):
- m_first(&v[0]),
- m_len(v.size())
- {}
- slice(T* ptr, unsigned int len):
- m_first(ptr),
- m_len(len)
- {}
-
- ::std::vector<T> to_vec() const {
- return ::std::vector<T>(begin(), end());
- }
-
- unsigned int size() const {
- return m_len;
- }
- T& operator[](unsigned int i) const {
- assert(i < m_len);
- return m_first[i];
- }
- slice<T> subslice(unsigned int ofs, unsigned int len) const {
- assert(ofs < m_len);
- assert(len <= m_len);
- assert(ofs + len <= m_len);
- return slice { m_first + ofs, len };
- }
-
- T* begin() const { return m_first; }
- T* end() const { return m_first + m_len; }
-
- T& front() const { return m_first[0]; }
- T& back() const { return m_first[m_len-1]; }
-};
-
-template<typename T>
-::std::ostream& operator<<(::std::ostream& os, slice<T> s) {
- if( s.size() > 0 )
- {
- bool is_first = true;
- for( const auto& i : s )
- {
- if(!is_first)
- os << ", ";
- is_first = false;
- os << i;
- }
- }
- return os;
-}
-
-namespace rust {
-
-template<typename T>
-class option
-{
- char m_data[ sizeof(T) ];
- bool m_set;
-
- void* data_ptr() { return m_data; }
- const void* data_ptr() const { return m_data; }
-public:
- option(T ent):
- m_set(true)
- {
- new (m_data) T(::std::move(ent));
- }
- option():
- m_set(false)
- {}
- ~option() {
- if( m_set ) {
- reinterpret_cast<T*>(data_ptr())->~T();
- }
- }
-
- bool is_none() const { return !m_set; }
- bool is_some() const { return m_set; }
-
- const T& unwrap() const {
- assert(is_some());
- return *reinterpret_cast<const T*>(m_data);
- }
-
- void if_set(::std::function<void (const T&)> f) const {
- if( m_set ) {
- return f(m_data);
- }
- }
- //template<typename U/*, class FcnSome, class FcnNone*/>
- //U match(::std::function<U(const T&)> if_some, ::Std::function<U()> if_none) const {
- // if( m_set ) {
- // return if_some(m_data);
- // }
- // else {
- // return if_none();
- // }
- //}
-};
-template<typename T>
-class option<T&>
-{
- T* m_ptr;
-public:
- option(T& ent):
- m_ptr(&ent)
- {}
- option():
- m_ptr(nullptr)
- {}
-
- bool is_none() const { return m_ptr == nullptr; }
- bool is_some() const { return m_ptr != nullptr; }
- T& unwrap() const {
- assert(is_some());
- return *m_ptr;
- }
- void if_set(::std::function<void (const T&)> f) const {
- if( m_ptr ) {
- return f(*m_ptr);
- }
- }
-};
-template<typename T>
-option<T> Some(T data) {
- return option<T>( ::std::move(data) );
-}
-template<typename T>
-option<T> None() {
- return option<T>( );
-}
-
-#define IF_OPTION_SOME(bind, var, ...) { auto __v = (var); if( var.is_some() ) { auto bind = __v.unwrap(); (void)&bind; __VA_ARGS__ } }
-
-};
diff --git a/src/include/stdspan.hpp b/src/include/stdspan.hpp
new file mode 100644
index 00000000..0d574cfc
--- /dev/null
+++ b/src/include/stdspan.hpp
@@ -0,0 +1,78 @@
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/stdspan.hpp
+ * - Clone of the C++20 span class
+ */
+#pragma once
+#include <vector>
+#include <iostream> // ostream
+
+namespace std {
+
+template<typename T>
+class span
+{
+ T* m_first;
+ unsigned int m_len;
+public:
+ span():
+ m_first(nullptr),
+ m_len(0)
+ {}
+ span(const ::std::vector<T>& v):
+ m_first(&v[0]),
+ m_len(v.size())
+ {}
+ span(::std::vector<T>& v):
+ m_first(&v[0]),
+ m_len(v.size())
+ {}
+ span(T* ptr, unsigned int len):
+ m_first(ptr),
+ m_len(len)
+ {}
+
+ ::std::vector<T> to_vec() const {
+ return ::std::vector<T>(begin(), end());
+ }
+
+ unsigned int size() const {
+ return m_len;
+ }
+ T& operator[](unsigned int i) const {
+ assert(i < m_len);
+ return m_first[i];
+ }
+ span<T> subspan(unsigned int ofs, unsigned int len) const {
+ assert(ofs < m_len);
+ assert(len <= m_len);
+ assert(ofs + len <= m_len);
+ return span { m_first + ofs, len };
+ }
+
+ T* begin() const { return m_first; }
+ T* end() const { return m_first + m_len; }
+
+ T& front() const { return m_first[0]; }
+ T& back() const { return m_first[m_len-1]; }
+};
+
+template<typename T>
+::std::ostream& operator<<(::std::ostream& os, span<T> s) {
+ if( s.size() > 0 )
+ {
+ bool is_first = true;
+ for( const auto& i : s )
+ {
+ if(!is_first)
+ os << ", ";
+ is_first = false;
+ os << i;
+ }
+ }
+ return os;
+}
+
+}
diff --git a/src/include/synext.hpp b/src/include/synext.hpp
index 67f3b87b..6a8e74b6 100644
--- a/src/include/synext.hpp
+++ b/src/include/synext.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/synext.hpp
+ * - Generic syntax extension support
*/
#pragma once
#ifndef _SYNEXT_HPP_
diff --git a/src/include/synext_decorator.hpp b/src/include/synext_decorator.hpp
index 049a28b0..eaed3154 100644
--- a/src/include/synext_decorator.hpp
+++ b/src/include/synext_decorator.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/synext_decorator.hpp
+ * - Decorator syntax extensions (#[foo])
*/
#pragma once
#ifndef _SYNEXT_DECORATOR_HPP_
diff --git a/src/include/synext_macro.hpp b/src/include/synext_macro.hpp
index 0359d508..d414ceb0 100644
--- a/src/include/synext_macro.hpp
+++ b/src/include/synext_macro.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/synext_macro.hpp
+ * - Macro-style syntax extensions ( `foo!()` )
*/
#pragma once
#ifndef _SYNEXT_MACRO_HPP_
diff --git a/src/include/tagged_union.hpp b/src/include/tagged_union.hpp
index 478953b9..bcc9eb3d 100644
--- a/src/include/tagged_union.hpp
+++ b/src/include/tagged_union.hpp
@@ -1,4 +1,11 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/tagged_union.hpp
+ * - Macro that allows construction of a tagged union (with various helper methods)
+ *
+ *
* The most evil CPP abuse I have ever written
*
* Constructs a tagged union that correctly handles objects.
@@ -169,11 +176,11 @@
*
* ```
* TAGGED_UNION(Inner, Any,
- * (Any, (bool flag)),
- * (Tuple, (::std::vector<Pattern> subpats)),
- * (TupleStruct, (Path path; ::std::vector<Pattern> sub_patterns;)),
- * (Value, (::std::unique_ptr<ExprNode> val )),
- * (Range, (::std::unique_ptr<ExprNode> left; ::std::unique_ptr<ExprNode> right;))
+ * (Any, (struct { bool match_multiple; })),
+ * (Tuple, (::std::vector<Pattern> )),
+ * (TupleStruct, (struct { Path path; ::std::vector<Pattern> sub_patterns; })),
+ * (Value, (::std::unique_ptr<ExprNode> )),
+ * (Range, (struct { ::std::unique_ptr<ExprNode> left; ::std::unique_ptr<ExprNode> right; }))
* );
* ```
*/
diff --git a/src/macro_rules/mod.cpp b/src/macro_rules/mod.cpp
index 2613a0b4..6410d334 100644
--- a/src/macro_rules/mod.cpp
+++ b/src/macro_rules/mod.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * macro_rules/mod.cpp
+ * - Top-level handling for macro_rules macros
*/
#include <common.hpp>
#include "macro_rules.hpp"
diff --git a/src/macro_rules/pattern_checks.hpp b/src/macro_rules/pattern_checks.hpp
index 138f11a3..4ebbe915 100644
--- a/src/macro_rules/pattern_checks.hpp
+++ b/src/macro_rules/pattern_checks.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * macro_rules/pattern_checks.hpp
+ * - Checking helpers for the fragement patterns
*/
#pragma once
diff --git a/src/parse/eTokenType.enum.h b/src/parse/eTokenType.enum.h
index 1e46721f..5104142b 100644
--- a/src/parse/eTokenType.enum.h
+++ b/src/parse/eTokenType.enum.h
@@ -1,3 +1,10 @@
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/eTokenType.enum.h
+ * - Multi-include file for defining the eTokenType enum
+ */
_(TOK_NULL)
_(TOK_EOF)
diff --git a/src/parse/interpolated_fragment.cpp b/src/parse/interpolated_fragment.cpp
index 9b7979f3..d8a8bc43 100644
--- a/src/parse/interpolated_fragment.cpp
+++ b/src/parse/interpolated_fragment.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/interpolated_fragment.cpp
+ * - An "interpolated fragment", result of parsing e.g. :expr in a macro invocation
*/
#include <iostream>
#include "interpolated_fragment.hpp"
diff --git a/src/parse/interpolated_fragment.hpp b/src/parse/interpolated_fragment.hpp
index 857e77aa..36539fb0 100644
--- a/src/parse/interpolated_fragment.hpp
+++ b/src/parse/interpolated_fragment.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/interpolated_fragment.hpp
+ * - An "interpolated fragment", result of parsing e.g. :expr in a macro invocation
*/
#pragma once
diff --git a/src/parse/parseerror.hpp b/src/parse/parseerror.hpp
index d6bcab6b..d6e2b03e 100644
--- a/src/parse/parseerror.hpp
+++ b/src/parse/parseerror.hpp
@@ -1,3 +1,10 @@
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/parseerror.hpp
+ * - Exception classes for parsing/lexing errors
+ */
#ifndef PARSEERROR_HPP_INCLUDED
#define PARSEERROR_HPP_INCLUDED
diff --git a/src/rc_string.cpp b/src/rc_string.cpp
index 59534d28..46f36923 100644
--- a/src/rc_string.cpp
+++ b/src/rc_string.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * rc_string.cpp
+ * - Reference-counted string
*/
#include <rc_string.hpp>
#include <cstring>
diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp
index c51cac72..19da5820 100644
--- a/src/resolve/absolute.cpp
+++ b/src/resolve/absolute.cpp
@@ -1,6 +1,11 @@
/*
- * Convert all paths in AST into absolute form (or to the relevant local item)
- * - NOTE: This is the core of the 'resolve' pass.
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * resolve/absolute.cpp
+ * - Convert all paths in AST into absolute form (or to the relevant local item)
+ *
+ * NOTE: This is the core of the 'resolve' pass.
*
* After complete there should be no:
* - Relative/super/self paths
diff --git a/src/resolve/index.cpp b/src/resolve/index.cpp
index 458aed5e..659bded4 100644
--- a/src/resolve/index.cpp
+++ b/src/resolve/index.cpp
@@ -1,5 +1,9 @@
/*
- * Build up a name index in all modules (optimising lookups in later stages)
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * resolve/index.cpp
+ * - Build up a name index in all modules (optimising lookups in later stages)
*/
#include <ast/ast.hpp>
#include <ast/crate.hpp>
diff --git a/src/resolve/main_bindings.hpp b/src/resolve/main_bindings.hpp
index cc6c74d7..f843a99e 100644
--- a/src/resolve/main_bindings.hpp
+++ b/src/resolve/main_bindings.hpp
@@ -1,6 +1,10 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * resolve/main_bindings.hpp
+ * - Functions in the resolve pass called by main
*/
-
#pragma once
namespace AST {
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp
index e36e40a0..23f7e70c 100644
--- a/src/resolve/use.cpp
+++ b/src/resolve/use.cpp
@@ -10,6 +10,7 @@
#include <ast/ast.hpp>
#include <ast/expr.hpp>
#include <hir/hir.hpp>
+#include <stdspan.hpp> // std::span
enum class Lookup
{
@@ -20,8 +21,8 @@ enum class Lookup
};
::AST::Path Resolve_Use_AbsolutisePath(const ::AST::Path& base_path, ::AST::Path path);
-void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path path, slice< const ::AST::Module* > parent_modules={});
-::AST::PathBinding Resolve_Use_GetBinding(const Span& span, const ::AST::Crate& crate, const ::AST::Path& path, slice< const ::AST::Module* > parent_modules, Lookup allow=Lookup::Any);
+void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path path, ::std::span< const ::AST::Module* > parent_modules={});
+::AST::PathBinding Resolve_Use_GetBinding(const Span& span, const ::AST::Crate& crate, const ::AST::Path& path, ::std::span< const ::AST::Module* > parent_modules, Lookup allow=Lookup::Any);
::AST::PathBinding Resolve_Use_GetBinding__ext(const Span& span, const ::AST::Crate& crate, const ::AST::Path& path, const ::HIR::Module& hmodr, unsigned int start, Lookup allow);
@@ -101,7 +102,7 @@ void Resolve_Use(::AST::Crate& crate)
throw "BUG: Reached end of Resolve_Use_AbsolutisePath";
}
-void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path path, slice< const ::AST::Module* > parent_modules)
+void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path path, ::std::span< const ::AST::Module* > parent_modules)
{
TRACE_FUNCTION_F("path = " << path);
@@ -267,7 +268,7 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path
const Span& span,
const ::AST::Crate& crate, const ::AST::Module& mod,
const ::std::string& des_item_name,
- slice< const ::AST::Module* > parent_modules,
+ ::std::span< const ::AST::Module* > parent_modules,
Lookup allow
)
{
@@ -476,7 +477,7 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path
if( mod.path().nodes().size() > 0 && mod.path().nodes().back().name()[0] == '#' ) {
assert( parent_modules.size() > 0 );
- return Resolve_Use_GetBinding_Mod(span, crate, *parent_modules.back(), des_item_name, parent_modules.subslice(0, parent_modules.size()-1), allow);
+ return Resolve_Use_GetBinding_Mod(span, crate, *parent_modules.back(), des_item_name, parent_modules.subspan(0, parent_modules.size()-1), allow);
}
else {
if( allow == Lookup::Any )
@@ -691,7 +692,7 @@ namespace {
return Resolve_Use_GetBinding__ext(span, crate, path, ec.m_hir->m_root_module, start, allow);
}
-::AST::PathBinding Resolve_Use_GetBinding(const Span& span, const ::AST::Crate& crate, const ::AST::Path& path, slice< const ::AST::Module* > parent_modules, Lookup allow)
+::AST::PathBinding Resolve_Use_GetBinding(const Span& span, const ::AST::Crate& crate, const ::AST::Path& path, ::std::span< const ::AST::Module* > parent_modules, Lookup allow)
{
TRACE_FUNCTION_F(path);
//::AST::Path rv;
diff --git a/src/trans/allocator.cpp b/src/trans/allocator.cpp
index ce4b3340..5f61093d 100644
--- a/src/trans/allocator.cpp
+++ b/src/trans/allocator.cpp
@@ -1,4 +1,10 @@
-
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * trans/allocator.cpp
+ * - Handling for switchable allocator backends
+ */
#include "allocator.hpp"
diff --git a/src/trans/allocator.hpp b/src/trans/allocator.hpp
index 67d56c11..8a4e5186 100644
--- a/src/trans/allocator.hpp
+++ b/src/trans/allocator.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * trans/allocator.hpp
+ * - Handling for switchable allocator backends
*/
#include <cstddef>
diff --git a/src/trans/codegen_c.hpp b/src/trans/codegen_c.hpp
index 094cc264..77ac5d5c 100644
--- a/src/trans/codegen_c.hpp
+++ b/src/trans/codegen_c.hpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * trans/codegen_c.hpp
+ * - C codegen backend (internal header)
*/
#pragma once
#include <vector>
diff --git a/src/trans/codegen_mmir.cpp b/src/trans/codegen_mmir.cpp
index 3347606c..b2c5282a 100644
--- a/src/trans/codegen_mmir.cpp
+++ b/src/trans/codegen_mmir.cpp
@@ -1,6 +1,12 @@
-//
-//
-//
+/*
+ * MRustC - Mutabah's Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * trans/codegen_mmir.cpp
+ * - Monomorphised MIR Backend
+ *
+ * Saves the MIR in a loadable form, used by the `standalone_miri` tool
+ */
#include "codegen.hpp"
#include <hir_typeck/static.hpp>
#include <mir/helpers.hpp>
diff --git a/tools/common/debug.h b/tools/common/debug.h
index 86c88de9..6935bfb9 100644
--- a/tools/common/debug.h
+++ b/tools/common/debug.h
@@ -1,3 +1,10 @@
+/*
+ * mrustc common tools
+ * - by John Hodge (Mutabah)
+ *
+ * tools/common/debug.h
+ * - Generic debug interface (used by minicargo/standalone_miri)
+ */
#pragma once
#include <functional>
diff --git a/tools/common/helpers.h b/tools/common/helpers.h
index 8111483a..a1250847 100644
--- a/tools/common/helpers.h
+++ b/tools/common/helpers.h
@@ -1,3 +1,11 @@
+/*
+ * mrustc common tools
+ * - by John Hodge (Mutabah)
+ *
+ * tools/common/helpers.h
+ * - General helper classes
+ */
+// TODO: Replace this header with src/includ/string_view.hpp
#pragma once
#include <string>
diff --git a/tools/common/path.cpp b/tools/common/path.cpp
index 12e505bb..4967a1d5 100644
--- a/tools/common/path.cpp
+++ b/tools/common/path.cpp
@@ -1,4 +1,9 @@
/*
+ * mrustc common code
+ * - by John Hodge (Mutabah)
+ *
+ * tools/common/path.cpp
+ * - Generic representation of a filesystem path
*/
#include "path.h"
#if _WIN32
diff --git a/tools/common/path.h b/tools/common/path.h
index dd97f9be..eae4951f 100644
--- a/tools/common/path.h
+++ b/tools/common/path.h
@@ -1,3 +1,10 @@
+/*
+ * mrustc common code
+ * - by John Hodge (Mutabah)
+ *
+ * tools/common/path.h
+ * - Generic representation of a filesystem path (HEADER)
+ */
#pragma once
#include <string>
diff --git a/tools/common/toml.cpp b/tools/common/toml.cpp
index 75a93810..489f32b6 100644
--- a/tools/common/toml.cpp
+++ b/tools/common/toml.cpp
@@ -1,13 +1,17 @@
/*
- * A very bad streaming TOML parser
+ * mrustc common tools
+ * - by John Hodge (Mutabah)
+ *
+ * tools/common/toml.cpp
+ * - A very basic (and probably incomplete) streaming TOML parser
*/
-#define NOLOG
+#define NOLOG // Disable logging
#include "toml.h"
#include "debug.h"
#include <cassert>
#include <string>
-
+// Representation of a syntatic token in a TOML file
struct Token
{
enum class Type
diff --git a/tools/common/toml.h b/tools/common/toml.h
index a2c03bf1..4c97e7f2 100644
--- a/tools/common/toml.h
+++ b/tools/common/toml.h
@@ -1,3 +1,10 @@
+/*
+ * mrustc common tools
+ * - by John Hodge (Mutabah)
+ *
+ * tools/common/toml.h
+ * - A very basic (and probably incomplete) streaming TOML parser
+ */
#pragma once
#include <fstream>
@@ -31,6 +38,7 @@ public:
TomlFileIter begin();
TomlFileIter end();
+ // Obtain the next value in the file
TomlKeyValue get_next_value();
};
@@ -38,11 +46,14 @@ struct TomlValue
{
enum class Type
{
+ // A true/false, 1/0, yes/no value
Boolean,
+ // A double-quoted string
String,
+ // Integer
Integer,
+ // A list of other values
List,
-
};
friend ::std::ostream& operator<<(::std::ostream& os, const Type& e) {
switch(e)
@@ -146,7 +157,10 @@ struct TomlValue
struct TomlKeyValue
{
+ // Path to the value (last node is the value name)
+ // TODO: How are things like `[[bin]]` handled?
::std::vector<::std::string> path;
+ // Relevant value
TomlValue value;
};
diff --git a/tools/minicargo/build.h b/tools/minicargo/build.h
index 54d03575..bba22964 100644
--- a/tools/minicargo/build.h
+++ b/tools/minicargo/build.h
@@ -1,3 +1,10 @@
+/*
+ * minicargo - MRustC-specific clone of `cargo`
+ * - By John Hodge (Mutabah)
+ *
+ * build.h
+ * - Definitions relating to building the crate (and dependencies)
+ */
#pragma once
#include "manifest.h"
@@ -21,7 +28,7 @@ class BuildList
struct Entry
{
const PackageManifest* package;
- bool is_host;
+ bool is_host;
::std::vector<unsigned> dependents; // Indexes into the list
};
const PackageManifest& m_root_manifest;
diff --git a/tools/minicargo/main.cpp b/tools/minicargo/main.cpp
index b185881b..b96a8a03 100644
--- a/tools/minicargo/main.cpp
+++ b/tools/minicargo/main.cpp
@@ -1,5 +1,6 @@
/*
- * Mini version of cargo
+ * mrustc "minicargo" (minimal cargo clone)
+ * - By John Hodge (Mutabah)
*
* main.cpp
* - Entrypoint
diff --git a/tools/minicargo/manifest.cpp b/tools/minicargo/manifest.cpp
index 687c3e2a..bbaa24f6 100644
--- a/tools/minicargo/manifest.cpp
+++ b/tools/minicargo/manifest.cpp
@@ -1,4 +1,9 @@
/*
+ * mrustc "minicargo" (minimal cargo clone)
+ * - By John Hodge (Mutabah)
+ *
+ * manifest.cpp
+ * - Cargo.toml manifest loading and manipulation code
*/
#include "manifest.h"
#include "toml.h"
@@ -9,7 +14,7 @@
#include <cctype> // toupper
#include "repository.h"
-// TODO: Extract this from the target at runtime
+// TODO: Extract this from the target at runtime (by invoking the compiler on the passed target)
#ifdef _WIN32
# define TARGET_NAME "i586-windows-msvc"
# define CFG_UNIX false
diff --git a/tools/minicargo/manifest.h b/tools/minicargo/manifest.h
index e48e7f2a..4bb8b843 100644
--- a/tools/minicargo/manifest.h
+++ b/tools/minicargo/manifest.h
@@ -1,3 +1,10 @@
+/*
+ * mrustc "minicargo" (minimal cargo clone)
+ * - By John Hodge (Mutabah)
+ *
+ * manifest.h
+ * - Cargo.toml package manifests
+ */
#pragma once
#include <string>
diff --git a/tools/minicargo/repository.cpp b/tools/minicargo/repository.cpp
index ebe660f1..f5ff5ea8 100644
--- a/tools/minicargo/repository.cpp
+++ b/tools/minicargo/repository.cpp
@@ -1,4 +1,9 @@
/*
+ * minicargo - MRustC-specific clone of `cargo`
+ * - By John Hodge (Mutabah)
+ *
+ * repository.cpp
+ * - Handling of (vendored) crates.io dependencies
*/
#include "repository.h"
#include "debug.h"
diff --git a/tools/minicargo/repository.h b/tools/minicargo/repository.h
index 0b186077..ca481166 100644
--- a/tools/minicargo/repository.h
+++ b/tools/minicargo/repository.h
@@ -1,3 +1,10 @@
+/*
+ * minicargo - MRustC-specific clone of `cargo`
+ * - By John Hodge (Mutabah)
+ *
+ * repository.h
+ * - Handling (vendored) crates.io dependencies
+ */
#pragma once
#include <string>
diff --git a/tools/standalone_miri/hir/type.hpp b/tools/standalone_miri/hir/type.hpp
index 2e566691..6a0abd8f 100644
--- a/tools/standalone_miri/hir/type.hpp
+++ b/tools/standalone_miri/hir/type.hpp
@@ -1 +1,8 @@
-#include "../hir_sim.hpp" \ No newline at end of file
+/*
+ * mrustc Standalone MIRI
+ * - by John Hodge (Mutabah)
+ *
+ * hir/type.hpp
+ * - Forwarding header so mrustc's mir.hpp can be imported
+ */
+#include "../hir_sim.hpp"
diff --git a/tools/standalone_miri/hir_sim.hpp b/tools/standalone_miri/hir_sim.hpp
index 7730ac48..62248fe9 100644
--- a/tools/standalone_miri/hir_sim.hpp
+++ b/tools/standalone_miri/hir_sim.hpp
@@ -1,6 +1,10 @@
-//
-//
-//
+/*
+ * mrustc Standalone MIRI
+ * - by John Hodge (Mutabah)
+ *
+ * hir_sim.hpp
+ * - Clones of the mrustc HIR types (HEADER)
+ */
#pragma once
#include <string>
#include <vector>
diff --git a/tools/standalone_miri/lex.cpp b/tools/standalone_miri/lex.cpp
index 8fc77f7a..07427bde 100644
--- a/tools/standalone_miri/lex.cpp
+++ b/tools/standalone_miri/lex.cpp
@@ -1,6 +1,10 @@
-//
-//
-//
+/*
+ * mrustc Standalone MIRI
+ * - by John Hodge (Mutabah)
+ *
+ * lex.cpp
+ * - MIR file lexer (very simple)
+ */
#include "lex.hpp"
#include <cctype>
#include <iostream>
diff --git a/tools/standalone_miri/lex.hpp b/tools/standalone_miri/lex.hpp
index cc1429f7..1d1b5c2a 100644
--- a/tools/standalone_miri/lex.hpp
+++ b/tools/standalone_miri/lex.hpp
@@ -1,6 +1,10 @@
-//
-//
-//
+/*
+ * mrustc Standalone MIRI
+ * - by John Hodge (Mutabah)
+ *
+ * lex.hpp
+ * - Simple lexer for MIR files (HEADER)
+ */
#pragma once
#include <string>
#include <fstream>
diff --git a/tools/standalone_miri/miri.hpp b/tools/standalone_miri/miri.hpp
index 09d92a9b..6f02ffee 100644
--- a/tools/standalone_miri/miri.hpp
+++ b/tools/standalone_miri/miri.hpp
@@ -1,4 +1,10 @@
-
+/*
+ * mrustc Standalone MIRI
+ * - by John Hodge (Mutabah)
+ *
+ * miri.hpp
+ * - MIR Interpreter State (HEADER)
+ */
#pragma once
#include "module_tree.hpp"
#include "value.hpp"
@@ -35,10 +41,10 @@ class InterpreterThread
::std::vector<Value> args;
::std::vector<Value> locals;
::std::vector<bool> drop_flags;
-
+
unsigned bb_idx;
unsigned stmt_idx;
-
+
StackFrame(const Function& fcn, ::std::vector<Value> args);
static StackFrame make_wrapper(::std::function<bool(Value&,Value)> cb) {
static Function f;
@@ -51,14 +57,14 @@ class InterpreterThread
ModuleTree& m_modtree;
ThreadState m_thread;
::std::vector<StackFrame> m_stack;
-
+
public:
InterpreterThread(ModuleTree& modtree):
m_modtree(modtree)
{
}
~InterpreterThread();
-
+
void start(const ::HIR::Path& p, ::std::vector<Value> args);
// Returns `true` if the call stack empties
bool step_one(Value& out_thread_result);
diff --git a/tools/standalone_miri/module_tree.cpp b/tools/standalone_miri/module_tree.cpp
index 8beba018..eb6b6b9e 100644
--- a/tools/standalone_miri/module_tree.cpp
+++ b/tools/standalone_miri/module_tree.cpp
@@ -1,11 +1,16 @@
-//
-//
-//
+/*
+ * mrustc Standalone MIRI
+ * - by John Hodge (Mutabah)
+ *
+ * module_tree.cpp
+ * - In-memory representation of a Monomorphised MIR executable
+ * - Also handles parsing the .mir files
+ */
#include "module_tree.hpp"
#include "lex.hpp"
#include "value.hpp"
#include <iostream>
-#include <algorithm> // std::find
+#include <algorithm> // std::find
#include "debug.hpp"
ModuleTree::ModuleTree()
diff --git a/tools/standalone_miri/module_tree.hpp b/tools/standalone_miri/module_tree.hpp
index 5479d9ef..efa0a034 100644
--- a/tools/standalone_miri/module_tree.hpp
+++ b/tools/standalone_miri/module_tree.hpp
@@ -1,6 +1,10 @@
-//
-//
-//
+/*
+ * mrustc Standalone MIRI
+ * - by John Hodge (Mutabah)
+ *
+ * module_tree.hpp
+ * - In-memory representation of a Monomorphised MIR executable (HEADER)
+ */
#pragma once
#include <string>
#include <vector>
@@ -27,6 +31,7 @@ struct Function
struct Static
{
::HIR::TypeRef ty;
+ // TODO: Should this value be stored in the program state (making the entire `ModuleTree` const)
Value val;
};
diff --git a/tools/testrunner/main.cpp b/tools/testrunner/main.cpp
index f21dc7fa..4dafe508 100644
--- a/tools/testrunner/main.cpp
+++ b/tools/testrunner/main.cpp
@@ -1,6 +1,13 @@
-///
-///
-///
+/*
+ * mrustc test runner
+ * - by John Hodge (Mutabah)
+ *
+ * tools/testrunner/main.cpp
+ * - Clone of rustc's integration test runner
+ *
+ *
+ * Runs all .rs files in a directory, parsing test options out of comments in the file
+ */
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>