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

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

import edu.rosehulman.minijavac.generator.ConstantPool;
import edu.rosehulman.minijavac.typechecker.Scope;
import edu.rosehulman.minijavac.typechecker.Type;

public class PrintlnStatement implements Statement {
    public final Expression expression;

    public PrintlnStatement(Expression expression) {
        this.expression = expression;
    }

    @Override
    public List<String> typecheck(Scope scope) {
        List<String> errors = new ArrayList<>();
        errors.addAll(expression.typecheck(scope));
        Type expressionType = expression.getType(scope);
        if (!expressionType.isA(Type.INT, scope)) {
            errors.add("In MiniJava, System.out.println only takes an int.  The expression has type " + expressionType);
        }
        return errors;
    }

    @Override
    public int numLocalVariables(List<String> vd) {
        return 0;
    }

    @Override
    public void addIntegerEntries(ConstantPool cp) {
        expression.addIntegerEntries(cp);
    }

    @Override
    public List<Byte> generateCode(ConstantPool cp, Map<String, Integer> variables) {
        ArrayList<Byte> bytes = new ArrayList<>();
        bytes.add((byte) 178); // getstatic
        bytes.add((byte) (cp.systemOutEntry.index >> 8));
        bytes.add((byte) cp.systemOutEntry.index);
        List<Byte> expBytes = expression.generateCode(cp, variables);
        bytes.addAll(expBytes);
        bytes.add((byte) 182); // invokevirtual
        bytes.add((byte) (cp.printlnEntry.index >> 8));
        bytes.add((byte) cp.printlnEntry.index);
        return bytes;
    }

    @Override
    public int maxBlockDepth() {
        return 0;
    }
}<commit_msg>Fixed max stack size for println statements<commit_after>package edu.rosehulman.minijavac.ast;

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

import edu.rosehulman.minijavac.generator.ConstantPool;
import edu.rosehulman.minijavac.typechecker.Scope;
import edu.rosehulman.minijavac.typechecker.Type;

public class PrintlnStatement implements Statement {
    public final Expression expression;

    public PrintlnStatement(Expression expression) {
        this.expression = expression;
    }

    @Override
    public List<String> typecheck(Scope scope) {
        List<String> errors = new ArrayList<>();
        errors.addAll(expression.typecheck(scope));
        Type expressionType = expression.getType(scope);
        if (!expressionType.isA(Type.INT, scope)) {
            errors.add("In MiniJava, System.out.println only takes an int.  The expression has type " + expressionType);
        }
        return errors;
    }

    @Override
    public int numLocalVariables(List<String> vd) {
        return 0;
    }

    @Override
    public void addIntegerEntries(ConstantPool cp) {
        expression.addIntegerEntries(cp);
    }

    @Override
    public List<Byte> generateCode(ConstantPool cp, Map<String, Integer> variables) {
        ArrayList<Byte> bytes = new ArrayList<>();
        bytes.add((byte) 178); // getstatic
        bytes.add((byte) (cp.systemOutEntry.index >> 8));
        bytes.add((byte) cp.systemOutEntry.index);
        List<Byte> expBytes = expression.generateCode(cp, variables);
        bytes.addAll(expBytes);
        bytes.add((byte) 182); // invokevirtual
        bytes.add((byte) (cp.printlnEntry.index >> 8));
        bytes.add((byte) cp.printlnEntry.index);
        return bytes;
    }

    @Override
    public int maxBlockDepth() {
        return expression.maxBlockDepth() + 1;
    }
}
{'fraction_non_alphanumeric': 0.11150782751991212, 'fraction_numerical': 0.005492996429552321, 'mean_word_length': 3.0556792873051224, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, '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': '6202185', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1041, 'n_words': 231}