Skip to content

Commit 9417792

Browse files
committed
finally, remove compile time bool implementation from visit_Call
1 parent 3b2499e commit 9417792

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,39 +2294,6 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
22942294
throw SemanticError(call_name + "() must have one integer argument",
22952295
x.base.base.loc);
22962296
}
2297-
} else if (call_name == "bool") {
2298-
if (args.size() != 1) {
2299-
throw SemanticError(call_name + "() takes exactly one argument (" +
2300-
std::to_string(args.size()) + " given)", x.base.base.loc);
2301-
}
2302-
ASR::ttype_t *type = ASRUtils::TYPE(ASR::make_Logical_t(al, x.base.base.loc,
2303-
1, nullptr, 0));
2304-
ASR::expr_t* arg = ASRUtils::expr_value(args[0]);
2305-
ASR::ttype_t* t = ASRUtils::expr_type(arg);
2306-
bool result;
2307-
if (ASRUtils::is_real(*t)) {
2308-
double rv = ASR::down_cast<ASR::ConstantReal_t>(arg)->m_r;
2309-
result = rv ? true : false;
2310-
} else if (ASRUtils::is_integer(*t)) {
2311-
int64_t rv = ASR::down_cast<ASR::ConstantInteger_t>(arg)->m_n;
2312-
result = rv ? true : false;
2313-
} else if (ASRUtils::is_complex(*t)) {
2314-
double re = ASR::down_cast<ASR::ConstantComplex_t>(arg)->m_re;
2315-
double im = ASR::down_cast<ASR::ConstantComplex_t>(arg)->m_im;
2316-
std::complex<double> c(re, im);
2317-
result = (re || im) ? true : false;
2318-
} else if (ASRUtils::is_logical(*t)) {
2319-
bool rv = ASR::down_cast<ASR::ConstantLogical_t>(arg)->m_value;
2320-
result = rv;
2321-
} else if (ASRUtils::is_character(*t)) {
2322-
char* c = ASR::down_cast<ASR::ConstantString_t>(ASRUtils::expr_value(arg))->m_s;
2323-
result = strlen(s2c(al, std::string(c))) ? true : false;
2324-
} else {
2325-
throw SemanticError(call_name + "() must have one real, integer, character,"
2326-
" complex, or logical argument", x.base.base.loc);
2327-
}
2328-
tmp = ASR::make_ConstantLogical_t(al, x.base.base.loc, result, type);
2329-
return;
23302297
} else if (call_name == "callable") {
23312298
if (args.size() != 1) {
23322299
throw SemanticError(call_name + "() takes exactly one argument (" +

0 commit comments

Comments
 (0)