<commit_before>package generator;

import org.objectweb.asm.commons.GeneratorAdapter;
import util.Fst;

/**
 * Created by devict on 21/06/15.
 */
public class FstCompiler {

    private final Fst fst;
    private GeneratorAdapter ga;

    public FstCompiler(Fst fst, GeneratorAdapter ga) {
        this.fst = fst;
        this.ga = ga;
    }

    public void compile() {
        // Switch generation etc. here
    }
}
<commit_msg>FEATURE/MAJOR: First (non working) bytecode version (lack switch)<commit_after>package generator;

import org.objectweb.asm.commons.GeneratorAdapter;
import util.Fst;

/**
 * Created by devict on 21/06/15.
 */
public class FstCompiler {

    private final Fst fst;
    private GeneratorAdapter ga;

    private errorLabel;

    public FstCompiler(Fst fst, GeneratorAdapter ga) {
        this.fst = fst;
        this.ga = ga;
    }

    public void compile() {
        // Switch generation etc. here
        State initState = fst.getStart();

        // pos=0;
        ga.push(0);
        ga.storeLocal(1);
        // result=0f;
        ga.push(0f);
        ga.storeLocal(2);

        generateCases(initState);
    }

    private void generateCases(State currentState) {
        if( currentState.getNumArcs() > 0) {
            // if(pos>=token.length) {return -1;}
            generateTokenLengthTest();

            // switch(token[pos++])
            ga.loadLocal(0);
            ga.loadLocal(1);
            ga.iinc(1,1);
            ga.arrayLoad(Type.INT_TYPE);

            TableSwitchGenerator tsg = new TableSwitchGenerator();
            List<Integer> keys = new ArrayList<>();
            Label switchEnd;

            for (int i = 0; i < currentState.getNumArcs(); i++) {
                // case '<char>' :
                keys.add(currentState.getArc(i).getIlabel());
                if (currentState.getArc(i).getWeight() != 0f) {
                    // result += <weight>;
                    ga.loadLocal(2);
                    ga.push(currentState.getArc(i).getWeight());
                    ga.math(GeneratorAdapter.ADD, Type.FLOAT_TYPE);
                    ga.storeLocal(2);
                }

                generateCases(currentState.getArc(i).getNextState());
            }

            // default : return -1
            tsg.generateDefault();

            switchEnd = ga.mark();
        } else {
            // return (pos!=token.length) ? -1 : result;
            generateTokenLengthTest();
            ga.loadLocal(2);
            ga.returnValue();
        }
    }

    private void generateTokenLengthTest() {
        // if(pos>=token.length) {return -1;}
        ga.loadLocal(1);
        ga.loadLocal(0);
        ga.arrayLength();
        ga.ifICmp(GeneratorAdapter.NE, errorLabel);
    }
}

{'fraction_non_alphanumeric': 0.124, 'fraction_numerical': 0.012363636363636363, 'mean_word_length': 1.770392749244713, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5155433', 'n_tokens_mistral': 836, 'n_tokens_neox': 797, 'n_words': 165}