/* This file is part of Gluon.
 *
 * Gluon is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Gluon is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Gluon.  If not, see <http://www.gnu.org/licenses/>.
 */

package gluon.analysis.programBehavior;

import soot.SootMethod;

public class PBNonTerminal
    extends gluon.grammar.NonTerminal
{
    private SootMethod method;
    private boolean noRemove;
    private boolean atomic;

    public PBNonTerminal(String s, SootMethod m)
    {
        super(s);
        method=m;
        noRemove=false;
        atomic=false;
    }

    public SootMethod getMethod()
    {
        return method;
    }

    public void setNoRemove()
    {
        noRemove=true;
    }

    public void setAtomic()
    {
        atomic=true;
    }

    public boolean isAtomic()
    {
        assert !atomic || noRemove;

        return atomic;
    }

    @Override
    public boolean noRemove()
    {
        assert !atomic || noRemove;

        return noRemove;
    }

    @Override
    public int hashCode()
    {
        return super.name.hashCode();
    }

    @Override
    public boolean equals(Object o)
    {
        PBNonTerminal other;

        if (!(o instanceof PBNonTerminal))
            return false;

        other=(PBNonTerminal)o;

        return other.name.equals(super.name);
    }

    @Override
    public PBNonTerminal clone()
    {
        PBNonTerminal clone=new PBNonTerminal(super.name,method);

        clone.noRemove=noRemove;
        clone.atomic=atomic;

        return clone;
    }
}
