package org.spoofax.interpreter.library.ssl;

import java.util.HashSet;
import java.util.List;

import org.spoofax.interpreter.IContext;
import org.spoofax.interpreter.InterpreterException;
import org.spoofax.interpreter.Tools;
import org.spoofax.interpreter.library.AbstractPrimitive;
import org.spoofax.interpreter.stratego.Strategy;
import org.spoofax.interpreter.terms.IStrategoTerm;

public class SSL_newname extends AbstractPrimitive {
	private HashSet<String> set;
	
	SSL_newname () {
		super("SSL_newname", 0, 1);
		set = new HashSet<String>();
	}
	
	@Override
	public boolean call(IContext env, List<Strategy> svars,
			IStrategoTerm[] tvars) throws InterpreterException {
        if(!Tools.isTermString(tvars[0]))
            return false;
        
        String var = tvars[0].toString();
        
        int n = 0;
        
        String s;
        do {
        	s = var + n++;
        } while (set.contains(s));

        env.setCurrent(env.getFactory().makeString(s));
        
		return true;
	}

}

@@ -69,31 +69,51 @@
 et;%0A
+%0A
 import 
-java.util.List;%0A
+org.spoofax.interpreter.IConstruct;
 %0Aimp
@@ -303,58 +303,8 @@
 ve;%0A
-import org.spoofax.interpreter.stratego.Strategy;%0A
 impo
@@ -571,22 +571,20 @@
 nv, 
-List%3CStrategy%3E
+IConstruct%5B%5D
  sva

Throw away lists.