package hu.swankey.ammo.common.methods;

import java.util.Map;

import hu.swankey.ammo.common.progstruct2.Method;
import hu.swankey.ammo.common.yggdrasil.basics.YObject;
import hu.swankey.ammo.common.yggdrasil.basics.IntegerField;

public class MAdd extends Method {

    public static final String FUNCTION_NAME = "+";
    public static final MAdd function = new MAdd();

    private MAdd() {
        super(FUNCTION_NAME);
    }



    @Override
    public YObject run(Map<String, YObject> params, Map<String, YObject> envrionment, YObject thisElement) {

    	//System.out.println("MAdd parameters: " + parameters);
    	
    	//Map<String, Element> computed = computeParams(location, parameters, envrionment);

        Integer result = 0;
        for(String key: params.keySet()){
            IntegerField num = (IntegerField)params.get(key);
            result += (Integer)num.getValue();
        }

        return new IntegerField("FAdd Result", result);
    }



    public static MAdd function() {
        return function;
    }



}
