<commit_before>package edu.rosehulman.minijavac.ast;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.google.common.collect.ImmutableList;
import edu.rosehulman.minijavac.generator.ConstantPool;
import edu.rosehulman.minijavac.typechecker.Scope;
import edu.rosehulman.minijavac.typechecker.Type;

public class LiteralValue implements LiteralExpression {
    public final Type type;
    public final Object value;

    public LiteralValue(String type, Object value) {
        this.type = new Type(type);
        this.value = value;
    }

    @Override
    public List<String> typecheck(Scope scope) {
        List<String> errors = new ArrayList<>();
        return errors;
    }

    @Override
    public Type getType(Scope scope) {
        return type;
    }

    @Override
    public List<Byte> generateCode(ConstantPool cp, Map<String, Integer> variables) {
        if(type.equals(Type.BOOLEAN)) {
            if(value.equals(Boolean.FALSE)) {
                return ImmutableList.of((byte) 3);
            } else {
                return ImmutableList.of((byte) 4);
            }
        } else if(type.equals(Type.INT)) {
            Integer integer = (Integer) value;
            if(integer >= -1 && integer <= 5) {
                return ImmutableList.of((byte) (3 + integer));
            } else if(integer >= Byte.MIN_VALUE && integer <= Byte.MAX_VALUE) {
                return ImmutableList.of((byte) 16, integer.byteValue());
            } else {
                throw new RuntimeException("Integer out of range " + integer);
            }
        } else {
            throw new RuntimeException("Illegal literal value");
        }
    }
}<commit_msg>Fixed LiteralValue type duplication.<commit_after>package edu.rosehulman.minijavac.ast;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.google.common.collect.ImmutableList;
import edu.rosehulman.minijavac.generator.ConstantPool;
import edu.rosehulman.minijavac.typechecker.Scope;
import edu.rosehulman.minijavac.typechecker.Type;

public class LiteralValue implements LiteralExpression {
    public final Type type;
    public final Object value;

    public LiteralValue(String type, Object value) {
        if (type.equals(Type.INT.toString())) {
            this.type = Type.INT;
        } else if (type.equals(Type.BOOLEAN.toString())) {
            this.type = Type.BOOLEAN;
        } else {
            this.type = new Type(type);
        }
        this.value = value;
    }

    @Override
    public List<String> typecheck(Scope scope) {
        List<String> errors = new ArrayList<>();
        return errors;
    }

    @Override
    public Type getType(Scope scope) {
        return type;
    }

    @Override
    public List<Byte> generateCode(ConstantPool cp, Map<String, Integer> variables) {
        if(type.equals(Type.BOOLEAN)) {
            if(value.equals(Boolean.FALSE)) {
                return ImmutableList.of((byte) 3);
            } else {
                return ImmutableList.of((byte) 4);
            }
        } else if(type.equals(Type.INT)) {
            Integer integer = (Integer) value;
            if(integer >= -1 && integer <= 5) {
                return ImmutableList.of((byte) (3 + integer));
            } else if(integer >= Byte.MIN_VALUE && integer <= Byte.MAX_VALUE) {
                return ImmutableList.of((byte) 16, integer.byteValue());
            } else {
                throw new RuntimeException("Integer out of range " + integer);
            }
        } else {
            throw new RuntimeException("Illegal literal value of type " + type.toString());
        }
    }
}
{'fraction_non_alphanumeric': 0.11120218579234972, 'fraction_numerical': 0.003825136612021858, 'mean_word_length': 2.2775290957923007, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5829949', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1041, 'n_words': 238}