summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/standalone_miri/Makefile7
-rw-r--r--tools/standalone_miri/hir_sim.cpp7
-rw-r--r--tools/standalone_miri/hir_sim.hpp89
-rw-r--r--tools/standalone_miri/mir.cpp90
-rw-r--r--tools/standalone_miri/miri.cpp228
-rw-r--r--tools/standalone_miri/miri.hpp2
-rw-r--r--tools/standalone_miri/module_tree.cpp21
-rw-r--r--tools/standalone_miri/module_tree.hpp1
8 files changed, 256 insertions, 189 deletions
diff --git a/tools/standalone_miri/Makefile b/tools/standalone_miri/Makefile
index f4dc0d0d..0a8bd672 100644
--- a/tools/standalone_miri/Makefile
+++ b/tools/standalone_miri/Makefile
@@ -11,7 +11,7 @@ V ?= @
OBJDIR := .obj/
BIN := ../bin/standalone_miri$(EXESUF)
-OBJS := main.o debug.o mir.o lex.o value.o module_tree.o hir_sim.o miri.o
+OBJS := main.o debug.o mir.o lex.o value.o module_tree.o hir_sim.o miri.o rc_string.o
LINKFLAGS := -g -lpthread
CXXFLAGS := -Wall -std=c++14 -g -O2
@@ -37,6 +37,11 @@ $(OBJDIR)%.o: %.cpp
@echo [CXX] $<
$V$(CXX) -o $@ -c $< $(CXXFLAGS) -MMD -MP -MF $@.dep
+$(OBJDIR)%.o: ../../src/%.cpp
+ @mkdir -p $(dir $@)
+ @echo [CXX] $<
+ $V$(CXX) -o $@ -c $< $(CXXFLAGS) -MMD -MP -MF $@.dep
+
../bin/common_lib.a:
make -C ../common
diff --git a/tools/standalone_miri/hir_sim.cpp b/tools/standalone_miri/hir_sim.cpp
index 88739730..085c045f 100644
--- a/tools/standalone_miri/hir_sim.cpp
+++ b/tools/standalone_miri/hir_sim.cpp
@@ -249,7 +249,7 @@ HIR::TypeRef HIR::TypeRef::get_field(size_t idx, size_t& ofs) const
if( w->type == TypeWrapper::Ty::Slice )
{
// TODO
- throw "TODO";
+ LOG_TODO("Field on slice - " << *this << " #" << idx);
}
else if( w->type == TypeWrapper::Ty::Array )
{
@@ -260,7 +260,7 @@ HIR::TypeRef HIR::TypeRef::get_field(size_t idx, size_t& ofs) const
}
else
{
- throw "ERROR";
+ LOG_ERROR("Field on unknown wrapper type - " << *this << " #" << idx);
}
}
else
@@ -273,8 +273,7 @@ HIR::TypeRef HIR::TypeRef::get_field(size_t idx, size_t& ofs) const
}
else
{
- ::std::cerr << *this << " doesn't have fields" << ::std::endl;
- throw "ERROR";
+ LOG_ERROR(*this << " doesn't have fields");
}
}
}
diff --git a/tools/standalone_miri/hir_sim.hpp b/tools/standalone_miri/hir_sim.hpp
index 62248fe9..cedbf3b9 100644
--- a/tools/standalone_miri/hir_sim.hpp
+++ b/tools/standalone_miri/hir_sim.hpp
@@ -9,18 +9,23 @@
#include <string>
#include <vector>
#include <memory>
+#include "../../src/include/rc_string.hpp"
const size_t POINTER_SIZE = 8;
+#define __ORD(fld) do { auto o = ::ord(this->fld, x.fld); if( o != OrdEqual ) return o; } while(0)
+#define __ORD_C(ty, fld) do { auto o = ::ord((ty)this->fld, (ty)x.fld); if( o != OrdEqual ) return o; } while(0)
#define __NE(fld) if(this->fld != x.fld) return true
#define __LT(fld) if(this->fld != x.fld) return this->fld < x.fld
+#if 0
enum Ordering
{
OrdLess,
OrdEqual,
OrdGreater,
};
+#endif
struct DataType;
@@ -56,18 +61,19 @@ struct TypeWrapper
} type;
size_t size;
+ Ordering ord(const TypeWrapper& x) const {
+ __ORD_C(int, type);
+ __ORD(size);
+ return OrdEqual;
+ }
bool operator==(const TypeWrapper& x) const {
- return !(*this != x);
+ return this->ord(x) == OrdEqual;
}
bool operator!=(const TypeWrapper& x) const {
- __NE(type);
- __NE(size);
- return false;
+ return this->ord(x) != OrdEqual;
}
bool operator<(const TypeWrapper& x) const {
- __LT(type);
- __LT(size);
- return false;
+ return this->ord(x) == OrdLess;
}
};
@@ -166,20 +172,20 @@ namespace HIR {
bool operator!=(const RawType& x) const {
return !(*this == x);
}
+ Ordering ord(const TypeRef& x) const {
+ __ORD(wrappers);
+ __ORD_C(int, inner_type);
+ __ORD_C(uintptr_t, composite_type);
+ return OrdEqual;
+ }
bool operator==(const TypeRef& x) const {
- return !(*this != x);
+ return this->ord(x) == OrdEqual;
}
bool operator!=(const TypeRef& x) const {
- __NE(wrappers);
- __NE(inner_type);
- __NE(composite_type);
- return false;
+ return this->ord(x) != OrdEqual;
}
bool operator<(const TypeRef& x) const {
- __LT(wrappers);
- __LT(inner_type);
- __LT(composite_type);
- return false;
+ return this->ord(x) == OrdLess;
}
friend ::std::ostream& operator<<(::std::ostream& os, const TypeRef& x);
@@ -189,18 +195,19 @@ namespace HIR {
{
::std::string crate_name;
::std::vector<::std::string> ents;
+ Ordering ord(const SimplePath& x) const {
+ __ORD(crate_name);
+ __ORD(ents);
+ return OrdEqual;
+ }
bool operator==(const SimplePath& x) const {
- return !(*this != x);
+ return this->ord(x) == OrdEqual;
}
bool operator!=(const SimplePath& x) const {
- __NE(crate_name);
- __NE(ents);
- return false;
+ return this->ord(x) != OrdEqual;
}
bool operator<(const SimplePath& x) const {
- __LT(crate_name);
- __LT(ents);
- return false;
+ return this->ord(x) == OrdLess;
}
friend ::std::ostream& operator<<(::std::ostream& os, const SimplePath& x);
};
@@ -221,18 +228,19 @@ namespace HIR {
m_simplepath(sp)
{
}
+ Ordering ord(const GenericPath& x) const {
+ __ORD(m_simplepath);
+ __ORD(m_params.tys);
+ return OrdEqual;
+ }
bool operator==(const GenericPath& x) const {
- return !(*this != x);
+ return this->ord(x) == OrdEqual;
}
bool operator!=(const GenericPath& x) const {
- __NE(m_simplepath);
- __NE(m_params.tys);
- return false;
+ return this->ord(x) != OrdEqual;
}
bool operator<(const GenericPath& x) const {
- __LT(m_simplepath);
- __LT(m_params.tys);
- return false;
+ return this->ord(x) == OrdLess;
}
friend ::std::ostream& operator<<(::std::ostream& os, const GenericPath& x);
@@ -263,22 +271,21 @@ namespace HIR {
{
}
+ Ordering ord(const Path& x) const {
+ __ORD(m_type);
+ __ORD(m_trait);
+ __ORD(m_name);
+ __ORD(m_params.tys);
+ return OrdEqual;
+ }
bool operator==(const Path& x) const {
- return !(*this != x);
+ return this->ord(x) == OrdEqual;
}
bool operator!=(const Path& x) const {
- __NE(m_type);
- __NE(m_trait);
- __NE(m_name);
- __NE(m_params.tys);
- return false;
+ return this->ord(x) != OrdEqual;
}
bool operator<(const Path& x) const {
- __LT(m_type);
- __LT(m_trait);
- __LT(m_name);
- __LT(m_params.tys);
- return false;
+ return this->ord(x) == OrdLess;
}
friend ::std::ostream& operator<<(::std::ostream& os, const Path& x);
diff --git a/tools/standalone_miri/mir.cpp b/tools/standalone_miri/mir.cpp
index f1b4841e..4a5df067 100644
--- a/tools/standalone_miri/mir.cpp
+++ b/tools/standalone_miri/mir.cpp
@@ -5,10 +5,12 @@
* mir/mir.cpp
* - MIR (Middle Intermediate Representation) definitions
*/
+#include "../../src/include/rc_string.hpp"
#include "../../src/mir/mir.hpp"
#include "hir_sim.hpp"
#include <iostream>
+#if 0
namespace std {
template <typename T>
inline ::std::ostream& operator<<(::std::ostream& os, const ::std::vector<T>& v) {
@@ -26,6 +28,7 @@ namespace std {
return os;
}
}
+#endif
namespace MIR {
::std::ostream& operator<<(::std::ostream& os, const Constant& v) {
@@ -70,36 +73,87 @@ namespace MIR {
)
return os;
}
- ::std::ostream& operator<<(::std::ostream& os, const LValue& x)
+ void LValue::RefCommon::fmt(::std::ostream& os) const
{
- TU_MATCHA( (x), (e),
+ TU_MATCHA( (m_lv->m_root), (e),
(Return,
- os << "Return";
+ os << "retval";
),
(Argument,
- os << "Argument(" << e.idx << ")";
+ os << "a" << e;
),
(Local,
- os << "Local(" << e << ")";
+ os << "_" << e;
),
(Static,
- os << "Static(" << *e << ")";
- ),
- (Field,
- os << "Field(" << e.field_index << ", " << *e.val << ")";
- ),
- (Deref,
- os << "Deref(" << *e.val << ")";
- ),
- (Index,
- os << "Index(" << *e.val << ", " << *e.idx << ")";
- ),
- (Downcast,
- os << "Downcast(" << e.variant_index << ", " << *e.val << ")";
+ os << "(" << e << ")";
)
)
+ for(size_t i = 0; i < m_wrapper_count; i ++)
+ {
+ const LValue::Wrapper& w = m_lv->m_wrappers.at(i);
+ TU_MATCHA( (w), (e),
+ (Field,
+ os << "." << e;
+ ),
+ (Deref,
+ os << "*";
+ ),
+ (Index,
+ os << "[_" << e << "]";
+ ),
+ (Downcast,
+ os << "#" << e;
+ )
+ )
+ }
+ }
+
+ ::std::ostream& operator<<(::std::ostream& os, const LValue& x)
+ {
+ LValue::CRef(x).fmt(os);
return os;
}
+
+ Ordering LValue::Storage::ord(const LValue::Storage& x) const
+ {
+ if( x.is_Static() )
+ {
+ if( this->is_Static() )
+ return this->as_Static().ord( x.as_Static() );
+ else
+ return OrdLess;
+ }
+ else
+ {
+ if( this->is_Static() )
+ return OrdGreater;
+ }
+
+ return ::ord(this->val, x.val);
+ }
+ Ordering LValue::ord(const LValue& x) const
+ {
+ auto rv = m_root.ord(x.m_root);
+ if( rv != OrdEqual )
+ return rv;
+ return ::ord(m_wrappers, x.m_wrappers);
+ }
+ Ordering LValue::RefCommon::ord(const LValue::RefCommon& x) const
+ {
+ Ordering rv;
+ //TRACE_FUNCTION_FR(FMT_CB(ss, this->fmt(ss); ss << " ? "; x.fmt(ss);), rv);
+ rv = m_lv->m_root.ord(x.m_lv->m_root);
+ if( rv != OrdEqual )
+ return rv;
+ for(size_t i = 0; i < ::std::min(m_wrapper_count, x.m_wrapper_count); i ++)
+ {
+ rv = m_lv->m_wrappers[i].ord(x.m_lv->m_wrappers[i]);
+ if( rv != OrdEqual )
+ return rv;
+ }
+ return (rv = ::ord(m_wrapper_count, x.m_wrapper_count));
+ }
::std::ostream& operator<<(::std::ostream& os, const Param& x)
{
TU_MATCHA( (x), (e),
diff --git a/tools/standalone_miri/miri.cpp b/tools/standalone_miri/miri.cpp
index 4bba4da4..3714ed56 100644
--- a/tools/standalone_miri/miri.cpp
+++ b/tools/standalone_miri/miri.cpp
@@ -254,137 +254,141 @@ struct MirHelpers
{
}
- ValueRef get_value_and_type(const ::MIR::LValue& lv, ::HIR::TypeRef& ty)
+ ValueRef get_value_and_type_root(const ::MIR::LValue::Storage& lv_root, ::HIR::TypeRef& ty)
{
- switch(lv.tag())
+ switch(lv_root.tag())
{
- case ::MIR::LValue::TAGDEAD: throw "";
+ case ::MIR::LValue::Storage::TAGDEAD: throw "";
// --> Slots
- TU_ARM(lv, Return, _e) {
+ TU_ARM(lv_root, Return, _e) {
ty = this->frame.fcn.ret_ty;
return ValueRef(this->frame.ret);
} break;
- TU_ARM(lv, Local, e) {
+ TU_ARM(lv_root, Local, e) {
ty = this->frame.fcn.m_mir.locals.at(e);
return ValueRef(this->frame.locals.at(e));
} break;
- TU_ARM(lv, Argument, e) {
- ty = this->frame.fcn.args.at(e.idx);
- return ValueRef(this->frame.args.at(e.idx));
+ TU_ARM(lv_root, Argument, e) {
+ ty = this->frame.fcn.args.at(e);
+ return ValueRef(this->frame.args.at(e));
} break;
- TU_ARM(lv, Static, e) {
- /*const*/ auto& s = this->thread.m_modtree.get_static(*e);
+ TU_ARM(lv_root, Static, e) {
+ /*const*/ auto& s = this->thread.m_modtree.get_static(e);
ty = s.ty;
return ValueRef(s.val);
} break;
- // --> Modifiers
- TU_ARM(lv, Index, e) {
- auto idx = get_value_ref(*e.idx).read_usize(0);
- ::HIR::TypeRef array_ty;
- auto base_val = get_value_and_type(*e.val, array_ty);
- const auto* wrapper = array_ty.get_wrapper();
- if( !wrapper )
- {
- LOG_ERROR("Indexing non-array/slice - " << array_ty);
- }
- else if( wrapper->type == TypeWrapper::Ty::Array )
- {
- ty = array_ty.get_inner();
- base_val.m_offset += ty.get_size() * idx;
- return base_val;
- }
- else if( wrapper->type == TypeWrapper::Ty::Slice )
- {
- LOG_TODO("Slice index");
- }
- else
- {
- LOG_ERROR("Indexing non-array/slice - " << array_ty);
- throw "ERROR";
- }
- } break;
- TU_ARM(lv, Field, e) {
- ::HIR::TypeRef composite_ty;
- auto base_val = get_value_and_type(*e.val, composite_ty);
- // TODO: if there's metadata present in the base, but the inner doesn't have metadata, clear the metadata
- size_t inner_ofs;
- ty = composite_ty.get_field(e.field_index, inner_ofs);
- LOG_DEBUG("Field - " << composite_ty << "#" << e.field_index << " = @" << inner_ofs << " " << ty);
- base_val.m_offset += inner_ofs;
- if( ty.get_meta_type() == HIR::TypeRef(RawType::Unreachable) )
- {
- LOG_ASSERT(base_val.m_size >= ty.get_size(), "Field didn't fit in the value - " << ty.get_size() << " required, but " << base_val.m_size << " avail");
- base_val.m_size = ty.get_size();
- }
- return base_val;
- }
- TU_ARM(lv, Downcast, e) {
- ::HIR::TypeRef composite_ty;
- auto base_val = get_value_and_type(*e.val, composite_ty);
- LOG_DEBUG("Downcast - " << composite_ty);
-
- size_t inner_ofs;
- ty = composite_ty.get_field(e.variant_index, inner_ofs);
- base_val.m_offset += inner_ofs;
- return base_val;
- }
- TU_ARM(lv, Deref, e) {
- ::HIR::TypeRef ptr_ty;
- auto val = get_value_and_type(*e.val, ptr_ty);
- ty = ptr_ty.get_inner();
- LOG_DEBUG("val = " << val << ", (inner) ty=" << ty);
-
- LOG_ASSERT(val.m_size >= POINTER_SIZE, "Deref of a value that doesn't fit a pointer - " << ty);
- size_t ofs = val.read_usize(0);
-
- // There MUST be a relocation at this point with a valid allocation.
- auto alloc = val.get_relocation(val.m_offset);
- LOG_TRACE("Deref " << alloc << " + " << ofs << " to give value of type " << ty);
- // NOTE: No alloc can happen when dereferencing a zero-sized pointer
- if( alloc.is_alloc() )
- {
- LOG_DEBUG("> " << lv << " alloc=" << alloc.alloc());
- }
- size_t size;
-
- const auto meta_ty = ty.get_meta_type();
- ::std::shared_ptr<Value> meta_val;
- // If the type has metadata, store it.
- if( meta_ty != RawType::Unreachable )
+ }
+ throw "";
+ }
+ ValueRef get_value_and_type(const ::MIR::LValue& lv, ::HIR::TypeRef& ty)
+ {
+ auto vr = get_value_and_type_root(lv.m_root, ty);
+ for(const auto& w : lv.m_wrappers)
+ {
+ switch(w.tag())
{
- auto meta_size = meta_ty.get_size();
- LOG_ASSERT(val.m_size == POINTER_SIZE + meta_size, "Deref of " << ty << ", but pointer isn't correct size");
- meta_val = ::std::make_shared<Value>( val.read_value(POINTER_SIZE, meta_size) );
+ case ::MIR::LValue::Wrapper::TAGDEAD: throw "";
+ // --> Modifiers
+ TU_ARM(w, Index, idx_var) {
+ auto idx = this->frame.locals.at(idx_var).read_usize(0);
+ const auto* wrapper = ty.get_wrapper();
+ if( !wrapper )
+ {
+ LOG_ERROR("Indexing non-array/slice - " << ty);
+ throw "ERROR";
+ }
+ else if( wrapper->type == TypeWrapper::Ty::Array )
+ {
+ ty = ty.get_inner();
+ vr.m_offset += ty.get_size() * idx;
+ }
+ else if( wrapper->type == TypeWrapper::Ty::Slice )
+ {
+ LOG_TODO("Slice index");
+ }
+ else
+ {
+ LOG_ERROR("Indexing non-array/slice - " << ty);
+ throw "ERROR";
+ }
+ } break;
+ TU_ARM(w, Field, fld_idx) {
+ // TODO: if there's metadata present in the base, but the inner doesn't have metadata, clear the metadata
+ size_t inner_ofs;
+ auto inner_ty = ty.get_field(fld_idx, inner_ofs);
+ LOG_DEBUG("Field - " << ty << "#" << fld_idx << " = @" << inner_ofs << " " << inner_ty);
+ vr.m_offset += inner_ofs;
+ if( inner_ty.get_meta_type() == HIR::TypeRef(RawType::Unreachable) )
+ {
+ LOG_ASSERT(vr.m_size >= inner_ty.get_size(), "Field didn't fit in the value - " << inner_ty.get_size() << " required, but " << vr.m_size << " available");
+ vr.m_size = inner_ty.get_size();
+ }
+ ty = ::std::move(inner_ty);
+ }
+ TU_ARM(w, Downcast, variant_index) {
+ auto composite_ty = ::std::move(ty);
+ LOG_DEBUG("Downcast - " << composite_ty);
- size_t slice_inner_size;
- if( ty.has_slice_meta(slice_inner_size) ) {
- size = (ty.get_wrapper() == nullptr ? ty.get_size() : 0) + meta_val->read_usize(0) * slice_inner_size;
+ size_t inner_ofs;
+ ty = composite_ty.get_field(variant_index, inner_ofs);
+ vr.m_offset += inner_ofs;
}
- //else if( ty == RawType::TraitObject) {
- // // NOTE: Getting the size from the allocation is semi-valid, as you can't sub-slice trait objects
- // size = alloc.get_size() - ofs;
- //}
- else {
- LOG_DEBUG("> Meta " << *meta_val << ", size = " << alloc.get_size() << " - " << ofs);
- size = alloc.get_size() - ofs;
+ TU_ARM(w, Deref, _) {
+ auto ptr_ty = ::std::move(ty);
+ ty = ptr_ty.get_inner();
+ LOG_DEBUG("val = " << vr << ", (inner) ty=" << ty);
+
+ LOG_ASSERT(vr.m_size >= POINTER_SIZE, "Deref of a value that doesn't fit a pointer - " << ty);
+ size_t ofs = vr.read_usize(0);
+
+ // There MUST be a relocation at this point with a valid allocation.
+ auto alloc = vr.get_relocation(vr.m_offset);
+ LOG_TRACE("Deref " << alloc << " + " << ofs << " to give value of type " << ty);
+ // NOTE: No alloc can happen when dereferencing a zero-sized pointer
+ if( alloc.is_alloc() )
+ {
+ LOG_DEBUG("> " << lv << " alloc=" << alloc.alloc());
}
- }
- else
- {
- LOG_ASSERT(val.m_size == POINTER_SIZE, "Deref of a value that isn't a pointer-sized value (size=" << val.m_size << ") - " << val << ": " << ptr_ty);
- size = ty.get_size();
- if( !alloc ) {
- LOG_ERROR("Deref of a value with no relocation - " << val);
+ size_t size;
+
+ const auto meta_ty = ty.get_meta_type();
+ ::std::shared_ptr<Value> meta_val;
+ // If the type has metadata, store it.
+ if( meta_ty != RawType::Unreachable )
+ {
+ auto meta_size = meta_ty.get_size();
+ LOG_ASSERT(vr.m_size == POINTER_SIZE + meta_size, "Deref of " << ty << ", but pointer isn't correct size");
+ meta_val = ::std::make_shared<Value>( vr.read_value(POINTER_SIZE, meta_size) );
+
+ size_t slice_inner_size;
+ if( ty.has_slice_meta(slice_inner_size) ) {
+ size = (ty.get_wrapper() == nullptr ? ty.get_size() : 0) + meta_val->read_usize(0) * slice_inner_size;
+ }
+ //else if( ty == RawType::TraitObject) {
+ // // NOTE: Getting the size from the allocation is semi-valid, as you can't sub-slice trait objects
+ // size = alloc.get_size() - ofs;
+ //}
+ else {
+ LOG_DEBUG("> Meta " << *meta_val << ", size = " << alloc.get_size() << " - " << ofs);
+ size = alloc.get_size() - ofs;
+ }
+ }
+ else
+ {
+ LOG_ASSERT(vr.m_size == POINTER_SIZE, "Deref of a value that isn't a pointer-sized value (size=" << vr << ") - " << vr << ": " << ptr_ty);
+ size = ty.get_size();
+ if( !alloc ) {
+ LOG_ERROR("Deref of a value with no relocation - " << vr);
+ }
}
- }
- LOG_DEBUG("alloc=" << alloc << ", ofs=" << ofs << ", size=" << size);
- auto rv = ValueRef(::std::move(alloc), ofs, size);
- rv.m_metadata = ::std::move(meta_val);
- return rv;
- } break;
+ LOG_DEBUG("alloc=" << alloc << ", ofs=" << ofs << ", size=" << size);
+ vr = ValueRef(::std::move(alloc), ofs, size);
+ vr.m_metadata = ::std::move(meta_val);
+ } break;
+ }
}
- throw "";
+ return vr;
}
ValueRef get_value_ref(const ::MIR::LValue& lv)
{
@@ -1907,7 +1911,7 @@ bool InterpreterThread::call_extern(Value& rv, const ::std::string& link_name, c
return true;
}
-bool InterpreterThread::call_intrinsic(Value& rv, const ::std::string& name, const ::HIR::PathParams& ty_params, ::std::vector<Value> args)
+bool InterpreterThread::call_intrinsic(Value& rv, const RcString& name, const ::HIR::PathParams& ty_params, ::std::vector<Value> args)
{
TRACE_FUNCTION_R(name, rv);
for(const auto& a : args)
diff --git a/tools/standalone_miri/miri.hpp b/tools/standalone_miri/miri.hpp
index 6f02ffee..2966e7bf 100644
--- a/tools/standalone_miri/miri.hpp
+++ b/tools/standalone_miri/miri.hpp
@@ -77,7 +77,7 @@ private:
// Returns true if the call was resolved instantly
bool call_extern(Value& ret_val, const ::std::string& name, const ::std::string& abi, ::std::vector<Value> args);
// Returns true if the call was resolved instantly
- bool call_intrinsic(Value& ret_val, const ::std::string& name, const ::HIR::PathParams& pp, ::std::vector<Value> args);
+ bool call_intrinsic(Value& ret_val, const RcString& name, const ::HIR::PathParams& pp, ::std::vector<Value> args);
// Returns true if the call was resolved instantly
bool drop_value(Value ptr, const ::HIR::TypeRef& ty, bool is_shallow=false);
diff --git a/tools/standalone_miri/module_tree.cpp b/tools/standalone_miri/module_tree.cpp
index 984662fe..82bbbf3f 100644
--- a/tools/standalone_miri/module_tree.cpp
+++ b/tools/standalone_miri/module_tree.cpp
@@ -332,9 +332,6 @@ bool Parser::parse_one()
struct H
{
- static ::std::unique_ptr<::MIR::LValue> make_lvp(::MIR::LValue&& lv) {
- return ::std::unique_ptr<::MIR::LValue>(new ::MIR::LValue(::std::move(lv)));
- }
//
// Parse a LValue
//
@@ -357,7 +354,7 @@ bool Parser::parse_one()
if( name.substr(0,3) == "arg" ) {
try {
auto idx = static_cast<unsigned>( ::std::stol(name.substr(3)) );
- lv = ::MIR::LValue::make_Argument({ idx });
+ lv = ::MIR::LValue::new_Argument( idx );
}
catch(const ::std::exception& e) {
LOG_ERROR(lex << "Invalid argument name - " << name << " - " << e.what());
@@ -365,7 +362,7 @@ bool Parser::parse_one()
}
// Hard-coded "RETURN" lvalue
else if( name == "RETURN" ) {
- lv = ::MIR::LValue::make_Return({});
+ lv = ::MIR::LValue::new_Return();
}
// Otherwise, look up variable names
else {
@@ -373,13 +370,13 @@ bool Parser::parse_one()
if( it == var_names.end() ) {
LOG_ERROR(lex << "Cannot find variable named '" << name << "'");
}
- lv = ::MIR::LValue::make_Local(static_cast<unsigned>(it - var_names.begin()));
+ lv = ::MIR::LValue::new_Local(static_cast<unsigned>(it - var_names.begin()));
}
}
else if( lex.next() == "::" || lex.next() == '<' )
{
auto path = p.parse_path();
- lv = ::MIR::LValue( ::std::make_unique<HIR::Path>(::std::move(path)) );
+ lv = ::MIR::LValue::new_Static( ::std::move(path) );
}
else {
LOG_ERROR(lex << "Unexpected token in LValue - " << lex.next());
@@ -390,19 +387,19 @@ bool Parser::parse_one()
{
lex.check(TokenClass::Integer);
auto idx = static_cast<unsigned>( lex.consume().integer() );
- lv = ::MIR::LValue::make_Downcast({ make_lvp(::std::move(lv)), idx });
+ lv = ::MIR::LValue::new_Downcast(::std::move(lv), idx);
}
else if( lex.consume_if('.') )
{
lex.check(TokenClass::Integer);
auto idx = static_cast<unsigned>( lex.consume().integer() );
- lv = ::MIR::LValue::make_Field({ make_lvp(::std::move(lv)), idx });
+ lv = ::MIR::LValue::new_Field( ::std::move(lv), idx );
}
else if( lex.next() == '[' )
{
lex.consume();
auto idx_lv = parse_lvalue(p, var_names);
- lv = ::MIR::LValue::make_Index({ make_lvp(::std::move(lv)), make_lvp(::std::move(idx_lv)) });
+ lv = ::MIR::LValue::new_Index(::std::move(lv), idx_lv.as_Local());
lex.check_consume(']');
}
else
@@ -412,7 +409,7 @@ bool Parser::parse_one()
}
while(deref --)
{
- lv = ::MIR::LValue::make_Deref({ make_lvp(::std::move(lv)) });
+ lv = ::MIR::LValue::new_Deref( ::std::move(lv) );
}
return lv;
}
@@ -936,7 +933,7 @@ bool Parser::parse_one()
lex.check_consume(')');
}
else if( lex.next() == TokenClass::String ) {
- auto name = ::std::move(lex.consume().strval);
+ auto name = RcString::new_interned(lex.consume().strval);
auto params = parse_pathparams();
ct = ::MIR::CallTarget::make_Intrinsic({ ::std::move(name), ::std::move(params) });
}
diff --git a/tools/standalone_miri/module_tree.hpp b/tools/standalone_miri/module_tree.hpp
index efa0a034..653104df 100644
--- a/tools/standalone_miri/module_tree.hpp
+++ b/tools/standalone_miri/module_tree.hpp
@@ -11,6 +11,7 @@
#include <map>
#include <set>
+#include "../../src/include/rc_string.hpp"
#include "../../src/mir/mir.hpp"
#include "hir_sim.hpp"
#include "value.hpp"