/* ************************************************************************
#
#  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.StringStruct;
import divconq.xml.XElement;

public class AppendMutator 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 StringStruct) {
			StringStruct idest = (StringStruct)dest;
			
			if (source instanceof StringStruct) {
				StringStruct isource = (StringStruct)source;
				
				// TODO may consider a more efficient approach
				idest.setValue(idest.getValue() + isource.getValue());
			}			
		}
		
		// TODO other types
	}
}
