21
21
22
22
#include " optional.h"
23
23
#include " rust-ast.h"
24
+ #include " rust-expr.h"
24
25
#include " rust-path.h"
25
26
26
27
namespace Rust {
@@ -678,27 +679,26 @@ class ReferenceType : public TypeNoBounds
678
679
class ArrayType : public TypeNoBounds
679
680
{
680
681
std::unique_ptr<Type> elem_type;
681
- std::unique_ptr<Expr> size;
682
+ AnonConst size;
682
683
location_t locus;
683
684
684
685
public:
685
686
// Constructor requires pointers for polymorphism
686
- ArrayType (std::unique_ptr<Type> type, std::unique_ptr<Expr> array_size,
687
- location_t locus)
687
+ ArrayType (std::unique_ptr<Type> type, AnonConst array_size, location_t locus)
688
688
: elem_type (std::move (type)), size (std::move (array_size)), locus (locus)
689
689
{}
690
690
691
691
// Copy constructor requires deep copies of both unique pointers
692
692
ArrayType (ArrayType const &other)
693
- : elem_type (other.elem_type->clone_type ()),
694
- size (other.size-> clone_expr ()), locus (other.locus)
693
+ : elem_type (other.elem_type->clone_type ()), size (other.size),
694
+ locus (other.locus)
695
695
{}
696
696
697
697
// Overload assignment operator to deep copy pointers
698
698
ArrayType &operator = (ArrayType const &other)
699
699
{
700
700
elem_type = other.elem_type ->clone_type ();
701
- size = other.size -> clone_expr () ;
701
+ size = other.size ;
702
702
locus = other.locus ;
703
703
return *this ;
704
704
}
@@ -721,17 +721,15 @@ class ArrayType : public TypeNoBounds
721
721
}
722
722
723
723
// TODO: would a "vis_expr" be better?
724
- Expr &get_size_expr ()
724
+ AnonConst &get_size_expr ()
725
725
{
726
- rust_assert (size != nullptr );
727
- return *size;
726
+ // rust_assert (size != nullptr);
727
+
728
+ return size;
728
729
}
729
730
730
731
std::unique_ptr<Type> &get_element_type () { return elem_type; }
731
732
732
- // Additional getter for direct access to the size expr unique_ptr
733
- std::unique_ptr<Expr> &get_size_ptr () { return size; }
734
-
735
733
protected:
736
734
/* Use covariance to implement clone function as returning this object rather
737
735
* than base */
@@ -741,10 +739,9 @@ class ArrayType : public TypeNoBounds
741
739
}
742
740
ArrayType *reconstruct_impl () const override
743
741
{
744
- return new ArrayType (
745
- elem_type->reconstruct (),
746
- size->clone_expr () /* FIXME: This should be `reconstruct_expr()` */ ,
747
- locus);
742
+ return new ArrayType (elem_type->reconstruct (),
743
+ size /* FIXME: This should be `reconstruct_expr()` */ ,
744
+ locus);
748
745
}
749
746
};
750
747
0 commit comments