/*
* KernelProlog Expanded - Pure Java based Prolog Engine
* Copyright (C) 1999 Paul Tarau (original KernelProlog)
* Copyright (C) 2009 Michiel Hendriks
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.kpex.builtins;
import net.sf.kpex.prolog.Const;
import net.sf.kpex.prolog.FunBuiltin;
import net.sf.kpex.prolog.Prog;
import net.sf.kpex.prolog.Source;
import net.sf.kpex.prolog.Term;
/**
* generic Source advancement step, similar to an iterator's nextElement
* operation, gets one element from the Source
*/
public class Get extends FunBuiltin
{
public Get()
{
super("get", 2);
}
@Override
public int exec(Prog p)
{
// IO.mes("<<"+getArg(0)+"\n"+p+p.getTrail().pprint());
Source S = (Source) getArg(0);
Term A = Const.the(S.getElement());
// if(null==A) A=Const.NO;
// else A=new Fun("the",A);
// IO.mes(">>"+A+"\n"+p+p.getTrail().pprint());
return putArg(1, A, p);
}
}