Lines Matching full:shape

1 //===-- lib/Evaluate/shape.cpp --------------------------------------------===//
9 #include "flang/Evaluate/shape.h"
35 details->shape().CanBeImpliedShape();
41 const auto &shape{details->shape()};
42 return shape.Rank() == 0 ||
43 shape.IsExplicitShape(); // true when scalar, too
46 .has<semantics::AssocEntityDetails>(); // exprs have explicit shape
50 Shape GetShapeHelper::ConstantShape(const Constant<ExtentType> &arrayConstant) {
52 Shape result;
69 Shape result;
84 Shape GetShapeHelper::CreateShape(int rank, NamedEntity &base) const {
85 Shape shape;
87 shape.emplace_back(GetExtent(base, dimension, invariantOnly_));
89 return shape;
92 std::optional<ExtentExpr> AsExtentArrayExpr(const Shape &shape) {
94 for (const auto &dim : shape) {
105 FoldingContext &context, const Shape &shape) {
106 if (auto shapeArray{AsExtentArrayExpr(shape)}) {
115 Constant<SubscriptInteger> AsConstantShape(const ConstantSubscripts &shape) {
118 for (auto dim : shape) {
121 return {std::move(result), ConstantSubscripts{GetRank(shape)}};
124 ConstantSubscripts AsConstantExtents(const Constant<ExtentType> &shape) {
126 for (const auto &extent : shape.values()) {
133 FoldingContext &context, const Shape &shape) {
134 if (auto shapeConstant{AsConstantShape(context, shape)}) {
141 Shape AsShape(const ConstantSubscripts &shape) {
142 Shape result;
143 for (const auto &extent : shape) {
149 std::optional<Shape> AsShape(const std::optional<ConstantSubscripts> &shape) {
150 if (shape) {
151 return AsShape(*shape);
157 Shape Fold(FoldingContext &context, Shape &&shape) {
158 for (auto &dim : shape) {
161 return std::move(shape);
164 std::optional<Shape> Fold(
165 FoldingContext &context, std::optional<Shape> &&shape) {
166 if (shape) {
167 return Fold(context, std::move(*shape));
203 MaybeExtentExpr GetSize(Shape &&shape) {
205 for (auto &&dim : std::move(shape)) {
215 ConstantSubscript GetSize(const ConstantSubscripts &shape) {
217 for (auto dim : shape) {
258 int rank{object->shape().Rank()};
260 const semantics::ShapeSpec &shapeSpec{object->shape()[dimension_]};
416 Shape GetRawLowerBounds(const NamedEntity &base, bool invariantOnly) {
417 Shape result;
425 Shape GetRawLowerBounds(
427 Shape result;
435 Shape GetLBOUNDs(const NamedEntity &base, bool invariantOnly) {
436 Shape result;
444 Shape GetLBOUNDs(
446 Shape result;
491 if (auto shape{GetShape(GetFoldingContextFrom(symbol), assoc->expr())};
492 shape && dimension < static_cast<int>(shape->size())) {
493 if (auto &extent{shape->at(dimension)};
495 // determine the shape of the selector's expression may change
527 if (auto shape{
529 if (dimension < static_cast<int>(shape->size())) {
530 return std::move(shape->at(dimension));
535 for (const auto &shapeSpec : details->shape()) {
577 if (auto shape{GetShape(
579 shape && GetRank(*shape) == 1) {
581 return std::move(shape->at(0));
617 int rank{details->shape().Rank()};
619 const auto &bound{details->shape()[dimension].ubound().GetExplicit()};
673 int rank{details->shape().Rank()};
675 const semantics::ShapeSpec &shapeSpec{details->shape()[dimension]};
718 static Shape GetUBOUNDs(
720 Shape result;
728 Shape GetUBOUNDs(
733 Shape GetUBOUNDs(const NamedEntity &base, bool invariantOnly) {
773 Shape GetLCOBOUNDs(const Symbol &symbol, bool invariantOnly) {
774 Shape result;
782 Shape GetUCOBOUNDs(const Symbol &symbol, bool invariantOnly) {
783 Shape result;
800 int n{object.shape().Rank()};
838 // Ensure the shape is constant. Otherwise, it may be reerring
876 Shape shape;
881 shape.emplace_back(GetExtent(ss, base, dimension));
885 if (shape.empty()) {
890 return shape;
898 Shape shape;
902 shape.emplace_back(GetExtent(ss, base, dimension));
906 return shape;
918 // Use the shape of an actual array argument associated with a
945 // We cannot take the shape from just any array argument,
947 // of the caller. Return unknown shape ranked according
949 return Shape(anyArrayArgRank, MaybeExtentExpr{});
959 if (intrinsic->name == "shape" || intrinsic->name == "lbound" ||
964 return Shape{MaybeExtentExpr{}};
966 return Shape{
1007 return Shape{ExtentExpr{rank}};
1017 return Shape(1, ExtentExpr{GetCorank(call.arguments().at(0))});
1038 // SHAPE(PACK(,,VECTOR=v)) -> SHAPE(v)
1053 return Shape{ExtentExpr{FunctionRef<ExtentType>{
1070 return Shape{ExtentExpr{FunctionRef<ExtentType>{
1078 // SHAPE(RESHAPE(array,shape)) -> shape
1089 // SHAPE(SPREAD(ARRAY,DIM,NCOPIES)) = SHAPE(ARRAY) with NCOPIES inserted
1110 // SIZE= is present; shape is vector [SIZE=]
1113 return Shape{
1136 return Shape{ExtentExpr{0}};
1150 return Shape{MaybeExtentExpr{std::move(extent)}};
1161 return Shape(1, ExtentExpr{GetCorank(call.arguments().at(0))});
1165 if (auto shape{(*this)(call.arguments().at(0))}) {
1166 if (shape->size() == 2) {
1167 std::swap((*shape)[0], (*shape)[1]);
1168 return shape;
1184 return Shape(static_cast<std::size_t>(call.Rank()), MaybeExtentExpr{});
1199 const Shape &left, const Shape &right, CheckConformanceFlags::Flags flags,