<commit_before>package kalang.compiler;

import java.util.HashMap;

import jast.ast.ClassNode;
import jast.ast.VarObject;
import java.lang.reflect.Modifier;

public class AstLoader {

    HashMap<String, ClassNode> asts = new HashMap();

    private AstLoader parent;

    public AstLoader() {

    }

    public AstLoader(AstLoader astLoader) {
        parent = astLoader;
    }

    public void add(ClassNode clazz) {
        asts.put(clazz.name, clazz);
    }

    protected ClassNode findAst(String className) throws AstNotFoundException {
        ClassNode ast = asts.get(className);
        if (ast == null) {
            if (parent != null) {
                return parent.findAst(className);
            } else {
                throw new AstNotFoundException(className);
            }
        }
        return ast;
    }

    public ClassNode loadAst(String className) throws AstNotFoundException {
        boolean isArray = false;
        String name = className;
        if(name.endsWith("[]")){
            isArray = true;
            name = name.substring(0,name.length()-2);
        }
        ClassNode ast = findAst(name);
        if(ast==null) throw new AstNotFoundException(className);
        if(isArray){
            return createArrayAst(ast);
        }
        return ast;
    }

    public ClassNode getAst(String className) {
        try {
            return loadAst(className);
        } catch (AstNotFoundException e) {
            return null;
        }
    }

    private ClassNode createArrayAst(ClassNode ast) {
        ClassNode clazz = ClassNode.create();
        clazz.fields.add(new VarObject(Modifier.PUBLIC, "int", "length", null));
        clazz.name = ast.name + "[]";
        clazz.isArray = true;
        return clazz;
    }
<commit_msg>array ast bug fixed<commit_after>package kalang.compiler;

import java.util.HashMap;

import jast.ast.ClassNode;
import jast.ast.VarObject;
import java.lang.reflect.Modifier;

public class AstLoader {

    HashMap<String, ClassNode> asts = new HashMap();

    private AstLoader parent;

    public AstLoader() {

    }

    public AstLoader(AstLoader astLoader) {
        parent = astLoader;
    }

    public void add(ClassNode clazz) {
        asts.put(clazz.name, clazz);
    }

    protected ClassNode findAst(String className) throws AstNotFoundException {
        ClassNode ast = asts.get(className);
        if (ast == null) {
            if (parent != null) {
                return parent.findAst(className);
            } else {
                throw new AstNotFoundException(className);
            }
        }
        return ast;
    }

    public ClassNode loadAst(String className) throws AstNotFoundException {
        boolean isArray = false;
        String name = className;
        if(name.endsWith("[]")){
            isArray = true;
            name = name.substring(0,name.length()-2);
        }
        ClassNode ast = findAst(name);
        if(ast==null) throw new AstNotFoundException(className);
        if(isArray){
            return createArrayAst(ast);
        }
        return ast;
    }

    public ClassNode getAst(String className) {
        try {
            return loadAst(className);
        } catch (AstNotFoundException e) {
            return null;
        }
    }

    private ClassNode createArrayAst(ClassNode ast) {
        ClassNode clazz = ClassNode.create();
        clazz.fields.add(new VarObject(Modifier.PUBLIC, "int", "length", null));
        clazz.name = ast.name + "[]";
        clazz.isArray = true;
        if(ast.parentName!=null){
            clazz.parentName = ast.parentName + "[]";
        }
        return clazz;
    }

{'fraction_non_alphanumeric': 0.10229759299781181, 'fraction_numerical': 0.0010940919037199124, 'mean_word_length': 2.0834738617200674, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5099349', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1015, 'n_words': 238}