<commit_before>package com.marasm.codegen.marasm;

/**
 * Created by sr3u on 31.08.15.
 */

import com.grahamedgecombe.tinybasic.codegen.CodeGenerator;
import com.grahamedgecombe.tinybasic.stackir.Instruction;
import com.grahamedgecombe.tinybasic.stackir.InstructionSequence;

import java.io.IOException;
import java.io.Writer;
import java.util.*;

public final class MarasmCodeGenerator extends CodeGenerator {

    private final Writer writer;
    private final String tagPrefix="tinybasic_";
    private final String funPrefix="tinybasic_";
    public MarasmCodeGenerator(Writer writer) {
        this.writer = writer;
    }
    private Set<String> dependencies=new HashSet();

    @Override
    public void generate(InstructionSequence seq) throws IOException {
        dependencies.add("conio");
        Map<String, String> strings = new HashMap<>();
        for (Instruction instruction : seq.getInstructions()) {
            writer.append("; "+instruction.toString()+"\n");
            switch (instruction.getOpcode()) {
                case LABEL:
                    writer.append("@"+tagPrefix+instruction.getStringOperand().get() + "\n");
                    writer.append("$"+funPrefix+instruction.getStringOperand().get() + "\n");
                    break;

                case PUSHI:
                    writer.append("push "+instruction.getNumberOperand().get().toString()+"\n");
                    break;<commit_msg>bugfixes<commit_after>package com.marasm.codegen.marasm;

/**
 * Created by sr3u on 31.08.15.
 */

import com.grahamedgecombe.tinybasic.codegen.CodeGenerator;
import com.grahamedgecombe.tinybasic.stackir.Instruction;
import com.grahamedgecombe.tinybasic.stackir.InstructionSequence;

import java.io.IOException;
import java.io.Writer;
import java.util.*;

public final class MarasmCodeGenerator extends CodeGenerator {

    private final Writer writer;
    private final String tagPrefix="tinybasic_";
    private final String funPrefix="tinybasic_";
    public MarasmCodeGenerator(Writer writer) {
        this.writer = writer;
    }
    private Set<String> dependencies=new HashSet();

    @Override
    public void generate(InstructionSequence seq) throws IOException {
        dependencies.add("conio");
        dependencies.add("debIO");
        Map<String, String> strings = new HashMap<>();
        for (Instruction instruction : seq.getInstructions()) {
            writer.append("; "+instruction.toString()+"\n");
            switch (instruction.getOpcode()) {
                case LABEL:
                    writer.append("@"+tagPrefix+instruction.getStringOperand().get() + "\n");
                    writer.append("$"+funPrefix+instruction.getStringOperand().get() + "\n");
                    break;

                case PUSHI:
                    writer.append("push "+instruction.getNumberOperand().get().toString()+"\n");
                    break;
{'fraction_non_alphanumeric': 0.12137931034482759, 'fraction_numerical': 0.004827586206896552, 'mean_word_length': 2.893959731543624, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2369509', 'n_tokens_mistral': 787, 'n_tokens_neox': 756, 'n_words': 158}