File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -235,7 +235,7 @@ RUN(NAME bindc_03 LABELS llvm
235
235
EXTRAFILES bindc_03b.c )
236
236
RUN (NAME test_generics_01 LABELS cpython llvm )
237
237
RUN (NAME test_cmath LABELS cpython llvm )
238
- RUN (NAME test_complex LABELS cpython llvm )
238
+ RUN (NAME test_complex LABELS cpython llvm c )
239
239
RUN (NAME test_max_min LABELS cpython llvm )
240
240
RUN (NAME test_global LABELS cpython llvm )
241
241
RUN (NAME test_integer_bitnot LABELS cpython llvm )
Original file line number Diff line number Diff line change 590
590
591
591
void visit_ComplexConstant (const ASR::ComplexConstant_t &x) {
592
592
headers.insert (" complex" );
593
-
594
- ASR::Complex_t *t = ASR::down_cast<ASR::Complex_t>(x.m_type );
595
-
596
593
std::string re = std::to_string (x.m_re );
597
594
std::string im = std::to_string (x.m_im );
598
-
599
- std::string type_name = " float complex" ;
600
- if (t->m_kind == 8 ) type_name = " double complex" ;
601
-
602
- src = " (" + type_name + " ) (" + re + " , " + im + " )" ;
595
+ src = " CMPLX(" + re + " , " + im + " )" ;
603
596
604
597
last_expr_precedence = 2 ;
605
598
}
Original file line number Diff line number Diff line change @@ -748,6 +748,10 @@ R"(#include <stdio.h>
748
748
handle_UnaryMinus (x);
749
749
}
750
750
751
+ void visit_ComplexUnaryMinus (const ASR::ComplexUnaryMinus_t &x) {
752
+ handle_UnaryMinus (x);
753
+ }
754
+
751
755
template <typename T>
752
756
void handle_UnaryMinus (const T &x) {
753
757
self ().visit_expr (*x.m_arg );
@@ -760,6 +764,26 @@ R"(#include <stdio.h>
760
764
}
761
765
}
762
766
767
+ void visit_ComplexRe (const ASR::ComplexRe_t &x) {
768
+ headers.insert (" complex" );
769
+ self ().visit_expr (*x.m_arg );
770
+ if (is_c) {
771
+ src = " creal(" + src + " )" ;
772
+ } else {
773
+ src = src + " .real()" ;
774
+ }
775
+ }
776
+
777
+ void visit_ComplexIm (const ASR::ComplexIm_t &x) {
778
+ headers.insert (" complex" );
779
+ self ().visit_expr (*x.m_arg );
780
+ if (is_c) {
781
+ src = " cimag(" + src + " )" ;
782
+ } else {
783
+ src = src + " .imag()" ;
784
+ }
785
+ }
786
+
763
787
void visit_LogicalNot (const ASR::LogicalNot_t &x) {
764
788
self ().visit_expr (*x.m_arg );
765
789
int expr_precedence = last_expr_precedence;
You can’t perform that action at this time.
0 commit comments