0022904: Clean up sccsid variables
[occt.git] / src / Expr / Expr_UnaryExpression.cxx
CommitLineData
7fd59977 1// Copyright: Matra-Datavision 1991
2// File: Expr_UnaryExpression.cxx
3// Created: Mon Apr 15 14:24:44 1991
4// Author: Arnaud BOUZY
5// <adn>
6
7#include <Expr_UnaryExpression.ixx>
8#include <Expr_NamedUnknown.hxx>
9#include <Expr_InvalidOperand.hxx>
10#include <Standard_OutOfRange.hxx>
11
12void Expr_UnaryExpression::SetOperand (const Handle(Expr_GeneralExpression)& exp)
13{
14 Handle(Expr_UnaryExpression) me = this;
15 if (exp == me) {
16 Expr_InvalidOperand::Raise();
17 }
18 if (exp->Contains(me)) {
19 Expr_InvalidOperand::Raise();
20 }
21 myOperand = exp;
22}
23
24void Expr_UnaryExpression::CreateOperand (const Handle(Expr_GeneralExpression)& exp)
25{
26 myOperand = exp;
27}
28
29Standard_Integer Expr_UnaryExpression::NbSubExpressions () const
30{
31 return 1;
32}
33
34const Handle(Expr_GeneralExpression)& Expr_UnaryExpression::SubExpression (const Standard_Integer I) const
35{
36 if (I != 1) {
37 Standard_OutOfRange::Raise();
38 }
39 return myOperand;
40}
41
42Standard_Boolean Expr_UnaryExpression::ContainsUnknowns () const
43{
44 if (!myOperand->IsKind(STANDARD_TYPE(Expr_NamedUnknown))) {
45 return myOperand->ContainsUnknowns();
46 }
47 return Standard_True;
48}
49
50Standard_Boolean Expr_UnaryExpression::Contains (const Handle(Expr_GeneralExpression)& exp) const
51{
52 if (myOperand != exp) {
53 return myOperand->Contains(exp);
54 }
55 return Standard_True;
56}
57
58void Expr_UnaryExpression::Replace (const Handle(Expr_NamedUnknown)& var, const Handle(Expr_GeneralExpression)& with)
59{
60 if (myOperand == var) {
61 SetOperand(with);
62 }
63 else {
64 if (myOperand->Contains(var)) {
65 myOperand->Replace(var,with);
66 }
67 }
68}
69
70
71Handle(Expr_GeneralExpression) Expr_UnaryExpression::Simplified() const
72{
73 Handle(Expr_UnaryExpression) cop = Handle(Expr_UnaryExpression)::DownCast(Copy());
74 Handle(Expr_GeneralExpression) op = cop->Operand();
75 cop->SetOperand(op->Simplified());
76 return cop->ShallowSimplified();
77}
78