package Reldb.RelUserCode;

import org.reldb.rel.v0.types.*;
import org.reldb.rel.v0.types.builtin.*;
import org.reldb.rel.v0.types.userdefined.*;
import org.reldb.rel.v0.values.*;
import org.reldb.rel.v0.vm.Context;

public class op_REPLACE_ALL__CHARACTER_CHARACTER_CHARACTER {
	private static final ValueCharacter do_REPLACE_ALL(Context context, ValueCharacter s, ValueCharacter regex, ValueCharacter replacement) {
		
		//          Replaces each substring of this string that matches the given regular expression with the given replacement.
			return ValueCharacter.select(context.getGenerator(), s.stringValue().replaceAll(regex.stringValue(), replacement.stringValue()));
	}

	public static final void execute(Context context) {
		ValueCharacter p2 = (ValueCharacter)context.pop();
		ValueCharacter p1 = (ValueCharacter)context.pop();
		ValueCharacter p0 = (ValueCharacter)context.pop();
		context.push(do_REPLACE_ALL(context, p0, p1, p2));
	}
}