/* ************************************************************************
#
#  DivConq
#
#  http://divconq.com/
#
#  Copyright:
#    Copyright 2012 eTimeline, LLC. All rights reserved.
#
#  License:
#    See the license.txt file in the project's top-level directory for details.
#
#  Authors:
#    * Andy White
#
************************************************************************ */
package divconq.script;

import divconq.lang.OperationResult;
import divconq.struct.RecordStruct;
import divconq.xml.XElement;

abstract public class Instruction {
	protected XElement source = null;

    public XElement getXml() {
        return this.source; 
    }
    
    public void setXml(XElement v) { 
    	this.source = v; 
    }

    public void compile(ActivityManager manager, OperationResult log) {
    	
    }
    
    abstract public void run(final StackEntry stack, final IInstructionCallback cb);
	
	public void collectDebugRecord(final StackEntry stack, RecordStruct rec) {		
		rec.setField("Line", this.source.getLine());
		rec.setField("Column", this.source.getCol());		
	   	rec.setField("Command", this.source.toString(true));
	}

	public StackEntry createStack(Activity act, StackEntry parent) {
		return new StackEntry(act, parent, this);
	}	
}
