-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dftatom: Changes from lfortran LibASR #2334
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -560,7 +560,25 @@ namespace LCompilers { | |
|
||
ASR::expr_t* get_bound(ASR::expr_t* arr_expr, int dim, std::string bound, | ||
Allocator& al) { | ||
ASR::ttype_t* x_mv_type = ASRUtils::expr_type(arr_expr); | ||
ASR::dimension_t* m_dims; | ||
int n_dims = ASRUtils::extract_dimensions_from_ttype(x_mv_type, m_dims); | ||
bool is_data_only_array = ASRUtils::is_fixed_size_array(m_dims, n_dims) && ASRUtils::get_asr_owner(arr_expr) && | ||
ASR::is_a<ASR::StructType_t>(*ASRUtils::get_asr_owner(arr_expr)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does "data only array" in this context mean "FixedSizeArray" inside a struct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I would maybe document this in a comment, or maybe name the variable |
||
ASR::ttype_t* int32_type = ASRUtils::TYPE(ASR::make_Integer_t(al, arr_expr->base.loc, 4)); | ||
if (is_data_only_array) { | ||
const Location& loc = arr_expr->base.loc; | ||
ASR::expr_t* zero = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, 0, int32_type)); | ||
ASR::expr_t* one = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, 1, int32_type)); | ||
if( bound == "ubound" ) { | ||
return ASRUtils::EXPR(ASR::make_IntegerBinOp_t( | ||
al, arr_expr->base.loc, m_dims[dim - 1].m_length, ASR::binopType::Sub, one, int32_type, nullptr)); | ||
} | ||
if ( m_dims[dim - 1].m_start != nullptr ) { | ||
return m_dims[dim - 1].m_start; | ||
} | ||
return zero; | ||
} | ||
ASR::expr_t* dim_expr = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, arr_expr->base.loc, dim, int32_type)); | ||
ASR::arrayboundType bound_type = ASR::arrayboundType::LBound; | ||
if( bound == "ubound" ) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this changes the API, now it will return
nullptr
if the node does not have an ASR owner.