AllocatableFactory.avt

Переключить прокрутку окна
Загрузить этот исходный код

/*
    Компилятор языка программирования
    Объектно-ориентированный продвинутый векторный транслятор

    Copyright © 2021, 2024 Малик Разработчик

    Это свободная программа: вы можете перераспространять ее и/или изменять
    ее на условиях Стандартной общественной лицензии GNU в том виде,
    в каком она была опубликована Фондом свободного программного обеспечения;
    либо версии 3 лицензии, либо (по вашему выбору) любой более поздней версии.

    Эта программа распространяется в надежде, что она будет полезной,
    но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА
    или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Подробнее см. в Стандартной
    общественной лицензии GNU.

    Вы должны были получить копию Стандартной общественной лицензии GNU
    вместе с этой программой. Если это не так, см.
    <https://www.gnu.org/licenses/>.
*/

package ru.malik.elaborarer.avtoo.lang;

import avt.lang.array.*;

public abstract service AllocatableFactory(ReflectItem, Cloneable, Measureable, ObjectArray, AVTOOConstants)
{
    public Union createNestedUnion(int declarationPosition, int documentationPosition) {
        Programme programme = parentProgramme;
        Union result = programme == null ? null : programme.newNestedUnion(this, declarationPosition, documentationPosition);
        if(result == null) result = new Union(this, declarationPosition, documentationPosition);
        appendChildItem(result);
        return result;
    }

    public Struct createNestedStruct(int declarationPosition, int documentationPosition) {
        Programme programme = parentProgramme;
        Struct result = programme == null ? null : programme.newNestedStruct(this, declarationPosition, documentationPosition);
        if(result == null) result = new Struct(this, declarationPosition, documentationPosition);
        appendChildItem(result);
        return result;
    }

    public Field createStructField(Type type, int capacity, String specialSimpleName, int declarationPosition, int documentationPosition) {
        if(type == null)
        {
            throw new NullPointerException(String.format(avt.lang.package.getResourceString("null-pointer.argument"), new Object[] { "type" }));
        }
        Programme programme = parentProgramme;
        if(type.parentProgramme != programme)
        {
            throw new IllegalArgumentException(package.getResourceString("type.not-same-programme.item"));
        }
        if(capacity > LIMIT_FIELD_LENGTH)
        {
            throw new IllegalArgumentException(String.format(package.getResourceString("field.length-too-large"), new Object[] { Int.toString(LIMIT_FIELD_LENGTH) }));
        }
        if(type.isVoid() || type.isNull() || (capacity <= 0 ? !type.isPrimitive() : !(type instanceof ArrayType) || !((ArrayType) type).componentType.isPrimitive()))
        {
            throw new IllegalArgumentException(package.getResourceString("type.not-suitable.field"));
        }
        Field result = programme == null ? null : programme.newStructField(this, type, capacity, specialSimpleName, declarationPosition, documentationPosition);
        if(result == null) result = new Field(this, type, capacity, specialSimpleName, declarationPosition, documentationPosition);
        appendChildItem(result);
        return result;
    }
}