// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) space 
// Source File Name:   PlusNode.java

package lt.monarch.function.node;

import java.util.Vector;
import lt.monarch.function.*;

// Referenced classes of package lt.monarch.function.node:
//            SumNode, OperatorNode, ConstantNode

public class PlusNode extends SumNode
{

    public Node cloneNode()
    {
        return (Node)new PlusNode(super.l.cloneNode(), super.r.cloneNode());
    }

    public String toString()
    {
        return super.l + "+" + super.r;
    }

    public double evaluate()
    {
        return super.l.evaluate() + super.r.evaluate();
    }

    public Node simplifyOperation()
    {
        if ((super.l instanceof ConstantNode) && super.l.evaluate() == 0.0D)
            return super.r;
        if ((super.r instanceof ConstantNode) && super.r.evaluate() == 0.0D)
            return super.l;
        else
            return super.simplifyOperation();
    }

    protected void enumerateOperands(Vector vector)
    {
        if (!(super.l instanceof SumNode))
            super.l = super.l.simplify();
        if (!(super.r instanceof SumNode))
            super.r = super.r.simplify();
        if (super.l instanceof SumNode)
            ((SumNode)super.l).enumerateOperands(vector);
        else
            vector.addElement(super.l);
        if (super.r instanceof SumNode)
            ((SumNode)super.r).enumerateOperands(vector);
        else
            vector.addElement(super.r);
    }

    public Node derivative(Variable variable)
    {
        return (Node)new PlusNode(super.l.derivative(variable), super.r.derivative(variable));
    }

    public void compile(NodeCompiler nodecompiler)
    {
        super.l.compile(nodecompiler);
        super.r.compile(nodecompiler);
        nodecompiler.append(99);
        nodecompiler.freeStack(2);
    }

    public PlusNode(Node node, Node node1)
    {
        super(node, node1);
    }
}
