<commit_before>import structs/ArrayList
import ../io/TabbedWriter

import ../frontend/Token
import Expression, Type, Visitor, TypeDecl, Cast, FunctionCall, FunctionDecl,
	   Module, Node, VariableDecl, VariableAccess, BinaryOp, Argument,
       Return, CoverDecl, BaseType
import tinker/[Response, Resolver, Trail]

ClassDecl: class extends TypeDecl {

    DESTROY_FUNC_NAME   := static const "__destroy__"
    LOAD_FUNC_NAME      := static const "__load__"
    DEFAULTS_FUNC_NAME  := static const "__defaults__"

    isAbstract := false
    isFinal := false

    defaultInit := null as FunctionDecl
    
    init: func ~classDeclNoSuper(.name, .token) {
        super(name, token)
    }
    
    init: func ~classDeclNotMeta(.name, .superType, .token) {
        init(name, superType, false, token)
    }

    init: func ~classDecl(.name, .superType, =isMeta, .token) {
        super(name, superType, token)
    }
    
    accept: func (visitor: Visitor) { visitor visitClassDecl(this) }
    
    resolve: func (trail: Trail, res: Resolver) -> Response {
        
        if(isMeta) {
            if(getNonMeta() class == ClassDecl) {
                if(!functions contains(This DEFAULTS_FUNC_NAME)) {
                    addFunction(FunctionDecl new(This DEFAULTS_FUNC_NAME, token))
                }
            }
            if(!functions contains(This LOAD_FUNC_NAME)) {
                fDecl := FunctionDecl new(This LOAD_FUNC_NAME, token)
                fDecl setStatic(true)
                addFunction(fDecl)
            }
        }
    
        {
            response := super(trail, res)
            if(!response ok()) return response
        }
        
        return Responses OK
    }
    <commit_msg>Ohum, let's not break interfaces so fast.<commit_after>import structs/ArrayList
import ../io/TabbedWriter

import ../frontend/Token
import Expression, Type, Visitor, TypeDecl, Cast, FunctionCall, FunctionDecl,
	   Module, Node, VariableDecl, VariableAccess, BinaryOp, Argument,
       Return, CoverDecl, BaseType
import tinker/[Response, Resolver, Trail]

ClassDecl: class extends TypeDecl {

    DESTROY_FUNC_NAME   := static const "__destroy__"
    LOAD_FUNC_NAME      := static const "__load__"
    DEFAULTS_FUNC_NAME  := static const "__defaults__"

    isAbstract := false
    isFinal := false

    defaultInit := null as FunctionDecl
    
    init: func ~classDeclNoSuper(.name, .token) {
        super(name, token)
    }
    
    init: func ~classDeclNotMeta(.name, .superType, .token) {
        init(name, superType, false, token)
    }

    init: func ~classDecl(.name, .superType, =isMeta, .token) {
        super(name, superType, token)
    }
    
    accept: func (visitor: Visitor) { visitor visitClassDecl(this) }
    
    resolve: func (trail: Trail, res: Resolver) -> Response {
        
        if(isMeta) {
            if(getNonMeta() class == ClassDecl) {
                if(!functions contains(This DEFAULTS_FUNC_NAME)) {
                    addFunction(FunctionDecl new(This DEFAULTS_FUNC_NAME, token))
                }
            }
            if(getNonMeta() class == ClassDecl || getNonMeta() class == CoverDecl) {
                if(!functions contains(This LOAD_FUNC_NAME)) {
                    fDecl := FunctionDecl new(This LOAD_FUNC_NAME, token)
                    fDecl setStatic(true)
                    addFunction(fDecl)
                }
            }
        }
    
        {
            response := super(trail, res)
            if(!response ok()) return response
        }
        
        return Responses OK
    }
    
{'fraction_non_alphanumeric': 0.09812692200167739, 'fraction_numerical': 0.0, 'mean_word_length': 2.141352063213345, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6591285', 'n_tokens_mistral': 1048, 'n_tokens_neox': 1007, 'n_words': 252}