summaryrefslogtreecommitdiff
path: root/src/mir/helpers.hpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-12-04 17:05:03 +0800
committerJohn Hodge <tpg@mutabah.net>2016-12-04 17:05:03 +0800
commit0fa897c376084e2719c00af35bc3d8b6c0c02da9 (patch)
tree0dfcc38937c1ae27f7a0ee28b59bf310cc2a0cf9 /src/mir/helpers.hpp
parent30f37248ed90edd2a8102f4d7365d785ba4fd587 (diff)
downloadmrust-0fa897c376084e2719c00af35bc3d8b6c0c02da9.tar.gz
Trans C - Some special cases
Diffstat (limited to 'src/mir/helpers.hpp')
-rw-r--r--src/mir/helpers.hpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/mir/helpers.hpp b/src/mir/helpers.hpp
new file mode 100644
index 00000000..884cafa7
--- /dev/null
+++ b/src/mir/helpers.hpp
@@ -0,0 +1,59 @@
+/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * mir/helpers.hpp
+ * - MIR Manipulation helpers
+ */
+#pragma once
+#include <vector>
+#include <functional>
+#include <hir_typeck/static.hpp>
+
+namespace HIR {
+class Crate;
+class TypeRef;
+class Pattern;
+class SimplePath;
+}
+
+namespace MIR {
+
+class Function;
+class LValue;
+
+class TypeResolve
+{
+public:
+ typedef ::std::vector< ::std::pair< ::HIR::Pattern, ::HIR::TypeRef> > args_t;
+private:
+ const Span& sp;
+ const ::HIR::Crate& m_crate;
+ const ::HIR::TypeRef& m_ret_type;
+ const args_t& m_args;
+ const ::MIR::Function& m_fcn;
+ ::StaticTraitResolve m_resolve;
+ const ::HIR::SimplePath* m_lang_Box = nullptr;
+
+public:
+ TypeResolve(const Span& sp, const ::HIR::Crate& crate, const ::HIR::TypeRef& ret_type, const args_t& args, const ::MIR::Function& fcn):
+ sp(sp),
+ m_crate(crate),
+ m_ret_type(ret_type),
+ m_args(args),
+ m_fcn(fcn),
+ m_resolve(crate)
+ {
+ if( m_crate.m_lang_items.count("owned_box") > 0 ) {
+ m_lang_Box = &m_crate.m_lang_items.at("owned_box");
+ }
+ }
+
+ const ::HIR::TypeRef& get_lvalue_type(::HIR::TypeRef& tmp, const ::MIR::LValue& val) const;
+
+private:
+ const ::HIR::TypeRef* is_type_owned_box(const ::HIR::TypeRef& ty) const;
+};
+
+
+} // namespace MIR