<commit_before>package org.yinwang.rubysonar.ast;

import org.jetbrains.annotations.NotNull;
import org.yinwang.rubysonar.State;
import org.yinwang.rubysonar._;
import org.yinwang.rubysonar.types.ModuleType;
import org.yinwang.rubysonar.types.Type;


public class Module extends Node {

    public Node locator;
    public Name name;
    public Block body;


    public Module(Node locator, Block body, String file, int start, int end) {
        super(file, start, end);
        this.locator = locator;
        this.body = body;
        if (locator instanceof Attribute) {
            this.name = ((Attribute) locator).attr;
        } else if (locator instanceof Name) {
            this.name = (Name) locator;
        } else {
            _.die("illegal module locator: " + locator);
        }
        addChildren(locator, body);
    }


    @NotNull
    @Override
    public Type transform(@NotNull State s) {
        ModuleType mt = s.lookupOrCreateModule(locator, file);
        transformExpr(body, mt.table);
        return mt;
    }


    @NotNull
    @Override
    public String toString() {
        return "(module:" + locator + ")";
    }
<commit_msg>bind module to "self"<commit_after>package org.yinwang.rubysonar.ast;

import org.jetbrains.annotations.NotNull;
import org.yinwang.rubysonar.Binding;
import org.yinwang.rubysonar.Constants;
import org.yinwang.rubysonar.State;
import org.yinwang.rubysonar._;
import org.yinwang.rubysonar.types.ModuleType;
import org.yinwang.rubysonar.types.Type;


public class Module extends Node {

    public Node locator;
    public Name name;
    public Block body;


    public Module(Node locator, Block body, String file, int start, int end) {
        super(file, start, end);
        this.locator = locator;
        this.body = body;
        if (locator instanceof Attribute) {
            this.name = ((Attribute) locator).attr;
        } else if (locator instanceof Name) {
            this.name = (Name) locator;
        } else {
            _.die("illegal module locator: " + locator);
        }
        addChildren(locator, body);
    }


    @NotNull
    @Override
    public Type transform(@NotNull State s) {
        ModuleType mt = s.lookupOrCreateModule(locator, file);
        mt.table.insert(Constants.SELFNAME, this, mt, Binding.Kind.SCOPE);
        transformExpr(body, mt.table);
        return mt;
    }


    @NotNull
    @Override
    public String toString() {
        return "(module:" + locator + ")";
    }

{'fraction_non_alphanumeric': 0.10681176944780331, 'fraction_numerical': 0.0, 'mean_word_length': 2.5507868383404864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3221202', 'n_tokens_mistral': 787, 'n_tokens_neox': 744, 'n_words': 189}