From: Richard Kreckel Date: Sat, 18 Aug 2001 21:46:14 +0000 (+0000) Subject: - carried on with felonious plot about making ex::bp private. X-Git-Tag: release_0-9-4~15 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=28e5e38935cc32a4e5f8995645f92f12fedcdaf5 - carried on with felonious plot about making ex::bp private. --- diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 8baa3536..1aff2e16 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -196,9 +196,9 @@ ex & basic::let_op(int i) ex basic::operator[](const ex & index) const { - if (is_exactly_of_type(*index.bp,numeric)) - return op(static_cast(*index.bp).to_int()); - + if (is_ex_exactly_of_type(index,numeric)) + return op(ex_to(index).to_int()); + throw(std::invalid_argument("non-numeric indices not supported by this type")); } diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 0303b6d7..bdd8903c 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -537,9 +537,9 @@ bool numeric::info(unsigned inf) const * sign as a multiplicative factor. */ bool numeric::has(const ex &other) const { - if (!is_exactly_of_type(*other.bp, numeric)) + if (!is_ex_exactly_of_type(other, numeric)) return false; - const numeric &o = static_cast(*other.bp); + const numeric &o = ex_to(other); if (this->is_equal(o) || this->is_equal(-o)) return true; if (o.imag().is_zero()) // e.g. scan for 3 in -3*I diff --git a/ginac/operators.cpp b/ginac/operators.cpp index 00c33a73..31c4cf03 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -223,7 +223,7 @@ const ex operator++(ex & lh, int) return tmp; } -/** Expression Postfix decrement. Returns the ex and leaves the original +/** Expression postfix decrement. Returns the ex and leaves the original * decremented by 1. */ const ex operator--(ex & lh, int) { @@ -259,7 +259,7 @@ const numeric operator++(numeric & lh, int) return tmp; } -/** Numeric Postfix decrement. Returns the number and leaves the original +/** Numeric postfix decrement. Returns the number and leaves the original * decremented by 1. */ const numeric operator--(numeric & lh, int) { diff --git a/ginac/power.cpp b/ginac/power.cpp index c1568145..c3f348da 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -240,7 +240,7 @@ ex power::map(map_function & f) const int power::degree(const ex & s) const { - if (is_exactly_of_type(*exponent.bp, numeric) && ex_to(exponent).is_integer()) { + if (is_ex_exactly_of_type(exponent, numeric) && ex_to(exponent).is_integer()) { if (basis.is_equal(s)) return ex_to(exponent).to_int(); else @@ -251,7 +251,7 @@ int power::degree(const ex & s) const int power::ldegree(const ex & s) const { - if (is_exactly_of_type(*exponent.bp, numeric) && ex_to(exponent).is_integer()) { + if (is_ex_exactly_of_type(exponent, numeric) && ex_to(exponent).is_integer()) { if (basis.is_equal(s)) return ex_to(exponent).to_int(); else @@ -270,7 +270,7 @@ ex power::coeff(const ex & s, int n) const return _ex0(); } else { // basis equal to s - if (is_exactly_of_type(*exponent.bp, numeric) && ex_to(exponent).is_integer()) { + if (is_ex_exactly_of_type(exponent, numeric) && ex_to(exponent).is_integer()) { // integer exponent int int_exp = ex_to(exponent).to_int(); if (n == int_exp) @@ -318,13 +318,13 @@ ex power::eval(int level) const const numeric *num_basis; const numeric *num_exponent; - if (is_exactly_of_type(*ebasis.bp,numeric)) { + if (is_ex_exactly_of_type(ebasis, numeric)) { basis_is_numerical = true; - num_basis = static_cast(ebasis.bp); + num_basis = &ex_to(ebasis); } - if (is_exactly_of_type(*eexponent.bp,numeric)) { + if (is_ex_exactly_of_type(eexponent, numeric)) { exponent_is_numerical = true; - num_exponent = static_cast(eexponent.bp); + num_exponent = &ex_to(eexponent); } // ^(x,0) -> 1 (0^0 also handled here) diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index 7ae30a9c..441ee408 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -489,7 +489,7 @@ bool pseries::is_terminating(void) const ex basic::series(const relational & r, int order, unsigned options) const { epvector seq; - numeric fac(1); + numeric fac = 1; ex deriv = *this; ex coeff = deriv.subs(r); const symbol &s = ex_to(r.lhs()); diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index f5fd4a09..322a45c4 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -182,17 +182,17 @@ bool symbol::info(unsigned inf) const int symbol::degree(const ex & s) const { - return is_equal(*s.bp) ? 1 : 0; + return is_equal(ex_to(s)) ? 1 : 0; } int symbol::ldegree(const ex & s) const { - return is_equal(*s.bp) ? 1 : 0; + return is_equal(ex_to(s)) ? 1 : 0; } ex symbol::coeff(const ex & s, int n) const { - if (is_equal(*s.bp)) + if (is_equal(ex_to(s))) return n==1 ? _ex1() : _ex0(); else return n==0 ? *this : _ex0(); diff --git a/ginac/wildcard.cpp b/ginac/wildcard.cpp index 5d88146f..c6dca58c 100644 --- a/ginac/wildcard.cpp +++ b/ginac/wildcard.cpp @@ -118,7 +118,7 @@ bool wildcard::match(const ex & pattern, lst & repl_lst) const // Wildcards must match each other exactly (this is required for // subs() to work properly because in the final step it substitutes // all wildcards by their matching expressions) - return is_equal(*pattern.bp); + return is_equal(ex_to(pattern)); } } // namespace GiNaC diff --git a/ginsh/ginsh_parser.yy b/ginsh/ginsh_parser.yy index 6020efbc..50d2a23b 100644 --- a/ginsh/ginsh_parser.yy +++ b/ginsh/ginsh_parser.yy @@ -203,9 +203,9 @@ exp : T_NUMBER {$$ = $1;} | T_SYMBOL '(' exprseq ')' { fcn_tab::const_iterator i = find_function($1, $3.nops()); if (i->second.is_ginac) { - $$ = ((fcnp2)(i->second.p))(static_cast(*($3.bp)), i->second.serial); + $$ = ((fcnp2)(i->second.p))(ex_to($3), i->second.serial); } else { - $$ = (i->second.p)(static_cast(*($3.bp))); + $$ = (i->second.p)(ex_to($3)); } } | T_DIGITS '=' T_NUMBER {$$ = $3; Digits = ex_to($3).to_int();} @@ -230,7 +230,7 @@ exp : T_NUMBER {$$ = $1;} ; exprseq : exp {$$ = exprseq($1);} - | exprseq ',' exp {exprseq es(static_cast(*($1.bp))); $$ = es.append($3);} + | exprseq ',' exp {exprseq es(ex_to($1)); $$ = es.append($3);} ; list_or_empty: /* empty */ {$$ = *new lst;} @@ -238,15 +238,15 @@ list_or_empty: /* empty */ {$$ = *new lst;} ; list : exp {$$ = lst($1);} - | list ',' exp {lst l(static_cast(*($1.bp))); $$ = l.append($3);} + | list ',' exp {lst l(ex_to($1)); $$ = l.append($3);} ; matrix : '[' row ']' {$$ = lst($2);} - | matrix ',' '[' row ']' {lst l(static_cast(*($1.bp))); $$ = l.append($4);} + | matrix ',' '[' row ']' {lst l(ex_to($1)); $$ = l.append($4);} ; row : exp {$$ = lst($1);} - | row ',' exp {lst l(static_cast(*($1.bp))); $$ = l.append($3);} + | row ',' exp {lst l(ex_to($1)); $$ = l.append($3);} ;