/* ************************************************************************
#
#  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.mutator;

import divconq.script.Activity;
import divconq.script.IMutator;
import divconq.script.StackEntry;
import divconq.struct.Struct;
import divconq.struct.scalar.IntegerStruct;
import divconq.xml.XElement;

public class AddMutator implements IMutator {

	@Override
	public void mutate(Activity activity, StackEntry stack, XElement code, Struct dest) {
		Struct source = stack.refFromSource(code, "Value", dest.getType()); 
				
		if (dest instanceof IntegerStruct) {
			IntegerStruct idest = (IntegerStruct)dest;
			
			if (source instanceof IntegerStruct) {
				IntegerStruct isource = (IntegerStruct)source;
				
				idest.setValue(idest.getValue() + isource.getValue());
			}			
		}
		
		// TODO other types
	}
}
