package org.genyris.task;

import org.genyris.core.Bignum;
import org.genyris.core.Constants;
import org.genyris.core.Dictionary;
import org.genyris.core.StrinG;
import org.genyris.exception.GenyrisException;
import org.genyris.interp.ApplicableFunction;
import org.genyris.interp.Environment;
import org.genyris.interp.Interpreter;
import org.genyris.interp.UnboundException;

public abstract class TaskFunction extends ApplicableFunction {

    public TaskFunction(Interpreter interp, String name, boolean eager) {
        super(interp, Constants.PREFIX_TASK+ name, eager);
    }

    protected Dictionary getThreadAsDictionary( Thread tr, Environment env) throws GenyrisException {
    	Dictionary result = new Dictionary(env);
    	result.addProperty(env, "state", new StrinG(tr.getState().toString()));
     	result.addProperty(env, "name", new StrinG(tr.getName()));
     	result.addProperty(env, "id", new Bignum(tr.getId()));
        return result;
       }

    public static void bindFunctionsAndMethods(Interpreter interpreter) throws UnboundException, GenyrisException {
        interpreter.bindGlobalProcedureInstance(new SleepFunction(interpreter));
        interpreter.bindGlobalProcedureInstance(new SpawnFunction(interpreter));
        interpreter.bindGlobalProcedureInstance(new KillTaskFunction(interpreter));
        interpreter.bindGlobalProcedureInstance(new SpawnHTTPDFunction(interpreter));
        interpreter.bindGlobalProcedureInstance(new ListTaskFunction(interpreter));
        interpreter.bindGlobalProcedureInstance(new CurrentTaskFunction(interpreter));               
        interpreter.bindGlobalProcedureInstance(new SynchronizeFunction(interpreter));               
    }


}
@@ -724,16 +724,143 @@
 y(env);%0A
+    %09if(result == null) %7B%0A    %09%09System.out.println(%22Dictionary constructor retuned null !!!!!%22);%0A    %09%09System.exit(-1);%0A    %09%7D%0A
     %09res

Attempt to find why a ctor retuns null