public Method evaluatorCode(NameEmbedding em, Map<String, String> natTypeMap) {
        String param = name + "_param";
        Statement e = new Return(new Conversion(rType, new VariableExpression(param))); // by default return the AST node
        for (Entry<String, IExpression> entry : transExprMap.entrySet()) {
            String[] vars = transVarMap.get(entry.getKey());
            Statement[] stmts = new Statement[vars.length + 1];
            for (int j = 0; j < vars.length; j++) {
                if(em.getnat(vars[j])) { // this needs to change to map vars[j] to the correponding nt
                    String type = natTypeMap.get(vars[j]);
                    if(type == null) type = "Object"; // if type not defined then use Object as the default type
                    stmts[j] = new Assignment("final " + type + " " + vars[j], new VariableExpression("("+type+")NAT(((erilex.data.generic.Tree)" + param + ").subtrees[" + (j) + "])"));

                } else {
                    stmts[j] = new Assignment("final Object " + vars[j], new VariableExpression("((erilex.data.generic.Tree)" + param + ").subtrees[" + (j) + "]"));
                }
            }
            stmts[stmts.length - 1] = (Statement) entry.getValue();
            final Block block = new Block(stmts);
            final String enc = entry.getKey();
            String[] dec = SemanticsCollection.decode(enc);
            String refName = dec[0];
            String t = dec.length==1? null:dec[1];
            final IExpression cond = t == null?
                new Invocation(new VariableExpression("((erilex.tree.ASTValueData)((erilex.data.generic.Tree)" + param + ").val).name"), "equals", new VariableExpression("\"" + refName + "\"")):
                new And(new Invocation(new VariableExpression("((erilex.tree.ASTValueData)((erilex.data.generic.Tree)" + param + ").subtrees[0].val).name"), "equals", new VariableExpression("\"" + t + "\"")), new Invocation(new VariableExpression("((erilex.tree.ASTValueData)((erilex.data.generic.Tree)" + param + ").val).name"), "equals", new VariableExpression("\"" + refName + "\"")));

            e = new IfStatement(cond, block, e);
        }
        Method m = new Method(rType, name);
        m.params.add(new Variable(new Type("Object"), param));
        if(state!=null && state.length>0 && state[0].name!=null)
        m.params.addAll(Arrays.asList(state));
        m.mBody.add(e);
        return m;
    }