{
Компилятор языка программирования
Объектно-ориентированный продвинутый векторный транслятор
Copyright © 2021, 2024, 2026 Малик Разработчик
Это свободная программа: вы можете перераспространять ее и/или изменять
ее на условиях Стандартной общественной лицензии GNU в том виде,
в каком она была опубликована Фондом свободного программного обеспечения;
либо версии 3 лицензии, либо (по вашему выбору) любой более поздней версии.
Эта программа распространяется в надежде, что она будет полезной,
но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА
или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Подробнее см. в Стандартной
общественной лицензии GNU.
Вы должны были получить копию Стандартной общественной лицензии GNU
вместе с этой программой. Если это не так, см.
<https://www.gnu.org/licenses/>.
}
unit ru.malik.elaborarer.avtoo.lang;
{$MODE OBJFPC}
interface
{%region} uses
pascalx.lang,
pascalx.lang.math.avo,
pascalx.lang.math.vcoverage,
pascalx.lang.table,
pascalx.io,
pascalx.io.bytearray,
pascalx.io.charset,
pascalx.io.extension,
platform.independent.filesystem,
platform.independent.osservices,
platform.independent.streamformat,
platform.independent.streamformat.compression.zlib;
{%endregion}
{$WARN 3018 OFF} { позволить конструкторы с любой видимостью }
{$WARN 3057 OFF} { позволить скрывать унаследованные члены }
{$TYPEINFO ON}
{$CALLING REGISTER}
const UNIT_NAME = 'ru.malik.elaborarer.avtoo.lang';
{%region} type
Measureable = interface;
IntArray = interface;
ObjectArray = interface;
SimpleArray = interface;
UnknownArray = interface;
MutableObjectArray = interface;
Source = interface;
TypedItem = interface;
TypedMember = interface;
ValuedItem = interface;
AllocatableFactory = interface;
Fieldoid = interface;
Constant = interface;
AVTOOConstants = class;
AVTOORecompilable = class;
AVTOOService = class;
SourceArray = class;
ChunkArray = class;
LibraryArray = class;
PackageArray = class;
RequiredReflectItemArray = class;
TypeArray = class;
ClassTypeArray = class;
ArrayTypeArray = class;
LocalArray = class;
ArgumentArray = class;
NodeArray = class;
UnicodeStringArray = class;
Storage = class;
Byte2Storage = class;
Byte4Storage = class;
Byte8Storage = class;
Short2Storage = class;
Short4Storage = class;
Short8Storage = class;
Int2Storage = class;
Int4Storage = class;
Int8Storage = class;
LongStorage = class;
Long2Storage = class;
Long4Storage = class;
Long8Storage = class;
FloatStorage = class;
Float2Storage = class;
Float4Storage = class;
Float8Storage = class;
DoubleStorage = class;
Double2Storage = class;
Double4Storage = class;
Double8Storage = class;
RealStorage = class;
AnsiStringStorage = class;
UnicodeStringStorage = class;
ArgumentArrayStorage = class;
LexemeSequence = class;
TextSource = class;
BinarySource = class;
Chunk = class;
ElementStack = class;
FieldsMap = class;
Programme = class;
ConstantFactory = class;
ProgrammeItem = class;
&Library = class;
TableItem = class;
ReflectItem = class;
RequiredReflectItem = class;
Package = class;
&Type = class;
PrimitiveType = class;
ReferenceType = class;
ClassType = class;
ArrayType = class;
NullType = class;
Member = class;
AllocatableMember = class;
Field = class;
NestedAllocatableMember = class;
Struct = class;
Union = class;
OverriddableMember = class;
Callable = class;
Method = class;
SpecialMethod = class;
ClassInit = class;
InstInit = class;
&Operator = class;
&Property = class;
Local = class;
CallableItem = class;
Code = class;
Node = class;
IllegalArrayDimensionsCountException = class;
IllegalConstantTypeException = class;
IllegalLexemeTypeException = class;
UnencodableDataException = class;
CompilerException = class;
SourceException = class;
BinarySourceException = class;
TextSourceException = class;
IllegalCompilerObjectStateException = class;
IllegalClassTypeStateException = class;
IllegalFieldsMapStateException = class;
IllegalMemberStateException = class;
IllegalFieldStateException = class;
IllegalProgrammeStateException = class;
IllegalSourceStateException = class;
Source_Array1d = specialize DynamicArray<Source>;
TypedItem_Array1d = specialize DynamicArray<TypedItem>;
Fieldoid_Array1d = specialize DynamicArray<Fieldoid>;
ArgumentArray_Array1d = specialize DynamicArray<ArgumentArray>;
Chunk_Array1d = specialize DynamicArray<Chunk>;
ProgrammeItem_Array1d = specialize DynamicArray<ProgrammeItem>;
Library_Array1d = specialize DynamicArray<&Library>;
RequiredReflectItem_Array1d = specialize DynamicArray<RequiredReflectItem>;
Package_Array1d = specialize DynamicArray<Package>;
Type_Array1d = specialize DynamicArray<&Type>;
PrimitiveType_Array1d = specialize DynamicArray<PrimitiveType>;
ClassType_Array1d = specialize DynamicArray<ClassType>;
ArrayType_Array1d = specialize DynamicArray<ArrayType>;
Member_Array1d = specialize DynamicArray<Member>;
Callable_Array1d = specialize DynamicArray<Callable>;
Method_Array1d = specialize DynamicArray<Method>;
InstInit_Array1d = specialize DynamicArray<InstInit>;
Operator_Array1d = specialize DynamicArray<&Operator>;
Local_Array1d = specialize DynamicArray<Local>;
Node_Array1d = specialize DynamicArray<Node>;
Measureable = interface(RawInterface) ['{D0980A8B-2915-4E75-82E8-04584EE84A9F}']
function getLength(): int;
end;
IntArray = interface(Measureable) ['{D0980A8B-2915-4E75-82E8-04584EE84AA7}']
function readComponent(index: int): int;
end;
ObjectArray = interface(Measureable) ['{D0980A8B-2915-4E75-82E8-04584EE84AAC}']
function readComponent(index: int): TObject;
end;
SimpleArray = interface(Measureable) ['{D0980A8B-2915-4E75-82E8-04584EE84AAD}']
function readComponent(index: int): ISimple;
end;
UnknownArray = interface(Measureable) ['{D0980A8B-2915-4E75-82E8-04584EE84AAE}']
function readComponent(index: int): IUnknown;
end;
MutableObjectArray = interface(ObjectArray) ['{D0980A8B-2915-4E75-82E8-04584EE84ABC}']
procedure writeComponent(index: int; value: TObject);
end;
Source = interface(InputAdapter) ['{232E3636-99E8-4764-96E0-FF520A37C200}']
procedure loadFromFileStream();
procedure parseInputStream();
procedure appendDeclared(__declared: ClassType);
procedure writeComponent(index: int; value: TObject);
function contains(&type: ClassType): boolean;
function isSameSource(anot: Source): boolean;
function getLength(): int;
function getRelativePath(): UnicodeString;
function getContents(): Measureable;
function getDeclared(): ClassTypeArray;
function getParentLibrary(): &Library;
function getParentProgramme(): Programme;
function readComponent(index: int): TObject;
property relativePath: UnicodeString read getRelativePath;
property contents: Measureable read getContents;
property declared: ClassTypeArray read getDeclared;
property parentLibrary: &Library read getParentLibrary;
property parentProgramme: Programme read getParentProgramme;
end;
TypedItem = interface(ObjectArray) ['{232E3636-99E8-4764-96E0-FF520A37C201}']
procedure setImplementationPosition(newImplementationPosition: int);
function getImplementationPosition(): int;
function getDeclarationPosition(): int;
function getDocumentationPosition(): int;
function getSpecialSimpleName(): AnsiString;
function getRecompilableName(): AnsiString;
function getFasmSimpleName(): AnsiString;
function getDocumentationContent(): LexemeSequence;
function getSource(): Source;
function getType(): &Type;
function getChildItem(const __specialSimpleName: AnsiString): ProgrammeItem;
function getChildItem(const __specialSimpleName: AnsiString; __ignoreCase: boolean): ProgrammeItem;
function getNextItem(): ProgrammeItem;
function getParentItem(): ProgrammeItem;
function getParentLibrary(): &Library;
function getParentProgramme(): Programme;
function readComponent(index: int): ProgrammeItem;
property implementationPosition: int read getImplementationPosition write setImplementationPosition;
property declarationPosition: int read getDeclarationPosition;
property documentationPosition: int read getDocumentationPosition;
property specialSimpleName: AnsiString read getSpecialSimpleName;
property recompilableName: AnsiString read getRecompilableName;
property fasmSimpleName: AnsiString read getFasmSimpleName;
property documentationContent: LexemeSequence read getDocumentationContent;
property source: Source read getSource;
property &type: &Type read getType;
property nextItem: ProgrammeItem read getNextItem;
property parentItem: ProgrammeItem read getParentItem;
property parentLibrary: &Library read getParentLibrary;
property parentProgramme: Programme read getParentProgramme;
end;
TypedMember = interface(TypedItem) ['{232E3636-99E8-4764-96E0-FF520A37C202}']
function isVisibleFrom(__type: ClassType): boolean;
function isVisibleFrom(__type, __impliedParentType: ClassType): boolean;
function isFinal(): boolean;
function isAbstract(): boolean;
function isSpecial(): boolean;
function isStatic(): boolean;
function isSynthetic(): boolean;
function getVisibility(): int;
function getAttributes(): int;
function getFasmFullName(): AnsiString;
function getParentType(): ClassType;
function getParentPackage(): Package;
property visibility: int read getVisibility;
property attributes: int read getAttributes;
property fasmFullName: AnsiString read getFasmFullName;
property parentType: ClassType read getParentType;
property parentPackage: Package read getParentPackage;
end;
ValuedItem = interface(TypedItem) ['{232E3636-99E8-4764-96E0-FF520A37C203}']
function isConstant(): boolean;
function getValue(): Constant;
property value: Constant read getValue;
end;
AllocatableFactory = interface(ObjectArray) ['{232E3636-99E8-4764-96E0-FF520A37C204}']
procedure setImplementationPosition(newImplementationPosition: int);
function isVisibleFrom(__type: ClassType): boolean;
function isFinal(): boolean;
function isAbstract(): boolean;
function getImplementationPosition(): int;
function getDeclarationPosition(): int;
function getDocumentationPosition(): int;
function getVisibility(): int;
function getAttributes(): int;
function getSpecialSimpleName(): AnsiString;
function getRecompilableName(): AnsiString;
function getFasmSimpleName(): AnsiString;
function getFasmFullName(): AnsiString;
function getDocumentationContent(): LexemeSequence;
function getSource(): Source;
function getChildItem(const __specialSimpleName: AnsiString): ProgrammeItem;
function getChildItem(const __specialSimpleName: AnsiString; __ignoreCase: boolean): ProgrammeItem;
function getNextItem(): ProgrammeItem;
function getParentItem(): ProgrammeItem;
function getParentLibrary(): &Library;
function getParentProgramme(): Programme;
function readComponent(index: int): ProgrammeItem;
function createNestedUnion(__declarationPosition, __documentationPosition: int): Union;
function createNestedStruct(__declarationPosition, __documentationPosition: int): Struct;
function createStructField(__type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field;
property implementationPosition: int read getImplementationPosition write setImplementationPosition;
property declarationPosition: int read getDeclarationPosition;
property documentationPosition: int read getDocumentationPosition;
property visibility: int read getVisibility;
property attributes: int read getAttributes;
property specialSimpleName: AnsiString read getSpecialSimpleName;
property recompilableName: AnsiString read getRecompilableName;
property fasmSimpleName: AnsiString read getFasmSimpleName;
property fasmFullName: AnsiString read getFasmFullName;
property documentationContent: LexemeSequence read getDocumentationContent;
property source: Source read getSource;
property nextItem: ProgrammeItem read getNextItem;
property parentItem: ProgrammeItem read getParentItem;
property parentLibrary: &Library read getParentLibrary;
property parentProgramme: Programme read getParentProgramme;
end;
Fieldoid = interface(TypedMember) ['{232E3636-99E8-4764-96E0-FF520A37C205}']
end;
Constant = interface(Numeric) ['{232E3636-99E8-4764-96E0-FF520A37C206}']
function isNull(): boolean;
function isClass(): boolean;
function isString(): boolean;
function isPackage(): boolean;
function isBoolean(): boolean;
function isNumeric(): boolean;
function isReference(): boolean;
function isReflective(): boolean;
function isDefaultValue(): boolean;
function asBoolean(): boolean;
function asObject(): TObject;
function asInterface(): IUnknown;
function castTo(__type: &Type): Constant;
function getType(): &Type;
property kind: int read getKind;
property &type: &Type read getType;
end;
AVTOOConstants = class(&Object)
public const
(*** ключевые слова ***)
(* ( Л — лексема, И — инструкция ) | Л | И | (. управление, + выражение, - временный) ссылки, операнды | примечания *)
LEXEMES_LENGTH = int($01a0); (* | | | | количество лексем языка *)
KEYWORDS_LENGTH = int($0060); (* | | | | количество ключевых слов *)
VIS_PRIVATE = int($0000); (* | + | | | private *)
RESERVED_SOURCE = int($0001); (* | | | | зарезервированная видимость (равна VIS_SOURCE, если используется) *)
VIS_SOURCE = int($0002); (* | | | | видимость по умолчанию (на уровне исходного кода) *)
RESERVED_PACKAGE = int($0003); (* | | | | зарезервированная видимость (равна VIS_PACKAGE, если используется) *)
VIS_PACKAGE = int($0004); (* | + | | | package *)
VIS_PROTECTED = int($0005); (* | + | | | protected *)
VIS_PUBLIC = int($0006); (* | + | | | public *)
VIS_PUBLISHED = int($0007); (* | + | | | published *)
DCL_IMPORT = int($0008); (* | + | | | import *)
DCL_UNION = int($0009); (* | + | | | union *)
DCL_ABSTRACT = int($000a); (* | + | | | abstract *)
DCL_FINAL = int($000b); (* | + | | | final *)
DCL_CLASS = int($000c); (* | + | | - ClassType | class *)
DCL_STRUCT = int($000d); (* | + | | | struct *)
DCL_SERVICE = int($000e); (* | + | | | service *)
DCL_INTERFACE = int($000f); (* | + | | | interface *)
DCL_HELPER = int($0010); (* | + | | | helper *)
DCL_STATIC = int($0012); (* | + | | | static *)
DCL_NATIVE = int($0013); (* | + | | | native *)
DCL_INTERRUPT = int($0014); (* | + | | | interrupt *)
DCL_SYNCHRONIZED = int($0015); (* | + | | | synchronized *)
DCL_OPERATOR = int($0016); (* | + | | | operator *)
DCL_THROWS = int($0017); (* | + | | | throws *)
EXP_FALSE = int($0018); (* | | | | false *)
EXP_TRUE = int($0019); (* | | | | true *)
EXP_NULL = int($001a); (* | + | | | null *)
EXP_NEW = int($001b); (* | + | | | new *)
EXP_SUPER = int($001c); (* | + | | | super *)
EXP_THIS = int($001d); (* | + | | | this *)
EXP_INSTANCEOF = int($001e); (* | + | + | + ClassType | instanceof *)
PRIMITIVES_LENGTH = int($0020); (* | | | | количество примитивных типов (TYP_LONG8 - TYP_VOID + 1) *)
TYP_VOID = int($0020); (* | + | | | void *)
TYP_BOOLEAN = int($0021); (* | + | | | boolean *)
TYP_CHAR = int($0022); (* | + | | | char *)
TYP_REF = int($0023); (* | | | | объектная ссылка *)
TYP_REAL = int($0024); (* | + | | | real *)
TYP_DOUBLE = int($0028); (* | + | | | double *)
TYP_DOUBLE2 = int($0029); (* | + | | | double2 *)
TYP_DOUBLE4 = int($002a); (* | + | | | double4 *)
TYP_DOUBLE8 = int($002b); (* | + | | | double8 *)
TYP_FLOAT = int($002c); (* | + | | | float *)
TYP_FLOAT2 = int($002d); (* | + | | | float2 *)
TYP_FLOAT4 = int($002e); (* | + | | | float4 *)
TYP_FLOAT8 = int($002f); (* | + | | | float8 *)
TYP_BYTE = int($0030); (* | + | | | byte *)
TYP_BYTE2 = int($0031); (* | + | | | byte2 *)
TYP_BYTE4 = int($0032); (* | + | | | byte4 *)
TYP_BYTE8 = int($0033); (* | + | | | byte8 *)
TYP_SHORT = int($0034); (* | + | | | short *)
TYP_SHORT2 = int($0035); (* | + | | | short2 *)
TYP_SHORT4 = int($0036); (* | + | | | short4 *)
TYP_SHORT8 = int($0037); (* | + | | | short8 *)
TYP_INT = int($0038); (* | + | | | int *)
TYP_INT2 = int($0039); (* | + | | | int2 *)
TYP_INT4 = int($003a); (* | + | | | int4 *)
TYP_INT8 = int($003b); (* | + | | | int8 *)
TYP_LONG = int($003c); (* | + | | | long *)
TYP_LONG2 = int($003d); (* | + | | | long2 *)
TYP_LONG4 = int($003e); (* | + | | | long4 *)
TYP_LONG8 = int($003f); (* | + | | | long8 *)
FCT_WITH = int($0040); (* | + | | | with *)
FCT_IF = int($0041); (* | + | | . | if *)
FCT_ELSE = int($0042); (* | + | | | else *)
FCT_SWITCH = int($0043); (* | + | | . | switch *)
FCT_BRANCH = int($0044); (* | | + | . | ветвление, используемое управляющей конструкцией switch *)
FCT_CASE = int($0045); (* | + | | . Int(значение метки) | case *)
FCT_DEFAULT = int($0046); (* | + | | . | default *)
FCT_LABEL = int($0047); (* | | | . String(название метки) | <метка>: *)
FCT_DO = int($0048); (* | + | | . | do *)
FCT_FOR = int($0049); (* | + | | . | for *)
FCT_WHILE = int($004a); (* | + | | . | while *)
FCT_BLOCK = int($004b); (* | | | . | { … } *)
FCT_JUMP = int($004c); (* | | + | . | инструкция ассемблера jmp *)
FCT_BREAK = int($004d); (* | + | | . Node(целевой DO, FOR, WHILE, SWITCH или LABEL) | break *)
FCT_CONTINUE = int($004e); (* | + | | . Node(целевой DO, FOR или WHILE) | continue *)
FCT_RETURN = int($004f); (* | + | + | . | return *)
FCT_THROW = int($0050); (* | + | + | . ClassType(тип Throwable) | throw *)
FCT_BOUND = int($0051); (* | | + | . | начало или конец блока try (берётся из двоичного исходного кода) *)
FCT_BEGIN = int($0052); (* | | + | . | начало блока try *)
FCT_END = int($0053); (* | | + | . | конец блока try *)
FCT_TRY = int($0054); (* | + | | . | try *)
FCT_CATCH = int($0055); (* | + | | . ClassType(тип Throwable) | catch *)
FCT_FINALLY = int($0056); (* | + | | | finally *)
INVOKE_FINALLY = int($0057); (* | | + | . Node(целевой FINALLY_ENTER) | вызов блока finally *)
CLINIT_TRY_LOCK = int($0058); (* | | + | + ClassType(окружающий) | вход в блок static *)
CLINIT_UNLOCK = int($0059); (* | | + | + ClassType(окружающий) | выход из блока static *)
FINALLY_ENTER = int($005a); (* | | + | . | вход в блок finally *)
FINALLY_LEAVE = int($005b); (* | | + | . | выход из блока finally *)
MONITOR_ENTER = int($005c); (* | | + | . | вход в блок synchronized *)
MONITOR_LEAVE = int($005d); (* | | + | . | выход из блока synchronized *)
METHOD_ENTER = int($005e); (* | | + | . Int(количество элементов стака для проверки) | вход в тело метода *)
METHOD_LEAVE = int($005f); (* | | + | . | выход из тела метода *)
FCT_SYNCHRONIZED = DCL_SYNCHRONIZED;
(*** управление данными ***)
(* ( Л — лексема, И — инструкция ) | Л | И | (. управление, + выражение, - временный) ссылки, операнды | примечания (W — ослабление ссылки или отброс значения) *)
READ_OPERATOR = int($0060); (* | | | | начальный код операторов чтения значения *)
LOAD_CONST = int($0060); (* | | + | + Constant | <W> загрузка константы *)
LOAD_LOCAL = int($0061); (* | | + | + Local [, Type(переменной)* ] | <W> загрузка локальной переменной *)
LOAD_INTERRUPT = int($0064); (* | | + | + Method(статичный, обработчик прерываний) | загрузка адреса обработчика прерывания *)
LOAD_STATIC = int($0065); (* | | + | + Field(статичный, не константа) | <W> загрузка глобальной переменной *)
READ_ELEMENT = int($0066); (* | | + | + PrimitiveType(векторный) [, Constant(тип int, от 0 до 1|3|7)] | чтение элемента вектора *)
READ_COMPONENT = int($0067); (* | | + | + Type(компонентов массива) [, доп. операнд типа int] | чтение компонента массива *)
READ_FIELD = int($0068); (* | | + | + Field(инстанционный) [, доп. операнд ссылочного типа] | чтение поля инстанции или структуры *)
READ_SPECIAL = int($0069); (* | | + | + Property(не абстрактный) [, доп. операнд ссылочного типа] | прямое чтение свойства *)
READ_PROPERTY = int($006a); (* | | + | + Property [, доп. операнд ссылочного типа] | косвенное чтение свойства *)
SWAP = int($006b); (* | | + | + Type(a, b всегда ссылочного типа) | обмен местами двух элементов: … a b → … b a *)
DUP1 = int($006c); (* | | + | + Type(b) | дублирование одного элемента: … a b → … a b b *)
DUP1X1 = int($006d); (* | | + | + Type(c, b всегда ссылочного типа) | дублирование одного элемента: … a b c → … a c b c *)
DUP1X2 = int($006e); (* | | + | + Type(d, b всегда ссылочного типа, тип c определяется по тагу) | дублирование одного элемента: … a b c d → … a d b c d *)
DUP2 = int($006f); (* | | + | + Type(c, b всегда ссылочного типа) | дублирование двух элементов: … a b c → … a b c b c *)
INVOKE_STATIC = int($0070); (* | | + | + Method(статичный) | <W> вызов статичного метода *)
INVOKE_SPECIAL = int($0072); (* | | + | + Callable(инстанционный, не абстрактный) | <W> вызов метода напрямую *)
INVOKE_VIRTUAL = int($0074); (* | | + | + Callable(инстанционный, классовый) | <W> вызов виртуального метода *)
INVOKE_SERVICE = int($0076); (* | | + | + Callable(инстанционный, сервисный) | <W> вызов сервисного метода *)
NEW_VECTOR = int($0078); (* | | + | + PrimitiveType(векторный) | создание значения векторного типа *)
NEW_ARRAY = int($0079); (* | | + | + ArrayType, Constant(тип int) | создание одномерного массива фиксированной длины *)
NEW_ARRAY_MONO = int($007a); (* | | + | + ArrayType | создание одномерного массива *)
NEW_ARRAY_MULTI = int($007b); (* | | + | + ArrayType | создание многомерного массива *)
NEW_INSTANCE = int($007c); (* | | + | + ClassType(не массив) | создание инстанции *)
NOP = int($007f); (* | | + | + | отсутствие операции *)
INC_LOCAL = int($0080); (* | + | + | + Local(числовой тип) [, Type(переменной)* ] | ++ инкремент локальной переменной *)
DEC_LOCAL = int($0081); (* | + | + | + Local(числовой тип) [, Type(переменной)* ] | -- декремент локальной переменной *)
INC_PRED_LOAD_LOCAL = int($0084); (* | | + | + Local(числовой тип) [, Type(переменной)* ] | инкремент и последующая загрузка локальной переменной *)
DEC_PRED_LOAD_LOCAL = int($0085); (* | | + | + Local(числовой тип) [, Type(переменной)* ] | декремент и последующая загрузка локальной переменной *)
INC_POST_LOAD_LOCAL = int($0086); (* | | + | + Local(числовой тип) [, Type(переменной)* ] | загрузка и последующий инкремент локальной переменной *)
DEC_POST_LOAD_LOCAL = int($0087); (* | | + | + Local(числовой тип) [, Type(переменной)* ] | загрузка и последующий декремент локальной переменной *)
CAST_TO = int($0088); (* | | + | + Type(новый), Type(исходный) | преобразование числового типа или проверка ссылочного *)
BOOL_NOT = int($0090); (* | + | | + | ! *)
BOOL_AND = int($0091); (* | + | | + | && *)
BOOL_OR = int($0092); (* | + | | + | || *)
BOOL_COND = int($0093); (* | | | + | ?: *)
REF_EQ = int($0094); (* | | + | + [доп. операнд ссылочного типа] | <W> проверка равенства двух объектных ссылок *)
REF_NE = int($0095); (* | | + | + [доп. операнд ссылочного типа] | <W> проверка неравенства двух объектных ссылок *)
REF_IS_NULL = int($0096); (* | | + | + | <W> проверка равенства объектной ссылки нулевой ссылке *)
REF_IS_OBJECT = int($0097); (* | | + | + | <W> проверка неравенства объектной ссылки нулевой ссылке *)
TEST_EQZ = int($0098); (* | | + | + PrimitiveType(тип long) [, доп. операнд типа long] | (a & b) == 0 *)
TEST_NEZ = int($0099); (* | | + | + PrimitiveType(тип long) [, доп. операнд типа long] | (a & b) != 0 *)
O_BIT_NOT = int($00a0); (* | + | + | + PrimitiveType | ~ *)
O_BIT_AND = int($00a1); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | & *)
O_BIT_OR = int($00a2); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | | *)
O_BIT_XOR = int($00a3); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | ^ *)
O_SCAL_POS = int($00a4); (* | | | | + (унарный) *)
O_SCAL_NEG = int($00a5); (* | | + | + PrimitiveType | - (унарный) *)
O_SCAL_MUL = int($00a6); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | * *)
O_SCAL_DIV = int($00a8); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | / *)
O_SCAL_DIVU = int($00a9); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | // *)
O_SCAL_REM = int($00aa); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | % *)
O_SCAL_REMU = int($00ab); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | %% *)
O_SCAL_ADD = int($00ac); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | + *)
O_SCAL_SUB = int($00ad); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | - *)
O_SCAL_SHR = int($00ae); (* | + | + | + PrimitiveType [, доп. операнд типа int] | >> *)
O_SCAL_SHRU = int($00af); (* | + | + | + PrimitiveType [, доп. операнд типа int] | >>> *)
O_SCAL_SHL = int($00b0); (* | + | + | + PrimitiveType [, доп. операнд типа int] | << *)
O_SCAL_EQ = int($00b2); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | == *)
O_SCAL_NE = int($00b3); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | != *)
O_SCAL_GT = int($00b4); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | > *)
O_SCAL_GE = int($00b5); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | >= *)
O_SCAL_LT = int($00b6); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | < *)
O_SCAL_LE = int($00b7); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | <= *)
O_VECT_OPERATOR = int($00c0); (* | | | | начальный код векторных операторов *)
O_VECT_LUP = int($00c0); (* | + | + | + PrimitiveType | #### *)
O_VECT_UUP = int($00c1); (* | + | + | + PrimitiveType | ^^^^ *)
O_VECT_PCK = int($00c2); (* | + | + | + PrimitiveType | @@@@ *)
O_VECT_POS = int($00c4); (* | | | | ++++ (унарный) *)
O_VECT_NEG = int($00c5); (* | | + | + PrimitiveType | ---- (унарный) *)
O_VECT_MUL = int($00c6); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | **** *)
O_VECT_DIV = int($00c8); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | //// *)
O_VECT_ADD = int($00cc); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | ++++ *)
O_VECT_SUB = int($00cd); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | ---- *)
O_VECT_SHR = int($00ce); (* | + | + | + PrimitiveType [, доп. операнд типа int] | >>>> *)
O_VECT_SHRU = int($00cf); (* | + | + | + PrimitiveType [, доп. операнд типа int] | >>>>> *)
O_VECT_SHL = int($00d0); (* | + | + | + PrimitiveType [, доп. операнд типа int] | <<<< *)
O_VECT_EQ = int($00d2); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | |==| *)
O_VECT_NE = int($00d3); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | |!=| *)
O_VECT_GT = int($00d4); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | |>>| *)
O_VECT_GE = int($00d5); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | |>=| *)
O_VECT_LT = int($00d6); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | |<<| *)
O_VECT_LE = int($00d7); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | |<=| *)
O_VECT_HMUL = int($00d8); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | |**| *)
O_VECT_HMULU = int($00d9); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | #**# *)
O_VECT_SADD = int($00dc); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | |++| *)
O_VECT_SADDU = int($00dd); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | #++# *)
O_VECT_SSUB = int($00de); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | |--| *)
O_VECT_SSUBU = int($00df); (* | + | + | + PrimitiveType [, доп. операнд примитивного типа] | #--# *)
WRITE_OPERATOR = int($00e0); (* | | | | начальный код операторов модифицирования значения *)
STORE_LOCAL = int($00e1); (* | | + | + Local [, Constant(тип null или int) или Type(переменной)* ] | сохранение в локальной переменной *)
DECLARE_LOCAL = int($00e2); (* | | + | + Local [, Constant(тип null или int) или Type(переменной)* ] | декларирование локальной переменной *)
DECLARE_WITH = int($00e3); (* | | + | + Local [, Constant(тип null) или Type(переменной)* ] | декларирование локальной переменной для with *)
STORE_STATIC = int($00e5); (* | | + | + Field(статичный, не константа) [, Constant(тип null или int)] | сохранение в глобальной переменной *)
WRITE_COMPONENT = int($00e7); (* | | + | + Type(компонентов массива) | запись компонента массива *)
WRITE_FIELD = int($00e8); (* | | + | + Field(инстанционный) | запись поля инстанции или структуры *)
WRITE_SPECIAL = int($00e9); (* | | + | + Property(не абстрактный) | прямая запись свойства *)
WRITE_PROPERTY = int($00ea); (* | | + | + Property | косвенная запись свойства *)
EXCEPT_ENTER = int($00fb); (* | | + | . | вход в обработчик исключений *)
EXCEPT_TRY = int($00fc); (* | | + | . Node(целевой BEGIN), Node(целевой END) | описатель блока try *)
EXCEPT_CATCH = int($00fd); (* | | + | . Node(целевой DECLARE_LOCAL), ClassType(тип Throwable) | описатель блока catch *)
EXCEPT_FINALLY = int($00fe); (* | | + | . Node(целевой FINALLY_ENTER) | описатель блока finally *)
EXCEPT_LEAVE = int($00ff); (* | | + | . | выход из обработчика исключений *)
(* | | | * генерируется из двоичного исходного кода | *)
(*** модифицирование значений ***)
(* ( Л — лексема ) | Л | примечания *)
A_DELTA = int($0080) ; (* | | разница между операторами чтения и модифицирования значения *)
A_BIT_AND = A_DELTA + O_BIT_AND ; (* | + | &= *)
A_BIT_OR = A_DELTA + O_BIT_OR ; (* | + | |= *)
A_BIT_XOR = A_DELTA + O_BIT_XOR ; (* | + | ^= *)
A_SCAL_MUL = A_DELTA + O_SCAL_MUL ; (* | + | *= *)
A_SCAL_DIV = A_DELTA + O_SCAL_DIV ; (* | + | /= *)
A_SCAL_DIVU = A_DELTA + O_SCAL_DIVU ; (* | + | //= *)
A_SCAL_REM = A_DELTA + O_SCAL_REM ; (* | + | %= *)
A_SCAL_REMU = A_DELTA + O_SCAL_REMU ; (* | + | %%= *)
A_SCAL_ADD = A_DELTA + O_SCAL_ADD ; (* | + | += *)
A_SCAL_SUB = A_DELTA + O_SCAL_SUB ; (* | + | -= *)
A_SCAL_SHR = A_DELTA + O_SCAL_SHR ; (* | + | >>= *)
A_SCAL_SHRU = A_DELTA + O_SCAL_SHRU ; (* | + | >>>= *)
A_SCAL_SHL = A_DELTA + O_SCAL_SHL ; (* | + | <<= *)
A_VECT_MUL = A_DELTA + O_VECT_MUL ; (* | + | ****= *)
A_VECT_DIV = A_DELTA + O_VECT_DIV ; (* | + | ////= *)
A_VECT_ADD = A_DELTA + O_VECT_ADD ; (* | + | ++++= *)
A_VECT_SUB = A_DELTA + O_VECT_SUB ; (* | + | ----= *)
A_VECT_SHR = A_DELTA + O_VECT_SHR ; (* | + | >>>>= *)
A_VECT_SHRU = A_DELTA + O_VECT_SHRU ; (* | + | >>>>>= *)
A_VECT_SHL = A_DELTA + O_VECT_SHL ; (* | + | <<<<= *)
A_VECT_GT = A_DELTA + O_VECT_GT ; (* | + | |>>|= *)
A_VECT_GE = A_DELTA + O_VECT_GE ; (* | + | |>=|= *)
A_VECT_LT = A_DELTA + O_VECT_LT ; (* | + | |<<|= *)
A_VECT_LE = A_DELTA + O_VECT_LE ; (* | + | |<=|= *)
A_VECT_EQ = A_DELTA + O_VECT_EQ ; (* | + | |==|= *)
A_VECT_NE = A_DELTA + O_VECT_NE ; (* | + | |!=|= *)
A_VECT_HMUL = A_DELTA + O_VECT_HMUL ; (* | + | |**|= *)
A_VECT_HMULU = A_DELTA + O_VECT_HMULU; (* | + | #**#= *)
A_VECT_SADD = A_DELTA + O_VECT_SADD ; (* | + | |++|= *)
A_VECT_SADDU = A_DELTA + O_VECT_SADDU; (* | + | #++#= *)
A_VECT_SSUB = A_DELTA + O_VECT_SSUB ; (* | + | |--|= *)
A_VECT_SSUBU = A_DELTA + O_VECT_SSUBU; (* | + | #--#= *)
(*** реверсные операторы ***) (* примечания *)
R_DELTA = int($00c0) ; (* разница между операторами чтения и реверсными операторами *)
R_BIT_AND = R_DELTA + O_BIT_AND ; (* &` *)
R_BIT_OR = R_DELTA + O_BIT_OR ; (* |` *)
R_BIT_XOR = R_DELTA + O_BIT_XOR ; (* ^` *)
R_SCAL_MUL = R_DELTA + O_SCAL_MUL ; (* *` *)
R_SCAL_DIV = R_DELTA + O_SCAL_DIV ; (* /` *)
R_SCAL_DIVU = R_DELTA + O_SCAL_DIVU ; (* //` *)
R_SCAL_REM = R_DELTA + O_SCAL_REM ; (* %` *)
R_SCAL_REMU = R_DELTA + O_SCAL_REMU ; (* %%` *)
R_SCAL_ADD = R_DELTA + O_SCAL_ADD ; (* +` *)
R_SCAL_SUB = R_DELTA + O_SCAL_SUB ; (* -` *)
R_SCAL_SHR = R_DELTA + O_SCAL_SHR ; (* >>` *)
R_SCAL_SHRU = R_DELTA + O_SCAL_SHRU ; (* >>>` *)
R_SCAL_SHL = R_DELTA + O_SCAL_SHL ; (* <<` *)
R_SCAL_GT = R_DELTA + O_SCAL_GT ; (* >` *)
R_SCAL_GE = R_DELTA + O_SCAL_GE ; (* >=` *)
R_SCAL_LT = R_DELTA + O_SCAL_LT ; (* <` *)
R_SCAL_LE = R_DELTA + O_SCAL_LE ; (* <=` *)
R_VECT_MUL = R_DELTA + O_VECT_MUL ; (* ****` *)
R_VECT_DIV = R_DELTA + O_VECT_DIV ; (* ////` *)
R_VECT_ADD = R_DELTA + O_VECT_ADD ; (* ++++` *)
R_VECT_SUB = R_DELTA + O_VECT_SUB ; (* ----` *)
R_VECT_SHR = R_DELTA + O_VECT_SHR ; (* >>>>` *)
R_VECT_SHRU = R_DELTA + O_VECT_SHRU ; (* >>>>>` *)
R_VECT_SHL = R_DELTA + O_VECT_SHL ; (* <<<<` *)
R_VECT_GT = R_DELTA + O_VECT_GT ; (* |>>|` *)
R_VECT_GE = R_DELTA + O_VECT_GE ; (* |>=|` *)
R_VECT_LT = R_DELTA + O_VECT_LT ; (* |<<|` *)
R_VECT_LE = R_DELTA + O_VECT_LE ; (* |<=|` *)
R_VECT_EQ = R_DELTA + O_VECT_EQ ; (* |==|` *)
R_VECT_NE = R_DELTA + O_VECT_NE ; (* |!=|` *)
R_VECT_HMUL = R_DELTA + O_VECT_HMUL ; (* |**|` *)
R_VECT_HMULU = R_DELTA + O_VECT_HMULU; (* #**#` *)
R_VECT_SADD = R_DELTA + O_VECT_SADD ; (* |++|` *)
R_VECT_SADDU = R_DELTA + O_VECT_SADDU; (* #++#` *)
R_VECT_SSUB = R_DELTA + O_VECT_SSUB ; (* |--|` *)
R_VECT_SSUBU = R_DELTA + O_VECT_SSUBU; (* #--#` *)
(*** литералы ***) (* примечания *)
L_NAME = int($0100); (* литерал – название элемента программы *)
L_STRING = int($0101); (* литерал – строка *)
L_DOC = int($0102); (* литерал – документация *)
L_BOOLEAN = int($0106); (* литерал типа boolean *)
L_CHAR = int($0107); (* литерал типа char *)
L_REAL = int($0109); (* литерал типа real *)
L_DOUBLE = int($010a); (* литерал типа double *)
L_FLOAT = int($010b); (* литерал типа float *)
L_BYTE = int($010c); (* литерал типа byte *)
L_SHORT = int($010d); (* литерал типа short *)
L_INT = int($010e); (* литерал типа int *)
L_LONG = int($010f); (* литерал типа long *)
(*** символы ***) (* примечания *)
PARENTH_OPENED = int($0110); (* ( *)
PARENTH_CLOSED = int($0111); (* ) *)
BRACKET_OPENED = int($0112); (* [ *)
BRACKET_CLOSED = int($0113); (* ] *)
CURLY_OPENED = int($0114); (* { *)
CURLY_CLOSED = int($0115); (* } *)
EQUAL = int($0118); (* = *)
QUESTION = int($0119); (* ? *)
REVERSE = int($011a); (* ` *)
PERIOD = int($011c); (* . *)
COMMA = int($011d); (* , *)
COLON = int($011e); (* : *)
SEMICOLON = int($011f); (* ; *)
L_END = int( -1); (* конец лексем *)
(*** документация кода ***) (* примечания *)
D_LEXEMES_LENGTH = int($0170); (* количество лексем документации *)
D_TEXT = int($0000); (* слово или текст *)
D_NAME = int($0001); (* название элемента программы *)
D_ALINK = int($0002); (* @link *)
D_APARAM = int($0003); (* @param *)
D_ARETURN = int($0004); (* @return *)
D_ATHROWS = int($0005); (* @throws *)
D_ASINCE = int($0006); (* @since *)
D_ASEE = int($0007); (* @see *)
D_AAUTHOR = int($000f); (* @author — последний @-таг *)
D_SCAL_DIVU = int($00a9); (* // *)
D_SCAL_REMU = int($00ab); (* %% *)
D_SCAL_SHR = int($00ae); (* >> *)
D_SCAL_SHRU = int($00af); (* >>> *)
D_SCAL_SHL = int($00b0); (* << *)
D_SCAL_EQ = int($00b2); (* == *)
D_SCAL_NE = int($00b3); (* != *)
D_SCAL_GE = int($00b5); (* >= *)
D_SCAL_LE = int($00b7); (* <= *)
D_VECT_LUP = int($00c0); (* #### *)
D_VECT_UUP = int($00c1); (* ^^^^ *)
D_VECT_PCK = int($00c2); (* @@@@ *)
D_VECT_MUL = int($00c6); (* **** *)
D_VECT_DIV = int($00c8); (* //// *)
D_VECT_ADD = int($00cc); (* ++++ *)
D_VECT_SUB = int($00cd); (* ---- *)
D_VECT_SHR = int($00ce); (* >>>> *)
D_VECT_SHRU = int($00cf); (* >>>>> *)
D_VECT_SHL = int($00d0); (* <<<< *)
D_VECT_EQ = int($00d2); (* |==| *)
D_VECT_NE = int($00d3); (* |!=| *)
D_VECT_GT = int($00d4); (* |>>| *)
D_VECT_GE = int($00d5); (* |>=| *)
D_VECT_LT = int($00d6); (* |<<| *)
D_VECT_LE = int($00d7); (* |<=| *)
D_VECT_HMUL = int($00d8); (* |**| *)
D_VECT_HMULU = int($00d9); (* #**# *)
D_VECT_SADD = int($00dc); (* |++| *)
D_VECT_SADDU = int($00dd); (* #++# *)
D_VECT_SSUB = int($00de); (* |--| *)
D_VECT_SSUBU = int($00df); (* #--# *)
D_PARENTH_OPENED = int($0150); (* ( *)
D_PARENTH_CLOSED = int($0151); (* ) *)
D_BRACKET_OPENED = int($0152); (* [ *)
D_BRACKET_CLOSED = int($0153); (* ] *)
D_CURLY_OPENED = int($0154); (* { *)
D_CURLY_CLOSED = int($0155); (* } *)
D_TAG_OPENED = int($0156); (* < *)
D_TAG_CLOSED = int($0157); (* > *)
D_EQUAL = int($0158); (* = *)
D_GRAVE_ACCENT = int($0159); (* ` *)
D_PERIOD = int($015a); (* . *)
D_COMMA = int($015b); (* , *)
D_QUOTE = int($015c); (* " *)
D_EXCLAM_MARK = int($0160); (* ! *)
D_VERTICAL_LINE = int($0161); (* | *)
D_AMPERSAND = int($0162); (* & *)
D_TILDE = int($0163); (* ~ *)
D_POUND_SIGN = int($0164); (* # *)
D_CIRCUMFLEX_ACC = int($0165); (* ^ *)
D_ASTERISK = int($0166); (* * *)
D_SOLIDUS = int($0167); (* / *)
D_PERCENT = int($0168); (* % *)
D_PLUS = int($0169); (* + *)
D_MINUS = int($016a); (* - *)
D_AT = int($016b); (* @ *)
D_EOL = int( -3); (* конец строки *)
D_EOP = int( -2); (* конец абзаца *)
D_END = int( -1); (* конец лексем *)
(*** типы лексем ***)
LT_NONE = int($00);
LT_BOOLEAN = int($01);
LT_CHAR = int($02);
LT_BYTE = int($03);
LT_SHORT = int($04);
LT_INT = int($05);
LT_LONG = int($06);
LT_FLOAT = int($07);
LT_DOUBLE = int($08);
LT_REAL = int($09);
LT_STRING = int($0a);
(*** индексы компонентов информации о лексеме ***)
ILINE = int(0); (* индекс строки *)
ICHAR = int(1); (* индекс символа *)
LKIND = int(2); (* разновидность лексемы *)
LTYPE = int(3); (* тип лексемы *)
(*** ограничения ***)
LIMIT_ARGUMENTS_LENGTH = int( 30); (* предельное количество аргументов вызываемого члена *)
LIMIT_DIMENSIONS_COUNT = int( 99); (* предельное количество измерений массива *)
LIMIT_NAME_LENGTH = int( 239); (* предельная длина названия элемента программы *)
LIMIT_FIELD_LENGTH = int($00010000); (* предельная длина поля структуры *)
LIMIT_EXCEPTIONS_LENGTH = int($20000000); (* предельное количество исключений метода в секции throws *)
LIMIT_FIELD_OFFSET = int($7fbfffff); (* предельное смещение поля структуры *)
(*** атрибуты и маски ***)
ATTR_ABSTRACT = int(%0000000001000); (* абстрактный *)
ATTR_FINAL = int(%0000000010000); (* финальный *)
ATTR_SERVICE = int(%0000000100000); (* сервис *)
ATTR_STRUCT = int(%0000001000000); (* структура *)
ATTR_INTERFACE = int(%0000001100000); (* протокол *)
ATTR_PRIMITIVE = int(%0000010000000); (* примитив *)
ATTR_STATIC = int(%0000100000000); (* статичный *)
ATTR_NATIVE = int(%0001000000000); (* написан на ассемблере (нет у абстрактных членов) *)
ATTR_INTERRUPT = int(%0010000000000); (* обработчик прерывания (нет у абстрактных методов) *)
ATTR_SYNCHRONIZED = int(%0100000000000); (* синхронизированный (нет у абстрактных членов) *)
ATTR_SYNTHETIC = int(%1000000000000); (* добавлен компилятором *)
MASK_VISIBILITY = int(%0000000000111); (* маска видимости *)
MASK_BINDING = int(%0000000011000); (* маска связывания *)
MASK_TYPE = int(%0000011100000); (* маска атрибутов типа *)
MASK_MEMBER = int(%1111100000000); (* маска атрибутов члена *)
MASK_CODE = int(%0111000000000); (* маска деталей реализации (нет у абстрактных членов) *)
MASK_ATTRIBUTES = int(%1111111111111); (* маска всех атрибутов *)
(*** канонические названия важных пакетов, используемых компилятором ***)
PACKNAME_LANG = 'avt.lang';
(*** простые названия важных типов, используемых компилятором ***)
TYPENAME_NULL = 'null';
TYPENAME_CLASS = 'Class';
TYPENAME_ERROR = 'Error';
TYPENAME_OBJECT = 'Object';
TYPENAME_STRING = 'String';
TYPENAME_STRUCT = 'Struct';
TYPENAME_PACKAGE = 'Package';
TYPENAME_THROWABLE = 'Throwable';
TYPENAME_RUNTIME_EXCEPTION = 'RuntimeException';
(*** специальные названия особых элементов ***)
SPECNAME_INST_INIT = '<init>'; (* конструктор *)
SPECNAME_CLASS_INIT = '<clinit>'; (* блок static *)
SPECNAME_THIS = 'this'; (* аргумент this *)
SPECNAME_VALUE = 'value'; (* аргумент value *)
SPECNAME_INDEX = 'index'; (* переменная index *)
(*** ассемблерные названия особых элементов ***)
FASMNAME_SYSTEM_PACKAGE = 'system.package'; (* системный пакет *)
FASMNAME_INST_INIT = '$init$'; (* конструктор *)
FASMNAME_CLASS_INIT = '$clinit$'; (* статичный блок *)
(*** просматриваемые названия особых элементов ***)
VIEWNAME_CLASS_INIT = 'static';
VIEWNAME_OPERATOR = 'operator'#$20;
(*** суффиксы особых членов ***)
MEMBER_SUFFIX_READ = 'read';
MEMBER_SUFFIX_WRITE = 'write';
MEMBER_SUFFIX_INDEX = 'index';
MEMBER_SUFFIX_STORED = 'stored';
(*** типы исходного кода ***)
TEXT_SOURCE = 'text';
BINARY_SOURCE = 'binary';
public
class function isPrimitiveKind(kind: int): boolean; static;
class function isAtTagDocumentLexeme(lexeme: int): boolean; static;
class function getVersion(): AnsiString; static;
end;
AVTOORecompilable = class(AVTOOConstants)
strict private const
(*** флаги данных ***)
FLAG_NEXT = int($8000); (* флаг следующей инструкции *)
FLAG_LONG = int($4000); (* флаг длинного номера *)
FLAG_LABEL = int($2000); (* флаг метки *)
public const
(*** типы констант ***)
CONST_Z = short((int(' ') shl &10) or int('Z')); (* boolean *)
CONST_C = short((int(' ') shl &10) or int('C')); (* char *)
CONST_R = short((int(' ') shl &10) or int('R')); (* real *)
CONST_D = short((int(' ') shl &10) or int('D')); (* double *)
CONST_D2 = short((int('D') shl &10) or int('2')); (* double2 *)
CONST_D4 = short((int('D') shl &10) or int('4')); (* double4 *)
CONST_D8 = short((int('D') shl &10) or int('8')); (* double8 *)
CONST_F = short((int(' ') shl &10) or int('F')); (* float *)
CONST_F2 = short((int('F') shl &10) or int('2')); (* float2 *)
CONST_F4 = short((int('F') shl &10) or int('4')); (* float4 *)
CONST_F8 = short((int('F') shl &10) or int('8')); (* float8 *)
CONST_B = short((int(' ') shl &10) or int('B')); (* byte *)
CONST_B2 = short((int('B') shl &10) or int('2')); (* byte2 *)
CONST_B4 = short((int('B') shl &10) or int('4')); (* byte4 *)
CONST_B8 = short((int('B') shl &10) or int('8')); (* byte8 *)
CONST_S = short((int(' ') shl &10) or int('S')); (* short *)
CONST_S2 = short((int('S') shl &10) or int('2')); (* short2 *)
CONST_S4 = short((int('S') shl &10) or int('4')); (* short4 *)
CONST_S8 = short((int('S') shl &10) or int('8')); (* short8 *)
CONST_I = short((int(' ') shl &10) or int('I')); (* int *)
CONST_I2 = short((int('I') shl &10) or int('2')); (* int2 *)
CONST_I4 = short((int('I') shl &10) or int('4')); (* int4 *)
CONST_I8 = short((int('I') shl &10) or int('8')); (* int8 *)
CONST_J = short((int(' ') shl &10) or int('J')); (* long *)
CONST_J2 = short((int('J') shl &10) or int('2')); (* long2 *)
CONST_J4 = short((int('J') shl &10) or int('4')); (* long4 *)
CONST_J8 = short((int('J') shl &10) or int('8')); (* long8 *)
CONST_ST = short((int('S') shl &10) or int('T')); (* строка (String) *)
CONST_PK = short((int('P') shl &10) or int('K')); (* пакет (Package) *)
CONST_TP = short((int('T') shl &10) or int('P')); (* тип (Type) *)
CONST_FL = short((int('F') shl &10) or int('L')); (* поле (Field) *)
CONST_PR = short((int('P') shl &10) or int('R')); (* свойство (Property) *)
CONST_CL = short((int('C') shl &10) or int('L')); (* вызываемый (Callable) *)
(*** null — по нулевому индексу ***)
(*** типы кусков ***)
CHUNK_VERS = int((int('v') shl &30) or (int('e') shl &20) or (int('R') shl &10) or int('s'));
CHUNK_CONS = int((int('c') shl &30) or (int('o') shl &20) or (int('N') shl &10) or int('s'));
CHUNK_SURC = int((int('s') shl &30) or (int('u') shl &20) or (int('R') shl &10) or int('c'));
CHUNK_PACK = int((int('p') shl &30) or (int('a') shl &20) or (int('C') shl &10) or int('k'));
CHUNK_TYPE = int((int('t') shl &30) or (int('y') shl &20) or (int('P') shl &10) or int('e'));
CHUNK_CFLD = int((int('c') shl &30) or (int('f') shl &20) or (int('L') shl &10) or int('d'));
CHUNK_SFLD = int((int('s') shl &30) or (int('f') shl &20) or (int('L') shl &10) or int('d'));
CHUNK_METH = int((int('m') shl &30) or (int('e') shl &20) or (int('T') shl &10) or int('h'));
CHUNK_OPER = int((int('o') shl &30) or (int('p') shl &20) or (int('E') shl &10) or int('r'));
CHUNK_PROP = int((int('p') shl &30) or (int('r') shl &20) or (int('O') shl &10) or int('p'));
CHUNK_CODE = int((int('c') shl &30) or (int('o') shl &20) or (int('D') shl &10) or int('e'));
CHUNK_IEND = int((int('I') shl &30) or (int('E') shl &20) or (int('N') shl &10) or int('D'));
(*** инструкции ***)
INST_METHOD_ENTER = int($8000);
INST_SWAP = int($8100);
INST_BOUND = int($8200);
INST_THROW = int($8300);
INST_LOAD_STATIC = int($8400);
INST_LOAD_STATICW = int($8500);
INST_LOAD_LOCAL = int($8600);
INST_LOAD_LOCALW = int($8700);
INST_LOAD_CONST = int($8800);
INST_LOAD_CONSTW = int($8900);
INST_READ_ELEMENT = int($8a00);
INST_READ_ELEMENTI = int($8b00);
INST_READ_COMPONENT = int($8c00);
INST_READ_FIELD = int($8d00);
INST_READ_SPECIAL = int($8e00);
INST_READ_PROPERTY = int($8f00);
INST_STORE_STATIC = int($9000);
INST_STORE_STATIC_NULL = int($9100);
INST_STORE_STATIC_SHORT = int($9200);
INST_STORE_STATIC_INT = int($9300);
INST_STORE_LOCAL = int($9400);
INST_STORE_LOCAL_NULL = int($9500);
INST_STORE_LOCAL_SHORT = int($9600);
INST_STORE_LOCAL_INT = int($9700);
INST_INC_PRED_LOAD_LOCAL = int($9800);
INST_INC_POST_LOAD_LOCAL = int($9900);
INST_DEC_PRED_LOAD_LOCAL = int($9a00);
INST_DEC_POST_LOAD_LOCAL = int($9b00);
INST_WRITE_COMPONENT = int($9c00);
INST_WRITE_FIELD = int($9d00);
INST_WRITE_SPECIAL = int($9e00);
INST_WRITE_PROPERTY = int($9f00);
INST_SWITCH_TABLE = int($a000);
INST_SWITCH_LOOKUP = int($a100);
INST_JUMP = int($a200);
INST_LOAD_INTERRUPT = int($a300);
INST_LOAD_CONST_BYTE = int($a400);
INST_LOAD_CONST_NULL = int($a500);
INST_LOAD_CONST_SHORT = int($a600);
INST_LOAD_CONST_INT = int($a700);
INST_REF_EQ = int($a800);
INST_REF_EQW = int($a900);
INST_REF_NE = int($aa00);
INST_REF_NEW = int($ab00);
INST_REF_IS_NULL = int($ac00);
INST_REF_IS_NULLW = int($ad00);
INST_REF_IS_OBJECT = int($ae00);
INST_REF_IS_OBJECTW = int($af00);
INST_CLINIT_TRY_LOCK = int($b000);
INST_CLINIT_UNLOCK = int($b100);
INST_MONITOR_ENTER = int($b200);
INST_MONITOR_LEAVE = int($b300);
INST_FINALLY_ENTER = int($b400);
INST_FINALLY_LEAVE = int($b500);
INST_NEW_ARRAY = int($b600);
INST_INVOKE_FINALLY = int($b700);
INST_INVOKE_STATIC = int($b800);
INST_INVOKE_STATICD = int($b900);
INST_INVOKE_SPECIAL = int($ba00);
INST_INVOKE_SPECIALD = int($bb00);
INST_INVOKE_VIRTUAL = int($bc00);
INST_INVOKE_VIRTUALD = int($bd00);
INST_INVOKE_SERVICE = int($be00);
INST_INVOKE_SERVICED = int($bf00);
INST_VECT_DIV = int($c000);
INST_VECT_PCK = int($c100);
INST_VECT_LUP = int($c200);
INST_VECT_UUP = int($c300);
INST_VECT_MUL = int($c400);
INST_VECT_SHL = int($c500);
INST_VECT_SHR = int($c600);
INST_VECT_SHRU = int($c700);
INST_VECT_ADD = int($c800);
INST_VECT_SUB = int($c900);
INST_VECT_EQ = int($ca00);
INST_VECT_NE = int($cb00);
INST_VECT_GT = int($cc00);
INST_VECT_GE = int($cd00);
INST_VECT_LT = int($ce00);
INST_VECT_LE = int($cf00);
INST_SCAL_DIV = int($d000);
INST_SCAL_DIVU = int($d100);
INST_SCAL_REM = int($d200);
INST_SCAL_REMU = int($d300);
INST_SCAL_MUL = int($d400);
INST_SCAL_SHL = int($d500);
INST_SCAL_SHR = int($d600);
INST_SCAL_SHRU = int($d700);
INST_SCAL_ADD = int($d800);
INST_SCAL_SUB = int($d900);
INST_SCAL_EQ = int($da00);
INST_SCAL_NE = int($db00);
INST_SCAL_GT = int($dc00);
INST_SCAL_GE = int($dd00);
INST_SCAL_LT = int($de00);
INST_SCAL_LE = int($df00);
INST_VECT_NEG = int($e000);
INST_CAST_TO = int($e100);
INST_INC_LOCAL = int($e200);
INST_DEC_LOCAL = int($e300);
INST_BIT_NOT = int($e400);
INST_BIT_AND = int($e500);
INST_BIT_OR = int($e600);
INST_BIT_XOR = int($e700);
INST_DUP1 = int($e800);
INST_DUP2 = int($e900);
INST_VECT_HMUL = int($ea00);
INST_VECT_HMULU = int($eb00);
INST_VECT_SADD = int($ec00);
INST_VECT_SADDU = int($ed00);
INST_VECT_SSUB = int($ee00);
INST_VECT_SSUBU = int($ef00);
INST_SCAL_NEG = int($f000);
INST_INSTANCE_OF = int($f100);
INST_TEST_EQZ = int($f200);
INST_TEST_NEZ = int($f300);
INST_NEW_VECTOR = int($f400);
INST_NEW_INSTANCE = int($f500);
INST_NEW_ARRAY_MONO = int($f600);
INST_NEW_ARRAY_MULTI = int($f700);
INST_DUP1X1 = int($f800);
INST_DUP1X2 = int($f900);
INST_METHOD_LEAVE = int($fa00);
INST_EXCEPT_ENTER = int($fb00);
INST_EXCEPT_TRY = int($fc00);
INST_EXCEPT_CATCH = int($fd00);
INST_EXCEPT_FINALLY = int($fe00);
INST_EXCEPT_LEAVE = int($ff00);
(*** флаги инструкций ***)
FLAG_WEAK = int($0100); (* флаг работы со слабой ссылкой *)
FLAG_DISCARD = int($0100); (* флаг отброса результата метода *)
FLAG_BOOLEAN_JUMP = int($0080); (* флаг ветвления по логическому значению *)
(*** необязательные операнды ***)
OPERAND_NONE = int(0); (* нет операнда *)
OPERAND_CONSTANT = int(1); (* константа *)
OPERAND_GLOBAL = int(2); (* глобальная переменная *)
OPERAND_LOCAL = int(3); (* локальная переменная *)
(*** способы сохранения значения в локальной переменной ***)
STORE_NORMAL = int(1); (* простое присвоение значения *)
STORE_DECLARE_LOCAL = int(2); (* объявление для нормального доступа *)
STORE_DECLARE_WITH = int(3); (* объявление для быстрого доступа *)
(*** поддерживаемая версия ***)
VERSION_AVTR = int((int(1) shl $10) or int(1));
(*** сигнатура ***)
SIGNATURE_AVTR = long($415654520d0a1a0a);
public
class function isLongEncoded(encoded: int): boolean; static;
class function isLongNumber(encoded: int): boolean; static;
class function isInstruction(encoded: int): boolean; static;
class function isNext(encoded: int): boolean; static;
class function decodeDeclareLabel(encoded: int): boolean; static;
class function decodeDeclareNumber(encoded: int): int; static;
class function decodeUsing(encoded: int): int; static;
class function decodeType(encoded: int): int; static;
class function decodeStore(encoded: int): int; static;
class function decodeOperand(encoded: int): int; static;
class function decodeVectorIndex(encoded: int): int; static;
class function encodeDeclare(&label: boolean; number: int): int; static;
class function encodeNext(): int; static;
class function encodeUsing(number: int): int; static;
class function encodeType(kind: int): int; static;
class function encodeType(&type: &Type): int; static;
class function encodeStore(store: int): int; static;
class function encodeOperand(operandC: Constant; operandI: TableItem): int; static;
class function encodeVectorIndex(index: int): int; static;
end;
AVTOOService = class(AVTOORecompilable)
public
class function getBestArrayCapacity(length: int): int; static;
private
class function getObjectName(const objectPath: UnicodeString): UnicodeString; static;
end;
SourceArray = class(&Object, Measureable, SimpleArray)
strict private
fldOwned: boolean;
fldLength: int;
fldArray: TObject_Array1d;
public
constructor create(owned: boolean);
destructor destroy; override;
function getLength(): int;
function readComponent(index: int): Source;
function readComponent(index: int): ISimple;
function clone(): Source_Array1d;
private
procedure append(item: Source);
function indexOf(item: Source): int;
end;
ChunkArray = class(&Object, Measureable, ObjectArray)
strict private
fldLength: int;
fldArray: Chunk_Array1d;
public
constructor create(const __array: Chunk_Array1d);
destructor destroy; override;
function getLength(): int;
function readComponent(index: int): Chunk;
function readComponent(index: int): TObject;
function clone(): Chunk_Array1d;
end;
LibraryArray = class(&Object, Measureable, ObjectArray)
strict private
fldOwned: boolean;
fldLength: int;
fldArray: Library_Array1d;
public
constructor create(owned: boolean);
destructor destroy; override;
function indexOf(item: &Library): int;
function getLength(): int;
function readComponent(index: int): &Library;
function readComponent(index: int): TObject;
function clone(): Library_Array1d;
private
procedure clear();
procedure append(item: &Library);
end;
PackageArray = class(&Object, Measureable, ObjectArray)
strict private
fldOwned: boolean;
fldLength: int;
fldArray: Package_Array1d;
public
constructor create(owned: boolean);
destructor destroy; override;
function getLength(): int;
function readComponent(index: int): Package;
function readComponent(index: int): TObject;
function clone(): Package_Array1d;
private
procedure clear();
procedure append(item: Package);
function indexOf(item: Package): int;
property length: int read fldLength;
property &array: Package_Array1d read fldArray;
end;
RequiredReflectItemArray = class(&Object, Measureable, ObjectArray)
strict private
fldOwned: boolean;
fldLength: int;
fldArray: RequiredReflectItem_Array1d;
public
constructor create(owned: boolean);
destructor destroy; override;
function getLength(): int;
function readComponent(index: int): RequiredReflectItem;
function readComponent(index: int): TObject;
function clone(): RequiredReflectItem_Array1d;
private
procedure clear();
procedure append(item: RequiredReflectItem);
function indexOf(item: RequiredReflectItem): int;
property length: int read fldLength;
property &array: RequiredReflectItem_Array1d read fldArray;
end;
TypeArray = class(&Object, Measureable, ObjectArray)
strict private
fldOwned: boolean;
fldLength: int;
fldArray: Type_Array1d;
public
constructor create(owned: boolean);
destructor destroy; override;
function getLength(): int;
function readComponent(index: int): &Type;
function readComponent(index: int): TObject;
function clone(): Type_Array1d;
private
procedure clear();
procedure append(item: &Type);
function indexOf(item: &Type): int;
property length: int read fldLength;
property &array: Type_Array1d read fldArray;
end;
ClassTypeArray = class(&Object, Measureable, ObjectArray)
strict private
fldOwned: boolean;
fldLength: int;
fldArray: ClassType_Array1d;
public
constructor create(owned: boolean);
destructor destroy; override;
function getLength(): int;
function readComponent(index: int): ClassType;
function readComponent(index: int): TObject;
function clone(): ClassType_Array1d;
private
procedure clear();
procedure append(item: ClassType);
property length: int read fldLength;
property &array: ClassType_Array1d read fldArray;
end;
ArrayTypeArray = class(&Object, Measureable, ObjectArray)
strict private
fldOwned: boolean;
fldLength: int;
fldArray: ArrayType_Array1d;
public
constructor create(owned: boolean);
destructor destroy; override;
function getLength(): int;
function readComponent(index: int): ArrayType;
function readComponent(index: int): TObject;
function clone(): ArrayType_Array1d;
private
procedure clear();
procedure append(item: ArrayType);
property length: int read fldLength;
property &array: ArrayType_Array1d read fldArray;
end;
LocalArray = class(&Object, Measureable, ObjectArray)
strict private
fldLength: int;
fldArray: Local_Array1d;
fldParentProgramme: Programme;
public
constructor create(parentProgramme: Programme);
constructor create(parentProgramme: Programme; const __array: Local_Array1d);
destructor destroy; override;
function getLength(): int;
function readComponent(index: int): Local;
function readComponent(index: int): TObject;
function clone(): TypedItem_Array1d;
function clone(alsoLocals: boolean): Local_Array1d;
private
procedure append(item: Local);
property length: int read fldLength;
property &array: Local_Array1d read fldArray;
end;
ArgumentArray = class(LocalArray)
public
class function toString(const arguments: Type_Array1d): AnsiString; static;
strict private
fldStackElements: int;
fldUserString: AnsiString;
fldFullString: AnsiString;
fldFasmString: AnsiString;
fldThisArgument: Local;
public
constructor create(parentProgramme: Programme; __thisArgument: Local; const __otherArguments: Local_Array1d);
function equals(anot: TObject): boolean; override;
function getHashCode(): long; override;
function toString(): AnsiString; override;
function toFullString(): AnsiString; virtual;
function toFasmString(): AnsiString; virtual;
property stackElements: int read fldStackElements;
property thisArgument: Local read fldThisArgument;
end;
NodeArray = class(&Object, Measureable, ObjectArray)
strict private
class function removeAndFreeItemFrom(const &array: Node_Array1d; length: int; item: Node): int; static;
class function removeAndFreeNodeFrom(const &array: Node_Array1d; length: int; node: Node): int; static;
class function removeAndFreeChildsFrom(const &array: Node_Array1d; length: int; node: Node): int; static;
private
class function removeItemFrom(const &array: Node_Array1d; length: int; item: Node): int; static;
class function removeNodeFrom(const &array: Node_Array1d; length: int; node: Node): int; static;
class function removeChildsFrom(const &array: Node_Array1d; length: int; node: Node): int; static;
strict private
fldLength: int;
fldArray: Node_Array1d;
public
constructor create();
destructor destroy; override;
function getLength(): int;
function readComponent(index: int): Node;
function readComponent(index: int): TObject;
function clone(): Node_Array1d;
private
procedure append(item: Node);
procedure remove(item: Node);
procedure removeNode(node: Node);
procedure removeChilds(node: Node);
function indexOf(item: Node): int;
property length: int read fldLength;
property &array: Node_Array1d read fldArray;
end;
UnicodeStringArray = class(&Object, Measureable, UnknownArray)
protected
fldLength: int;
fldArray: UnicodeString_Array1d;
public
constructor create(const &array: UnicodeString_Array1d);
function getLength(): int;
function readComponent(index: int): Value;
function readComponent(index: int): IUnknown;
function clone(): UnicodeString_Array1d;
end;
Storage = class abstract(&Object, Measureable)
protected
fldLength: int;
public
procedure clear(); virtual;
function getLength(): int;
function clone(): Storage; virtual;
end;
Byte2Storage = class sealed(Storage)
private
fldArray: byte2_Array1d;
public
constructor create();
constructor create(source: Byte2Storage);
function clone(): Byte2Storage; override;
function indexOf(const item: byte2): int;
function indexAcquire(const item: byte2): int;
function readComponent(index: int): byte2;
end;
Byte4Storage = class sealed(Storage)
private
fldArray: byte4_Array1d;
public
constructor create();
constructor create(source: Byte4Storage);
function clone(): Byte4Storage; override;
function indexOf(const item: byte4): int;
function indexAcquire(const item: byte4): int;
function readComponent(index: int): byte4;
end;
Byte8Storage = class sealed(Storage)
private
fldArray: byte8_Array1d;
public
constructor create();
constructor create(source: Byte8Storage);
function clone(): Byte8Storage; override;
function indexOf(const item: byte8): int;
function indexAcquire(const item: byte8): int;
function readComponent(index: int): byte8;
end;
Short2Storage = class sealed(Storage)
private
fldArray: short2_Array1d;
public
constructor create();
constructor create(source: Short2Storage);
function clone(): Short2Storage; override;
function indexOf(const item: short2): int;
function indexAcquire(const item: short2): int;
function readComponent(index: int): short2;
end;
Short4Storage = class sealed(Storage)
private
fldArray: short4_Array1d;
public
constructor create();
constructor create(source: Short4Storage);
function clone(): Short4Storage; override;
function indexOf(const item: short4): int;
function indexAcquire(const item: short4): int;
function readComponent(index: int): short4;
end;
Short8Storage = class sealed(Storage)
private
fldArray: short8_Array1d;
public
constructor create();
constructor create(source: Short8Storage);
function clone(): Short8Storage; override;
function indexOf(const item: short8): int;
function indexAcquire(const item: short8): int;
function readComponent(index: int): short8;
end;
Int2Storage = class sealed(Storage)
private
fldArray: int2_Array1d;
public
constructor create();
constructor create(source: Int2Storage);
function clone(): Int2Storage; override;
function indexOf(const item: int2): int;
function indexAcquire(const item: int2): int;
function readComponent(index: int): int2;
end;
Int4Storage = class sealed(Storage)
private
fldArray: int4_Array1d;
public
constructor create();
constructor create(source: Int4Storage);
function clone(): Int4Storage; override;
function indexOf(const item: int4): int;
function indexAcquire(const item: int4): int;
function readComponent(index: int): int4;
end;
Int8Storage = class sealed(Storage)
private
fldArray: int8_Array1d;
public
constructor create();
constructor create(source: Int8Storage);
function clone(): Int8Storage; override;
function indexOf(const item: int8): int;
function indexAcquire(const item: int8): int;
function readComponent(index: int): int8;
end;
LongStorage = class sealed(Storage)
private
fldArray: long_Array1d;
public
constructor create();
constructor create(source: LongStorage);
function clone(): LongStorage; override;
function indexOf(const item: long): int;
function indexAcquire(const item: long): int;
function readComponent(index: int): long;
end;
Long2Storage = class sealed(Storage)
private
fldArray: long2_Array1d;
public
constructor create();
constructor create(source: Long2Storage);
function clone(): Long2Storage; override;
function indexOf(const item: long2): int;
function indexAcquire(const item: long2): int;
function readComponent(index: int): long2;
end;
Long4Storage = class sealed(Storage)
private
fldArray: long4_Array1d;
public
constructor create();
constructor create(source: Long4Storage);
function clone(): Long4Storage; override;
function indexOf(const item: long4): int;
function indexAcquire(const item: long4): int;
function readComponent(index: int): long4;
end;
Long8Storage = class sealed(Storage)
private
fldArray: long8_Array1d;
public
constructor create();
constructor create(source: Long8Storage);
function clone(): Long8Storage; override;
function indexOf(const item: long8): int;
function indexAcquire(const item: long8): int;
function readComponent(index: int): long8;
end;
FloatStorage = class sealed(Storage)
private
fldArray: int_Array1d;
public
constructor create();
constructor create(source: FloatStorage);
function clone(): FloatStorage; override;
function indexOf(const item: float): int;
function indexAcquire(const item: float): int;
function readComponent(index: int): float;
end;
Float2Storage = class sealed(Storage)
private
fldArray: int2_Array1d;
public
constructor create();
constructor create(source: Float2Storage);
function clone(): Float2Storage; override;
function indexOf(const item: float2): int;
function indexAcquire(const item: float2): int;
function readComponent(index: int): float2;
end;
Float4Storage = class sealed(Storage)
private
fldArray: int4_Array1d;
public
constructor create();
constructor create(source: Float4Storage);
function clone(): Float4Storage; override;
function indexOf(const item: float4): int;
function indexAcquire(const item: float4): int;
function readComponent(index: int): float4;
end;
Float8Storage = class sealed(Storage)
private
fldArray: int8_Array1d;
public
constructor create();
constructor create(source: Float8Storage);
function clone(): Float8Storage; override;
function indexOf(const item: float8): int;
function indexAcquire(const item: float8): int;
function readComponent(index: int): float8;
end;
DoubleStorage = class sealed(Storage)
private
fldArray: long_Array1d;
public
constructor create();
constructor create(source: DoubleStorage);
function clone(): DoubleStorage; override;
function indexOf(const item: double): int;
function indexAcquire(const item: double): int;
function readComponent(index: int): double;
end;
Double2Storage = class sealed(Storage)
private
fldArray: long2_Array1d;
public
constructor create();
constructor create(source: Double2Storage);
function clone(): Double2Storage; override;
function indexOf(const item: double2): int;
function indexAcquire(const item: double2): int;
function readComponent(index: int): double2;
end;
Double4Storage = class sealed(Storage)
private
fldArray: long4_Array1d;
public
constructor create();
constructor create(source: Double4Storage);
function clone(): Double4Storage; override;
function indexOf(const item: double4): int;
function indexAcquire(const item: double4): int;
function readComponent(index: int): double4;
end;
Double8Storage = class sealed(Storage)
private
fldArray: long8_Array1d;
public
constructor create();
constructor create(source: Double8Storage);
function clone(): Double8Storage; override;
function indexOf(const item: double8): int;
function indexAcquire(const item: double8): int;
function readComponent(index: int): double8;
end;
RealStorage = class sealed(Storage)
private
fldArray: real_Array1d;
public
constructor create();
constructor create(source: RealStorage);
function clone(): RealStorage; override;
function indexOf(const item: real): int;
function indexAcquire(const item: real): int;
function readComponent(index: int): real;
end;
AnsiStringStorage = class sealed(Storage)
private type
Value_Array1d = specialize DynamicArray<Value>;
private
fldHashs: long_Array1d;
fldArray: Value_Array1d;
public
constructor create();
constructor create(source: AnsiStringStorage);
function clone(): AnsiStringStorage; override;
function indexOf(const item: AnsiString): int;
function indexAcquire(const item: AnsiString): int;
function readComponent(index: int): AnsiString;
end;
UnicodeStringStorage = class sealed(Storage)
private type
Value_Array1d = specialize DynamicArray<Value>;
private
fldHashs: long_Array1d;
fldArray: Value_Array1d;
public
constructor create();
constructor create(source: UnicodeStringStorage);
function clone(): UnicodeStringStorage; override;
function indexOf(const item: UnicodeString): int;
function indexAcquire(const item: UnicodeString): int;
function readComponent(index: int): UnicodeString;
end;
ArgumentArrayStorage = class sealed(Storage)
private
fldHashs: long_Array1d;
fldArray: ArgumentArray_Array1d;
public
constructor create();
function indexOf(const item: ArgumentArray): int;
function indexAcquire(const item: ArgumentArray): int;
function readComponent(index: int): ArgumentArray;
end;
LexemeSequence = class(AVTOOConstants, Measureable, ObjectArray, MutableObjectArray)
strict private
fldLength: int;
fldLexemes: int4_Array1d;
fldObjects: TObject_Array1d;
fldLongs: LongStorage;
fldReals: RealStorage;
fldFloats: FloatStorage;
fldDoubles: DoubleStorage;
fldStrings: UnicodeStringStorage;
procedure checkPosition(position: int);
procedure appendLexemeInternal(lineIndex, charIndex, lexemeKind, lexemeType, lexemeValue: int);
procedure appendLexemeInternal(lineIndex, charIndex, lexemeKind, lexemeType, lexemeValue: int; component: TObject);
function getLongs(): LongStorage;
function getReals(): RealStorage;
function getFloats(): FloatStorage;
function getDoubles(): DoubleStorage;
function getStrings(): UnicodeStringStorage;
public
constructor create();
destructor destroy; override;
procedure writeComponent(position: int; value: TObject); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: boolean); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: uchar); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: byte); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: short); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: int); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: long); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: float); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: double); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: real); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: UnicodeString); virtual;
procedure appendLexeme(lineIndex, charIndex, lexemeKind: int; component: TObject); virtual;
procedure insertLexeme(position, lineIndex, charIndex, lexemeKind: int); virtual;
procedure setLexeme(position, lineIndex, charIndex, lexemeKind: int); virtual;
procedure removeLexeme(position: int); virtual;
function readComponent(position: int): TObject; virtual;
function getLength(): int; virtual;
function getLineIndex(position: int): int; virtual;
function getCharIndex(position: int): int; virtual;
function getLexemeKind(position: int): int; virtual;
function getLexemeType(position: int): int; virtual;
function getLexemeLocation(position: int): int2; virtual;
function getLexemeInfo(position: int): int4; virtual;
function getLexemeBoolean(position: int): boolean; virtual;
function getLexemeChar(position: int): uchar; virtual;
function getLexemeInt(position: int): int; virtual;
function getLexemeLong(position: int): long; virtual;
function getLexemeFloat(position: int): float; virtual;
function getLexemeDouble(position: int): double; virtual;
function getLexemeReal(position: int): real; virtual;
function getLexemeString(position: int): UnicodeString; virtual;
end;
TextSource = class(LexemeSequence, InputAdapter, CharsetInputAdapter, Source)
private type
HashtableOfAnsiStringToClassType = specialize HashtableOfAnsiString<ClassType>;
private
fldLoaded: boolean;
fldText: UnicodeString;
fldFileName: UnicodeString;
fldRelativePath: UnicodeString;
fldTextSourcePath: UnicodeString;
fldInputStream: byte_Array1d;
fldLines: UnicodeStringArray;
fldOwner: Package;
fldDecoder: CharDecoder;
fldImportedTable: HashtableOfAnsiStringToClassType;
fldDeclaredTable: HashtableOfAnsiStringToClassType;
fldImportedArray: RequiredReflectItemArray;
fldDeclaredArray: ClassTypeArray;
fldParentLibrary: &Library;
fldParentProgramme: Programme;
protected
procedure setOwner(newOwner: Package); virtual;
public
constructor create(__parentLibrary: &Library; const __relativePath: UnicodeString);
destructor destroy; override;
procedure loadFromInputStream(stream: ByteReader); virtual;
procedure loadFromInputStream(stream: ByteReader; decoder: CharDecoder); virtual;
procedure loadFromFileStream(); virtual;
procedure parseInputStream(); virtual;
procedure appendDeclared(__declared: ClassType); virtual;
procedure appendImported(__imported: RequiredReflectItem); virtual;
function contains(&type: ClassType): boolean; virtual;
function isSameSource(anot: Source): boolean; virtual;
function getRelativePath(): UnicodeString;
function getContents(): Measureable;
function getDeclared(): ClassTypeArray;
function getParentLibrary(): &Library;
function getParentProgramme(): Programme;
function isImported(pack: Package): boolean;
function findImplicitlyImportedTypes(const specialSimpleName: AnsiString; enclosingClass: ClassType): ClassType_Array1d;
function getImportedType(const specialSimpleName: AnsiString): ClassType;
function getDeclaredType(const specialSimpleName: AnsiString): ClassType;
property relativePath: UnicodeString read fldRelativePath;
property contents: UnicodeStringArray read fldLines;
property declared: ClassTypeArray read fldDeclaredArray;
property parentLibrary: &Library read fldParentLibrary;
property parentProgramme: Programme read fldParentProgramme;
property text: UnicodeString read fldText;
property textSourcePath: UnicodeString read fldTextSourcePath;
property fileName: UnicodeString read fldFileName;
property imported: RequiredReflectItemArray read fldImportedArray;
property lines: UnicodeStringArray read fldLines;
property owner: Package read fldOwner write setOwner;
end;
BinarySource = class(AVTOORecompilable, Measureable, ObjectArray, MutableObjectArray, InputAdapter, Source)
private
fldLoaded: boolean;
fldRelativePath: UnicodeString;
fldInputStream: byte_Array1d;
fldObjects: TObject_Array1d;
fldChunks: ChunkArray;
fldDeclaredArray: ClassTypeArray;
fldParentLibrary: &Library;
fldParentProgramme: Programme;
public
constructor create(__parentLibrary: &Library; const __relativePath: UnicodeString);
destructor destroy; override;
procedure loadFromInputStream(stream: ByteReader); virtual;
procedure loadFromFileStream(); virtual;
procedure parseInputStream(); virtual;
procedure appendDeclared(__declared: ClassType); virtual;
procedure writeComponent(index: int; value: TObject); virtual;
function contains(&type: ClassType): boolean; virtual;
function isSameSource(anot: Source): boolean; virtual;
function getLength(): int; virtual;
function readComponent(index: int): TObject; virtual;
function getRelativePath(): UnicodeString;
function getContents(): Measureable;
function getDeclared(): ClassTypeArray;
function getParentLibrary(): &Library;
function getParentProgramme(): Programme;
property relativePath: UnicodeString read fldRelativePath;
property contents: ChunkArray read fldChunks;
property declared: ClassTypeArray read fldDeclaredArray;
property parentLibrary: &Library read fldParentLibrary;
property parentProgramme: Programme read fldParentProgramme;
property chunks: ChunkArray read fldChunks;
end;
Chunk = class sealed(&Object, DataInput, Measureable)
private
class function typeToString(&type: int): AnsiString; static;
public const
NEXT = CoInt.MIN_VALUE;
private
fldHash: int;
fldOffset: int;
fldLength: int;
fldTypeAsInt: int;
fldTypeAsString: AnsiString;
fldData: byte_Array1d;
fldInput: DataInput;
fldDriver: DataInputStream;
fldStream: ByteArrayInputStream; { ChunkByteArrayInputStream }
procedure setPosition(newPosition: int);
function getPosition(): int;
public
constructor create(__offset, __type: int; const __data: byte_Array1d; __hash: int);
destructor destroy; override;
procedure readFully(const dst: byte_Array1d);
procedure readFully(const dst: byte_Array1d; offset, length: int);
procedure readFully(const dst: uchar_Array1d);
procedure readFully(const dst: uchar_Array1d; offset, length: int);
function equals(anot: TObject): boolean; override;
function getHashCode(): long; override;
function toString(): AnsiString; override;
function getLength(): int;
function readBoolean(): boolean;
function readChar(): char;
function readUChar(): uchar;
function readUnsignedByte(): int;
function readUnsignedShort(): int;
function readByte(): int;
function readShort(): int;
function readInt(): int;
function readLong(): long;
function readFloat(): float;
function readDouble(): double;
function readReal(): real;
function readUTF(): UnicodeString;
function readln(): UnicodeString;
function read(): UnicodeString;
function readIndex(): int;
function readLabel(): int;
function readByte2(): int2;
function readShort2(): int2;
function readInt2(): int2;
function readByte4(): int4;
function readShort4(): int4;
function readInt4(): int4;
function readByte8(): int8;
function readShort8(): int8;
function readInt8(): int8;
function readLong2(): long2;
function readLong4(): long4;
function readLong8(): long8;
function readFloat2(): float2;
function readFloat4(): float4;
function readFloat8(): float8;
function readDouble2(): double2;
function readDouble4(): double4;
function readDouble8(): double8;
function dataOffsetToSourceOffset(offset: int): int;
function seek(offset: int; from: SeekFrom): int;
function available(): int;
function typeToString(): AnsiString;
property &type: int read fldTypeAsInt;
property offset: int read fldOffset;
property position: int read getPosition write setPosition;
end;
ElementStack = class sealed(&Object)
private
fldStackElements: int;
fldMaximumElements: int;
procedure setStackElements(newStackElements: int);
public
procedure reset();
procedure change(deltaElements: int);
property maximumElements: int read fldMaximumElements;
property stackElements: int read fldStackElements write setStackElements;
end;
FieldsMap = class sealed(&Object)
public const
MIN_FIELD_WIDTH = int($01);
MAX_FIELD_WIDTH = int($40);
private
fldFinalized: boolean;
fldBitMap: long_Array1d;
constructor create(const bitMap: long_Array1d);
function allocateAlignedField(fieldWidthInBytes, align: int): int;
public
constructor create();
procedure finalize();
function allocateDwordAlignedField(fieldWidthInBytes: int): int;
function allocateQwordAlignedField(fieldWidthInBytes: int): int;
function allocateXwordAlignedField(fieldWidthInBytes: int): int;
function allocateYwordAlignedField(fieldWidthInBytes: int): int;
function allocateZwordAlignedField(fieldWidthInBytes: int): int;
function clone(): FieldsMap;
property finalized: boolean read fldFinalized;
end;
Programme = class abstract(AVTOOService)
strict private type
HashtableOfRefCountInterfaceToLibrary = specialize Hashtable<RefCountInterface, &Library>;
HashtableOfAnsiStringToPackage = specialize HashtableOfAnsiString<Package>;
HashtableOfAnsiStringToType = specialize HashtableOfAnsiString<&Type>;
strict private
class procedure initSubtypes(const classes: ClassType_Array1d; length: int); static;
class function comparisonOrder(&type: &Type): int; static;
strict private
fldConstantFactoryIsUnlocked: boolean;
fldPrimitives: PrimitiveType_Array1d;
fldLanguagePackage: Package;
fldSystemPackage: Package;
fldNullType: NullType;
fldLibrariesArray: LibraryArray;
fldPackagesArray: PackageArray;
fldClassesArray: ClassTypeArray;
fldArraysArray: ArrayTypeArray;
fldTypesArray: TypeArray;
fldLibrariesTable: HashtableOfRefCountInterfaceToLibrary;
fldPackagesTable: HashtableOfAnsiStringToPackage;
fldTypesTable: HashtableOfAnsiStringToType;
fldConstantFactory: ConstantFactory;
fldMonitor: Mutex;
function createArrayType(componentType: &Type): ArrayType;
protected
procedure prefetchSupertypesForPrimitiveArray(&array: ArrayType); virtual; abstract;
procedure prefetchSupertypesForObjectArray(&array: ArrayType); virtual; abstract;
procedure prefetchSupertypesForReferenceArray(&array: ArrayType); virtual; abstract;
procedure createMembersForPrimitiveArray(&array: ArrayType); virtual; abstract;
procedure createMembersForObjectArray(&array: ArrayType); virtual; abstract;
procedure appendLibrary(item: &Library); virtual;
procedure appendPackage(item: Package); virtual;
procedure appendType(item: &Type); virtual;
procedure sortTypes();
procedure initSubtypes();
procedure createArrayTypes();
procedure createPrimitiveTypes();
procedure createMembersForArrayTypes();
procedure checkEssentialTypesPresence();
function compareTypes(type0, type1: &Type): int; virtual;
function essentialTypesNames(): AnsiString_Array1d; virtual;
function createLocal(isFinal: boolean; &type: &Type; const specialSimpleName: AnsiString; value: Constant; source: Source; declarationPosition: int): Local; virtual;
function newLibrary(fileSystem: FileSystem; const directoryPath: UnicodeString; application: boolean): &Library; virtual;
function newSource(parentLibrary: &Library; const relativePath: UnicodeString; const &type: AnsiString): Source; virtual;
function newPackage(parentLibrary: &Library; visibility: int; const specialCanonicalName: AnsiString; source: Source; declarationPosition, documentationPosition: int): Package; virtual;
function newClassType(parentPackage: Package; attributes: int; const specialSimpleName: AnsiString; source: Source; declarationPosition, documentationPosition: int;
const textSourcePath: UnicodeString): ClassType; virtual;
function newArrayType(componentType: &Type): ArrayType; virtual;
function newNestedUnion(parentItem: AllocatableFactory; declarationPosition, documentationPosition: int): Union; virtual;
function newNestedStruct(parentItem: AllocatableFactory; declarationPosition, documentationPosition: int): Struct; virtual;
function newStructField(parentItem: AllocatableFactory; &type: &Type; capacity: int; const specialSimpleName: AnsiString; declarationPosition, documentationPosition: int): Field; virtual;
function newStructField(parentType: ClassType; structOffset: int; &type: &Type; capacity: int; const specialSimpleName: AnsiString;
declarationPosition, documentationPosition: int): Field; virtual;
function newClassField(parentType: ClassType; attributes: int; &type: &Type; const specialSimpleName; declarationPosition, documentationPosition: int): Field; virtual;
function newStaticBlock(parentType: ClassType; attributes, declarationPosition, documentationPosition: int): ClassInit; virtual;
function newConstructor(parentType: ClassType; attributes: int; const arguments: Local_Array1d; declarationPosition, documentationPosition: int): InstInit; virtual;
function newMethod(parentType: ClassType; attributes: int; &type: &Type; const specialSimpleName: AnsiString; const arguments: Local_Array1d;
declarationPosition, documentationPosition: int): Method; virtual;
function newOperator(parentType: ClassType; attributes: int; &type: &Type; kind: int; const arguments: Local_Array1d; declarationPosition, documentationPosition: int): &Operator; virtual;
function newProperty(parentType: ClassType; attributes: int; &type: &Type; const specialSimpleName: AnsiString; declarationPosition, documentationPosition: int): &Property; virtual;
function newLocal(isFinal: boolean; &type: &Type; const specialSimpleName: AnsiString; value: Constant; source: Source; declarationPosition: int): Local; virtual;
function newCode(parentCallable: Callable): Code; virtual;
function newNode(parentCode: Code): Node; virtual;
public
constructor create();
destructor destroy; override;
procedure compile(); virtual; abstract;
procedure clear(); virtual;
function createLibrary(__fileSystem: FileSystem; const __directoryPath: UnicodeString; __application: boolean): &Library; virtual;
function isConstantFactoryUnlocked(): boolean;
function getConstantFactory(): ConstantFactory;
function getLibrary(fileSystem: FileSystem; const directoryPath: UnicodeString): &Library;
function getPackage(const specialCanonicalName: AnsiString): Package;
function getPackage(const specialCanonicalName: AnsiString; ignoreCase: boolean): Package;
function getSystemPackage(): Package;
function getLanguagePackage(): Package;
function getType(const specialCanonicalName: AnsiString): &Type;
function getNullType(): NullType;
function getPrimitiveType(kind: int): PrimitiveType;
function getClassType(const specialCanonicalName: AnsiString): ClassType;
function getArrayType(componentType: &Type): ArrayType;
function getArrayType(componentType: &Type; dimensionsCount: int): ArrayType;
function acquireArrayType(componentType: &Type): ArrayType;
function acquireArrayType(componentType: &Type; dimensionsCount: int): ArrayType;
property libraries: LibraryArray read fldLibrariesArray;
property packages: PackageArray read fldPackagesArray;
property types: TypeArray read fldTypesArray;
property arrays: ArrayTypeArray read fldArraysArray;
property classes: ClassTypeArray read fldClassesArray;
end;
ConstantFactory = class sealed(AVTOOConstants)
public const
KIND_BOOLEAN = int(22);
KIND_CHAR = CustomNumeric.KIND_CHAR;
KIND_UCHAR = CustomNumeric.KIND_UCHAR;
KIND_BYTE = CustomNumeric.KIND_BYTE;
KIND_BYTE2 = CustomNumeric.KIND_BYTE2;
KIND_BYTE4 = CustomNumeric.KIND_BYTE4;
KIND_BYTE8 = CustomNumeric.KIND_BYTE8;
KIND_SHORT = CustomNumeric.KIND_SHORT;
KIND_SHORT2 = CustomNumeric.KIND_SHORT2;
KIND_SHORT4 = CustomNumeric.KIND_SHORT4;
KIND_SHORT8 = CustomNumeric.KIND_SHORT8;
KIND_INT = CustomNumeric.KIND_INT;
KIND_INT2 = CustomNumeric.KIND_INT2;
KIND_INT4 = CustomNumeric.KIND_INT4;
KIND_INT8 = CustomNumeric.KIND_INT8;
KIND_LONG = CustomNumeric.KIND_LONG;
KIND_LONG2 = CustomNumeric.KIND_LONG2;
KIND_LONG4 = CustomNumeric.KIND_LONG4;
KIND_LONG8 = CustomNumeric.KIND_LONG8;
KIND_FLOAT = CustomNumeric.KIND_FLOAT;
KIND_FLOAT2 = CustomNumeric.KIND_FLOAT2;
KIND_FLOAT4 = CustomNumeric.KIND_FLOAT4;
KIND_FLOAT8 = CustomNumeric.KIND_FLOAT8;
KIND_DOUBLE = CustomNumeric.KIND_DOUBLE;
KIND_DOUBLE2 = CustomNumeric.KIND_DOUBLE2;
KIND_DOUBLE4 = CustomNumeric.KIND_DOUBLE4;
KIND_DOUBLE8 = CustomNumeric.KIND_DOUBLE8;
KIND_REAL = CustomNumeric.KIND_REAL;
strict private
fldPackageType: ClassType;
fldStringType: ClassType;
fldClassType: ClassType;
fldFalseValue: Constant;
fldTrueValue: Constant;
fldNullValue: Constant;
fldPrimitives: PrimitiveType_Array1d;
private
procedure loadDataFrom(source: Programme);
procedure checkUnlocked();
procedure clear();
public
constructor create();
function createNull(): Constant;
function createBoolean(const value: boolean): Constant;
function createIntegral(const value: int): Constant;
function createChar(const value: uchar): Constant;
function createByte(const value: byte): Constant;
function createByte2(const value: byte2): Constant;
function createByte4(const value: byte4): Constant;
function createByte8(const value: byte8): Constant;
function createShort(const value: short): Constant;
function createShort2(const value: short2): Constant;
function createShort4(const value: short4): Constant;
function createShort8(const value: short8): Constant;
function createInt(const value: int): Constant;
function createInt2(const value: int2): Constant;
function createInt4(const value: int4): Constant;
function createInt8(const value: int8): Constant;
function createLong(const value: long): Constant;
function createLong2(const value: long2): Constant;
function createLong4(const value: long4): Constant;
function createLong8(const value: long8): Constant;
function createFloat(const value: float): Constant;
function createFloat2(const value: float2): Constant;
function createFloat4(const value: float4): Constant;
function createFloat8(const value: float8): Constant;
function createDouble(const value: double): Constant;
function createDouble2(const value: double2): Constant;
function createDouble4(const value: double4): Constant;
function createDouble8(const value: double8): Constant;
function createReal(const value: real): Constant;
function createString(const value: UnicodeString): Constant;
function createPackage(value: Package): Constant;
function createClass(value: &Type): Constant;
function createFrom(source: TObject): Constant;
function createFrom(source: IUnknown): Constant;
end;
ProgrammeItem = class abstract(AVTOOConstants, Measureable, ObjectArray)
strict private type
HashtableOfAnsiStringToProgrammeItem = specialize HashtableOfAnsiString<ProgrammeItem>;
strict private
fldChildItemsLength: int;
fldSpecialSimpleName: AnsiString;
fldChildItemsStore: ProgrammeItem_Array1d;
fldChildItemsTable: HashtableOfAnsiStringToProgrammeItem;
fldNextItem: ProgrammeItem;
fldParentItem: ProgrammeItem;
fldParentProgramme: Programme;
private
function isOwner(): boolean; virtual;
protected
procedure insertChildItem(item: ProgrammeItem; position: int); virtual;
procedure removeChildItem(item: ProgrammeItem); virtual;
procedure appendChildItem(item: ProgrammeItem);
public
constructor create(__parentProgramme: Programme; const __specialSimpleName: AnsiString);
constructor create(__parentItem: ProgrammeItem; const __specialSimpleName: AnsiString);
destructor destroy; override;
function toString(): AnsiString; override;
function getLength(): int;
function readComponent(index: int): ProgrammeItem;
function readComponent(index: int): TObject;
function getSpecialSimpleName(): AnsiString;
function getChildItem(const __specialSimpleName: AnsiString): ProgrammeItem;
function getChildItem(const __specialSimpleName: AnsiString; __ignoreCase: boolean): ProgrammeItem;
function getNextItem(): ProgrammeItem;
function getParentItem(): ProgrammeItem;
function getParentProgramme(): Programme;
property specialSimpleName: AnsiString read fldSpecialSimpleName;
property nextItem: ProgrammeItem read fldNextItem;
property parentItem: ProgrammeItem read fldParentItem;
property parentProgramme: Programme read fldParentProgramme;
end;
&Library = class(ProgrammeItem)
strict private
fldApplication: boolean;
fldDirectoryPath: UnicodeString;
fldFileSystem: FileSystem;
fldSourcesArray: SourceArray;
fldClassesArray: ClassTypeArray;
protected
procedure insertChildItem(item: ProgrammeItem; position: int); override;
procedure appendClass(item: ClassType); virtual;
procedure appendSource(item: Source); virtual;
public
constructor create(__parentProgramme: Programme; __fileSystem: FileSystem; const __directoryPath: UnicodeString; __application: boolean);
destructor destroy; override;
function createSource(const __relativePath: UnicodeString; const __type: AnsiString): Source; virtual;
function createPackage(__visibility: int; const __specialCanonicalName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int): Package; virtual;
function readComponent(index: int): Package;
function getChildPackage(const specialCanonicalName: AnsiString): Package;
function getChildPackage(const specialCanonicalName: AnsiString; ignoreCase: boolean): Package;
property application: boolean read fldApplication;
property directoryPath: UnicodeString read fldDirectoryPath;
property fileSystem: platform.independent.filesystem.FileSystem read fldFileSystem;
property classes: ClassTypeArray read fldClassesArray;
property sources: SourceArray read fldSourcesArray;
end;
TableItem = class abstract(ProgrammeItem)
strict private
fldDeclarationPosition: int;
fldDocumentationPosition: int;
fldImplementationPosition: int;
fldFasmSimpleName: AnsiString;
fldRecompilableName: AnsiString;
fldSource: Source;
fldParentLibrary: &Library;
fldDocumentationContent: LexemeSequence;
protected
function composeRecompilableName(): AnsiString; virtual; abstract;
function composeFasmSimpleName(): AnsiString; virtual; abstract;
public
constructor create(__parentItem: ProgrammeItem; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int);
procedure afterConstruction(); override;
procedure setImplementationPosition(newImplementationPosition: int);
function getImplementationPosition(): int;
function getDeclarationPosition(): int;
function getDocumentationPosition(): int;
function getFasmSimpleName(): AnsiString;
function getRecompilableName(): AnsiString;
function getDocumentationContent(): LexemeSequence;
function getSource(): Source;
function getParentLibrary(): &Library;
property implementationPosition: int read fldImplementationPosition write fldImplementationPosition;
property declarationPosition: int read fldDeclarationPosition;
property documentationPosition: int read fldDocumentationPosition;
property fasmSimpleName: AnsiString read fldFasmSimpleName;
property recompilableName: AnsiString read fldRecompilableName;
property documentationContent: LexemeSequence read fldDocumentationContent;
property source: Source read fldSource;
property parentLibrary: &Library read fldParentLibrary;
end;
ReflectItem = class abstract(TableItem)
strict private
fldVisibility: int;
fldAttributes: int;
fldFasmFullName: AnsiString;
protected
function composeRecompilableName(): AnsiString; override; abstract;
function composeFasmSimpleName(): AnsiString; override; abstract;
function composeFasmFullName(): AnsiString; virtual; abstract;
function AllocatableFactory_inherited_createNestedUnion(__declarationPosition, __documentationPosition: int): Union;
function AllocatableFactory_inherited_createNestedStruct(__declarationPosition, __documentationPosition: int): Struct;
function AllocatableFactory_inherited_createStructField(__type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field;
public
constructor create(__parentItem: ProgrammeItem; __attributes: int; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int);
procedure afterConstruction(); override;
function isVisibleFrom(__type: ClassType): boolean; virtual; abstract;
function isFinal(): boolean;
function isAbstract(): boolean;
function getVisibility(): int;
function getAttributes(): int;
function getFasmFullName(): AnsiString;
property visibility: int read fldVisibility;
property attributes: int read fldAttributes;
property fasmFullName: AnsiString read fldFasmFullName;
end;
RequiredReflectItem = class abstract(ReflectItem)
strict private
fldSpecialCanonicalName: AnsiString;
fldFasmFileName: UnicodeString;
protected
function composeRecompilableName(): AnsiString; override; abstract;
function composeFasmSimpleName(): AnsiString; override; abstract;
function composeFasmFullName(): AnsiString; override; abstract;
function composeFasmFileName(): UnicodeString; virtual; abstract;
public
constructor create(__parentItem: ProgrammeItem; __attributes: int; const __specialSimpleName, __specialCanonicalName: AnsiString;
__source: Source; __declarationPosition, __documentationPosition: int);
procedure afterConstruction(); override;
function isVisibleFrom(__type: ClassType): boolean; override; abstract;
function toString(): AnsiString; override;
property specialCanonicalName: AnsiString read fldSpecialCanonicalName;
property fasmFileName: UnicodeString read fldFasmFileName;
end;
Package = class(RequiredReflectItem)
protected
procedure insertChildItem(item: ProgrammeItem; position: int); override;
function composeRecompilableName(): AnsiString; override;
function composeFasmSimpleName(): AnsiString; override;
function composeFasmFullName(): AnsiString; override;
function composeFasmFileName(): UnicodeString; override;
public
constructor create(__parentLibrary: &Library; __visibility: int; const __specialCanonicalName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int);
function isVisibleFrom(__type: ClassType): boolean; override;
function createClassType(__attributes: int; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int;
const __textSourcePath: UnicodeString): ClassType; virtual;
function readComponent(index: int): &Type;
function getChildType(const __specialSimpleName: AnsiString): &Type;
function getChildType(const __specialSimpleName: AnsiString; __ignoreCase: boolean): &Type;
end;
&Type = class abstract(RequiredReflectItem)
strict private
class function getSpecialCanonicalName(__parentItem: RequiredReflectItem; const __specialSimpleName: AnsiString): AnsiString; static;
strict private
fldFieldWidth: int;
fldStackElements: int;
fldParentPackage: Package;
protected
function composeRecompilableName(): AnsiString; override; abstract;
function composeFasmSimpleName(): AnsiString; override; abstract;
function composeFasmFullName(): AnsiString; override; abstract;
function composeFasmFileName(): UnicodeString; override; abstract;
function computeFieldWidth(): int; virtual; abstract;
function getKind(): int; virtual; abstract;
public
constructor create(__parentPackage: Package; __attributes: int; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int);
procedure afterConstruction(); override;
procedure makeCompilable(); virtual;
function isAssignableFrom(anot: &Type): boolean; virtual; abstract;
function isConvertableFrom(anot: &Type): boolean; virtual; abstract;
function isCompatibleWith(anot: &Type): boolean; virtual; abstract;
function getScalarCommonType(anot: &Type): &Type; virtual; abstract;
function getVectorCommonType(anot: &Type): &Type; virtual; abstract;
function isVisibleFrom(__type: ClassType): boolean; override;
function isCompilable(): boolean; virtual;
function isNull(): boolean; virtual;
function isArray(): boolean; virtual;
function isClass(): boolean; virtual;
function isStruct(): boolean; virtual;
function isService(): boolean; virtual;
function isInterface(): boolean; virtual;
function isHelper(): boolean; virtual;
function isPrimitive(): boolean; virtual;
function isVoid(): boolean; virtual;
function isBoolean(): boolean; virtual;
function isChar(): boolean; virtual;
function isInt(): boolean; virtual;
function isLong(): boolean; virtual;
function isVector(): boolean; virtual;
function isNumeric(): boolean; virtual;
function isFloating(): boolean; virtual;
function isStackable(): boolean; virtual;
function toStackable(): int; virtual;
function getRealType(): &Type; virtual;
property kind: int read getKind;
property fieldWidth: int read fldFieldWidth;
property stackElements: int read fldStackElements;
property parentPackage: Package read fldParentPackage;
end;
PrimitiveType = class sealed(&Type)
public
class function recompilableNameToKind(const name: AnsiString): int; static;
class function kindToSpecialSimpleName(__kind: int): AnsiString; static;
class function kindToRecompilableName(__kind: int): AnsiString; static;
strict private
fldKind: int;
fldVectorLength: int;
fldVectorBaseKind: int;
fldVectorBaseType: PrimitiveType;
function isSameType(anot: &Type): boolean;
function getCommonType(__anot: &Type; __isVector: boolean): PrimitiveType;
protected
function getKind(): int; override;
function computeFieldWidth(): int; override;
function composeRecompilableName(): AnsiString; override;
function composeFasmSimpleName(): AnsiString; override;
function composeFasmFullName(): AnsiString; override;
function composeFasmFileName(): UnicodeString; override;
public
constructor create(__parentPackage: Package; __kind: int);
function isAssignableFrom(anot: &Type): boolean; override;
function isConvertableFrom(anot: &Type): boolean; override;
function isCompatibleWith(anot: &Type): boolean; override;
function isPrimitive(): boolean; override;
function isVoid(): boolean; override;
function isBoolean(): boolean; override;
function isChar(): boolean; override;
function isInt(): boolean; override;
function isLong(): boolean; override;
function isVector(): boolean; override;
function isNumeric(): boolean; override;
function isFloating(): boolean; override;
function isStackable(): boolean; override;
function toStackable(): int; override;
function getScalarCommonType(anot: &Type): &Type; override;
function getVectorCommonType(anot: &Type): &Type; override;
property vectorLength: int read fldVectorLength;
property vectorBaseKind: int read fldVectorBaseKind;
property vectorBaseType: PrimitiveType read fldVectorBaseType;
end;
ReferenceType = class abstract(&Type)
strict private
function getCommonType(anot: &Type): ReferenceType;
protected
function getCommonType(anot: ReferenceType): ReferenceType; virtual; abstract;
function composeRecompilableName(): AnsiString; override;
function composeFasmSimpleName(): AnsiString; override;
function composeFasmFullName(): AnsiString; override;
function composeFasmFileName(): UnicodeString; override;
function computeFieldWidth(): int; override; final;
function getKind(): int; override; final;
public
function isAssignableFrom(anot: &Type): boolean; override; abstract;
function isCompatibleWith(anot: &Type): boolean; override; abstract;
function isConvertableFrom(anot: &Type): boolean; override; final;
function getScalarCommonType(anot: &Type): &Type; override; final;
function getVectorCommonType(anot: &Type): &Type; override; final;
end;
ClassType = class(ReferenceType, AllocatableFactory)
strict private
class function checkArguments(const arguments: Local_Array1d): Local_Array1d; static;
strict private
fldStructMarked: boolean;
fldStructSize: int;
fldInstanceSize: int;
fldVirtualLength: int;
fldServiceLength: int;
fldHelperForPosition: int;
fldSuperclassPosition: int;
fldSuperservicesLength: int;
fldNativeCallablesCounter: int;
fldUserMembersInsertionPosition: int;
fldTextSourcePath: UnicodeString;
fldSuperservicesPositions: int_Array1d;
fldVirtualCallables: Callable_Array1d;
fldServiceCallables: Callable_Array1d;
fldSuperservicesTypes: ClassType_Array1d;
fldSuperclassType: ClassType;
fldHelperForType: ClassType;
fldDefaultConstructor: InstInit;
fldStaticBlock: ClassInit;
fldFieldsMap: FieldsMap;
fldThisArgument: Local;
fldHelpers: ClassTypeArray;
fldSubtypes: ClassTypeArray;
function createThisArgument(): Local;
private
procedure initSubtypes();
property thisArgument: Local read fldThisArgument;
protected
procedure insertChildItem(item: ProgrammeItem; position: int); override;
procedure removeChildItem(item: ProgrammeItem); override;
function composeRecompilableName(): AnsiString; override;
function composeFasmSimpleName(): AnsiString; override;
function composeFasmFullName(): AnsiString; override;
function composeFasmFileName(): UnicodeString; override;
function getCommonType(anot: ReferenceType): ReferenceType; override;
public
constructor create(__parentPackage: Package; __attributes: int; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int;
const __textSourcePath: UnicodeString);
destructor destroy; override;
procedure removeStaticBlock(); virtual;
procedure initHelperFor(target: ClassType; position: int); virtual;
procedure initSuperclass(superclass: ClassType; position: int); virtual;
procedure appendSuperservice(superservice: ClassType; position: int); virtual;
procedure appendImpliedSuperservices(); virtual;
procedure markupClass();
procedure markupStruct();
function isAssignableFrom(anot: &Type): boolean; override;
function isCompatibleWith(anot: &Type): boolean; override;
function isClass(): boolean; override;
function isStruct(): boolean; override;
function isService(): boolean; override;
function isInterface(): boolean; override;
function isHelper(): boolean; override;
function getRealType(): ClassType; override;
function createNestedUnion(__declarationPosition, __documentationPosition: int): Union; virtual;
function createNestedStruct(__declarationPosition, __documentationPosition: int): Struct; virtual;
function createStructField(__type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field; virtual;
function isFreeThrowableType(): boolean; virtual;
function createStructField(__structOffset: int; __type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field; virtual;
function createClassField(__attributes: int; __type: &Type; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field; virtual;
function createStaticBlock(__attributes, __declarationPosition, __documentationPosition: int): ClassInit; virtual;
function createConstructor(__attributes: int; const __arguments: Local_Array1d; __declarationPosition, __documentationPosition: int): InstInit; virtual;
function createMethod(__attributes: int; __type: &Type; const __specialSimpleName: AnsiString; const __arguments: Local_Array1d;
__declarationPosition, __documentationPosition: int): Method; virtual;
function createOperator(__attributes: int; __type: &Type; __kind: int; const __arguments: Local_Array1d; __declarationPosition, __documentationPosition: int): &Operator; virtual;
function createProperty(__attributes: int; __type: &Type; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): &Property; virtual;
function hasNativeCallables(): boolean;
function isSuperclass(&type: ClassType): boolean;
function isSuperclass(const __specialCanonicalName: AnsiString): boolean;
function isSuperservice(&type: ClassType): boolean;
function isSuperservice(const __specialCanonicalName: AnsiString): boolean;
function getHelperForPosition(): int;
function getSuperclassPosition(): int;
function getSuperservicesLength(): int;
function getSuperservicePositionAt(index: int): int;
function getSuperserviceIndex(&type: ClassType): int;
function virtualCallables(): Callable_Array1d;
function serviceCallables(): Callable_Array1d;
function findFieldoids(const __specialSimpleName: AnsiString; __areVisibleFrom: ClassType): Fieldoid_Array1d;
function findInterrupts(const __specialSimpleName: AnsiString; __areVisibleFrom: ClassType): Callable_Array1d;
function findConstructors(const __arguments: Type_Array1d; __areVisibleFrom: ClassType): InstInit_Array1d;
function findMethods(const __specialSimpleName: AnsiString; const __arguments: Type_Array1d; __areVisibleFrom: ClassType): Method_Array1d;
function findOperators(__kind: int; const __arguments: Type_Array1d; __areVisibleFrom: ClassType): Operator_Array1d;
function resolveName(const __specialSimpleName: AnsiString; __isVisibleFrom: ClassType; __isVisibleOnly: boolean): Member;
function readComponent(index: int): Member;
function readComponent(index: int): ProgrammeItem;
function readComponent(index: int): TObject;
function getChildMember(const __specialSimpleName: AnsiString): Member;
function getChildMember(const __specialSimpleName: AnsiString; __ignoreCase: boolean): Member;
function getChildFieldoid(const __specialSimpleName: AnsiString): Fieldoid;
function getChildCallable(const __specialSimpleName: AnsiString; const __arguments: Type_Array1d): Callable;
function getChildCallable(const __specialSimpleName: AnsiString; const __arguments: TypedItem_Array1d): Callable;
function getDefaultConstructor(): InstInit;
function getStaticBlock(): ClassInit;
function getHelperForType(): ClassType;
function getSuperclassType(): ClassType;
function getSuperserviceTypeAt(index: int): ClassType;
property structSize: int read fldStructSize;
property instanceSize: int read fldInstanceSize;
property textSourcePath: UnicodeString read fldTextSourcePath;
end;
ArrayType = class(ClassType)
strict private
fldCompilable: boolean;
fldDimensionsCount: int;
fldComponentType: &Type;
fldCellType: &Type;
function composeFasmDimensionsCount(): AnsiString;
protected
function composeRecompilableName(): AnsiString; override;
function composeFasmSimpleName(): AnsiString; override;
function composeFasmFullName(): AnsiString; override;
function composeFasmFileName(): UnicodeString; override;
public
constructor create(__componentType: &Type);
procedure makeCompilable(); override;
function isCompilable(): boolean; override;
function isAssignableFrom(anot: &Type): boolean; override;
function isCompatibleWith(anot: &Type): boolean; override;
function isVisibleFrom(__type: ClassType): boolean; override;
function isArray(): boolean; override;
property dimensionsCount: int read fldDimensionsCount;
property componentType: &Type read fldComponentType;
property cellType: &Type read fldCellType;
end;
NullType = class sealed(ReferenceType)
protected
function getCommonType(anot: ReferenceType): ReferenceType; override;
public
constructor create();
function isCompilable(): boolean; override;
function isAssignableFrom(anot: &Type): boolean; override;
function isCompatibleWith(anot: &Type): boolean; override;
function isNull(): boolean; override;
end;
Member = class abstract(ReflectItem)
strict private
class function isClassTypeAssignable(&type, anot: ClassType): boolean; static;
class function getSource(item: TableItem): Source; static;
strict private
fldParentType: ClassType;
fldParentPackage: Package;
protected
function composeRecompilableName(): AnsiString; override; abstract;
function composeFasmSimpleName(): AnsiString; override; abstract;
function composeFasmFullName(): AnsiString; override; abstract;
function Fieldoid_inherited_toString(): AnsiString;
function Fieldoid_inherited_composeFasmFullName(): AnsiString;
public
constructor create(__parentType: ClassType; __attributes: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
function isVisibleFrom(__type: ClassType): boolean; override;
function isVisibleFrom(__type, __impliedParentType: ClassType): boolean; virtual;
function isSpecial(): boolean; virtual;
function isStatic(): boolean;
function isSynthetic(): boolean;
function getParentType(): ClassType;
function getParentPackage(): Package;
property parentType: ClassType read fldParentType;
property parentPackage: Package read fldParentPackage;
end;
AllocatableMember = class abstract(Member)
strict private
class function getParentType(item: TObject): ClassType; static;
strict private
fldStructOffset: int;
fldInstanceOffset: int;
fldParentNested: NestedAllocatableMember;
protected
function composeRecompilableName(): AnsiString; override; abstract;
function composeFasmSimpleName(): AnsiString; override; abstract;
function composeFasmFullName(): AnsiString; override; abstract;
function computeStructOffset(currentOffset: int): int; virtual;
function computeInstanceOffset(currentOffset: int; fieldsMap: FieldsMap): int; virtual;
public
constructor create(__parentItem: AllocatableFactory; __attributes: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
property structOffset: int read fldStructOffset;
property instanceOffset: int read fldInstanceOffset;
property parentNested: NestedAllocatableMember read fldParentNested;
end;
Field = class(AllocatableMember, ValuedItem, TypedItem, TypedMember, Fieldoid)
public const
NOT_COMPUTED = int(-1);
COMPUTING = int(0);
COMPUTED = int(1);
strict private
fldHasStructOffset: boolean;
fldCapacity: int;
fldState: int;
fldFasmStructName: AnsiString;
fldValue: Constant;
fldType: &Type;
protected
function computeStructOffset(currentOffset: int): int; override;
function computeInstanceOffset(currentOffset: int; fieldsMap: FieldsMap): int; override;
function composeRecompilableName(): AnsiString; override;
function composeFasmSimpleName(): AnsiString; override;
function composeFasmFullName(): AnsiString; override;
function composeFasmStructName(): AnsiString; virtual;
public
constructor create(__parentItem: AllocatableFactory; __type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
constructor create(__parentType: ClassType; __structOffset: int; __type: &Type; __capacity: int; const __specialSimpleName: AnsiString;
__declarationPosition, __documentationPosition: int);
constructor create(__parentType: ClassType; __attributes: int; __type: &Type; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
procedure afterConstruction(); override;
procedure openComputing(); virtual;
procedure closeComputing(); virtual;
procedure setComputedValue(__value: Constant); virtual;
function toString(): AnsiString; override;
function isConstant(): boolean;
function getValue(): Constant;
function getType(): &Type;
property capacity: int read fldCapacity;
property state: int read fldState;
property fasmStructName: AnsiString read fldFasmStructName;
property &type: &Type read fldType;
property value: Constant read fldValue;
end;
NestedAllocatableMember = class abstract(AllocatableMember, AllocatableFactory)
private
function isOwner(): boolean; override;
protected
procedure insertChildItem(item: ProgrammeItem; position: int); override;
function computeInstanceOffset(currentOffset: int; fieldsMap: FieldsMap): int; override;
function composeRecompilableName(): AnsiString; override;
function composeFasmSimpleName(): AnsiString; override;
function composeFasmFullName(): AnsiString; override;
public
constructor create(__parentItem: AllocatableFactory; __declarationPosition, __documentationPosition: int);
function createNestedUnion(__declarationPosition, __documentationPosition: int): Union; virtual;
function createNestedStruct(__declarationPosition, __documentationPosition: int): Struct; virtual;
function createStructField(__type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field; virtual;
function readComponent(index: int): AllocatableMember;
function readComponent(index: int): ProgrammeItem;
function readComponent(index: int): TObject;
function getChildMember(const __specialSimpleName: AnsiString): AllocatableMember;
function getChildMember(const __specialSimpleName: AnsiString; __ignoreCase: boolean): AllocatableMember;
end;
Struct = class(NestedAllocatableMember)
protected
function computeStructOffset(currentOffset: int): int; override;
end;
Union = class(NestedAllocatableMember)
protected
function computeStructOffset(currentOffset: int): int; override;
end;
OverriddableMember = class abstract(Member, TypedItem, TypedMember)
public const
CURRENT_TYPE = int(1);
SUPERCLASSES = int(2);
SUPERTYPES = int(4);
strict private
fldType: &Type;
function directOverridesIn(&type: ClassType): OverriddableMember;
protected
function composeFasmSimpleName(): AnsiString; override; abstract;
function composeFasmFullName(): AnsiString; override; abstract;
function composeRecompilableName(): AnsiString; override;
public
constructor create(__parentType: ClassType; __attributes: int; __type: &Type; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
function isOverrides(anot: OverriddableMember): boolean; virtual;
function getType(): &Type;
function overridesIn(__type: ClassType; __place: int): OverriddableMember;
property &type: &Type read fldType;
end;
Callable = class abstract(OverriddableMember)
strict private type
HashtableOfAnsiStringToLocal = specialize HashtableOfAnsiString<Local>;
strict private
fldVirtualIndex: int;
fldServiceIndex: int;
fldArgumentsStore: Local_Array1d;
fldArgumentsArray: ArgumentArray;
fldArgumentsTable: HashtableOfAnsiStringToLocal;
fldThisArgument: Local;
fldCode: Code;
function createCode(): Code;
private
procedure setVirtualIndex(newVirtualIndex: int);
procedure setServiceIndex(newServiceIndex: int);
protected
function composeFasmSimpleName(): AnsiString; override; abstract;
function composeFasmFullName(): AnsiString; override;
public
constructor create(__parentType: ClassType; __attributes: int; __type: &Type; const __specialSimpleName: AnsiString; const __arguments: Local_Array1d;
__declarationPosition, __documentationPosition: int);
destructor destroy; override;
function isOverrides(anot: OverriddableMember): boolean; override;
function canThrown(): boolean; virtual;
function canThrown(throwable: ClassType): boolean; virtual;
function isNative(): boolean;
function isInterrupt(): boolean;
function isSynchronized(): boolean;
function isArgument(argument: Local): boolean;
function isIdentityArguments(member: Callable): boolean;
function isIdentityArguments(const arguments: Type_Array1d): boolean;
function isIdentityArguments(const arguments: TypedItem_Array1d): boolean;
function isAssignableArguments(const arguments: Type_Array1d): boolean;
function isConvertableArguments(const arguments: Type_Array1d): boolean;
function getArgument(const __specialSimpleName: AnsiString): Local;
property virtualIndex: int read fldVirtualIndex;
property serviceIndex: int read fldServiceIndex;
property arguments: ArgumentArray read fldArgumentsArray;
property code: Code read fldCode;
end;
Method = class(Callable)
strict private
fldThrowablesLength: int;
fldThrowablesPositions: int_Array1d;
fldThrowablesTypes: ClassType_Array1d;
fldFirstNonFreeThrowableType: ClassType;
protected
function composeFasmSimpleName(): AnsiString; override;
public
procedure appendThrowable(throwable: ClassType; position: int); virtual;
function canThrown(): boolean; override;
function canThrown(throwable: ClassType): boolean; override;
function toString(): AnsiString; override;
function isThrows(throwable: ClassType): boolean;
function getThrowablesLength(): int;
function getThrowablePositionAt(index: int): int;
function getThrowableTypeAt(index: int): ClassType;
function firstNonFreeThrowableType(): ClassType;
end;
SpecialMethod = class abstract(Method)
strict private
class function getVoidType(item: ProgrammeItem): &Type; static;
protected
function composeFasmSimpleName(): AnsiString; override; abstract;
public
constructor create(__parentType: ClassType; __attributes: int; const __specialSimpleName: AnsiString; const __arguments: Local_Array1d;
__declarationPosition, __documentationPosition: int);
function isSpecial(): boolean; override; final;
function isOverrides(anot: OverriddableMember): boolean; override; final;
end;
ClassInit = class(SpecialMethod)
protected
function composeFasmSimpleName(): AnsiString; override;
public
constructor create(__parentType: ClassType; __attributes, __declarationPosition, __documentationPosition: int);
procedure appendThrowable(throwable: ClassType; position: int); override;
function toString(): AnsiString; override;
end;
InstInit = class(SpecialMethod)
protected
function composeFasmSimpleName(): AnsiString; override;
public
constructor create(__parentType: ClassType; __attributes: int; const __arguments: Local_Array1d; __declarationPosition, __documentationPosition: int);
function toString(): AnsiString; override;
end;
&Operator = class(Callable)
strict private
class function kindToInternalName(kind: int): AnsiString; static;
public
class function symbolToKind(const __symbol: AnsiString): int; static;
class function specialSimpleNameToKind(const name: AnsiString): int; static;
class function kindToSymbol(kind: int): AnsiString; static;
class function kindToSpecialSimpleName(kind: int): AnsiString; static;
strict private
fldKind: int;
fldSymbol: AnsiString;
protected
function composeFasmSimpleName(): AnsiString; override;
public
constructor create(__parentType: ClassType; __attributes: int; __type: &Type; __kind: int; const __arguments: Local_Array1d; __declarationPosition, __documentationPosition: int);
function toString(): AnsiString; override;
property kind: int read fldKind;
property symbol: AnsiString read fldSymbol;
end;
&Property = class(OverriddableMember, Fieldoid)
strict private
fldReadSynthetic: Method;
fldWriteSynthetic: Method;
fldIndexSynthetic: Method;
fldStoredSynthetic: Method;
fldReadMember: TypedMember;
fldWriteMember: TypedMember;
fldIndexMember: TypedMember;
fldStoredMember: TypedMember;
fldReadConstant: Constant;
fldIndexConstant: Constant;
fldStoredConstant: Constant;
private
procedure setReadSynthetic(newReadSynthetic: Method);
procedure setWriteSynthetic(newWriteSynthetic: Method);
procedure setIndexSynthetic(newIndexSynthetic: Method);
procedure setStoredSynthetic(newStoredSynthetic: Method);
protected
function composeFasmSimpleName(): AnsiString; override;
function composeFasmFullName(): AnsiString; override;
public
function toString(): AnsiString; override;
function hasRead(): boolean;
function hasWrite(): boolean;
function hasIndex(): boolean;
function hasStored(): boolean;
property readMember: TypedMember read fldReadMember write fldReadMember;
property writeMember: TypedMember read fldWriteMember write fldWriteMember;
property indexMember: TypedMember read fldIndexMember write fldIndexMember;
property storedMember: TypedMember read fldStoredMember write fldStoredMember;
property readConstant: Constant read fldReadConstant write fldReadConstant;
property indexConstant: Constant read fldIndexConstant write fldIndexConstant;
property storedConstant: Constant read fldStoredConstant write fldStoredConstant;
property readSynthetic: Method read fldReadSynthetic;
property writeSynthetic: Method read fldWriteSynthetic;
property indexSynthetic: Method read fldIndexSynthetic;
property storedSynthetic: Method read fldStoredSynthetic;
end;
Local = class(TableItem, ValuedItem, TypedItem)
strict private
fldFinal: boolean;
fldType: &Type;
fldValue: Constant;
protected
function composeRecompilableName(): AnsiString; override;
function composeFasmSimpleName(): AnsiString; override;
public
constructor create(__isFinal: boolean; __type: &Type; const __specialSimpleName: AnsiString; __value: Constant; __source: Source; __declarationPosition: int);
function toString(): AnsiString; override;
function isConstant(): boolean;
function getValue(): Constant;
function getType(): &Type;
function isFinal(): boolean;
property &type: &Type read fldType;
property value: Constant read fldValue;
end;
CallableItem = class abstract(&Object, DataHolder, Measureable, ObjectArray)
strict private
fldPosition: int;
fldLocation: int2;
fldSequence: LexemeSequence;
protected
procedure setPosition(newPosition: int); virtual;
function getNodeAt(index: int): Node; virtual; abstract;
public
constructor create(__sequence: LexemeSequence);
procedure replaceJumpNode(oldJumpNode, newJumpNode: Node); virtual; abstract;
function isEmpty(): boolean; virtual; abstract;
function getLength(): int; virtual; abstract;
function hasJumpsTo(node: Node): boolean; virtual; abstract;
function readComponent(index: int): Node;
function readComponent(index: int): TObject;
property position: int read fldPosition write setPosition;
property location: int2 read fldLocation write fldLocation;
property sequence: LexemeSequence read fldSequence;
end;
Code = class(CallableItem)
strict private
class function getLexemeSequence(item: TableItem): LexemeSequence; static;
strict private
fldWithLocalIndex: int;
fldMonitorLocalIndex: int;
fldInstructionsLength: int;
fldInstructionsNodes: Node_Array1d;
fldRoot: Node;
fldNodesArray: NodeArray;
fldLocalsArray: LocalArray;
fldDebugLineIndicesArray: TObject; { CodeLineIndexArray }
fldParentCallable: Callable;
fldParentProgramme: Programme;
function createNode(): Node;
function getDebugLineIndices(): IntArray;
private
function orderOf(node: Node): int;
protected
function getNodeAt(index: int): Node; override; final;
public
constructor create(__parentCallable: Callable);
destructor destroy; override;
procedure afterConstruction(); override;
procedure replaceJumpNode(oldJumpNode, newJumpNode: Node); override;
procedure assignOrder(node: Node; order: int); virtual;
procedure clearOrder(node: Node); virtual;
procedure removeChilds(node: Node); virtual;
procedure removeNode(node: Node); virtual;
procedure moveNode(node: Node; index: int); virtual;
procedure moveNode(node, parent: Node; index: int); virtual;
function createDebugIndex(lineIndex: int): int; virtual;
function createWithLocal(&type: ClassType; value: Constant): Local; virtual;
function createMonitorLocal(&type: ClassType; value: Constant): Local; virtual;
function createLocal(isFinal: boolean; &type: &Type; const specialSimpleName: AnsiString; value: Constant; declarationPosition: int): Local; virtual;
function createAndInsertNode(parent: Node; index: int): Node; virtual;
function createAndPrependNode(parent: Node): Node; virtual;
function createAndAppendNode(parent: Node): Node; virtual;
function hasJumpsTo(node: Node): boolean; override; final;
function isEmpty(): boolean; override; final;
function getLength(): int; override; final;
function clone(): Node_Array1d;
property root: Node read fldRoot;
property nodes: NodeArray read fldNodesArray;
property locals: LocalArray read fldLocalsArray;
property debugLineIndices: IntArray read getDebugLineIndices;
property parentCallable: Callable read fldParentCallable;
property parentProgramme: Programme read fldParentProgramme;
end;
Node = class(CallableItem)
strict private
class function getLexemeSequence(code: Code): LexemeSequence; static;
strict private
fldWeak: boolean;
fldUseSuper: boolean;
fldEndPoint: boolean;
fldIsRefCount1: boolean;
fldIsRefCount2: boolean;
fldDebugIndex: int;
fldLabelIndex: int;
fldInstruction: int;
fldChildsLength: int;
fldSpecialState: int;
fldStackElements: int;
fldJumpCasesLength: int;
fldJumpCasesValues: int_Array1d;
fldJumpCasesNodes: Node_Array1d;
fldChildsNodes: Node_Array1d;
fldJumpDefault: Node;
fldParentNode: Node;
fldType: &Type;
fldReference1: TObject;
fldReference2: TObject;
fldOperand1: TableItem;
fldOperand2: TableItem;
fldOperandC: Constant;
fldParentCode: Code;
procedure setEndPoint(newEndPoint: boolean);
procedure setSpecialState(index: int; newSpecialState: boolean);
function getSpecialState(index: int): boolean;
function getIndex(): int;
function getOrder(): int;
function getJumpDefault(): Node;
private
procedure moveChild(oldIndex, newIndex: int);
procedure insertChild(index: int; child: Node);
procedure deleteChild(index: int);
procedure deleteChilds();
protected
procedure setType(newType: &Type); virtual;
procedure setWeak(newWeak: boolean); virtual;
procedure setInstruction(newInstruction: int); virtual;
procedure setReference1(newReference1: TObject); virtual;
procedure setReference2(newReference2: TObject); virtual;
procedure setOperand1(newOperand1: TableItem); virtual;
procedure setOperand2(newOperand2: TableItem); virtual;
procedure setOperandC(newOperandC: Constant); virtual;
procedure setJumpDefault(newJumpDefault: Node); virtual;
procedure setJumpIsFalse(newJumpIsFalse: Node); virtual;
procedure setJumpIsTrue(newJumpIsTrue: Node); virtual;
function getJumpIsFalse(): Node; virtual;
function getJumpIsTrue(): Node; virtual;
function getNodeAt(index: int): Node; override; final;
public
constructor create(__parentCode: Code);
destructor destroy; override;
procedure replaceJumpNode(oldJumpNode, newJumpNode: Node); override;
procedure setJumpCase(valueOfCase: int; jumpIsCase: Node); virtual;
procedure clearJumpCases(); virtual;
function setData(__position, __instruction: int): Node; virtual;
function setData(__position, __instruction: int; __reference1: TObject): Node; virtual;
function setData(__position, __instruction: int; __reference1, __reference2: TObject): Node; virtual;
function setData(__position: int; __type: &Type; __instruction: int): Node; virtual;
function setData(__position: int; __type: &Type; __instruction: int; __operandC: Constant): Node; virtual;
function setData(__position: int; __type: &Type; __instruction: int; __operand1: TableItem): Node; virtual;
function setData(__position: int; __type: &Type; __instruction: int; __operand1, __operand2: TableItem): Node; virtual;
function setData(__position: int; __type: &Type; __instruction: int; __operand1: TableItem; __operandC: Constant): Node; virtual;
function hasJumpsTo(node: Node): boolean; override; final;
function isEmpty(): boolean; override; final;
function getLength(): int; override; final;
function isParent(node: Node): boolean;
function minOrder(): int;
function maxOrder(): int;
function getJumpCasesLength(): int;
function getJumpCaseValueAt(index: int): int;
function getJumpCaseNodeAt(index: int): Node;
function getJumpCase(valueOfCase: int): Node;
property weak: boolean read fldWeak write setWeak;
property special: boolean index 0 read getSpecialState write setSpecialState;
property endPoint: boolean read fldEndPoint write setEndPoint;
property useSuper: boolean read fldUseSuper write fldUseSuper;
property persistent: boolean index 1 read getSpecialState write setSpecialState;
property index: int read getIndex;
property order: int read getOrder;
property debugIndex: int read fldDebugIndex write fldDebugIndex;
property labelIndex: int read fldLabelIndex write fldLabelIndex;
property instruction: int read fldInstruction write setInstruction;
property stackElements: int read fldStackElements write fldStackElements;
property &type: &Type read fldType write setType;
property operand1: TableItem read fldOperand1 write setOperand1;
property operand2: TableItem read fldOperand2 write setOperand2;
property operandC: Constant read fldOperandC write setOperandC;
property reference1: TObject read fldReference1 write setReference1;
property reference2: TObject read fldReference2 write setReference2;
property jumpDefault: Node read getJumpDefault write setJumpDefault;
property jumpIsFalse: Node read getJumpIsFalse write setJumpIsFalse;
property jumpIsTrue: Node read getJumpIsTrue write setJumpIsTrue;
property parentNode: Node read fldParentNode;
property parentCode: Code read fldParentCode;
end;
IllegalArrayDimensionsCountException = class(IllegalArgumentException);
IllegalConstantTypeException = class(RuntimeException);
IllegalLexemeTypeException = class(RuntimeException);
UnencodableDataException = class(UnsupportedDataException);
CompilerException = class(Exception);
SourceException = class(CompilerException)
private
fldRelativePath: UnicodeString;
public
function toString(): AnsiString; override;
function clone(): Throwable; override;
property relativePath: UnicodeString read fldRelativePath write fldRelativePath;
end;
BinarySourceException = class(SourceException)
strict private
fldOffset: int;
fldPosition: int;
fldSource: BinarySource;
procedure setPosition(newPosition: int);
procedure setSource(newSource: BinarySource);
public
function toString(): AnsiString; override;
function clone(): Throwable; override;
property offset: int read fldOffset write fldOffset;
property position: int read fldPosition write setPosition;
property source: BinarySource read fldSource write setSource;
end;
TextSourceException = class(SourceException)
strict private
fldPosition: int;
fldLineIndex: int;
fldCharIndex: int;
fldSource: TextSource;
procedure setPosition(newPosition: int);
procedure setSource(newSource: TextSource);
public
function toString(): AnsiString; override;
function clone(): Throwable; override;
property lineIndex: int read fldLineIndex write fldLineIndex;
property charIndex: int read fldCharIndex write fldCharIndex;
property position: int read fldPosition write setPosition;
property source: TextSource read fldSource write setSource;
end;
IllegalCompilerObjectStateException = class(IllegalStateException);
IllegalClassTypeStateException = class(IllegalCompilerObjectStateException);
IllegalFieldsMapStateException = class(IllegalCompilerObjectStateException);
IllegalMemberStateException = class(IllegalCompilerObjectStateException);
IllegalFieldStateException = class(IllegalMemberStateException);
IllegalProgrammeStateException = class(IllegalCompilerObjectStateException);
IllegalSourceStateException = class(IllegalCompilerObjectStateException);
{%endregion}
implementation
{$R *.res}
{$TYPEINFO OFF}
{$CALLING REGISTER}
{%region} type
ConstantItem = class;
ConstantValue = class;
ChunkByteArrayInputStream = class;
ProgrammeLibraryKey = class;
CodeLineIndexArray = class;
ConstantItem = class sealed(TableItem, Numeric, Constant, TypedItem)
strict private
fldValue: ConstantValue;
protected
function composeRecompilableName(): AnsiString; override;
function composeFasmSimpleName(): AnsiString; override;
public
constructor create();
constructor create(&type: PrimitiveType; const value: boolean);
constructor create(&type: PrimitiveType; const value: uchar);
constructor create(&type: PrimitiveType; const value: long8);
constructor create(&type: PrimitiveType; const value: double8);
constructor create(&type: PrimitiveType; const value: real);
constructor create(&type: ReferenceType; const value: TObject);
constructor create(&type: ReferenceType; const value: IUnknown);
destructor destroy; override;
{$IFDEF WINDOWS}{$CALLING STDCALL}{$ELSE}{$CALLING CDECL}{$ENDIF}
function _addref(): int; override;
function _release(): int; override;
{$CALLING REGISTER}
function toString(): AnsiString; override;
function getKind(): int;
function isNaN(): boolean;
function isInfinite(): boolean;
function asChar(): char;
function asUChar(): uchar;
function asByte(): byte;
function asByte2(): byte2;
function asByte4(): byte4;
function asByte8(): byte8;
function asShort(): short;
function asShort2(): short2;
function asShort4(): short4;
function asShort8(): short8;
function asInt(): int;
function asInt2(): int2;
function asInt4(): int4;
function asInt8(): int8;
function asLong(): long;
function asLong2(): long2;
function asLong4(): long4;
function asLong8(): long8;
function asFloat(): float;
function asFloat2(): float2;
function asFloat4(): float4;
function asFloat8(): float8;
function asDouble(): double;
function asDouble2(): double2;
function asDouble4(): double4;
function asDouble8(): double8;
function asReal(): real;
function isNull(): boolean;
function isClass(): boolean;
function isString(): boolean;
function isPackage(): boolean;
function isBoolean(): boolean;
function isNumeric(): boolean;
function isReference(): boolean;
function isReflective(): boolean;
function isDefaultValue(): boolean;
function asBoolean(): boolean;
function asObject(): TObject;
function asInterface(): IUnknown;
function castTo(&type: &Type): Constant;
function getType(): &Type;
end;
ConstantValue = class sealed(CustomNumeric)
strict private type
Value_Array1d = specialize DynamicArray<Value>;
strict private const
KIND_BOOLEAN = ConstantFactory.KIND_BOOLEAN;
strict private const
TYP_BOOLEAN = AVTOOConstants.TYP_BOOLEAN;
TYP_NUMERIC = AVTOOConstants.TYP_REAL;
TYP_REFERENCE = AVTOOConstants.TYP_REF;
strict private
fldTypeKind: int;
fldClassKind: int;
fldBoolean: boolean;
fldUChar: uchar;
fldIntegral: long8;
fldFloating: double8;
fldReal: real;
fldObject: TObject;
fldInterface: IUnknown;
fldType: &Type;
procedure checkTypeKind(kind: int);
public
constructor create(&type: PrimitiveType; const value: boolean);
constructor create(&type: PrimitiveType; const value: uchar);
constructor create(&type: PrimitiveType; const value: long8);
constructor create(&type: PrimitiveType; const value: double8);
constructor create(&type: PrimitiveType; const value: real);
constructor create(&type: ReferenceType; const value: TObject);
constructor create(&type: ReferenceType; const value: IUnknown);
function toString(): AnsiString; override;
function getKind(): int; override;
function isNaN(): boolean; override;
function isInfinite(): boolean; override;
function asChar(): char; override;
function asUChar(): uchar; override;
function asByte8(): byte8; override;
function asShort8(): short8; override;
function asInt8(): int8; override;
function asLong8(): long8; override;
function asFloat8(): float8; override;
function asDouble8(): double8; override;
function asReal(): real; override;
function isNull(): boolean;
function isClass(): boolean;
function isString(): boolean;
function isPackage(): boolean;
function isBoolean(): boolean;
function isNumeric(): boolean;
function isReference(): boolean;
function isReflective(): boolean;
function isDefaultValue(): boolean;
function asBoolean(): boolean;
function asObject(): TObject;
function asInterface(): IUnknown;
function castTo(&type: &Type; item: ConstantItem): ConstantItem;
function getType(): &Type;
end;
ChunkByteArrayInputStream = class(ByteArrayInputStream)
strict private
procedure setPosition(newPosition: int);
function getPosition(): int;
public
property position: int read getPosition write setPosition;
end;
ProgrammeLibraryKey = class(RefCountObject)
private
fldHash: long;
fldDirectoryPath: UnicodeString;
fldFileSystem: FileSystem;
public
constructor create(&library: &Library);
constructor create(fileSystem: FileSystem; const directoryPath: UnicodeString);
function equals(anot: TObject): boolean; override;
function getHashCode(): long; override;
end;
CodeLineIndexArray = class(&Object, Measureable, IntArray)
strict private
fldLength: int;
fldArray: int_Array1d;
public
constructor create();
function getLength(): int;
function readComponent(index: int): int;
function append(item: int): int;
end;
{%endregion}
{%region AVTOOConstants }
class function AVTOOConstants.isPrimitiveKind(kind: int): boolean;
begin
result := (kind <> TYP_REF) and ((kind <= TYP_REAL) or (kind >= TYP_DOUBLE));
end;
class function AVTOOConstants.isAtTagDocumentLexeme(lexeme: int): boolean;
begin
result := (lexeme >= $03) and (lexeme < $10);
end;
class function AVTOOConstants.getVersion(): AnsiString;
begin
result := '0.7';
end;
{%endregion}
{%region AVTOORecompilable }
class function AVTOORecompilable.isLongEncoded(encoded: int): boolean;
begin
result := (encoded < 0) or (encoded > $ffff);
end;
class function AVTOORecompilable.isLongNumber(encoded: int): boolean;
begin
result := (encoded and FLAG_LONG) <> 0;
end;
class function AVTOORecompilable.isInstruction(encoded: int): boolean;
begin
result := (encoded and $8000) <> 0;
end;
class function AVTOORecompilable.isNext(encoded: int): boolean;
begin
result := (encoded and FLAG_NEXT) <> 0;
end;
class function AVTOORecompilable.decodeDeclareLabel(encoded: int): boolean;
begin
result := (encoded and FLAG_LABEL) <> 0;
end;
class function AVTOORecompilable.decodeDeclareNumber(encoded: int): int;
begin
if isLongEncoded(encoded) then begin
result := CoInt.sar(encoded shl 3, 3);
exit
end;
result := CoInt.sar(encoded shl 19, 19);
end;
class function AVTOORecompilable.decodeUsing(encoded: int): int;
begin
if isLongEncoded(encoded) then begin
result := CoInt.sar(encoded shl 2, 2);
exit
end;
result := CoInt.sar(encoded shl 18, 18);
end;
class function AVTOORecompilable.decodeType(encoded: int): int;
begin
result := (encoded and $1f) + TYP_VOID;
end;
class function AVTOORecompilable.decodeStore(encoded: int): int;
begin
encoded := (encoded shr 5) and 3;
if encoded < STORE_NORMAL then begin
result := STORE_NORMAL;
exit;
end;
result := encoded;
end;
class function AVTOORecompilable.decodeOperand(encoded: int): int;
begin
result := (encoded shr 5) and 3;
end;
class function AVTOORecompilable.decodeVectorIndex(encoded: int): int;
begin
result := (encoded shr 5) and 7;
end;
class function AVTOORecompilable.encodeDeclare(&label: boolean; number: int): int;
begin
if (number < -$10000000) or (number > $0fffffff) then begin
raise UnencodableDataException.create(AnsiString.format(
AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'binary-source.format.order-number-too-large'), [
CoAnsiString.create(CoInt.toString(number))
]
));
end;
if (number < -$1000) or (number > $0fff) then begin
if &label then begin
result := ((FLAG_LONG or FLAG_LABEL) shl $10) or (number and $1fffffff);
exit;
end;
result := (FLAG_LONG shl $10) or (number and $1fffffff);
exit
end;
if &label then begin
result := FLAG_LABEL or (number and $1fff);
exit;
end;
result := number and $1fff;
end;
class function AVTOORecompilable.encodeNext(): int;
begin
result := FLAG_NEXT;
end;
class function AVTOORecompilable.encodeUsing(number: int): int;
begin
if (number < -$10000000) or (number > $0fffffff) then begin
raise UnencodableDataException.create(AnsiString.format(
AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'binary-source.format.order-number-too-large'), [
CoAnsiString.create(CoInt.toString(number))
]
));
end;
if (number < -$2000) or (number > $1fff) then begin
result := (FLAG_LONG shl $10) or (number and $3fffffff);
exit;
end;
result := number and $3fff;
end;
class function AVTOORecompilable.encodeType(kind: int): int;
begin
result := kind - TYP_VOID;
end;
class function AVTOORecompilable.encodeType(&type: &Type): int;
begin
if &type = nil then begin
result := TYP_REF - TYP_VOID;
exit;
end;
result := &type.kind - TYP_VOID;
end;
class function AVTOORecompilable.encodeStore(store: int): int;
begin
result := store shl 5;
end;
class function AVTOORecompilable.encodeOperand(operandC: Constant; operandI: TableItem): int;
begin
if operandC <> nil then begin
result := OPERAND_CONSTANT shl 5;
exit;
end;
if operandI is Field then begin
result := OPERAND_GLOBAL shl 5;
exit;
end;
if operandI is Local then begin
result := OPERAND_LOCAL shl 5;
exit;
end;
result := OPERAND_NONE shl 5;
end;
class function AVTOORecompilable.encodeVectorIndex(index: int): int;
begin
result := (index and 7) shl 5;
end;
{%endregion}
{%region AVTOOService }
class function AVTOOService.getBestArrayCapacity(length: int): int;
begin
if length <= $0f then begin
result := $0f;
exit;
end;
result := length;
repeat
length := length shr 1;
if length <= 0 then break;
result := result or length;
until false;
end;
class function AVTOOService.getObjectName(const objectPath: UnicodeString): UnicodeString;
var
index: int;
begin
if objectPath.endsWith('/') then begin
index := objectPath.length - 1;
end else begin
index := objectPath.length;
end;
result := objectPath.substring(objectPath.lastIndexOf('/', index) + 1, index + 1);
end;
{%endregion}
{%region SourceArray }
constructor SourceArray.create(owned: boolean);
begin
inherited create();
fldOwned := owned;
fldArray := &Array.newTObject1d($0f);
end;
destructor SourceArray.destroy;
var
index: int;
&array: TObject_Array1d;
begin
if fldOwned then begin
&array := fldArray;
for index := fldLength - 1 downto 0 do begin
&array[index].free();
&array[index] := nil;
end;
end;
inherited destroy;
end;
function SourceArray.getLength(): int;
begin
result := fldLength;
end;
function SourceArray.readComponent(index: int): Source;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index] as Source;
end;
function SourceArray.readComponent(index: int): ISimple;
begin
result := readComponent(index);
end;
function SourceArray.clone(): Source_Array1d;
var
index: int;
length: int;
__array: TObject_Array1d;
begin
length := fldLength;
__array := fldArray;
result := Source_Array1d(&Array.newISimple1d(length));
for index := length - 1 downto 0 do result[index] := __array[index] as Source;
end;
procedure SourceArray.append(item: Source);
var
length: int;
__array: TObject_Array1d;
__buffer: TObject_Array1d;
begin
length := fldLength;
__array := fldArray;
if length = system.length(__array) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
__buffer := &Array.newTObject1d((length shl 1) or 1);
&Array.copyObjects(__array, 0, __buffer, 0, length);
fldArray := __buffer;
__array := __buffer;
end;
__array[length] := Lang.cast(item, TObject);
fldLength := length + 1;
end;
function SourceArray.indexOf(item: Source): int;
var
length: int;
begin
length := fldLength;
if length <= 0 then begin
result := -1;
exit;
end;
result := &Array.indexOf(Lang.cast(item, TObject), fldArray, 0, length);
end;
{%endregion}
{%region ChunkArray }
constructor ChunkArray.create(const __array: Chunk_Array1d);
begin
inherited create();
fldLength := system.length(__array);
fldArray := __array;
end;
destructor ChunkArray.destroy;
var
index: int;
&array: Chunk_Array1d;
begin
&array := fldArray;
for index := fldLength - 1 downto 0 do begin
&array[index].free();
&array[index] := nil;
end;
inherited destroy;
end;
function ChunkArray.getLength(): int;
begin
result := fldLength;
end;
function ChunkArray.readComponent(index: int): Chunk;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function ChunkArray.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function ChunkArray.clone(): Chunk_Array1d;
var
length: int;
begin
length := fldLength;
result := Chunk_Array1d(&Array.newTObject1d(length));
&Array.copyObjects(fldArray, 0, result, 0, length);
end;
{%endregion}
{%region LibraryArray }
constructor LibraryArray.create(owned: boolean);
begin
inherited create();
fldOwned := owned;
fldArray := Library_Array1d(&Array.newTObject1d($0f));
end;
destructor LibraryArray.destroy;
begin
clear();
inherited destroy;
end;
function LibraryArray.indexOf(item: &Library): int;
var
length: int;
begin
length := fldLength;
if length <= 0 then begin
result := -1;
exit;
end;
result := &Array.indexOf(item, fldArray, 0, length);
end;
function LibraryArray.getLength(): int;
begin
result := fldLength;
end;
function LibraryArray.readComponent(index: int): &Library;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function LibraryArray.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function LibraryArray.clone(): Library_Array1d;
var
length: int;
begin
length := fldLength;
result := Library_Array1d(&Array.newTObject1d(length));
&Array.copyObjects(fldArray, 0, result, 0, length);
end;
procedure LibraryArray.clear();
var
index: int;
&array: Library_Array1d;
begin
if fldOwned then begin
&array := fldArray;
for index := fldLength - 1 downto 0 do begin
&array[index].free();
&array[index] := nil;
end;
end;
fldLength := 0;
end;
procedure LibraryArray.append(item: &Library);
var
length: int;
__array: Library_Array1d;
__buffer: Library_Array1d;
begin
length := fldLength;
__array := fldArray;
if length = system.length(__array) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
__buffer := Library_Array1d(&Array.newTObject1d((length shl 1) or 1));
&Array.copyObjects(__array, 0, __buffer, 0, length);
fldArray := __buffer;
__array := __buffer;
end;
__array[length] := item;
fldLength := length + 1;
end;
{%endregion}
{%region PackageArray }
constructor PackageArray.create(owned: boolean);
begin
inherited create();
fldOwned := owned;
fldArray := Package_Array1d(pascalx.lang.&Array.newTObject1d($0f));
end;
destructor PackageArray.destroy;
begin
clear();
inherited destroy;
end;
function PackageArray.getLength(): int;
begin
result := fldLength;
end;
function PackageArray.readComponent(index: int): Package;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function PackageArray.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function PackageArray.clone(): Package_Array1d;
var
__length: int;
begin
__length := fldLength;
result := Package_Array1d(pascalx.lang.&Array.newTObject1d(__length));
pascalx.lang.&Array.copyObjects(fldArray, 0, result, 0, __length);
end;
procedure PackageArray.clear();
var
index: int;
__array: Package_Array1d;
begin
if fldOwned then begin
__array := fldArray;
for index := fldLength - 1 downto 0 do begin
__array[index].free();
__array[index] := nil;
end;
end;
fldLength := 0;
end;
procedure PackageArray.append(item: Package);
var
__length: int;
__array: Package_Array1d;
__buffer: Package_Array1d;
begin
__length := fldLength;
__array := fldArray;
if __length = system.length(__array) then begin
if __length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
__buffer := Package_Array1d(pascalx.lang.&Array.newTObject1d((__length shl 1) or 1));
pascalx.lang.&Array.copyObjects(__array, 0, __buffer, 0, __length);
fldArray := __buffer;
__array := __buffer;
end;
__array[__length] := item;
fldLength := __length + 1;
end;
function PackageArray.indexOf(item: Package): int;
var
__length: int;
begin
__length := fldLength;
if __length <= 0 then begin
result := -1;
exit;
end;
result := pascalx.lang.&Array.indexOf(item, fldArray, 0, __length);
end;
{%endregion}
{%region RequiredReflectItemArray }
constructor RequiredReflectItemArray.create(owned: boolean);
begin
inherited create();
fldOwned := owned;
fldArray := RequiredReflectItem_Array1d(pascalx.lang.&Array.newTObject1d($0f));
end;
destructor RequiredReflectItemArray.destroy;
begin
clear();
inherited destroy;
end;
function RequiredReflectItemArray.getLength(): int;
begin
result := fldLength;
end;
function RequiredReflectItemArray.readComponent(index: int): RequiredReflectItem;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function RequiredReflectItemArray.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function RequiredReflectItemArray.clone(): RequiredReflectItem_Array1d;
var
__length: int;
begin
__length := fldLength;
result := RequiredReflectItem_Array1d(pascalx.lang.&Array.newTObject1d(__length));
pascalx.lang.&Array.copyObjects(fldArray, 0, result, 0, __length);
end;
procedure RequiredReflectItemArray.clear();
var
index: int;
__array: RequiredReflectItem_Array1d;
begin
if fldOwned then begin
__array := fldArray;
for index := fldLength - 1 downto 0 do begin
__array[index].free();
__array[index] := nil;
end;
end;
fldLength := 0;
end;
procedure RequiredReflectItemArray.append(item: RequiredReflectItem);
var
__length: int;
__array: RequiredReflectItem_Array1d;
__buffer: RequiredReflectItem_Array1d;
begin
__length := fldLength;
__array := fldArray;
if __length = system.length(__array) then begin
if __length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
__buffer := RequiredReflectItem_Array1d(pascalx.lang.&Array.newTObject1d((__length shl 1) or 1));
pascalx.lang.&Array.copyObjects(__array, 0, __buffer, 0, __length);
fldArray := __buffer;
__array := __buffer;
end;
__array[__length] := item;
fldLength := __length + 1;
end;
function RequiredReflectItemArray.indexOf(item: RequiredReflectItem): int;
var
__length: int;
begin
__length := fldLength;
if __length <= 0 then begin
result := -1;
exit;
end;
result := pascalx.lang.&Array.indexOf(item, fldArray, 0, __length);
end;
{%endregion}
{%region TypeArray }
constructor TypeArray.create(owned: boolean);
begin
inherited create();
fldOwned := owned;
fldArray := Type_Array1d(pascalx.lang.&Array.newTObject1d($0f));
end;
destructor TypeArray.destroy;
begin
clear();
inherited destroy;
end;
function TypeArray.getLength(): int;
begin
result := fldLength;
end;
function TypeArray.readComponent(index: int): &Type;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function TypeArray.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function TypeArray.clone(): Type_Array1d;
var
__length: int;
begin
__length := fldLength;
result := Type_Array1d(pascalx.lang.&Array.newTObject1d(__length));
pascalx.lang.&Array.copyObjects(fldArray, 0, result, 0, __length);
end;
procedure TypeArray.clear();
var
index: int;
__array: Type_Array1d;
begin
if fldOwned then begin
__array := fldArray;
for index := fldLength - 1 downto 0 do begin
__array[index].free();
__array[index] := nil;
end;
end;
fldLength := 0;
end;
procedure TypeArray.append(item: &Type);
var
__length: int;
__array: Type_Array1d;
__buffer: Type_Array1d;
begin
__length := fldLength;
__array := fldArray;
if __length = system.length(__array) then begin
if __length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
__buffer := Type_Array1d(pascalx.lang.&Array.newTObject1d((__length shl 1) or 1));
pascalx.lang.&Array.copyObjects(__array, 0, __buffer, 0, __length);
fldArray := __buffer;
__array := __buffer;
end;
__array[__length] := item;
fldLength := __length + 1;
end;
function TypeArray.indexOf(item: &Type): int;
var
__length: int;
begin
__length := fldLength;
if __length <= 0 then begin
result := -1;
exit;
end;
result := pascalx.lang.&Array.indexOf(item, fldArray, 0, __length);
end;
{%endregion}
{%region ClassTypeArray }
constructor ClassTypeArray.create(owned: boolean);
begin
inherited create();
fldOwned := owned;
fldArray := ClassType_Array1d(pascalx.lang.&Array.newTObject1d($0f));
end;
destructor ClassTypeArray.destroy;
begin
clear();
inherited destroy;
end;
function ClassTypeArray.getLength(): int;
begin
result := fldLength;
end;
function ClassTypeArray.readComponent(index: int): ClassType;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function ClassTypeArray.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function ClassTypeArray.clone(): ClassType_Array1d;
var
__length: int;
begin
__length := fldLength;
result := ClassType_Array1d(pascalx.lang.&Array.newTObject1d(__length));
pascalx.lang.&Array.copyObjects(fldArray, 0, result, 0, __length);
end;
procedure ClassTypeArray.clear();
var
index: int;
__array: ClassType_Array1d;
begin
if fldOwned then begin
__array := fldArray;
for index := fldLength - 1 downto 0 do begin
__array[index].free();
__array[index] := nil;
end;
end;
fldLength := 0;
end;
procedure ClassTypeArray.append(item: ClassType);
var
__length: int;
__array: ClassType_Array1d;
__buffer: ClassType_Array1d;
begin
__length := fldLength;
__array := fldArray;
if __length = system.length(__array) then begin
if __length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
__buffer := ClassType_Array1d(pascalx.lang.&Array.newTObject1d((__length shl 1) or 1));
pascalx.lang.&Array.copyObjects(__array, 0, __buffer, 0, __length);
fldArray := __buffer;
__array := __buffer;
end;
__array[__length] := item;
fldLength := __length + 1;
end;
{%endregion}
{%region ArrayTypeArray }
constructor ArrayTypeArray.create(owned: boolean);
begin
inherited create();
fldOwned := owned;
fldArray := ArrayType_Array1d(pascalx.lang.&Array.newTObject1d($0f));
end;
destructor ArrayTypeArray.destroy;
begin
clear();
inherited destroy;
end;
function ArrayTypeArray.getLength(): int;
begin
result := fldLength;
end;
function ArrayTypeArray.readComponent(index: int): ArrayType;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function ArrayTypeArray.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function ArrayTypeArray.clone(): ArrayType_Array1d;
var
__length: int;
begin
__length := fldLength;
result := ArrayType_Array1d(pascalx.lang.&Array.newTObject1d(__length));
pascalx.lang.&Array.copyObjects(fldArray, 0, result, 0, __length);
end;
procedure ArrayTypeArray.clear();
var
index: int;
__array: ArrayType_Array1d;
begin
if fldOwned then begin
__array := fldArray;
for index := fldLength - 1 downto 0 do begin
__array[index].free();
__array[index] := nil;
end;
end;
fldLength := 0;
end;
procedure ArrayTypeArray.append(item: ArrayType);
var
__length: int;
__array: ArrayType_Array1d;
__buffer: ArrayType_Array1d;
begin
__length := fldLength;
__array := fldArray;
if __length = system.length(__array) then begin
if __length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
__buffer := ArrayType_Array1d(pascalx.lang.&Array.newTObject1d((__length shl 1) or 1));
pascalx.lang.&Array.copyObjects(__array, 0, __buffer, 0, __length);
fldArray := __buffer;
__array := __buffer;
end;
__array[__length] := item;
fldLength := __length + 1;
end;
{%endregion}
{%region LocalArray }
constructor LocalArray.create(parentProgramme: Programme);
begin
inherited create();
fldParentProgramme := parentProgramme;
end;
constructor LocalArray.create(parentProgramme: Programme; const __array: Local_Array1d);
begin
inherited create();
fldLength := system.length(__array);
fldArray := __array;
fldParentProgramme := parentProgramme;
end;
destructor LocalArray.destroy;
var
index: int;
__array: Local_Array1d;
begin
__array := fldArray;
for index := fldLength - 1 downto 0 do begin
__array[index].free();
__array[index] := nil;
end;
inherited destroy;
end;
function LocalArray.getLength(): int;
begin
result := fldLength;
end;
function LocalArray.readComponent(index: int): Local;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function LocalArray.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function LocalArray.clone(): TypedItem_Array1d;
var
index: int;
__length: int;
__array: Local_Array1d;
begin
__array := fldArray;
__length := fldLength;
result := TypedItem_Array1d(pascalx.lang.&Array.newISimple1d(__length));
for index := __length - 1 downto 0 do result[index] := __array[index];
end;
function LocalArray.clone(alsoLocals: boolean): Local_Array1d;
var
index: int;
__length: int;
__array: Local_Array1d;
__programme: Programme;
__local: Local;
begin
__length := fldLength;
result := Local_Array1d(pascalx.lang.&Array.newTObject1d(__length));
if not alsoLocals then begin
pascalx.lang.&Array.copyObjects(fldArray, 0, result, 0, __length);
exit;
end;
__array := fldArray;
__programme := fldParentProgramme;
for index := __length - 1 downto 0 do with __array[index] do begin
__local := nil;
if __programme <> nil then begin
__local := __programme.newLocal(isFinal(), &type, specialSimpleName, value, source, declarationPosition);
end;
if __local = nil then begin
__local := Local.create(isFinal(), &type, specialSimpleName, value, source, declarationPosition);
end;
result[index] := __local;
end;
end;
procedure LocalArray.append(item: Local);
var
__length: int;
__array: Local_Array1d;
__buffer: Local_Array1d;
begin
__length := fldLength;
__array := fldArray;
if __length = system.length(__array) then begin
if __length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
__buffer := Local_Array1d(pascalx.lang.&Array.newTObject1d((__length shl 1) or 1));
pascalx.lang.&Array.copyObjects(__array, 0, __buffer, 0, __length);
fldArray := __buffer;
__array := __buffer;
end;
__array[__length] := item;
fldLength := __length + 1;
end;
{%endregion}
{%region ArgumentArray }
class function ArgumentArray.toString(const arguments: Type_Array1d): AnsiString;
var
index: int;
limit: int;
representation: AnsiString;
begin
representation := '';
limit := system.length(arguments) - 1;
for index := 0 to limit do begin
representation := representation + arguments[index].specialCanonicalName;
if index < limit then representation := representation + ', ';
end;
result := '(' + representation + ')';
end;
constructor ArgumentArray.create(parentProgramme: Programme; __thisArgument: Local; const __otherArguments: Local_Array1d);
var
index: int;
limit: int;
__stackElements: int;
fullRepresentation: AnsiString;
userRepresentation: AnsiString;
fasmRepresentation: AnsiString;
typeName: AnsiString;
typeRef: &Type;
otherArgument: Local;
begin
inherited create(parentProgramme, __otherArguments);
if __thisArgument = nil then begin
__stackElements := 0;
end else begin
__stackElements := 1;
end;
fullRepresentation := '';
userRepresentation := '';
fasmRepresentation := '';
limit := system.length(__otherArguments) - 1;
for index := 0 to limit do begin
otherArgument := __otherArguments[index];
typeRef := otherArgument.&type;
typeName := typeRef.specialCanonicalName;
inc(__stackElements, typeRef.stackElements);
fullRepresentation := fullRepresentation + typeName + ' ' + otherArgument.specialSimpleName;
userRepresentation := userRepresentation + typeName;
if index < limit then begin
fullRepresentation := fullRepresentation + ', ';
userRepresentation := userRepresentation + ', ';
end;
fasmRepresentation := fasmRepresentation + typeRef.fasmSimpleName + '$';
end;
fldStackElements := __stackElements;
fldUserString := '(' + userRepresentation + ')';
fldFullString := '(' + fullRepresentation + ')';
fldFasmString := '$' + fasmRepresentation;
fldThisArgument := __thisArgument;
end;
function ArgumentArray.equals(anot: TObject): boolean;
label
break_label0;
var
index: int;
anotArgs: Local_Array1d;
thisArgs: Local_Array1d;
begin
if anot = self then begin
result := true;
exit;
end;
if not(anot is ArgumentArray) then begin
result := false;
exit;
end;
anotArgs := ArgumentArray(anot).&array;
thisArgs := &array;
index := system.length(anotArgs);
if index = system.length(thisArgs) then begin
while index > 0 do begin
dec(index);
if thisArgs[index].&type <> anotArgs[index].&type then goto break_label0;
end;
result := true;
exit;
end;
break_label0:
result := false;
end;
function ArgumentArray.getHashCode(): long;
var
index: int;
hash: long;
args: Local_Array1d;
begin
hash := 0;
args := &array;
for index := system.length(args) - 1 downto 0 do begin
hash := hash xor CoLong.rol((CoAnsiString.create(args[index].&type.specialCanonicalName) as RefCountInterface).getHashCode(), index shl 1);
end;
result := hash;
end;
function ArgumentArray.toString(): AnsiString;
begin
result := fldUserString;
end;
function ArgumentArray.toFullString(): AnsiString;
begin
result := fldFullString;
end;
function ArgumentArray.toFasmString(): AnsiString;
begin
result := fldFasmString;
end;
{%endregion}
{%region NodeArray }
class function NodeArray.removeAndFreeItemFrom(const &array: Node_Array1d; length: int; item: Node): int;
var
index: int;
begin
if length <= 0 then begin
result := 0;
exit;
end;
index := pascalx.lang.&Array.indexOf(item, &array, 0, length);
if index >= 0 then begin
dec(length);
pascalx.lang.&Array.copyObjects(&array, index + 1, &array, index, length - index);
&array[length] := nil;
item.free();
end;
result := length;
end;
class function NodeArray.removeAndFreeNodeFrom(const &array: Node_Array1d; length: int; node: Node): int;
var
index: int;
__length: int;
current: Node;
__buffer: Node_Array1d;
begin
if length <= 0 then begin
result := 0;
exit;
end;
__length := 0;
__buffer := Node_Array1d(pascalx.lang.&Array.newTObject1d(length));
for index := length - 1 downto 0 do begin
current := &array[index];
if (current = node) or current.isParent(node) then begin
dec(length);
pascalx.lang.&Array.copyObjects(&array, index + 1, &array, index, length - index);
&array[length] := nil;
__buffer[__length] := current;
inc(__length);
end;
end;
for index := __length - 1 downto 0 do begin
__buffer[index].free();
__buffer[index] := nil;
end;
result := length;
end;
class function NodeArray.removeAndFreeChildsFrom(const &array: Node_Array1d; length: int; node: Node): int;
var
index: int;
__length: int;
current: Node;
__buffer: Node_Array1d;
begin
if length <= 0 then begin
result := 0;
exit;
end;
__length := 0;
__buffer := Node_Array1d(pascalx.lang.&Array.newTObject1d(length));
for index := length - 1 downto 0 do begin
current := &array[index];
if current.isParent(node) then begin
dec(length);
pascalx.lang.&Array.copyObjects(&array, index + 1, &array, index, length - index);
&array[length] := nil;
__buffer[__length] := current;
inc(__length);
end;
end;
for index := __length - 1 downto 0 do begin
__buffer[index].free();
__buffer[index] := nil;
end;
result := length;
end;
class function NodeArray.removeItemFrom(const &array: Node_Array1d; length: int; item: Node): int;
var
index: int;
begin
if length <= 0 then begin
result := 0;
exit;
end;
index := pascalx.lang.&Array.indexOf(item, &array, 0, length);
if index >= 0 then begin
dec(length);
pascalx.lang.&Array.copyObjects(&array, index + 1, &array, index, length - index);
&array[length] := nil;
end;
result := length;
end;
class function NodeArray.removeNodeFrom(const &array: Node_Array1d; length: int; node: Node): int;
var
index: int;
current: Node;
begin
if length <= 0 then begin
result := 0;
exit;
end;
for index := length - 1 downto 0 do begin
current := &array[index];
if (current = node) or current.isParent(node) then begin
dec(length);
pascalx.lang.&Array.copyObjects(&array, index + 1, &array, index, length - index);
&array[length] := nil;
end;
end;
result := length;
end;
class function NodeArray.removeChildsFrom(const &array: Node_Array1d; length: int; node: Node): int;
var
index: int;
current: Node;
begin
if length <= 0 then begin
result := 0;
exit;
end;
for index := length - 1 downto 0 do begin
current := &array[index];
if current.isParent(node) then begin
dec(length);
pascalx.lang.&Array.copyObjects(&array, index + 1, &array, index, length - index);
&array[length] := nil;
end;
end;
result := length;
end;
constructor NodeArray.create();
begin
inherited create();
fldArray := Node_Array1d(pascalx.lang.&Array.newTObject1d($0f));
end;
destructor NodeArray.destroy;
var
index: int;
__array: Node_Array1d;
begin
__array := fldArray;
for index := fldLength - 1 downto 0 do begin
__array[index].free();
__array[index] := nil;
end;
inherited destroy;
end;
function NodeArray.getLength(): int;
begin
result := fldLength;
end;
function NodeArray.readComponent(index: int): Node;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function NodeArray.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function NodeArray.clone(): Node_Array1d;
var
__length: int;
begin
__length := fldLength;
result := Node_Array1d(pascalx.lang.&Array.newTObject1d(__length));
pascalx.lang.&Array.copyObjects(fldArray, 0, result, 0, __length);
end;
procedure NodeArray.append(item: Node);
var
__length: int;
__array: Node_Array1d;
__buffer: Node_Array1d;
begin
__length := fldLength;
__array := fldArray;
if __length = system.length(__array) then begin
if __length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
__buffer := Node_Array1d(pascalx.lang.&Array.newTObject1d((__length shl 1) or 1));
pascalx.lang.&Array.copyObjects(__array, 0, __buffer, 0, __length);
fldArray := __buffer;
__array := __buffer;
end;
__array[__length] := item;
fldLength := __length + 1;
end;
procedure NodeArray.remove(item: Node);
begin
fldLength := removeAndFreeItemFrom(fldArray, fldLength, item);
end;
procedure NodeArray.removeNode(node: Node);
begin
fldLength := removeAndFreeNodeFrom(fldArray, fldLength, node);
end;
procedure NodeArray.removeChilds(node: Node);
begin
fldLength := removeAndFreeChildsFrom(fldArray, fldLength, node);
end;
function NodeArray.indexOf(item: Node): int;
var
__length: int;
begin
__length := fldLength;
if __length <= 0 then begin
result := -1;
exit;
end;
result := pascalx.lang.&Array.indexOf(item, fldArray, 0, __length);
end;
{%endregion}
{%region UnicodeStringArray }
constructor UnicodeStringArray.create(const &array: UnicodeString_Array1d);
begin
inherited create();
fldLength := system.length(&array);
fldArray := &array;
end;
function UnicodeStringArray.getLength(): int;
begin
result := fldLength;
end;
function UnicodeStringArray.readComponent(index: int): Value;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := CoUnicodeString.create(fldArray[index]);
end;
function UnicodeStringArray.readComponent(index: int): IUnknown;
begin
result := readComponent(index);
end;
function UnicodeStringArray.clone(): UnicodeString_Array1d;
var
length: int;
begin
length := fldLength;
result := &Array.newUnicodeString1d(length);
&Array.copyStrings(fldArray, 0, result, 0, length);
end;
{%endregion}
{%region Storage }
procedure Storage.clear();
begin
fldLength := 0;
end;
function Storage.getLength(): int;
begin
result := fldLength;
end;
{$WARN 5033 OFF} { позволить функции, состоящие только из одной управляющей конструкции raise }
function Storage.clone(): Storage;
begin
raise UnsupportedOperationException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'unsupported-operation'));
end;
{$WARN 5033 ON}
{%endregion}
{%region Byte2Storage }
constructor Byte2Storage.create();
begin
inherited create();
fldArray := VArray.newByte2_1d($3f);
end;
constructor Byte2Storage.create(source: Byte2Storage);
var
length: int;
sarray: byte2_Array1d;
buffer: byte2_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newByte2_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newByte2_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Byte2Storage.clone(): Byte2Storage;
begin
result := Byte2Storage.create(self);
end;
function Byte2Storage.indexOf(const item: byte2): int;
var
index: int;
sarray: byte2_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Byte2Storage.indexAcquire(const item: byte2): int;
var
length: int;
sarray: byte2_Array1d;
buffer: byte2_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newByte2_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Byte2Storage.readComponent(index: int): byte2;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Byte4Storage }
constructor Byte4Storage.create();
begin
inherited create();
fldArray := VArray.newByte4_1d($3f);
end;
constructor Byte4Storage.create(source: Byte4Storage);
var
length: int;
sarray: byte4_Array1d;
buffer: byte4_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newByte4_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newByte4_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Byte4Storage.clone(): Byte4Storage;
begin
result := Byte4Storage.create(self);
end;
function Byte4Storage.indexOf(const item: byte4): int;
var
index: int;
sarray: byte4_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Byte4Storage.indexAcquire(const item: byte4): int;
var
length: int;
sarray: byte4_Array1d;
buffer: byte4_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newByte4_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Byte4Storage.readComponent(index: int): byte4;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Byte8Storage }
constructor Byte8Storage.create();
begin
inherited create();
fldArray := VArray.newByte8_1d($3f);
end;
constructor Byte8Storage.create(source: Byte8Storage);
var
length: int;
sarray: byte8_Array1d;
buffer: byte8_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newByte8_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newByte8_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Byte8Storage.clone(): Byte8Storage;
begin
result := Byte8Storage.create(self);
end;
function Byte8Storage.indexOf(const item: byte8): int;
var
index: int;
sarray: byte8_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Byte8Storage.indexAcquire(const item: byte8): int;
var
length: int;
sarray: byte8_Array1d;
buffer: byte8_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newByte8_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Byte8Storage.readComponent(index: int): byte8;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Short2Storage }
constructor Short2Storage.create();
begin
inherited create();
fldArray := VArray.newShort2_1d($3f);
end;
constructor Short2Storage.create(source: Short2Storage);
var
length: int;
sarray: short2_Array1d;
buffer: short2_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newShort2_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newShort2_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Short2Storage.clone(): Short2Storage;
begin
result := Short2Storage.create(self);
end;
function Short2Storage.indexOf(const item: short2): int;
var
index: int;
sarray: short2_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Short2Storage.indexAcquire(const item: short2): int;
var
length: int;
sarray: short2_Array1d;
buffer: short2_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newShort2_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Short2Storage.readComponent(index: int): short2;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Short4Storage }
constructor Short4Storage.create();
begin
inherited create();
fldArray := VArray.newShort4_1d($3f);
end;
constructor Short4Storage.create(source: Short4Storage);
var
length: int;
sarray: short4_Array1d;
buffer: short4_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newShort4_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newShort4_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Short4Storage.clone(): Short4Storage;
begin
result := Short4Storage.create(self);
end;
function Short4Storage.indexOf(const item: short4): int;
var
index: int;
sarray: short4_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Short4Storage.indexAcquire(const item: short4): int;
var
length: int;
sarray: short4_Array1d;
buffer: short4_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newShort4_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Short4Storage.readComponent(index: int): short4;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Short8Storage }
constructor Short8Storage.create();
begin
inherited create();
fldArray := VArray.newShort8_1d($3f);
end;
constructor Short8Storage.create(source: Short8Storage);
var
length: int;
sarray: short8_Array1d;
buffer: short8_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newShort8_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newShort8_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Short8Storage.clone(): Short8Storage;
begin
result := Short8Storage.create(self);
end;
function Short8Storage.indexOf(const item: short8): int;
var
index: int;
sarray: short8_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Short8Storage.indexAcquire(const item: short8): int;
var
length: int;
sarray: short8_Array1d;
buffer: short8_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newShort8_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Short8Storage.readComponent(index: int): short8;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Int2Storage }
constructor Int2Storage.create();
begin
inherited create();
fldArray := VArray.newInt2_1d($3f);
end;
constructor Int2Storage.create(source: Int2Storage);
var
length: int;
sarray: int2_Array1d;
buffer: int2_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newInt2_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newInt2_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Int2Storage.clone(): Int2Storage;
begin
result := Int2Storage.create(self);
end;
function Int2Storage.indexOf(const item: int2): int;
var
index: int;
sarray: int2_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Int2Storage.indexAcquire(const item: int2): int;
var
length: int;
sarray: Int2_Array1d;
buffer: Int2_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newInt2_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Int2Storage.readComponent(index: int): int2;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Int4Storage }
constructor Int4Storage.create();
begin
inherited create();
fldArray := VArray.newInt4_1d($3f);
end;
constructor Int4Storage.create(source: Int4Storage);
var
length: int;
sarray: int4_Array1d;
buffer: int4_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newInt4_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newInt4_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Int4Storage.clone(): Int4Storage;
begin
result := Int4Storage.create(self);
end;
function Int4Storage.indexOf(const item: int4): int;
var
index: int;
sarray: int4_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Int4Storage.indexAcquire(const item: int4): int;
var
length: int;
sarray: Int4_Array1d;
buffer: Int4_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newInt4_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Int4Storage.readComponent(index: int): int4;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Int8Storage }
constructor Int8Storage.create();
begin
inherited create();
fldArray := VArray.newInt8_1d($3f);
end;
constructor Int8Storage.create(source: Int8Storage);
var
length: int;
sarray: int8_Array1d;
buffer: int8_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newInt8_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newInt8_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Int8Storage.clone(): Int8Storage;
begin
result := Int8Storage.create(self);
end;
function Int8Storage.indexOf(const item: int8): int;
var
index: int;
sarray: int8_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Int8Storage.indexAcquire(const item: int8): int;
var
length: int;
sarray: int8_Array1d;
buffer: int8_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newInt8_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Int8Storage.readComponent(index: int): int8;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region LongStorage }
constructor LongStorage.create();
begin
inherited create();
fldArray := &Array.newLong1d($3f);
end;
constructor LongStorage.create(source: LongStorage);
var
length: int;
sarray: long_Array1d;
buffer: long_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := &Array.newLong1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := &Array.newLong1d(int(system.length(sarray)));
&Array.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function LongStorage.clone(): LongStorage;
begin
result := LongStorage.create(self);
end;
function LongStorage.indexOf(const item: long): int;
var
length: int;
begin
length := fldLength;
if length > 0 then begin
result := &Array.indexOf(item, fldArray, 0, length);
exit;
end;
result := -1;
end;
function LongStorage.indexAcquire(const item: long): int;
var
length: int;
sarray: long_Array1d;
buffer: long_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := &Array.newLong1d((length shl 1) or 1);
&Array.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function LongStorage.readComponent(index: int): long;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Long2Storage }
constructor Long2Storage.create();
begin
inherited create();
fldArray := VArray.newLong2_1d($3f);
end;
constructor Long2Storage.create(source: Long2Storage);
var
length: int;
sarray: long2_Array1d;
buffer: long2_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newLong2_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newLong2_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Long2Storage.clone(): Long2Storage;
begin
result := Long2Storage.create(self);
end;
function Long2Storage.indexOf(const item: long2): int;
var
index: int;
sarray: long2_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Long2Storage.indexAcquire(const item: long2): int;
var
length: int;
sarray: long2_Array1d;
buffer: long2_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newLong2_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Long2Storage.readComponent(index: int): long2;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Long4Storage }
constructor Long4Storage.create();
begin
inherited create();
fldArray := VArray.newLong4_1d($3f);
end;
constructor Long4Storage.create(source: Long4Storage);
var
length: int;
sarray: long4_Array1d;
buffer: long4_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newLong4_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newLong4_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Long4Storage.clone(): Long4Storage;
begin
result := Long4Storage.create(self);
end;
function Long4Storage.indexOf(const item: long4): int;
var
index: int;
sarray: long4_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Long4Storage.indexAcquire(const item: long4): int;
var
length: int;
sarray: long4_Array1d;
buffer: long4_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newLong4_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Long4Storage.readComponent(index: int): long4;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region Long8Storage }
constructor Long8Storage.create();
begin
inherited create();
fldArray := VArray.newLong8_1d($3f);
end;
constructor Long8Storage.create(source: Long8Storage);
var
length: int;
sarray: long8_Array1d;
buffer: long8_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newLong8_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newLong8_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Long8Storage.clone(): Long8Storage;
begin
result := Long8Storage.create(self);
end;
function Long8Storage.indexOf(const item: long8): int;
var
index: int;
sarray: long8_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = item then begin
result := index;
exit;
end;
result := -1;
end;
function Long8Storage.indexAcquire(const item: long8): int;
var
length: int;
sarray: long8_Array1d;
buffer: long8_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newLong8_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function Long8Storage.readComponent(index: int): long8;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region FloatStorage }
constructor FloatStorage.create();
begin
inherited create();
fldArray := &Array.newInt1d($3f);
end;
constructor FloatStorage.create(source: FloatStorage);
var
length: int;
sarray: int_Array1d;
buffer: int_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := &Array.newInt1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := &Array.newInt1d(int(system.length(sarray)));
&Array.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function FloatStorage.clone(): FloatStorage;
begin
result := FloatStorage.create(self);
end;
function FloatStorage.indexOf(const item: float): int;
var
length: int;
svalue: int absolute item;
begin
length := fldLength;
if length > 0 then begin
result := &Array.indexOf(svalue, fldArray, 0, length);
exit;
end;
result := -1;
end;
function FloatStorage.indexAcquire(const item: float): int;
var
length: int;
svalue: int absolute item;
sarray: int_Array1d;
buffer: int_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := &Array.newInt1d((length shl 1) or 1);
&Array.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function FloatStorage.readComponent(index: int): float;
var
rvalue: int absolute result;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
rvalue := fldArray[index];
end;
{%endregion}
{%region Float2Storage }
constructor Float2Storage.create();
begin
inherited create();
fldArray := VArray.newInt2_1d($3f);
end;
constructor Float2Storage.create(source: Float2Storage);
var
length: int;
sarray: int2_Array1d;
buffer: int2_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newInt2_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newInt2_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Float2Storage.clone(): Float2Storage;
begin
result := Float2Storage.create(self);
end;
function Float2Storage.indexOf(const item: float2): int;
var
index: int;
svalue: int2 absolute item;
sarray: int2_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = svalue then begin
result := index;
exit;
end;
result := -1;
end;
function Float2Storage.indexAcquire(const item: float2): int;
var
length: int;
svalue: int2 absolute item;
sarray: int2_Array1d;
buffer: int2_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newInt2_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function Float2Storage.readComponent(index: int): float2;
var
rvalue: int2 absolute result;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
rvalue := fldArray[index];
end;
{%endregion}
{%region Float4Storage }
constructor Float4Storage.create();
begin
inherited create();
fldArray := VArray.newInt4_1d($3f);
end;
constructor Float4Storage.create(source: Float4Storage);
var
length: int;
sarray: int4_Array1d;
buffer: int4_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newInt4_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newInt4_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Float4Storage.clone(): Float4Storage;
begin
result := Float4Storage.create(self);
end;
function Float4Storage.indexOf(const item: float4): int;
var
index: int;
svalue: int4 absolute item;
sarray: int4_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = svalue then begin
result := index;
exit;
end;
result := -1;
end;
function Float4Storage.indexAcquire(const item: float4): int;
var
length: int;
svalue: int4 absolute item;
sarray: int4_Array1d;
buffer: int4_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newInt4_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function Float4Storage.readComponent(index: int): float4;
var
rvalue: int4 absolute result;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
rvalue := fldArray[index];
end;
{%endregion}
{%region Float8Storage }
constructor Float8Storage.create();
begin
inherited create();
fldArray := VArray.newInt8_1d($3f);
end;
constructor Float8Storage.create(source: Float8Storage);
var
length: int;
sarray: int8_Array1d;
buffer: int8_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newInt8_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newInt8_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Float8Storage.clone(): Float8Storage;
begin
result := Float8Storage.create(self);
end;
function Float8Storage.indexOf(const item: float8): int;
var
index: int;
svalue: int8 absolute item;
sarray: int8_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = svalue then begin
result := index;
exit;
end;
result := -1;
end;
function Float8Storage.indexAcquire(const item: float8): int;
var
length: int;
svalue: int8 absolute item;
sarray: int8_Array1d;
buffer: int8_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newInt8_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function Float8Storage.readComponent(index: int): float8;
var
rvalue: int8 absolute result;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
rvalue := fldArray[index];
end;
{%endregion}
{%region DoubleStorage }
constructor DoubleStorage.create();
begin
inherited create();
fldArray := &Array.newLong1d($3f);
end;
constructor DoubleStorage.create(source: DoubleStorage);
var
length: int;
sarray: long_Array1d;
buffer: long_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := &Array.newLong1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := &Array.newLong1d(int(system.length(sarray)));
&Array.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function DoubleStorage.clone(): DoubleStorage;
begin
result := DoubleStorage.create(self);
end;
function DoubleStorage.indexOf(const item: double): int;
var
length: int;
svalue: long absolute item;
begin
length := fldLength;
if length > 0 then begin
result := &Array.indexOf(svalue, fldArray, 0, length);
exit;
end;
result := -1;
end;
function DoubleStorage.indexAcquire(const item: double): int;
var
length: int;
svalue: long absolute item;
sarray: long_Array1d;
buffer: long_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := &Array.newLong1d((length shl 1) or 1);
&Array.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function DoubleStorage.readComponent(index: int): double;
var
rvalue: long absolute result;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
rvalue := fldArray[index];
end;
{%endregion}
{%region Double2Storage }
constructor Double2Storage.create();
begin
inherited create();
fldArray := VArray.newLong2_1d($3f);
end;
constructor Double2Storage.create(source: Double2Storage);
var
length: int;
sarray: long2_Array1d;
buffer: long2_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newLong2_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newLong2_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Double2Storage.clone(): Double2Storage;
begin
result := Double2Storage.create(self);
end;
function Double2Storage.indexOf(const item: double2): int;
var
index: int;
svalue: long2 absolute item;
sarray: long2_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = svalue then begin
result := index;
exit;
end;
result := -1;
end;
function Double2Storage.indexAcquire(const item: double2): int;
var
length: int;
svalue: long2 absolute item;
sarray: long2_Array1d;
buffer: long2_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newLong2_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function Double2Storage.readComponent(index: int): double2;
var
rvalue: long2 absolute result;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
rvalue := fldArray[index];
end;
{%endregion}
{%region Double4Storage }
constructor Double4Storage.create();
begin
inherited create();
fldArray := VArray.newLong4_1d($3f);
end;
constructor Double4Storage.create(source: Double4Storage);
var
length: int;
sarray: long4_Array1d;
buffer: long4_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newLong4_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newLong4_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Double4Storage.clone(): Double4Storage;
begin
result := Double4Storage.create(self);
end;
function Double4Storage.indexOf(const item: double4): int;
var
index: int;
svalue: long4 absolute item;
sarray: long4_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = svalue then begin
result := index;
exit;
end;
result := -1;
end;
function Double4Storage.indexAcquire(const item: double4): int;
var
length: int;
svalue: long4 absolute item;
sarray: long4_Array1d;
buffer: long4_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newLong4_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function Double4Storage.readComponent(index: int): double4;
var
rvalue: long4 absolute result;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
rvalue := fldArray[index];
end;
{%endregion}
{%region Double8Storage }
constructor Double8Storage.create();
begin
inherited create();
fldArray := VArray.newLong8_1d($3f);
end;
constructor Double8Storage.create(source: Double8Storage);
var
length: int;
sarray: long8_Array1d;
buffer: long8_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := VArray.newLong8_1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := VArray.newLong8_1d(system.length(sarray));
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function Double8Storage.clone(): Double8Storage;
begin
result := Double8Storage.create(self);
end;
function Double8Storage.indexOf(const item: double8): int;
var
index: int;
svalue: long8 absolute item;
sarray: long8_Array1d;
begin
sarray := fldArray;
for index := 0 to fldLength - 1 do if sarray[index] = svalue then begin
result := index;
exit;
end;
result := -1;
end;
function Double8Storage.indexAcquire(const item: double8): int;
var
length: int;
svalue: long8 absolute item;
sarray: long8_Array1d;
buffer: long8_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := VArray.newLong8_1d((length shl 1) or 1);
VArray.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function Double8Storage.readComponent(index: int): double8;
var
rvalue: long8 absolute result;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
rvalue := fldArray[index];
end;
{%endregion}
{%region RealStorage }
constructor RealStorage.create();
begin
inherited create();
fldArray := &Array.newReal1d($3f);
end;
constructor RealStorage.create(source: RealStorage);
var
length: int;
sarray: real_Array1d;
buffer: real_Array1d;
begin
inherited create();
if source = nil then begin
fldArray := &Array.newReal1d($3f);
exit;
end;
length := source.fldLength;
sarray := source.fldArray;
buffer := &Array.newReal1d(int(system.length(sarray)));
&Array.copyPrimitives(sarray, 0, buffer, 0, length);
fldLength := length;
fldArray := buffer;
end;
function RealStorage.clone(): RealStorage;
begin
result := RealStorage.create(self);
end;
function RealStorage.indexOf(const item: real): int;
var
index: int;
svalue: long2;
sarray: real_Array1d;
begin
svalue := VCoReal.toLong2Bits(item);
sarray := fldArray;
for index := 0 to fldLength - 1 do if VCoReal.toLong2Bits(sarray[index]) = svalue then begin
result := index;
exit;
end;
result := -1;
end;
function RealStorage.indexAcquire(const item: real): int;
var
length: int;
sarray: real_Array1d;
buffer: real_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := &Array.newReal1d((length shl 1) or 1);
&Array.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function RealStorage.readComponent(index: int): real;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region AnsiStringStorage }
constructor AnsiStringStorage.create();
begin
inherited create();
fldHashs := &Array.newLong1d($3f);
fldArray := Value_Array1d(&Array.newIUnknown1d($3f));
end;
constructor AnsiStringStorage.create(source: AnsiStringStorage);
var
length: int;
shashs: long_Array1d;
bhashs: long_Array1d;
sarray: Value_Array1d;
barray: Value_Array1d;
begin
inherited create();
if source = nil then begin
fldHashs := &Array.newLong1d($3f);
fldArray := Value_Array1d(&Array.newIUnknown1d($3f));
exit;
end;
length := source.fldLength;
shashs := source.fldHashs;
sarray := source.fldArray;
bhashs := &Array.newLong1d(int(system.length(shashs)));
barray := Value_Array1d(&Array.newIUnknown1d(int(system.length(sarray))));
&Array.copyPrimitives(shashs, 0, bhashs, 0, length);
&Array.copyUnknowns(sarray, 0, barray, 0, length);
fldLength := length;
fldHashs := bhashs;
fldArray := barray;
end;
function AnsiStringStorage.clone(): AnsiStringStorage;
begin
result := AnsiStringStorage.create(self);
end;
function AnsiStringStorage.indexOf(const item: AnsiString): int;
var
length: int;
index: int;
hash: long;
svalue: Value;
shashs: long_Array1d;
sarray: Value_Array1d;
begin
length := fldLength;
if length > 0 then begin
sarray := fldArray;
shashs := fldHashs;
svalue := CoAnsiString.create(item);
hash := svalue.getHashCode();
index := -1;
repeat
index := &Array.indexOf(hash, shashs, index + 1, length - index - 1);
if index < 0 then break;
if svalue.equals(sarray[index] as TObject) then begin
result := index;
exit;
end;
until false;
end;
result := -1;
end;
function AnsiStringStorage.indexAcquire(const item: AnsiString): int;
var
capacity: int;
length: int;
hash: long;
svalue: Value;
shashs: long_Array1d;
bhashs: long_Array1d;
sarray: Value_Array1d;
barray: Value_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
shashs := fldHashs;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (length shl 1) or 1;
bhashs := &Array.newLong1d(capacity);
barray := Value_Array1d(&Array.newIUnknown1d(capacity));
&Array.copyPrimitives(shashs, 0, bhashs, 0, length);
&Array.copyUnknowns(sarray, 0, barray, 0, length);
fldHashs := bhashs;
fldArray := barray;
shashs := bhashs;
sarray := barray;
end;
svalue := CoAnsiString.create(item);
hash := svalue.getHashCode();
shashs[length] := hash;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function AnsiStringStorage.readComponent(index: int): AnsiString;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index].asAnsiString();
end;
{%endregion}
{%region UnicodeStringStorage }
constructor UnicodeStringStorage.create();
begin
inherited create();
fldHashs := &Array.newLong1d($3f);
fldArray := Value_Array1d(&Array.newIUnknown1d($3f));
end;
constructor UnicodeStringStorage.create(source: UnicodeStringStorage);
var
length: int;
shashs: long_Array1d;
bhashs: long_Array1d;
sarray: Value_Array1d;
barray: Value_Array1d;
begin
inherited create();
if source = nil then begin
fldHashs := &Array.newLong1d($3f);
fldArray := Value_Array1d(&Array.newIUnknown1d($3f));
exit;
end;
length := source.fldLength;
shashs := source.fldHashs;
sarray := source.fldArray;
bhashs := &Array.newLong1d(int(system.length(shashs)));
barray := Value_Array1d(&Array.newIUnknown1d(int(system.length(sarray))));
&Array.copyPrimitives(shashs, 0, bhashs, 0, length);
&Array.copyUnknowns(sarray, 0, barray, 0, length);
fldLength := length;
fldHashs := bhashs;
fldArray := barray;
end;
function UnicodeStringStorage.clone(): UnicodeStringStorage;
begin
result := UnicodeStringStorage.create(self);
end;
function UnicodeStringStorage.indexOf(const item: UnicodeString): int;
var
length: int;
index: int;
hash: long;
svalue: Value;
shashs: long_Array1d;
sarray: Value_Array1d;
begin
length := fldLength;
if length > 0 then begin
sarray := fldArray;
shashs := fldHashs;
svalue := CoUnicodeString.create(item);
hash := svalue.getHashCode();
index := -1;
repeat
index := &Array.indexOf(hash, shashs, index + 1, length - index - 1);
if index < 0 then break;
if svalue.equals(sarray[index] as TObject) then begin
result := index;
exit;
end;
until false;
end;
result := -1;
end;
function UnicodeStringStorage.indexAcquire(const item: UnicodeString): int;
var
capacity: int;
length: int;
hash: long;
svalue: Value;
shashs: long_Array1d;
bhashs: long_Array1d;
sarray: Value_Array1d;
barray: Value_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
shashs := fldHashs;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (length shl 1) or 1;
bhashs := &Array.newLong1d(capacity);
barray := Value_Array1d(&Array.newIUnknown1d(capacity));
&Array.copyPrimitives(shashs, 0, bhashs, 0, length);
&Array.copyUnknowns(sarray, 0, barray, 0, length);
fldHashs := bhashs;
fldArray := barray;
shashs := bhashs;
sarray := barray;
end;
svalue := CoUnicodeString.create(item);
hash := svalue.getHashCode();
shashs[length] := hash;
sarray[length] := svalue;
fldLength := length + 1;
end;
result := length;
end;
function UnicodeStringStorage.readComponent(index: int): UnicodeString;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index].asUnicodeString();
end;
{%endregion}
{%region ArgumentArrayStorage }
constructor ArgumentArrayStorage.create();
begin
inherited create();
fldHashs := &Array.newLong1d($3f);
fldArray := ArgumentArray_Array1d(&Array.newTObject1d($3f));
end;
function ArgumentArrayStorage.indexOf(const item: ArgumentArray): int;
var
length: int;
index: int;
hash: long;
shashs: long_Array1d;
sarray: ArgumentArray_Array1d;
begin
length := fldLength;
if length > 0 then begin
if item = nil then begin
result := &Array.indexOf(nil, fldArray, 0, length);
exit;
end;
sarray := fldArray;
index := &Array.indexOf(item, sarray, 0, length);
if index >= 0 then begin
result := index;
exit;
end;
shashs := fldHashs;
hash := item.getHashCode();
index := -1;
repeat
index := &Array.indexOf(hash, shashs, index + 1, length - index - 1);
if index < 0 then break;
if item.equals(sarray[index]) then begin
result := index;
exit;
end;
until false;
end;
result := -1;
end;
function ArgumentArrayStorage.indexAcquire(const item: ArgumentArray): int;
var
capacity: int;
length: int;
hash: long;
shashs: long_Array1d;
bhashs: long_Array1d;
sarray: ArgumentArray_Array1d;
barray: ArgumentArray_Array1d;
begin
length := indexOf(item);
if length < 0 then begin
length := fldLength;
shashs := fldHashs;
sarray := fldArray;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (length shl 1) or 1;
bhashs := &Array.newLong1d(capacity);
barray := ArgumentArray_Array1d(&Array.newTObject1d(capacity));
&Array.copyPrimitives(shashs, 0, bhashs, 0, length);
&Array.copyObjects(sarray, 0, barray, 0, length);
fldHashs := bhashs;
fldArray := barray;
shashs := bhashs;
sarray := barray;
end;
if item = nil then begin
hash := 0;
end else begin
hash := item.getHashCode();
end;
shashs[length] := hash;
sarray[length] := item;
fldLength := length + 1;
end;
result := length;
end;
function ArgumentArrayStorage.readComponent(index: int): ArgumentArray;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
{%endregion}
{%region LexemeSequence }
procedure LexemeSequence.checkPosition(position: int);
begin
if (position < 0) or (position >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
end;
procedure LexemeSequence.appendLexemeInternal(lineIndex, charIndex, lexemeKind, lexemeType, lexemeValue: int);
var
length: int;
capacity: int;
slexemes: int4_Array1d;
blexemes: int4_Array1d;
sobjects: TObject_Array1d;
bobjects: TObject_Array1d;
begin
length := fldLength;
slexemes := fldLexemes;
sobjects := fldObjects;
if length = system.length(slexemes) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (length shl 1) or 1;
blexemes := VArray.newInt4_1d(capacity);
bobjects := &Array.newTObject1d(capacity);
VArray.copyPrimitives(slexemes, 0, blexemes, 0, length);
&Array.copyObjects(sobjects, 0, bobjects, 0, length);
fldLexemes := blexemes;
fldObjects := bobjects;
slexemes := blexemes;
sobjects := bobjects;
end;
slexemes[length] := Vector.newInt4(lineIndex, charIndex, (lexemeKind shl 4) or lexemeType, lexemeValue);
fldLength := length + 1;
end;
procedure LexemeSequence.appendLexemeInternal(lineIndex, charIndex, lexemeKind, lexemeType, lexemeValue: int; component: TObject);
var
length: int;
capacity: int;
slexemes: int4_Array1d;
blexemes: int4_Array1d;
sobjects: TObject_Array1d;
bobjects: TObject_Array1d;
begin
length := fldLength;
slexemes := fldLexemes;
sobjects := fldObjects;
if length = system.length(slexemes) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (length shl 1) or 1;
blexemes := VArray.newInt4_1d(capacity);
bobjects := &Array.newTObject1d(capacity);
VArray.copyPrimitives(slexemes, 0, blexemes, 0, length);
&Array.copyObjects(sobjects, 0, bobjects, 0, length);
fldLexemes := blexemes;
fldObjects := bobjects;
slexemes := blexemes;
sobjects := bobjects;
end;
slexemes[length] := Vector.newInt4(lineIndex, charIndex, (lexemeKind shl 4) or lexemeType, lexemeValue);
sobjects[length] := component;
fldLength := length + 1;
end;
function LexemeSequence.getLongs(): LongStorage;
var
storage: LongStorage;
begin
storage := fldLongs;
if storage = nil then begin
storage := LongStorage.create();
fldLongs := storage;
end;
result := storage;
end;
function LexemeSequence.getReals(): RealStorage;
var
storage: RealStorage;
begin
storage := fldReals;
if storage = nil then begin
storage := RealStorage.create();
fldReals := storage;
end;
result := storage;
end;
function LexemeSequence.getFloats(): FloatStorage;
var
storage: FloatStorage;
begin
storage := fldFloats;
if storage = nil then begin
storage := FloatStorage.create();
fldFloats := storage;
end;
result := storage;
end;
function LexemeSequence.getDoubles(): DoubleStorage;
var
storage: DoubleStorage;
begin
storage := fldDoubles;
if storage = nil then begin
storage := DoubleStorage.create();
fldDoubles := storage;
end;
result := storage;
end;
function LexemeSequence.getStrings(): UnicodeStringStorage;
var
storage: UnicodeStringStorage;
begin
storage := fldStrings;
if storage = nil then begin
storage := UnicodeStringStorage.create();
fldStrings := storage;
end;
result := storage;
end;
constructor LexemeSequence.create();
begin
inherited create();
fldLexemes := VArray.newInt4_1d($3f);
fldObjects := &Array.newTObject1d($3f);
end;
destructor LexemeSequence.destroy;
var
index: int;
component: TObject;
objects: TObject_Array1d;
begin
objects := fldObjects;
for index := 0 to fldLength - 1 do begin
component := objects[index];
if (component <> self) and (component is LexemeSequence) then begin
component.free();
objects[index] := nil;
end;
end;
fldLongs.free();
fldReals.free();
fldFloats.free();
fldDoubles.free();
fldStrings.free();
inherited destroy;
end;
procedure LexemeSequence.writeComponent(position: int; value: TObject);
begin
checkPosition(position);
fldObjects[position] := value;
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_NONE, 0);
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: boolean);
var
lvalue: int;
begin
if lexemeValue then begin
lvalue := -1;
end else begin
lvalue := 0;
end;
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_BOOLEAN, lvalue);
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: uchar);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_CHAR, int(lexemeValue));
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: byte);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_BYTE, lexemeValue);
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: short);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_SHORT, lexemeValue);
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: int);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_INT, lexemeValue);
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: long);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_LONG, getLongs().indexAcquire(lexemeValue));
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: float);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_FLOAT, getFloats().indexAcquire(lexemeValue));
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: double);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_DOUBLE, getDoubles().indexAcquire(lexemeValue));
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: real);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_REAL, getReals().indexAcquire(lexemeValue));
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; const lexemeValue: UnicodeString);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_STRING, getStrings().indexAcquire(lexemeValue));
end;
procedure LexemeSequence.appendLexeme(lineIndex, charIndex, lexemeKind: int; component: TObject);
begin
appendLexemeInternal(lineIndex, charIndex, lexemeKind, LT_NONE, 0, component);
end;
procedure LexemeSequence.insertLexeme(position, lineIndex, charIndex, lexemeKind: int);
var
length: int;
nextpos: int;
copylen: int;
capacity: int;
slexemes: int4_Array1d;
blexemes: int4_Array1d;
sobjects: TObject_Array1d;
bobjects: TObject_Array1d;
begin
length := fldLength;
slexemes := fldLexemes;
sobjects := fldObjects;
if length = system.length(slexemes) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (length shl 1) or 1;
blexemes := VArray.newInt4_1d(capacity);
bobjects := &Array.newTObject1d(capacity);
VArray.copyPrimitives(slexemes, 0, blexemes, 0, length);
&Array.copyObjects(sobjects, 0, bobjects, 0, length);
fldLexemes := blexemes;
fldObjects := bobjects;
slexemes := blexemes;
sobjects := bobjects;
end;
if position < 0 then position := 0;
if position > length then position := length;
nextpos := position + 1;
copylen := length - position;
VArray.copyPrimitives(slexemes, position, slexemes, nextpos, copylen);
&Array.copyObjects(sobjects, position, sobjects, nextpos, copylen);
slexemes[position] := Vector.newInt4(lineIndex, charIndex, lexemeKind shl 4, 0);
sobjects[position] := nil;
fldLength := length + 1;
end;
procedure LexemeSequence.setLexeme(position, lineIndex, charIndex, lexemeKind: int);
begin
checkPosition(position);
fldLexemes[position] := Vector.newInt4(lineIndex, charIndex, lexemeKind shl 4, 0);
end;
procedure LexemeSequence.removeLexeme(position: int);
var
length: int;
nextpos: int;
copylen: int;
slexemes: int4_Array1d;
sobjects: TObject_Array1d;
begin
length := fldLength;
if (position < 0) or (position >= length) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
slexemes := fldLexemes;
sobjects := fldObjects;
nextpos := position + 1;
copylen := length - nextpos;
VArray.copyPrimitives(slexemes, nextpos, slexemes, position, copylen);
&Array.copyObjects(sobjects, nextpos, sobjects, position, copylen);
dec(length);
slexemes[length] := 0;
sobjects[length] := nil;
fldLength := length;
end;
function LexemeSequence.readComponent(position: int): TObject;
begin
checkPosition(position);
result := fldObjects[position];
end;
function LexemeSequence.getLength(): int;
begin
result := fldLength;
end;
function LexemeSequence.getLineIndex(position: int): int;
begin
checkPosition(position);
result := fldLexemes[position][0];
end;
function LexemeSequence.getCharIndex(position: int): int;
begin
checkPosition(position);
result := fldLexemes[position][1];
end;
function LexemeSequence.getLexemeKind(position: int): int;
begin
checkPosition(position);
result := CoInt.sar(fldLexemes[position][2], 4);
end;
function LexemeSequence.getLexemeType(position: int): int;
begin
checkPosition(position);
result := fldLexemes[position][2] and $0f;
end;
function LexemeSequence.getLexemeLocation(position: int): int2;
begin
checkPosition(position);
result := Cast.toInt2(fldLexemes[position]);
end;
function LexemeSequence.getLexemeInfo(position: int): int4;
var
kind: int;
info: int4;
begin
checkPosition(position);
info := fldLexemes[position];
kind := info[2];
info[2] := CoInt.sar(kind, 4);
info[3] := kind and $0f;
result := info;
end;
function LexemeSequence.getLexemeBoolean(position: int): boolean;
var
info: int4;
begin
checkPosition(position);
info := fldLexemes[position];
case info[2] and $0f of
LT_BOOLEAN:
result := info[3] <> 0;
else
raise IllegalLexemeTypeException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-type.lexeme'));
end;
end;
function LexemeSequence.getLexemeChar(position: int): uchar;
var
info: int4;
begin
checkPosition(position);
info := fldLexemes[position];
case info[2] and $0f of
LT_CHAR:
result := uchar(info[3]);
else
raise IllegalLexemeTypeException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-type.lexeme'));
end;
end;
function LexemeSequence.getLexemeInt(position: int): int;
var
info: int4;
begin
checkPosition(position);
info := fldLexemes[position];
case info[2] and $0f of
LT_BYTE..LT_INT:
result := info[3];
else
raise IllegalLexemeTypeException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-type.lexeme'));
end;
end;
function LexemeSequence.getLexemeLong(position: int): long;
var
info: int4;
begin
checkPosition(position);
info := fldLexemes[position];
case info[2] and $0f of
LT_BYTE..LT_INT:
result := info[3];
LT_LONG:
result := fldLongs.readComponent(info[3]);
else
raise IllegalLexemeTypeException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-type.lexeme'));
end;
end;
function LexemeSequence.getLexemeFloat(position: int): float;
var
info: int4;
begin
checkPosition(position);
info := fldLexemes[position];
case info[2] and $0f of
LT_FLOAT:
result := fldFloats.readComponent(info[3]);
else
raise IllegalLexemeTypeException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-type.lexeme'));
end;
end;
function LexemeSequence.getLexemeDouble(position: int): double;
var
info: int4;
begin
checkPosition(position);
info := fldLexemes[position];
case info[2] and $0f of
LT_FLOAT:
result := fldFloats.readComponent(info[3]);
LT_DOUBLE:
result := fldDoubles.readComponent(info[3]);
else
raise IllegalLexemeTypeException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-type.lexeme'));
end;
end;
function LexemeSequence.getLexemeReal(position: int): real;
var
info: int4;
begin
checkPosition(position);
info := fldLexemes[position];
case info[2] and $0f of
LT_FLOAT:
result := fldFloats.readComponent(info[3]);
LT_DOUBLE:
result := fldDoubles.readComponent(info[3]);
LT_REAL:
result := fldReals.readComponent(info[3]);
else
raise IllegalLexemeTypeException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-type.lexeme'));
end;
end;
function LexemeSequence.getLexemeString(position: int): UnicodeString;
var
info: int4;
begin
checkPosition(position);
info := fldLexemes[position];
case info[2] and $0f of
LT_STRING:
result := fldStrings.readComponent(info[3]);
else
raise IllegalLexemeTypeException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-type.lexeme'));
end;
end;
{%endregion}
{%region TextSource }
procedure TextSource.setOwner(newOwner: Package);
begin
fldOwner := newOwner;
end;
constructor TextSource.create(__parentLibrary: &Library; const __relativePath: UnicodeString);
var
solidusPosition: int;
begin
inherited create();
solidusPosition := __relativePath.indexOf('/');
if solidusPosition < 1 then solidusPosition := 1;
fldFileName := AVTOOService.getObjectName(__relativePath);
fldRelativePath := __relativePath;
fldTextSourcePath := __relativePath.substring(solidusPosition);
fldImportedTable := HashtableOfAnsiStringToClassType.create();
fldDeclaredTable := HashtableOfAnsiStringToClassType.create();
fldImportedArray := RequiredReflectItemArray.create(false);
fldDeclaredArray := ClassTypeArray.create(false);
fldParentLibrary := __parentLibrary;
if __parentLibrary <> nil then begin
fldParentProgramme := __parentLibrary.parentProgramme;
end;
end;
destructor TextSource.destroy;
begin
fldLines.free();
fldImportedTable.free();
fldDeclaredTable.free();
fldImportedArray.free();
fldDeclaredArray.free();
inherited destroy;
end;
procedure TextSource.loadFromInputStream(stream: ByteReader);
begin
loadFromInputStream(stream, nil);
end;
procedure TextSource.loadFromInputStream(stream: ByteReader; decoder: CharDecoder);
var
readed: int;
length: int;
size: long;
data: byte_Array1d;
buffer: byte_Array1d;
sizeable: LimitedSizeExtension;
begin
if stream = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('stream') ]));
end;
sizeable := LimitedSizeExtension(stream.getExtension(LimitedSizeExtension));
if sizeable = nil then begin
raise InvalidStreamException.create(AnsiString.format(
AResource.readUnitResourceAsAnsiString(platform.independent.streamformat.UNIT_NAME, 'invalid-stream.input.unsupported-extension'), [
CoAnsiString.create(Lang.classFor(LimitedSizeExtension).getSimpleName())
]
));
end;
size := sizeable.available();
if (size < 0) or (size > CoInt.MAX_VALUE) then begin
raise InvalidStreamException.create(AResource.readUnitResourceAsAnsiString(platform.independent.streamformat.UNIT_NAME, 'invalid-stream.input.size-too-large'));
end;
length := int(size);
data := &Array.newByte1d(length);
readed := stream.read(data, 0, length);
if readed < length then begin
buffer := &Array.newByte1d(readed);
&Array.copyPrimitives(data, 0, buffer, 0, readed);
data := buffer;
end;
fldInputStream := data;
fldDecoder := decoder;
fldLoaded := true;
end;
procedure TextSource.loadFromFileStream();
var
sourcePath: UnicodeString;
fileSystem: platform.independent.filesystem.FileSystem;
stream: ByteReader;
__parentLibrary: &Library;
begin
__parentLibrary := fldParentLibrary;
if __parentLibrary = nil then begin
fileSystem := FileSystemRoot.get(Process.current().workingDirectory).fileSystem;
sourcePath := fldRelativePath;
end else begin
fileSystem := __parentLibrary.fileSystem;
sourcePath := __parentLibrary.directoryPath + fldRelativePath;
end;
stream := fileSystem.openFileForRead(sourcePath);
try
loadFromInputStream(stream, nil);
finally
stream.close();
end;
end;
procedure TextSource.parseInputStream();
var
owned: boolean;
bom: int;
position: int;
available: int;
__text: UnicodeString;
source: byte_Array1d;
decoder: CharDecoder;
exception: TextSourceException;
begin
{ преобразование массива байт в массив символов }
if not fldLoaded then begin
raise IllegalSourceStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'source.not-loaded'));
end;
owned := false;
source := fldInputStream;
decoder := fldDecoder;
position := 0;
available := system.length(source);
fldLoaded := false;
fldDecoder := nil;
fldInputStream := nil;
if decoder = nil then begin
{ UTF-кодировка }
if available >= 3 then begin
bom := ((source[2] and $ff) shl &20) or ((source[1] and $ff) shl &10) or (source[0] and $ff);
end else
if available = 2 then begin
bom := ((source[1] and $ff) shl &10) or (source[0] and $ff);
end else begin
bom := 0;
end;
owned := true;
try
if bom = $bfbbef then begin
position := 3;
decoder := Charset.get('UTF-8').newDecoder();
end else begin
bom := bom and $ffff;
if bom = $feff then begin
position := 2;
decoder := Charset.get('UTF-16 LE').newDecoder();
end else
if bom = $fffe then begin
position := 2;
decoder := Charset.get('UTF-16 BE').newDecoder();
end else begin
decoder := Charset.get('UTF-8').newDecoder();
end;
end;
except
on exc: UnsupportedCharsetNameException do begin
exception := TextSourceException.create(exc.message, exc.helpContext);
exception.source := self;
raise exception;
end;
end;
end;
try
{ любая кодировка }
try
fldLines.free();
fldLines := nil;
decoder.errorAction := ErrorAction.eaIgnore;
__text := UnicodeString.create(decoder.decode(source, position, available - position));
fldText := __text;
fldLines := UnicodeStringArray.create(__text.split());
except
on exc: CharacterDecodingException do begin
exception := TextSourceException.create(exc.message, exc.helpContext);
exception.source := self;
raise exception;
end;
end;
finally
if owned then decoder.free();
end;
end;
procedure TextSource.appendDeclared(__declared: ClassType);
begin
if __declared = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('declared') ]));
end;
fldDeclaredArray.append(__declared);
fldDeclaredTable[__declared.specialSimpleName] := __declared;
end;
procedure TextSource.appendImported(__imported: RequiredReflectItem);
begin
if __imported = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('imported') ]));
end;
fldImportedArray.append(__imported);
if __imported is ru.malik.elaborarer.avtoo.lang.ClassType then fldImportedTable[__imported.specialSimpleName] := ru.malik.elaborarer.avtoo.lang.ClassType(__imported);
end;
function TextSource.contains(&type: ClassType): boolean;
var
index: int;
__length: int;
__imported: RequiredReflectItem_Array1d;
__programme: Programme;
item: RequiredReflectItem;
begin
if &type = nil then begin
result := false;
exit;
end;
if &Array.indexOf(&type, fldDeclaredArray.&array, 0, 0) >= 0 then begin
result := true;
exit;
end;
__programme := fldParentProgramme;
with fldImportedArray do begin
__length := length;
__imported := &array;
end;
for index := __length downto -1 do begin
if index >= __length then begin
item := fldOwner;
end else
if index >= 0 then begin
item := __imported[index];
end else
if __programme <> nil then begin
item := __programme.getLanguagePackage();
end else begin
item := nil;
end;
if (item <> nil) and ((&type = item) or (&type.parentPackage = item)) then begin
result := true;
exit;
end;
end;
result := false;
end;
function TextSource.isSameSource(anot: Source): boolean;
var
src: TextSource;
begin
if not Lang.isInstance(anot, TextSource) then begin
result := false;
exit;
end;
src := TextSource(Lang.cast(anot, TextSource));
result := (src.fldOwner = fldOwner) and (src.fldFileName = fldFileName);
end;
function TextSource.getRelativePath(): UnicodeString;
begin
result := fldRelativePath;
end;
function TextSource.getContents(): Measureable;
begin
result := fldLines;
end;
function TextSource.getDeclared(): ClassTypeArray;
begin
result := fldDeclaredArray;
end;
function TextSource.getParentLibrary(): &Library;
begin
result := fldParentLibrary;
end;
function TextSource.getParentProgramme(): Programme;
begin
result := fldParentProgramme;
end;
function TextSource.isImported(pack: Package): boolean;
begin
result := fldImportedArray.indexOf(pack) >= 0;
end;
function TextSource.findImplicitlyImportedTypes(const specialSimpleName: AnsiString; enclosingClass: ClassType): ClassType_Array1d;
label
break_label0;
var
index: int;
rlength: int;
__length: int;
__imported: RequiredReflectItem_Array1d;
found: ClassType_Array1d;
item: ProgrammeItem;
begin
if specialSimpleName.length <= 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-argument.empty.item-name'));
end;
if enclosingClass = nil then begin
raise NullPointerException.create(AnsiString.format(
AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [
CoAnsiString.create('enclosingClass')
]
));
end;
if enclosingClass.parentProgramme <> fldParentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.source'));
end;
rlength := 0;
found := ClassType_Array1d(&Array.newTObject1d(2));
with fldImportedArray do begin
__length := length;
__imported := &array;
end;
begin
{ поиск видимых типов }
for index := __length - 1 downto 0 do begin
item := __imported[index];
if item is Package then begin
item := item.getChildItem(specialSimpleName);
if (item is ru.malik.elaborarer.avtoo.lang.ClassType) and ReflectItem(item).isVisibleFrom(enclosingClass) then begin
found[rlength] := ru.malik.elaborarer.avtoo.lang.ClassType(item);
inc(rlength);
if rlength = 2 then goto break_label0;
end;
end;
end;
{ поиск типа без учёта видимости }
if rlength = 0 then for index := __length - 1 downto 0 do begin
item := __imported[index];
if item is Package then begin
item := item.getChildItem(specialSimpleName);
if item is ru.malik.elaborarer.avtoo.lang.ClassType then begin
found[rlength] := ru.malik.elaborarer.avtoo.lang.ClassType(item);
inc(rlength);
goto break_label0;
end;
end;
end;
end;
break_label0:
case rlength of
1:
result := [ found[0] ];
2:
result := found;
else
result := nil;
end;
end;
function TextSource.getImportedType(const specialSimpleName: AnsiString): ClassType;
begin
result := fldImportedTable[specialSimpleName];
end;
function TextSource.getDeclaredType(const specialSimpleName: AnsiString): ClassType;
begin
result := fldDeclaredTable[specialSimpleName];
end;
{%endregion}
{%region BinarySource }
constructor BinarySource.create(__parentLibrary: &Library; const __relativePath: UnicodeString);
begin
inherited create();
fldRelativePath := __relativePath;
fldDeclaredArray := ClassTypeArray.create(false);
fldParentLibrary := __parentLibrary;
if __parentLibrary <> nil then begin
fldParentProgramme := __parentLibrary.parentProgramme;
end;
end;
destructor BinarySource.destroy;
begin
fldChunks.free();
fldDeclaredArray.free();
inherited destroy;
end;
procedure BinarySource.loadFromInputStream(stream: ByteReader);
var
readed: int;
length: int;
size: long;
data: byte_Array1d;
buffer: byte_Array1d;
sizeable: LimitedSizeExtension;
begin
if stream = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('stream') ]));
end;
sizeable := LimitedSizeExtension(stream.getExtension(LimitedSizeExtension));
if sizeable = nil then begin
raise InvalidStreamException.create(AnsiString.format(
AResource.readUnitResourceAsAnsiString(platform.independent.streamformat.UNIT_NAME, 'invalid-stream.input.unsupported-extension'), [
CoAnsiString.create(Lang.classFor(LimitedSizeExtension).getSimpleName())
]
));
end;
size := sizeable.available();
if (size < 0) or (size > CoInt.MAX_VALUE) then begin
raise InvalidStreamException.create(AResource.readUnitResourceAsAnsiString(platform.independent.streamformat.UNIT_NAME, 'invalid-stream.input.size-too-large'));
end;
length := int(size);
data := &Array.newByte1d(length);
readed := stream.read(data, 0, length);
if readed < length then begin
buffer := &Array.newByte1d(readed);
&Array.copyPrimitives(data, 0, buffer, 0, readed);
data := buffer;
end;
fldInputStream := data;
fldLoaded := true;
end;
procedure BinarySource.loadFromFileStream();
var
sourcePath: UnicodeString;
fileSystem: platform.independent.filesystem.FileSystem;
stream: ByteReader;
__parentLibrary: &Library;
begin
__parentLibrary := fldParentLibrary;
if __parentLibrary = nil then begin
fileSystem := FileSystemRoot.get(Process.current().workingDirectory).fileSystem;
sourcePath := fldRelativePath;
end else begin
fileSystem := __parentLibrary.fileSystem;
sourcePath := __parentLibrary.directoryPath + fldRelativePath;
end;
stream := fileSystem.openFileForRead(sourcePath);
try
loadFromInputStream(stream);
finally
stream.close();
end;
end;
procedure BinarySource.parseInputStream();
var
hash: int;
&type: int;
offset: int;
dlength: int;
clength: int;
data: byte_Array1d;
source: byte_Array1d;
__chunks: Chunk_Array1d;
buffer: Chunk_Array1d;
stream: ByteArrayInputStream;
input: DataInputStream;
checksum: Checksum32;
exception: BinarySourceException;
begin
{ преобразование массива байт в поток ввода данных }
if not fldLoaded then begin
raise IllegalSourceStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'source.not-loaded'));
end;
source := fldInputStream;
fldLoaded := false;
fldInputStream := nil;
clength := 0;
__chunks := Chunk_Array1d(&Array.newTObject1d($0f));
checksum := nil;
stream := ByteArrayInputStream.create(source);
input := DataInputStream.create(stream);
try
checksum := CRC32.create();
with input.bigEndianDataInput, checksum do try
{ чтение сигнатуры }
if readLong() <> SIGNATURE_AVTR then begin
exception := BinarySourceException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'binary-source.format.invalid-signature'));
exception.source := self;
exception.offset := int(stream.position());
raise exception;
end;
{ чтение кусков }
while stream.available() > 0 do begin
dlength := readInt();
if (dlength > ((CoInt.MAX_VALUE - 4) shr 1)) or (dlength < 0) then begin
exception := BinarySourceException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'binary-source.format.invalid-chunk-length'));
exception.source := self;
exception.offset := int(stream.position());
raise exception;
end;
if dlength > ((int(stream.available()) - 4) shr 1) then begin
exception := BinarySourceException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'binary-source.format.invalid-markup'));
exception.source := self;
exception.offset := int(stream.position());
raise exception;
end;
offset := int(stream.position());
&type := readInt();
data := &Array.newByte1d(dlength shl 1);
readFully(data);
hash := readInt();
update(source, offset, (dlength + 2) shl 1);
if getValue() <> hash then begin
exception := BinarySourceException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'binary-source.format.invalid-checksum'));
exception.source := self;
exception.offset := int(stream.position());
raise exception;
end;
reset();
if clength = system.length(__chunks) then begin
buffer := Chunk_Array1d(&Array.newTObject1d((clength shl 1) or 1));
&Array.copyObjects(__chunks, 0, buffer, 0, clength);
__chunks := buffer;
end;
__chunks[clength] := Chunk.create(offset, &type, data, hash);
inc(clength);
if &type = CHUNK_IEND then break;
end;
except
on exc: IOException do begin
exception := BinarySourceException.create(exc.message, exc.helpContext);
exception.source := self;
exception.offset := int(stream.position());
raise exception;
end;
end;
finally
checksum.free();
input.close();
end;
{ обрезка массива кусков }
if clength <> system.length(__chunks) then begin
buffer := Chunk_Array1d(&Array.newTObject1d(clength));
&Array.copyObjects(__chunks, 0, buffer, 0, clength);
__chunks := buffer;
end;
fldObjects := &Array.newTObject1d(clength);
fldChunks := ChunkArray.create(__chunks);
end;
procedure BinarySource.appendDeclared(__declared: ClassType);
begin
if __declared = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('declared') ]));
end;
fldDeclaredArray.append(__declared);
end;
procedure BinarySource.writeComponent(index: int; value: TObject);
var
objects: TObject_Array1d;
begin
objects := fldObjects;
if (index < 0) or (index >= system.length(objects)) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
objects[index] := value;
end;
function BinarySource.contains(&type: ClassType): boolean;
begin
result := false;
end;
function BinarySource.isSameSource(anot: Source): boolean;
begin
result := Lang.cast(anot, TObject) = self;
end;
function BinarySource.getLength(): int;
begin
result := system.length(fldObjects);
end;
function BinarySource.readComponent(index: int): TObject;
var
objects: TObject_Array1d;
begin
objects := fldObjects;
if (index < 0) or (index >= system.length(objects)) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := objects[index];
end;
function BinarySource.getRelativePath(): UnicodeString;
begin
result := fldRelativePath;
end;
function BinarySource.getContents(): Measureable;
begin
result := fldChunks;
end;
function BinarySource.getDeclared(): ClassTypeArray;
begin
result := fldDeclaredArray;
end;
function BinarySource.getParentLibrary(): &Library;
begin
result := fldParentLibrary;
end;
function BinarySource.getParentProgramme(): Programme;
begin
result := fldParentProgramme;
end;
{%endregion}
{%region Chunk }
class function Chunk.typeToString(&type: int): AnsiString;
var
chars: char_Array1d;
begin
chars := [ char((&type shr &30) and $5f), char((&type shr &20) and $5f), char((&type shr &10) and $5f), char(&type and $5f) ];
result := AnsiString.create(chars);
end;
procedure Chunk.setPosition(newPosition: int);
var
length: int;
begin
length := fldLength;
if newPosition < 0 then newPosition := 0;
if newPosition > length then newPosition := length;
ChunkByteArrayInputStream(fldStream).position := newPosition;
end;
function Chunk.getPosition(): int;
begin
result := ChunkByteArrayInputStream(fldStream).position;
end;
constructor Chunk.create(__offset, __type: int; const __data: byte_Array1d; __hash: int);
var
driver: DataInputStream;
stream: ChunkByteArrayInputStream;
begin
inherited create();
stream := ChunkByteArrayInputStream.create(__data);
driver := DataInputStream.create(stream);
fldHash := __hash;
fldOffset := __offset;
fldLength := system.length(__data) shr 1;
fldTypeAsInt := __type;
fldTypeAsString := typeToString(__type);
fldData := __data;
fldInput := driver.bigEndianDataInput;
fldDriver := driver;
fldStream := stream;
end;
destructor Chunk.destroy;
begin
fldDriver.close();
inherited destroy;
end;
procedure Chunk.readFully(const dst: byte_Array1d);
begin
raise UnsupportedOperationException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'chunk.read'));
end;
procedure Chunk.readFully(const dst: byte_Array1d; offset, length: int);
begin
raise UnsupportedOperationException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'chunk.read'));
end;
procedure Chunk.readFully(const dst: uchar_Array1d);
begin
readFully(dst, 0, system.length(dst));
end;
procedure Chunk.readFully(const dst: uchar_Array1d; offset, length: int);
begin
&Array.checkBounds(dst, offset, length);
if ChunkByteArrayInputStream(fldStream).position > fldLength - length then begin
raise EndOfStreamException.create(AResource.readUnitResourceAsAnsiString(pascalx.io.UNIT_NAME, 'io.read.end-of-stream'));
end;
with fldInput do while length > 0 do begin
dst[offset] := readUChar();
inc(offset);
dec(length);
end;
end;
function Chunk.equals(anot: TObject): boolean;
var
length: int;
__chunk: chunk;
begin
if anot = self then begin
result := true;
exit;
end;
if anot is Chunk then begin
__chunk := Chunk(anot);
if fldTypeAsInt = __chunk.fldTypeAsInt then begin
length := fldLength;
if (length = __chunk.fldLength) and (&Array.offsetOfNonEqual(fldData, 0, __chunk.fldData, 0, length) = &Array.NOT_FOUND) then begin
result := true;
exit;
end;
end;
end;
result := false;
end;
function Chunk.getHashCode(): long;
begin
result := Vector.lup(fldHash);
end;
function Chunk.toString(): AnsiString;
begin
result := AnsiString.format(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'chunk.string'), [
CoAnsiString.create(fldTypeAsString), CoAnsiString.create(CoInt.toString(fldLength))
]);
end;
function Chunk.getLength(): int;
begin
result := fldLength;
end;
function Chunk.readBoolean(): boolean;
begin
result := fldInput.readShort() <> 0;
end;
function Chunk.readChar(): char;
begin
result := char(fldInput.readUnsignedShort());
end;
function Chunk.readUChar(): uchar;
begin
result := uchar(fldInput.readUnsignedShort());
end;
function Chunk.readUnsignedByte(): int;
begin
result := fldInput.readShort() and $ff;
end;
function Chunk.readUnsignedShort(): int;
begin
result := fldInput.readUnsignedShort();
end;
function Chunk.readByte(): int;
begin
result := byte(fldInput.readShort());
end;
function Chunk.readShort(): int;
begin
result := fldInput.readShort();
end;
function Chunk.readInt(): int;
begin
result := fldInput.readInt();
end;
function Chunk.readLong(): long;
begin
result := fldInput.readLong();
end;
function Chunk.readFloat(): float;
begin
result := fldInput.readFloat();
end;
function Chunk.readDouble(): double;
begin
result := fldInput.readDouble();
end;
function Chunk.readReal(): real;
begin
result := fldInput.readReal();
end;
{$WARN 5033 OFF} { позволить функции, состоящие только из одной управляющей конструкции raise }
function Chunk.readUTF(): UnicodeString;
begin
raise UnsupportedOperationException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'chunk.read'));
end;
function Chunk.readln(): UnicodeString;
begin
raise UnsupportedOperationException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'chunk.read'));
end;
function Chunk.read(): UnicodeString;
begin
raise UnsupportedOperationException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'chunk.read'));
end;
{$WARN 5033 ON}
function Chunk.readIndex(): int;
var
index: int;
begin
with fldInput do begin
index := readShort();
if index < 0 then index := ((index shl $10) and CoInt.MAX_VALUE) or readUnsignedShort();
end;
result := index;
end;
function Chunk.readLabel(): int;
var
index: int;
begin
with fldInput do begin
index := readUnsignedShort();
if AVTOORecompilable.isNext(index) then begin
index := NEXT;
end else begin
if AVTOORecompilable.isLongNumber(index) then begin
index := (index shl $10) or readUnsignedShort();
end;
index := AVTOORecompilable.decodeUsing(index);
end;
end;
result := index;
end;
function Chunk.readByte2(): int2;
var
index: int;
begin
with fldInput do for index := 1 downto 0 do result[index] := readByte();
end;
function Chunk.readShort2(): int2;
var
index: int;
begin
with fldInput do for index := 1 downto 0 do result[index] := readShort();
end;
function Chunk.readInt2(): int2;
var
index: int;
begin
with fldInput do for index := 1 downto 0 do result[index] := readInt();
end;
function Chunk.readByte4(): int4;
var
index: int;
begin
with fldInput do for index := 3 downto 0 do result[index] := readByte();
end;
function Chunk.readShort4(): int4;
var
index: int;
begin
with fldInput do for index := 3 downto 0 do result[index] := readShort();
end;
function Chunk.readInt4(): int4;
var
index: int;
begin
with fldInput do for index := 3 downto 0 do result[index] := readInt();
end;
function Chunk.readByte8(): int8;
var
index: int;
begin
with fldInput do for index := 7 downto 0 do result[index] := readByte();
end;
function Chunk.readShort8(): int8;
var
index: int;
begin
with fldInput do for index := 7 downto 0 do result[index] := readShort();
end;
function Chunk.readInt8(): int8;
var
index: int;
begin
with fldInput do for index := 7 downto 0 do result[index] := readInt();
end;
function Chunk.readLong2(): long2;
var
index: int;
begin
with fldInput do for index := 1 downto 0 do result[index] := readLong();
end;
function Chunk.readLong4(): long4;
var
index: int;
begin
with fldInput do for index := 3 downto 0 do result[index] := readLong();
end;
function Chunk.readLong8(): long8;
var
index: int;
begin
with fldInput do for index := 7 downto 0 do result[index] := readLong();
end;
function Chunk.readFloat2(): float2;
var
index: int;
begin
with fldInput do for index := 1 downto 0 do result[index] := readFloat();
end;
function Chunk.readFloat4(): float4;
var
index: int;
begin
with fldInput do for index := 3 downto 0 do result[index] := readFloat();
end;
function Chunk.readFloat8(): float8;
var
index: int;
begin
with fldInput do for index := 7 downto 0 do result[index] := readFloat();
end;
function Chunk.readDouble2(): double2;
var
index: int;
begin
with fldInput do for index := 1 downto 0 do result[index] := readDouble();
end;
function Chunk.readDouble4(): double4;
var
index: int;
begin
with fldInput do for index := 3 downto 0 do result[index] := readDouble();
end;
function Chunk.readDouble8(): double8;
var
index: int;
begin
with fldInput do for index := 7 downto 0 do result[index] := readDouble();
end;
function Chunk.dataOffsetToSourceOffset(offset: int): int;
begin
result := fldOffset + ((offset + 2) shl 1);
end;
function Chunk.seek(offset: int; from: SeekFrom): int;
var
length: int;
__position: int;
stream: ChunkByteArrayInputStream;
begin
length := fldLength;
stream := ChunkByteArrayInputStream(fldStream);
case from of
SeekFrom.sfBegin:
__position := offset;
SeekFrom.sfEnd:
__position := offset + length;
SeekFrom.sfCurrent:
__position := offset + stream.position;
else
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('from') ]));
end;
if __position < 0 then __position := 0;
if __position > length then __position := length;
stream.position := __position;
result := __position;
end;
function Chunk.available(): int;
begin
result := fldLength - ChunkByteArrayInputStream(fldStream).position;
end;
function Chunk.typeToString(): AnsiString;
begin
result := fldTypeAsString;
end;
{%endregion}
{%region ElementStack }
procedure ElementStack.setStackElements(newStackElements: int);
begin
if newStackElements < 0 then newStackElements := 0;
if fldMaximumElements < newStackElements then fldMaximumElements := newStackElements;
fldStackElements := newStackElements;
end;
procedure ElementStack.reset();
begin
fldStackElements := 0;
end;
procedure ElementStack.change(deltaElements: int);
begin
setStackElements(fldStackElements + deltaElements);
end;
{%endregion}
{%region FieldsMap }
constructor FieldsMap.create(const bitMap: long_Array1d);
var
length: int;
begin
inherited create();
length := system.length(bitMap);
if length <= 0 then begin
fldBitMap := &Array.newLong1d($10);
exit;
end;
fldBitMap := &Array.newLong1d(length);
&Array.copyPrimitives(bitMap, 0, fldBitMap, 0, length);
end;
function FieldsMap.allocateAlignedField(fieldWidthInBytes, align: int): int;
var
step: int;
shift: int;
limit: int;
index: int;
length: int;
fieldWidthInDwords: int;
mask: long;
subMap: long;
bitMap: long_Array1d;
buffer: long_Array1d;
begin
if fldFinalized then begin
raise IllegalFieldsMapStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'fields-map.finalized'));
end;
if (fieldWidthInBytes < MIN_FIELD_WIDTH) or (fieldWidthInBytes > MAX_FIELD_WIDTH) then begin
raise IllegalArgumentException.create(AnsiString.format(
AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [
CoAnsiString.create('fieldWidthInBytes')
]
));
end;
fieldWidthInDwords := (fieldWidthInBytes + (-fieldWidthInBytes and (align - 1))) shr 2;
mask := (1 shl fieldWidthInDwords) - 1;
bitMap := fldBitMap;
length := system.length(bitMap);
index := &Array.indexOfNon(-1, bitMap, 0, length);
if index >= 0 then begin
subMap := bitMap[index];
limit := $41 - fieldWidthInDwords;
step := align shr 2;
shift := 0;
while shift < limit do begin
if (subMap and (mask shl shift)) = 0 then begin
bitMap[index] := subMap or (mask shl shift);
result := (index shl 8) or (shift shl 2);
exit;
end;
inc(shift, step);
end;
end;
if length >= $00800000 then begin
raise IllegalFieldsMapStateException(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'fields-map.full'));
end;
buffer := &Array.newLong1d(length shl 1);
&Array.copyPrimitives(bitMap, 0, buffer, 0, length);
fldBitMap := buffer;
buffer[length] := mask;
result := length shl 8;
end;
constructor FieldsMap.create();
begin
inherited create();
fldBitMap := &Array.newLong1d($10);
end;
procedure FieldsMap.finalize();
begin
fldFinalized := true;
end;
function FieldsMap.allocateDwordAlignedField(fieldWidthInBytes: int): int;
begin
result := allocateAlignedField(fieldWidthInBytes, $04);
end;
function FieldsMap.allocateQwordAlignedField(fieldWidthInBytes: int): int;
begin
result := allocateAlignedField(fieldWidthInBytes, $08);
end;
function FieldsMap.allocateXwordAlignedField(fieldWidthInBytes: int): int;
begin
result := allocateAlignedField(fieldWidthInBytes, $10);
end;
function FieldsMap.allocateYwordAlignedField(fieldWidthInBytes: int): int;
begin
result := allocateAlignedField(fieldWidthInBytes, $20);
end;
function FieldsMap.allocateZwordAlignedField(fieldWidthInBytes: int): int;
begin
result := allocateAlignedField(fieldWidthInBytes, $40);
end;
function FieldsMap.clone(): FieldsMap;
begin
result := FieldsMap.create(fldBitMap);
end;
{%endregion}
{%region Programme }
class procedure Programme.initSubtypes(const classes: ClassType_Array1d; length: int);
var
index: int;
begin
for index := 0 to length - 1 do classes[index].initSubtypes();
end;
class function Programme.comparisonOrder(&type: &Type): int;
begin
if &type is ArrayType then begin
result := 3;
exit;
end;
if &type is ru.malik.elaborarer.avtoo.lang.ClassType then begin
result := 2;
exit;
end;
if &type is PrimitiveType then begin
result := 1;
exit;
end;
result := 0;
end;
function Programme.createArrayType(componentType: &Type): ArrayType;
var
&array: ArrayType;
begin
&array := newArrayType(componentType);
if &array = nil then &array := ArrayType.create(componentType);
componentType.parentPackage.appendChildItem(&array);
appendType(&array);
prefetchSupertypesForReferenceArray(&array);
&array.appendImpliedSuperservices();
result := &array;
end;
procedure Programme.appendLibrary(item: &Library);
var
list: LibraryArray;
begin
if item = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('item') ]));
end;
if item.parentProgramme <> self then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-library.not-owned-by-programme'));
end;
list := fldLibrariesArray;
if list.indexOf(item) >= 0 then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-library.already-added'));
end;
list.append(item);
fldLibrariesTable[ProgrammeLibraryKey.create(item)] := item;
end;
procedure Programme.appendPackage(item: Package);
var
name: AnsiString;
list: PackageArray;
begin
if item = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('item') ]));
end;
if item.parentProgramme <> self then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-package.not-owned-by-programme'));
end;
list := fldPackagesArray;
if list.indexOf(item) >= 0 then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-package.already-added'));
end;
name := item.specialCanonicalName;
list.append(item);
fldPackagesTable[name] := item;
if name.length <= 0 then fldSystemPackage := item;
if name = PACKNAME_LANG then fldLanguagePackage := item;
end;
procedure Programme.appendType(item: &Type);
var
list: TypeArray;
primitive: PrimitiveType;
begin
if item = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('item') ]));
end;
if item.parentProgramme <> self then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-type.not-owned-by-programme'));
end;
list := fldTypesArray;
if list.indexOf(item) >= 0 then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-type.already.added'));
end;
list.append(item);
fldTypesTable[item.specialCanonicalName] := item;
if item is ArrayType then begin
fldArraysArray.append(ArrayType(item));
exit;
end;
if item is ru.malik.elaborarer.avtoo.lang.ClassType then begin
fldClassesArray.append(ru.malik.elaborarer.avtoo.lang.ClassType(item));
exit;
end;
if item is PrimitiveType then begin
primitive := PrimitiveType(item);
fldPrimitives[primitive.kind - TYP_VOID] := primitive;
end;
end;
procedure Programme.sortTypes();
var
tpi: int;
tpj: int;
__lenght: int;
__types: Type_Array1d;
type0: &Type;
type1: &Type;
begin
with fldTypesArray do begin
__types := &array;
__lenght := length;
end;
for tpi := 0 to __lenght - 2 do begin
type0 := __types[tpi];
tpj := tpi + 1;
while tpj < __lenght do begin
type1 := __types[tpj];
if compareTypes(type0, type1) > 0 then begin
__types[tpj] := type0;
__types[tpi] := type1;
type0 := type1;
tpj := tpi;
end;
inc(tpj);
end;
end;
end;
procedure Programme.initSubtypes();
begin
with fldClassesArray do initSubtypes(&array, length);
with fldArraysArray do initSubtypes(ClassType_Array1d(&array), length);
end;
procedure Programme.createArrayTypes();
var
kind: int;
index: int;
__arrays: ArrayType_Array1d;
primitives: PrimitiveType_Array1d;
list: ArrayTypeArray;
packageSystem: Package;
packageLanguage: Package;
classObject: ClassType;
primitive: PrimitiveType;
&array: ArrayType;
begin
list := fldArraysArray;
if list.length > 0 then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.already-created.main-arrays-types'));
end;
packageSystem := fldSystemPackage;
if packageSystem = nil then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.not-created.system-package'));
end;
packageLanguage := fldLanguagePackage;
if packageLanguage = nil then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.not-created.language-package'));
end;
classObject := getClassType(PACKNAME_LANG + '.' + TYPENAME_OBJECT);
if classObject = nil then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.not-created.object-type'));
end;
primitives := fldPrimitives;
for kind := TYP_BOOLEAN to TYP_VOID + PRIMITIVES_LENGTH - 1 do if isPrimitiveKind(kind) and (primitives[kind - TYP_VOID] = nil) then begin
raise IllegalProgrammeStateException.create(AnsiString.format(
AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.not-created.primitive-type'), [
CoAnsiString.create(PrimitiveType.kindToSpecialSimpleName(kind))
]
));
end;
{ разблокировка возможности создания констант }
if getClassType(PACKNAME_LANG + '.' + TYPENAME_STRING) = nil then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.not-created.string-type'));
end;
if getClassType(PACKNAME_LANG + '.' + TYPENAME_CLASS) = nil then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.not-created.class-type'));
end;
if getClassType(PACKNAME_LANG + '.' + TYPENAME_PACKAGE) = nil then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.not-created.package-type'));
end;
fldConstantFactory.loadDataFrom(self);
fldConstantFactoryIsUnlocked := true;
{ создание массивов }
for kind := TYP_BOOLEAN to TYP_VOID + PRIMITIVES_LENGTH - 1 do if isPrimitiveKind(kind) then begin
primitive := primitives[kind - TYP_VOID];
&array := newArrayType(primitive);
if &array = nil then &array := ArrayType.create(primitive);
packageSystem.appendChildItem(&array);
appendType(&array);
&array.makeCompilable();
end;
begin
&array := newArrayType(classObject);
if &array = nil then &array := ArrayType.create(classObject);
packageLanguage.appendChildItem(&array);
appendType(&array);
&array.makeCompilable();
end;
{ определение супертипов массивов }
__arrays := list.&array;
for index := 0 to list.length - 1 do begin
&array := __arrays[index];
if &array.componentType.classType() = PrimitiveType then begin
prefetchSupertypesForPrimitiveArray(&array);
continue;
end;
prefetchSupertypesForObjectArray(&array);
end;
end;
procedure Programme.createPrimitiveTypes();
var
kind: int;
primitives: PrimitiveType_Array1d;
packageSystem: Package;
primitive: PrimitiveType;
begin
packageSystem := fldSystemPackage;
if packageSystem = nil then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.not-created.system-package'));
end;
primitives := fldPrimitives;
for kind := TYP_VOID to TYP_VOID + PRIMITIVES_LENGTH - 1 do if isPrimitiveKind(kind) and (primitives[kind - TYP_VOID] <> nil) then begin
raise IllegalProgrammeStateException.create(AnsiString.format(
AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.already-created.primitive-type'), [
CoAnsiString.create(PrimitiveType.kindToSpecialSimpleName(kind))
]
));
end;
{ создание примитивов }
for kind := TYP_VOID to TYP_VOID + PRIMITIVES_LENGTH - 1 do if isPrimitiveKind(kind) then begin
primitive := PrimitiveType.create(packageSystem, kind);
packageSystem.appendChildItem(primitive);
appendType(primitive);
end;
end;
procedure Programme.createMembersForArrayTypes();
var
index: int;
__length: int;
__arrays: ArrayType_Array1d;
classObject: ClassType;
&array: ArrayType;
component: &Type;
begin
classObject := getClassType(PACKNAME_LANG + '.' + TYPENAME_OBJECT);
with fldArraysArray do begin
__arrays := &array;
__length := length;
end;
for index := 0 to __length - 1 do begin
&array := __arrays[index];
component := &array.componentType;
if component.classType() = PrimitiveType then begin
createMembersForPrimitiveArray(&array);
continue;
end;
if component = classObject then begin
createMembersForObjectArray(&array);
continue;
end;
break;
end;
end;
procedure Programme.checkEssentialTypesPresence();
var
index: int;
aname: AnsiString;
names: AnsiString_Array1d;
begin
names := essentialTypesNames();
for index := 0 to system.length(names) - 1 do begin
aname := names[index];
if getType(aname) = nil then begin
raise CompilerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'essential-type.not-found'), [
CoAnsiString.create(aname)
]));
end;
end;
end;
function Programme.compareTypes(type0, type1: &Type): int;
var
isHelper0: boolean;
isHelper1: boolean;
order0: int;
order1: int;
array0: ArrayType;
array1: ArrayType;
component0: &Type;
component1: &Type;
begin
order0 := comparisonOrder(type0);
order1 := comparisonOrder(type1);
if order0 <> order1 then begin
result := order0 - order1;
exit;
end;
case order0 of
1: begin
result := type0.kind - type1.kind;
end;
2: begin
isHelper0 := type0.isHelper();
isHelper1 := type1.isHelper();
if (type0 = type1) or (isHelper0 and isHelper1) then begin
result := 0;
exit;
end;
if isHelper0 then begin
result := 1;
exit;
end;
if isHelper1 then begin
result := -1;
exit;
end;
if type0.isAssignableFrom(type1) then begin
result := -1;
exit;
end;
if type1.isAssignableFrom(type0) then begin
result := 1;
exit;
end;
end;
3: begin
array0 := type0 as ArrayType;
array1 := type1 as ArrayType;
if array0.isSuperclass(array1) then begin
result := 1;
exit;
end;
if array1.isSuperclass(array0) then begin
result := -1;
exit;
end;
component0 := array0.componentType;
component1 := array1.componentType;
order0 := comparisonOrder(component0);
order1 := comparisonOrder(component1);
if order0 <> order1 then begin
result := order0 - order1;
exit;
end;
if order0 = 1 then begin
result := component0.kind - component1.kind;
exit;
end;
result := array0.dimensionsCount - array1.dimensionsCount;
exit;
end;
end;
result := &Array.NOT_FOUND;
end;
function Programme.essentialTypesNames(): AnsiString_Array1d;
begin
result := [
PACKNAME_LANG + '.' + TYPENAME_CLASS,
PACKNAME_LANG + '.' + TYPENAME_OBJECT,
PACKNAME_LANG + '.' + TYPENAME_STRING,
PACKNAME_LANG + '.' + TYPENAME_STRUCT,
PACKNAME_LANG + '.' + TYPENAME_PACKAGE,
PACKNAME_LANG + '.' + TYPENAME_THROWABLE
];
end;
function Programme.createLocal(isFinal: boolean; &type: &Type; const specialSimpleName: AnsiString; value: Constant; source: Source; declarationPosition: int): Local;
begin
result := newLocal(isFinal, &type, specialSimpleName, value, source, declarationPosition);
if result = nil then result := Local.create(isFinal, &type, specialSimpleName, value, source, declarationPosition);
end;
function Programme.newLibrary(fileSystem: FileSystem; const directoryPath: UnicodeString; application: boolean): &Library;
begin
result := nil;
end;
function Programme.newSource(parentLibrary: &Library; const relativePath: UnicodeString; const &type: AnsiString): Source;
begin
result := nil;
end;
function Programme.newPackage(parentLibrary: &Library; visibility: int; const specialCanonicalName: AnsiString; source: Source; declarationPosition, documentationPosition: int): Package;
begin
result := nil;
end;
function Programme.newClassType(parentPackage: Package; attributes: int; const specialSimpleName: AnsiString; source: Source; declarationPosition, documentationPosition: int;
const textSourcePath: UnicodeString): ClassType;
begin
result := nil;
end;
function Programme.newArrayType(componentType: &Type): ArrayType;
begin
result := nil;
end;
function Programme.newNestedUnion(parentItem: AllocatableFactory; declarationPosition, documentationPosition: int): Union;
begin
result := nil;
end;
function Programme.newNestedStruct(parentItem: AllocatableFactory; declarationPosition, documentationPosition: int): Struct;
begin
result := nil;
end;
function Programme.newStructField(parentItem: AllocatableFactory; &type: &Type; capacity: int; const specialSimpleName: AnsiString; declarationPosition, documentationPosition: int): Field;
begin
result := nil;
end;
function Programme.newStructField(parentType: ClassType; structOffset: int; &type: &Type; capacity: int; const specialSimpleName: AnsiString;
declarationPosition, documentationPosition: int): Field;
begin
result := nil;
end;
function Programme.newClassField(parentType: ClassType; attributes: int; &type: &Type; const specialSimpleName; declarationPosition, documentationPosition: int): Field;
begin
result := nil;
end;
function Programme.newStaticBlock(parentType: ClassType; attributes, declarationPosition, documentationPosition: int): ClassInit;
begin
result := nil;
end;
function Programme.newConstructor(parentType: ClassType; attributes: int; const arguments: Local_Array1d; declarationPosition, documentationPosition: int): InstInit;
begin
result := nil;
end;
function Programme.newMethod(parentType: ClassType; attributes: int; &type: &Type; const specialSimpleName: AnsiString; const arguments: Local_Array1d;
declarationPosition, documentationPosition: int): Method;
begin
result := nil;
end;
function Programme.newOperator(parentType: ClassType; attributes: int; &type: &Type; kind: int; const arguments: Local_Array1d; declarationPosition, documentationPosition: int): &Operator;
begin
result := nil;
end;
function Programme.newProperty(parentType: ClassType; attributes: int; &type: &Type; const specialSimpleName: AnsiString; declarationPosition, documentationPosition: int): &Property;
begin
result := nil;
end;
function Programme.newLocal(isFinal: boolean; &type: &Type; const specialSimpleName: AnsiString; value: Constant; source: Source; declarationPosition: int): Local;
begin
result := nil;
end;
function Programme.newCode(parentCallable: Callable): Code;
begin
result := nil;
end;
function Programme.newNode(parentCode: Code): Node;
begin
result := nil;
end;
constructor Programme.create();
begin
inherited create();
fldPrimitives := PrimitiveType_Array1d(&Array.newTObject1d(PRIMITIVES_LENGTH));
fldNullType := NullType.create();
fldLibrariesArray := LibraryArray.create(true);
fldPackagesArray := PackageArray.create(false);
fldClassesArray := ClassTypeArray.create(false);
fldArraysArray := ArrayTypeArray.create(false);
fldTypesArray := TypeArray.create(false);
fldLibrariesTable := HashtableOfRefCountInterfaceToLibrary.create();
fldPackagesTable := HashtableOfAnsiStringToPackage.create();
fldTypesTable := HashtableOfAnsiStringToType.create();
fldConstantFactory := ConstantFactory.create();
fldMonitor := Mutex.create();
end;
destructor Programme.destroy;
begin
fldMonitor.free();
fldConstantFactory.free();
fldTypesTable.free();
fldPackagesTable.free();
fldLibrariesTable.free();
fldTypesArray.free();
fldArraysArray.free();
fldClassesArray.free();
fldPackagesArray.free();
fldLibrariesArray.free();
fldNullType.free();
inherited destroy;
end;
procedure Programme.clear();
begin
fldConstantFactoryIsUnlocked := false;
&Array.fillObjects(fldPrimitives, 0, PRIMITIVES_LENGTH, nil);
fldLanguagePackage := nil;
fldSystemPackage := nil;
fldConstantFactory.clear();
fldTypesTable.clear();
fldPackagesTable.clear();
fldLibrariesTable.clear();
fldTypesArray.clear();
fldArraysArray.clear();
fldClassesArray.clear();
fldPackagesArray.clear();
fldLibrariesArray.clear();
end;
function Programme.createLibrary(__fileSystem: FileSystem; const __directoryPath: UnicodeString; __application: boolean): &Library;
var
__library: &Library;
begin
__library := newLibrary(__fileSystem, __directoryPath, __application);
if __library = nil then begin
__library := &Library.create(self, __fileSystem, __directoryPath, __application);
end;
appendLibrary(__library);
result := __library;
end;
function Programme.isConstantFactoryUnlocked(): boolean;
begin
result := fldConstantFactoryIsUnlocked;
end;
function Programme.getConstantFactory(): ConstantFactory;
begin
if not fldConstantFactoryIsUnlocked then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.can-not-create.constants'));
end;
result := fldConstantFactory;
end;
function Programme.getLibrary(fileSystem: FileSystem; const directoryPath: UnicodeString): &Library;
begin
result := fldLibrariesTable[ProgrammeLibraryKey.create(fileSystem, directoryPath)];
end;
function Programme.getPackage(const specialCanonicalName: AnsiString): Package;
begin
result := fldPackagesTable[specialCanonicalName];
end;
function Programme.getPackage(const specialCanonicalName: AnsiString; ignoreCase: boolean): Package;
var
index: int;
__length: int;
uname: UnicodeString;
__packages: Package_Array1d;
pack: Package;
begin
if not ignoreCase then begin
result := fldPackagesTable[specialCanonicalName];
exit;
end;
with fldPackagesArray do begin
__packages := &array;
__length := length;
end;
uname := specialCanonicalName.toUTF16();
for index := __length - 1 downto 0 do begin
pack := __packages[index];
if uname.equalsIgnoreCase(pack.specialCanonicalName.toUTF16()) then begin
result := pack;
exit;
end;
end;
result := nil;
end;
function Programme.getSystemPackage(): Package;
begin
result := fldSystemPackage;
end;
function Programme.getLanguagePackage(): Package;
begin
result := fldLanguagePackage;
end;
function Programme.getType(const specialCanonicalName: AnsiString): &Type;
begin
if specialCanonicalName = TYPENAME_NULL then begin
result := fldNullType;
exit;
end;
result := fldTypesTable[specialCanonicalName];
end;
function Programme.getNullType(): NullType;
begin
result := fldNullType;
end;
function Programme.getPrimitiveType(kind: int): PrimitiveType;
begin
if (kind < TYP_VOID) or (kind >= TYP_VOID + PRIMITIVES_LENGTH) then begin
result := nil;
exit;
end;
result := fldPrimitives[kind - TYP_VOID];
end;
function Programme.getClassType(const specialCanonicalName: AnsiString): ClassType;
var
&type: ru.malik.elaborarer.avtoo.lang.&Type;
begin
&type := fldTypesTable[specialCanonicalName];
if not(&type is ru.malik.elaborarer.avtoo.lang.ClassType) then begin
result := nil;
exit;
end;
result := ru.malik.elaborarer.avtoo.lang.ClassType(&type);
end;
function Programme.getArrayType(componentType: &Type): ArrayType;
var
count: int;
&type: ru.malik.elaborarer.avtoo.lang.&Type;
begin
if componentType = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('componentType') ]));
end;
if componentType.isVoid() or componentType.isNull() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.components-type.illegal'));
end;
if componentType.parentProgramme <> self then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.components-type.not-same-programme'));
end;
if componentType is ArrayType then begin
count := ArrayType(componentType).dimensionsCount;
end else begin
count := 0;
end;
if count > LIMIT_DIMENSIONS_COUNT - 1 then begin
raise IllegalArrayDimensionsCountException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.dimensions-count'));
end;
&type := fldTypesTable[componentType.specialCanonicalName + '[]'];
if not(&type is ArrayType) then begin
result := nil;
exit;
end;
result := ArrayType(&type);
end;
function Programme.getArrayType(componentType: &Type; dimensionsCount: int): ArrayType;
var
count: int;
aname: AnsiString;
&type: ru.malik.elaborarer.avtoo.lang.&Type;
begin
if componentType = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('componentType') ]));
end;
if componentType.isVoid() or componentType.isNull() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.components-type.illegal'));
end;
if componentType.parentProgramme <> self then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.components-type.not-same-programme'));
end;
if componentType is ArrayType then begin
count := LIMIT_DIMENSIONS_COUNT - ArrayType(componentType).dimensionsCount;
end else begin
count := LIMIT_DIMENSIONS_COUNT;
end;
if (dimensionsCount < 1) or (dimensionsCount > count) then begin
raise IllegalArrayDimensionsCountException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.dimensions-count'));
end;
aname := componentType.specialCanonicalName;
repeat
aname := aname + '[]';
dec(dimensionsCount);
until dimensionsCount <= 0;
&type := fldTypesTable[aname];
if not(&type is ArrayType) then begin
result := nil;
exit;
end;
result := ArrayType(&type);
end;
function Programme.acquireArrayType(componentType: &Type): ArrayType;
var
count: int;
&type: ru.malik.elaborarer.avtoo.lang.&Type;
monitor: Mutex;
begin
if componentType = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('componentType') ]));
end;
if componentType.isVoid() or componentType.isNull() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.components-type.illegal'));
end;
if componentType.parentProgramme <> self then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.components-type.not-same-programme'));
end;
if componentType is ArrayType then begin
count := ArrayType(componentType).dimensionsCount;
end else begin
count := 0;
end;
if count > LIMIT_DIMENSIONS_COUNT - 1 then begin
raise IllegalArrayDimensionsCountException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.dimensions-count'));
end;
&type := nil;
monitor := fldMonitor;
monitor.beginSynchronized();
try
&type := fldTypesTable[componentType.specialCanonicalName + '[]'];
if &type = nil then &type := createArrayType(componentType);
finally
monitor.endSynchronized();
end;
if not(&type is ArrayType) then begin
raise IllegalProgrammeStateException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-a-array'), [
CoAnsiString.create(&type.specialCanonicalName)
]));
end;
result := ArrayType(&type);
end;
function Programme.acquireArrayType(componentType: &Type; dimensionsCount: int): ArrayType;
var
count: int;
aname: AnsiString;
table: HashtableOfAnsiStringToType;
&type: ru.malik.elaborarer.avtoo.lang.&Type;
monitor: Mutex;
begin
if componentType = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('componentType') ]));
end;
if componentType.isVoid() or componentType.isNull() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.components-type.illegal'));
end;
if componentType.parentProgramme <> self then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.components-type.not-same-programme'));
end;
if componentType is ArrayType then begin
count := LIMIT_DIMENSIONS_COUNT - ArrayType(componentType).dimensionsCount;
end else begin
count := LIMIT_DIMENSIONS_COUNT;
end;
if (dimensionsCount < 1) or (dimensionsCount > count) then begin
raise IllegalArrayDimensionsCountException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'array.dimensions-count'));
end;
&type := nil;
monitor := fldMonitor;
monitor.beginSynchronized();
try
table := fldTypesTable;
aname := componentType.specialCanonicalName;
repeat
aname := aname + '[]';
&type := table[aname];
if &type = nil then &type := createArrayType(componentType);
componentType := &type;
dec(dimensionsCount);
until dimensionsCount <= 0;
finally
monitor.endSynchronized();
end;
if not(&type is ArrayType) then begin
raise IllegalProgrammeStateException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-a-array'), [
CoAnsiString.create(&type.specialCanonicalName)
]));
end;
result := ArrayType(&type);
end;
{%endregion}
{%region ConstantFactory }
procedure ConstantFactory.loadDataFrom(source: Programme);
var
kind: int;
typeBoolean: PrimitiveType;
primitives: PrimitiveType_Array1d;
begin
typeBoolean := source.getPrimitiveType(TYP_BOOLEAN);
fldPackageType := source.getClassType(PACKNAME_LANG + '.' + TYPENAME_PACKAGE);
fldStringType := source.getClassType(PACKNAME_LANG + '.' + TYPENAME_STRING);
fldClassType := source.getClassType(PACKNAME_LANG + '.' + TYPENAME_CLASS);
fldFalseValue := ConstantItem.create(typeBoolean, false);
fldTrueValue := ConstantItem.create(typeBoolean, true);
fldNullValue := ConstantItem.create(source.getNullType(), RefCountInterface(nil));
primitives := fldPrimitives;
for kind := TYP_BOOLEAN to TYP_VOID + PRIMITIVES_LENGTH - 1 do begin
primitives[kind - TYP_VOID] := source.getPrimitiveType(kind);
end;
end;
procedure ConstantFactory.checkUnlocked();
begin
if fldNullValue = nil then begin
raise IllegalProgrammeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'programme.can-not-create.constants'));
end;
end;
procedure ConstantFactory.clear();
begin
fldPackageType := nil;
fldStringType := nil;
fldClassType := nil;
fldFalseValue := nil;
fldTrueValue := nil;
fldNullValue := nil;
&Array.fillObjects(fldPrimitives, 0, PRIMITIVES_LENGTH, nil);
end;
constructor ConstantFactory.create();
begin
inherited create();
fldPrimitives := PrimitiveType_Array1d(&Array.newTObject1d(PRIMITIVES_LENGTH));
end;
function ConstantFactory.createNull(): Constant;
begin
checkUnlocked();
result := fldNullValue;
end;
function ConstantFactory.createBoolean(const value: boolean): Constant;
begin
checkUnlocked();
if value then begin
result := fldTrueValue;
exit;
end;
result := fldFalseValue;
end;
function ConstantFactory.createIntegral(const value: int): Constant;
var
&type: PrimitiveType;
begin
checkUnlocked();
if (value >= CoByte.MIN_VALUE) and (value <= CoByte.MAX_VALUE) then begin
&type := fldPrimitives[TYP_BYTE - TYP_VOID];
end else
if (value >= CoShort.MIN_VALUE) and (value <= CoShort.MAX_VALUE) then begin
&type := fldPrimitives[TYP_SHORT - TYP_VOID];
end else begin
&type := fldPrimitives[TYP_INT - TYP_VOID];
end;
result := ConstantItem.create(&type, long8(value));
end;
function ConstantFactory.createChar(const value: uchar): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_CHAR - TYP_VOID], value);
end;
function ConstantFactory.createByte(const value: byte): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_BYTE - TYP_VOID], long8(value));
end;
function ConstantFactory.createByte2(const value: byte2): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_BYTE2 - TYP_VOID], long8(value));
end;
function ConstantFactory.createByte4(const value: byte4): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_BYTE4 - TYP_VOID], long8(value));
end;
function ConstantFactory.createByte8(const value: byte8): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_BYTE8 - TYP_VOID], long8(value));
end;
function ConstantFactory.createShort(const value: short): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_SHORT - TYP_VOID], long8(value));
end;
function ConstantFactory.createShort2(const value: short2): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_SHORT2 - TYP_VOID], long8(value));
end;
function ConstantFactory.createShort4(const value: short4): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_SHORT4 - TYP_VOID], long8(value));
end;
function ConstantFactory.createShort8(const value: short8): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_SHORT8 - TYP_VOID], long8(value));
end;
function ConstantFactory.createInt(const value: int): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_INT - TYP_VOID], long8(value));
end;
function ConstantFactory.createInt2(const value: int2): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_INT2 - TYP_VOID], long8(value));
end;
function ConstantFactory.createInt4(const value: int4): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_INT4 - TYP_VOID], long8(value));
end;
function ConstantFactory.createInt8(const value: int8): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_INT8 - TYP_VOID], long8(value));
end;
function ConstantFactory.createLong(const value: long): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_LONG - TYP_VOID], long8(value));
end;
function ConstantFactory.createLong2(const value: long2): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_LONG2 - TYP_VOID], long8(value));
end;
function ConstantFactory.createLong4(const value: long4): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_LONG4 - TYP_VOID], long8(value));
end;
function ConstantFactory.createLong8(const value: long8): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_LONG8 - TYP_VOID], value);
end;
function ConstantFactory.createFloat(const value: float): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_FLOAT - TYP_VOID], double8(value));
end;
function ConstantFactory.createFloat2(const value: float2): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_FLOAT2 - TYP_VOID], double8(value));
end;
function ConstantFactory.createFloat4(const value: float4): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_FLOAT4 - TYP_VOID], double8(value));
end;
function ConstantFactory.createFloat8(const value: float8): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_FLOAT8 - TYP_VOID], double8(value));
end;
function ConstantFactory.createDouble(const value: double): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_DOUBLE - TYP_VOID], double8(value));
end;
function ConstantFactory.createDouble2(const value: double2): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_DOUBLE2 - TYP_VOID], double8(value));
end;
function ConstantFactory.createDouble4(const value: double4): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_DOUBLE4 - TYP_VOID], double8(value));
end;
function ConstantFactory.createDouble8(const value: double8): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_DOUBLE8 - TYP_VOID], value);
end;
function ConstantFactory.createReal(const value: real): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPrimitives[TYP_REAL - TYP_VOID], value);
end;
function ConstantFactory.createString(const value: UnicodeString): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldStringType, CoUnicodeString.create(value) as RefCountInterface);
end;
function ConstantFactory.createPackage(value: Package): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldPackageType, value);
end;
function ConstantFactory.createClass(value: &Type): Constant;
begin
checkUnlocked();
result := ConstantItem.create(fldClassType, value);
end;
function ConstantFactory.createFrom(source: TObject): Constant;
begin
if source = nil then begin
result := createNull();
exit;
end;
if source is VCoByte then begin
result := createByte(VCoByte(source).asByte());
exit;
end;
if source is VCoByte2 then begin
result := createByte2(VCoByte2(source).asByte2());
exit;
end;
if source is VCoByte4 then begin
result := createByte4(VCoByte4(source).asByte4());
exit;
end;
if source is VCoByte8 then begin
result := createByte8(VCoByte8(source).asByte8());
exit;
end;
if source is VCoShort then begin
result := createShort(VCoShort(source).asShort());
exit;
end;
if source is VCoShort2 then begin
result := createShort2(VCoShort2(source).asShort2());
exit;
end;
if source is VCoShort4 then begin
result := createShort4(VCoShort4(source).asShort4());
exit;
end;
if source is VCoShort8 then begin
result := createShort8(VCoShort8(source).asShort8());
exit;
end;
if source is VCoInt then begin
result := createInt(VCoInt(source).asInt());
exit;
end;
if source is VCoInt2 then begin
result := createInt2(VCoInt2(source).asInt2());
exit;
end;
if source is VCoInt4 then begin
result := createInt4(VCoInt4(source).asInt4());
exit;
end;
if source is VCoInt8 then begin
result := createInt8(VCoInt8(source).asInt8());
exit;
end;
if source is VCoLong then begin
result := createLong(VCoLong(source).asLong());
exit;
end;
if source is VCoLong2 then begin
result := createLong2(VCoLong2(source).asLong2());
exit;
end;
if source is VCoLong4 then begin
result := createLong4(VCoLong4(source).asLong4());
exit;
end;
if source is VCoLong8 then begin
result := createLong8(VCoLong8(source).asLong8());
exit;
end;
if source is VCoFloat then begin
result := createFloat(VCoFloat(source).asFloat());
exit;
end;
if source is VCoFloat2 then begin
result := createFloat2(VCoFloat2(source).asFloat2());
exit;
end;
if source is VCoFloat4 then begin
result := createFloat4(VCoFloat4(source).asFloat4());
exit;
end;
if source is VCoFloat8 then begin
result := createFloat8(VCoFloat8(source).asFloat8());
exit;
end;
if source is VCoDouble then begin
result := createDouble(VCoDouble(source).asDouble());
exit;
end;
if source is VCoDouble2 then begin
result := createDouble2(VCoDouble2(source).asDouble2());
exit;
end;
if source is VCoDouble4 then begin
result := createDouble4(VCoDouble4(source).asDouble4());
exit;
end;
if source is VCoDouble8 then begin
result := createDouble8(VCoDouble8(source).asDouble8());
exit;
end;
if source is VCoReal then begin
result := createReal(VCoReal(source).asReal());
exit;
end;
if source is CoBoolean then begin
result := createBoolean(CoBoolean(source).asBoolean());
exit;
end;
if source is CoChar then begin
result := createChar(uchar(CoChar(source).asInt()));
exit;
end;
if source is CoUChar then begin
result := createChar(uchar(CoUChar(source).asInt()));
exit;
end;
if source is CoByte then begin
result := createByte(byte(CoByte(source).asInt()));
exit;
end;
if source is CoShort then begin
result := createShort(short(CoShort(source).asInt()));
exit;
end;
if source is CoInt then begin
result := createInt(CoInt(source).asInt());
exit;
end;
if source is CoLong then begin
result := createLong(CoLong(source).asLong());
exit;
end;
if source is CoFloat then begin
result := createFloat(CoFloat(source).asFloat());
exit;
end;
if source is CoDouble then begin
result := createDouble(CoDouble(source).asDouble());
exit;
end;
if source is CoReal then begin
result := createReal(CoReal(source).asReal());
exit;
end;
if source is CoAnsiString then begin
result := createString(CoAnsiString(source).asUnicodeString());
exit;
end;
if source is CoUnicodeString then begin
result := createString(CoUnicodeString(source).asUnicodeString());
exit;
end;
if source is Package then begin
result := createPackage(Package(source));
exit;
end;
if source is &Type then begin
result := createClass(&Type(source));
exit;
end;
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument.unsupported-type'), [
CoAnsiString.create('source')
]));
end;
function ConstantFactory.createFrom(source: IUnknown): Constant;
begin
if source = nil then begin
result := createNull();
exit;
end;
if source is Numeric then with source as Numeric do case getKind() of
CustomNumeric.KIND_CHAR, CustomNumeric.KIND_UCHAR: begin
result := createChar(asUChar());
exit;
end;
CustomNumeric.KIND_BYTE: begin
result := createByte(asByte());
exit;
end;
CustomNumeric.KIND_BYTE2: begin
result := createByte2(asByte2());
exit;
end;
CustomNumeric.KIND_BYTE4: begin
result := createByte4(asByte4());
exit;
end;
CustomNumeric.KIND_BYTE8: begin
result := createByte8(asByte8());
exit;
end;
CustomNumeric.KIND_SHORT: begin
result := createShort(asShort());
exit;
end;
CustomNumeric.KIND_SHORT2: begin
result := createShort2(asShort2());
exit;
end;
CustomNumeric.KIND_SHORT4: begin
result := createShort4(asShort4());
exit;
end;
CustomNumeric.KIND_SHORT8: begin
result := createShort8(asShort8());
exit;
end;
CustomNumeric.KIND_INT: begin
result := createInt(asInt());
exit;
end;
CustomNumeric.KIND_INT2: begin
result := createInt2(asInt2());
exit;
end;
CustomNumeric.KIND_INT4: begin
result := createInt4(asInt4());
exit;
end;
CustomNumeric.KIND_INT8: begin
result := createInt8(asInt8());
exit;
end;
CustomNumeric.KIND_LONG: begin
result := createLong(asLong());
exit;
end;
CustomNumeric.KIND_LONG2: begin
result := createLong2(asLong2());
exit;
end;
CustomNumeric.KIND_LONG4: begin
result := createLong4(asLong4());
exit;
end;
CustomNumeric.KIND_LONG8: begin
result := createLong8(asLong8());
exit;
end;
CustomNumeric.KIND_FLOAT: begin
result := createFloat(asFloat());
exit;
end;
CustomNumeric.KIND_FLOAT2: begin
result := createFloat2(asFloat2());
exit;
end;
CustomNumeric.KIND_FLOAT4: begin
result := createFloat4(asFloat4());
exit;
end;
CustomNumeric.KIND_FLOAT8: begin
result := createFloat8(asFloat8());
exit;
end;
CustomNumeric.KIND_DOUBLE: begin
result := createDouble(asDouble());
exit;
end;
CustomNumeric.KIND_DOUBLE2: begin
result := createDouble2(asDouble2());
exit;
end;
CustomNumeric.KIND_DOUBLE4: begin
result := createDouble4(asDouble4());
exit;
end;
CustomNumeric.KIND_DOUBLE8: begin
result := createDouble8(asDouble8());
exit;
end;
CustomNumeric.KIND_REAL: begin
result := createReal(asReal());
exit;
end;
end else
if source is Value then with source as Value do case getType() of
Lang.TYPE_BOOLEAN: begin
result := createBoolean(asBoolean());
exit;
end;
Lang.TYPE_CHAR, Lang.TYPE_UCHAR: begin
result := createChar(uchar(asInt()));
exit;
end;
Lang.TYPE_BYTE: begin
result := createByte(byte(asInt()));
exit;
end;
Lang.TYPE_SHORT: begin
result := createShort(short(asInt()));
exit;
end;
Lang.TYPE_INT: begin
result := createInt(asInt());
exit;
end;
Lang.TYPE_LONG: begin
result := createLong(asLong());
exit;
end;
Lang.TYPE_FLOAT: begin
result := createFloat(asFloat());
exit;
end;
Lang.TYPE_DOUBLE: begin
result := createDouble(asDouble());
exit;
end;
Lang.TYPE_REAL: begin
result := createReal(asReal());
exit;
end;
Lang.TYPE_ANSISTRING, Lang.TYPE_UNICODESTRING: begin
result := createString(asUnicodeString());
exit;
end;
end;
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument.unsupported-type'), [
CoAnsiString.create('source')
]));
end;
{%endregion}
{%region ProgrammeItem }
function ProgrammeItem.isOwner(): boolean;
begin
result := true;
end;
procedure ProgrammeItem.insertChildItem(item: ProgrammeItem; position: int);
var
length: int;
iname: AnsiString;
store: ProgrammeItem_Array1d;
buffer: ProgrammeItem_Array1d;
table: HashtableOfAnsiStringToProgrammeItem;
begin
if item = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('item') ]));
end;
if item.fldParentProgramme <> fldParentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-item.not-same-programme'));
end;
length := fldChildItemsLength;
store := fldChildItemsStore;
table := fldChildItemsTable;
if store = nil then begin
store := ProgrammeItem_Array1d(&Array.newTObject1d($0f));
table := HashtableOfAnsiStringToProgrammeItem.create();
fldChildItemsStore := store;
fldChildItemsTable := table;
end else
if length = system.length(store) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := ProgrammeItem_Array1d(&Array.newTObject1d((length shl 1) or 1));
&Array.copyObjects(store, 0, buffer, 0, length);
fldChildItemsStore := buffer;
store := buffer;
end;
if position < 0 then position := 0;
if position > length then position := length;
iname := item.fldSpecialSimpleName;
item.fldNextItem := table[iname];
table[iname] := item;
&Array.copyObjects(store, position, store, position + 1, length - position);
store[position] := item;
fldChildItemsLength := length + 1;
end;
procedure ProgrammeItem.removeChildItem(item: ProgrammeItem);
var
index: int;
length: int;
iname: AnsiString;
curr: ProgrammeItem;
prev: ProgrammeItem;
store: ProgrammeItem_Array1d;
table: HashtableOfAnsiStringToProgrammeItem;
begin
table := fldChildItemsTable;
length := fldChildItemsLength;
if (item <> nil) and (table <> nil) and (length > 0) then begin
iname := item.fldSpecialSimpleName;
curr := table[iname];
if curr = item then begin
table[iname] := curr.fldNextItem;
end else
if curr <> nil then repeat
prev := curr;
curr := curr.fldNextItem;
if curr = nil then break;
if curr = item then begin
prev.fldNextItem := curr.fldNextItem;
break;
end;
until false;
store := fldChildItemsStore;
index := &Array.indexOf(item, store, 0, length);
if index >= 0 then begin
dec(length);
&Array.copyObjects(store, index + 1, store, index, length - index);
store[length] := nil;
fldChildItemsLength := length;
if isOwner() then item.free();
end;
end;
end;
procedure ProgrammeItem.appendChildItem(item: ProgrammeItem);
begin
insertChildItem(item, CoInt.MAX_VALUE);
end;
constructor ProgrammeItem.create(__parentProgramme: Programme; const __specialSimpleName: AnsiString);
begin
inherited create();
fldSpecialSimpleName := __specialSimpleName;
fldParentProgramme := __parentProgramme;
end;
constructor ProgrammeItem.create(__parentItem: ProgrammeItem; const __specialSimpleName: AnsiString);
begin
inherited create();
fldSpecialSimpleName := __specialSimpleName;
fldParentItem := __parentItem;
if __parentItem <> nil then begin
fldParentProgramme := __parentItem.fldParentProgramme;
end;
end;
destructor ProgrammeItem.destroy;
var
index: int;
length: int;
store: ProgrammeItem_Array1d;
item: ProgrammeItem;
begin
store := fldChildItemsStore;
length := fldChildItemsLength;
for index := length - 1 downto 0 do begin
item := store[index];
if item.fldChildItemsLength > 0 then begin
item.free();
store[index] := nil;
end;
end;
if isOwner() then begin
for index := length - 1 downto 0 do begin
store[index].free();
store[index] := nil;
end;
end;
fldChildItemsTable.free();
inherited destroy;
end;
function ProgrammeItem.toString(): AnsiString;
begin
result := fldSpecialSimpleName;
end;
function ProgrammeItem.getLength(): int;
begin
result := fldChildItemsLength;
end;
function ProgrammeItem.readComponent(index: int): ProgrammeItem;
begin
if (index < 0) or (index >= fldChildItemsLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldChildItemsStore[index];
end;
function ProgrammeItem.readComponent(index: int): TObject;
begin
result := readComponent(index);
end;
function ProgrammeItem.getSpecialSimpleName(): AnsiString;
begin
result := fldSpecialSimpleName;
end;
function ProgrammeItem.getChildItem(const __specialSimpleName: AnsiString): ProgrammeItem;
var
table: HashtableOfAnsiStringToProgrammeItem;
begin
table := fldChildItemsTable;
if table = nil then begin
result := nil;
exit;
end;
result := table[__specialSimpleName];
end;
function ProgrammeItem.getChildItem(const __specialSimpleName: AnsiString; __ignoreCase: boolean): ProgrammeItem;
var
index: int;
uname: UnicodeString;
item: ProgrammeItem;
store: ProgrammeItem_Array1d;
table: HashtableOfAnsiStringToProgrammeItem;
begin
table := fldChildItemsTable;
if table = nil then begin
result := nil;
exit;
end;
if not __ignoreCase then begin
result := table[__specialSimpleName];
exit;
end;
store := fldChildItemsStore;
uname := __specialSimpleName.toUTF16();
for index := 0 to fldChildItemsLength - 1 do begin
item := store[index];
if uname.equalsIgnoreCase(item.fldSpecialSimpleName.toUTF16()) then begin
result := item;
exit;
end;
end;
result := nil;
end;
function ProgrammeItem.getNextItem(): ProgrammeItem;
begin
result := fldNextItem;
end;
function ProgrammeItem.getParentItem(): ProgrammeItem;
begin
result := fldParentItem;
end;
function ProgrammeItem.getParentProgramme(): Programme;
begin
result := fldParentProgramme;
end;
{%endregion}
{%region &Library }
procedure &Library.insertChildItem(item: ProgrammeItem; position: int);
begin
if (item <> nil) and not(item is Package) then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-item.not-a-package'));
end;
inherited insertChildItem(item, position);
end;
procedure &Library.appendClass(item: ClassType);
begin
if item = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('item') ]));
end;
fldClassesArray.append(item);
end;
procedure &Library.appendSource(item: Source);
begin
if item = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('item') ]));
end;
fldSourcesArray.append(item);
end;
constructor &Library.create(__parentProgramme: Programme; __fileSystem: FileSystem; const __directoryPath: UnicodeString; __application: boolean);
begin
inherited create(__parentProgramme, AVTOOService.getObjectName(__directoryPath).toUTF8());
if __fileSystem = nil then begin
__fileSystem := FileSystemRoot.get(Process.current().workingDirectory).fileSystem;
end;
fldApplication := __application;
if __directoryPath.endsWith('/') then begin
fldDirectoryPath := __directoryPath;
end else begin
fldDirectoryPath := __directoryPath + '/';
end;
fldFileSystem := __fileSystem;
fldSourcesArray := SourceArray.create(true);
fldClassesArray := ClassTypeArray.create(false);
end;
destructor &Library.destroy;
begin
fldSourcesArray.free();
fldClassesArray.free();
inherited destroy;
end;
function &Library.createSource(const __relativePath: UnicodeString; const __type: AnsiString): Source;
label
break_label0;
var
__source: Source;
__programme: Programme;
begin
__programme := parentProgramme;
__source := nil;
if __programme <> nil then begin
__source := __programme.newSource(self, __relativePath, __type);
end;
if __source = nil then begin
if __type = TEXT_SOURCE then begin
__source := TextSource.create(self, __relativePath);
goto break_label0;
end;
if __type = BINARY_SOURCE then begin
__source := BinarySource.create(self, __relativePath);
goto break_label0;
end;
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('__type') ]));
end;
break_label0:
appendSource(__source);
result := __source;
end;
function &Library.createPackage(__visibility: int; const __specialCanonicalName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int): Package;
var
__package: Package;
__programme: Programme;
begin
if (__source <> nil) and (fldSourcesArray.indexOf(__source) < 0) then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'library.source.not-owned-by'));
end;
__programme := parentProgramme;
__package := nil;
if __programme <> nil then begin
__package := __programme.newPackage(self, __visibility, __specialCanonicalName, __source, __declarationPosition, __documentationPosition);
end;
if __package = nil then begin
__package := Package.create(self, __visibility, __specialCanonicalName, __source, __declarationPosition, __documentationPosition);
end;
appendChildItem(__package);
if __programme <> nil then __programme.appendPackage(__package);
result := __package;
end;
function &Library.readComponent(index: int): Package;
begin
result := inherited readComponent(index) as Package;
end;
function &Library.getChildPackage(const specialCanonicalName: AnsiString): Package;
begin
result := inherited getChildItem(specialCanonicalName) as Package;
end;
function &Library.getChildPackage(const specialCanonicalName: AnsiString; ignoreCase: boolean): Package;
begin
result := inherited getChildItem(specialCanonicalName, ignoreCase) as Package;
end;
{%endregion}
{%region TableItem }
constructor TableItem.create(__parentItem: ProgrammeItem; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int);
var
__documentationContent: TObject;
begin
inherited create(__parentItem, __specialSimpleName);
if (__source <> nil) and (__documentationPosition >= 0) and (__documentationPosition < __source.getLength()) then begin
__documentationContent := __source.readComponent(__documentationPosition);
end else begin
__documentationContent := nil;
end;
fldDeclarationPosition := __declarationPosition;
fldDocumentationPosition := __documentationPosition;
fldImplementationPosition := -1;
fldSource := __source;
if __parentItem is &Library then begin
fldParentLibrary := &Library(__parentItem);
end else
if __parentItem is TableItem then begin
fldParentLibrary := TableItem(__parentItem).fldParentLibrary;
end;
if __documentationContent is LexemeSequence then begin
fldDocumentationContent := LexemeSequence(__documentationContent);
end;
end;
procedure TableItem.afterConstruction();
begin
inherited afterConstruction();
fldRecompilableName := composeRecompilableName();
fldFasmSimpleName := composeFasmSimpleName();
end;
procedure TableItem.setImplementationPosition(newImplementationPosition: int);
begin
fldImplementationPosition := newImplementationPosition;
end;
function TableItem.getImplementationPosition(): int;
begin
result := fldImplementationPosition;
end;
function TableItem.getDeclarationPosition(): int;
begin
result := fldDeclarationPosition;
end;
function TableItem.getDocumentationPosition(): int;
begin
result := fldDocumentationPosition;
end;
function TableItem.getFasmSimpleName(): AnsiString;
begin
result := fldFasmSimpleName;
end;
function TableItem.getRecompilableName(): AnsiString;
begin
result := fldRecompilableName;
end;
function TableItem.getDocumentationContent(): LexemeSequence;
begin
result := fldDocumentationContent;
end;
function TableItem.getSource(): Source;
begin
result := fldSource;
end;
function TableItem.getParentLibrary(): &Library;
begin
result := fldParentLibrary;
end;
{%endregion}
{%region ReflectItem }
function ReflectItem.AllocatableFactory_inherited_createNestedUnion(__declarationPosition, __documentationPosition: int): Union;
var
__union: Union;
__programme: Programme;
begin
__union := nil;
__programme := parentProgramme;
if __programme <> nil then begin
__union := __programme.newNestedUnion(self as AllocatableFactory, __declarationPosition, __documentationPosition);
end;
if __union = nil then begin
__union := Union.create(self as AllocatableFactory, __declarationPosition, __documentationPosition);
end;
appendChildItem(__union);
result := __union;
end;
function ReflectItem.AllocatableFactory_inherited_createNestedStruct(__declarationPosition, __documentationPosition: int): Struct;
var
__struct: Struct;
__programme: Programme;
begin
__struct := nil;
__programme := parentProgramme;
if __programme <> nil then begin
__struct := __programme.newNestedStruct(self as AllocatableFactory, __declarationPosition, __documentationPosition);
end;
if __struct = nil then begin
__struct := Struct.create(self as AllocatableFactory, __declarationPosition, __documentationPosition);
end;
appendChildItem(__struct);
result := __struct;
end;
function ReflectItem.AllocatableFactory_inherited_createStructField(__type: &Type; __capacity: int; const __specialSimpleName: AnsiString;
__declarationPosition, __documentationPosition: int): Field;
var
__field: Field;
__programme: Programme;
begin
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
__programme := parentProgramme;
if __type.parentProgramme <> __programme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.item'));
end;
if __capacity > LIMIT_FIELD_LENGTH then begin
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'field.length-too-large'), [
CoAnsiString.create(CoInt.toString(LIMIT_FIELD_LENGTH))
]));
end;
if
__type.isVoid() or
__type.isNull() or
(__capacity <= 0) and not __type.isPrimitive() or
(__capacity > 0) and (not(__type is ArrayType) or not ArrayType(__type).componentType.isPrimitive())
then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-suitable.field'));
end;
__field := nil;
if __programme <> nil then begin
__field := __programme.newStructField(self as AllocatableFactory, __type, __capacity, __specialSimpleName, __declarationPosition, __documentationPosition);
end;
if __field = nil then begin
__field := Field.create(self as AllocatableFactory, __type, __capacity, __specialSimpleName, __declarationPosition, __documentationPosition);
end;
appendChildItem(__field);
result := __field;
end;
constructor ReflectItem.create(__parentItem: ProgrammeItem; __attributes: int; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentItem, __specialSimpleName, __source, __declarationPosition, __documentationPosition);
fldVisibility := __attributes and MASK_VISIBILITY;
fldAttributes := __attributes;
end;
procedure ReflectItem.afterConstruction();
begin
inherited afterConstruction();
fldFasmFullName := composeFasmFullName();
end;
function ReflectItem.isFinal(): boolean;
begin
result := (fldAttributes and ATTR_FINAL) <> 0;
end;
function ReflectItem.isAbstract(): boolean;
begin
result := (fldAttributes and ATTR_ABSTRACT) <> 0;
end;
function ReflectItem.getVisibility(): int;
begin
result := fldVisibility;
end;
function ReflectItem.getAttributes(): int;
begin
result := fldAttributes;
end;
function ReflectItem.getFasmFullName(): AnsiString;
begin
result := fldFasmFullName;
end;
{%endregion}
{%region RequiredReflectItem }
constructor RequiredReflectItem.create(__parentItem: ProgrammeItem; __attributes: int; const __specialSimpleName, __specialCanonicalName: AnsiString;
__source: Source; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentItem, __attributes, __specialSimpleName, __source, __declarationPosition, __documentationPosition);
fldSpecialCanonicalName := __specialCanonicalName;
end;
procedure RequiredReflectItem.afterConstruction();
begin
inherited afterConstruction();
fldFasmFileName := composeFasmFileName();
end;
function RequiredReflectItem.toString(): AnsiString;
begin
result := fldSpecialCanonicalName;
end;
{%endregion}
{%region Package }
procedure Package.insertChildItem(item: ProgrammeItem; position: int);
begin
if (item <> nil) and not(item is &Type) then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-item.not-a-type'));
end;
inherited insertChildItem(item, position);
end;
function Package.composeRecompilableName(): AnsiString;
begin
result := specialCanonicalName;
end;
function Package.composeFasmSimpleName(): AnsiString;
var
name: AnsiString;
begin
name := specialCanonicalName;
if name.length > 0 then begin
result := name;
exit;
end;
result := FASMNAME_SYSTEM_PACKAGE;
end;
function Package.composeFasmFullName(): AnsiString;
begin
result := fasmSimpleName;
end;
function Package.composeFasmFileName(): UnicodeString;
begin
result := fasmSimpleName.toUTF16();
end;
constructor Package.create(__parentLibrary: &Library; __visibility: int; const __specialCanonicalName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentLibrary, __visibility and MASK_VISIBILITY, __specialCanonicalName, __specialCanonicalName, __source, __declarationPosition, __documentationPosition);
end;
function Package.isVisibleFrom(__type: ClassType): boolean;
var
__library: &Library;
begin
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
if __type.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.package'));
end;
case visibility of
VIS_PUBLIC,
VIS_PUBLISHED: begin
result := true;
end;
VIS_PROTECTED,
VIS_PACKAGE,
RESERVED_PACKAGE: begin
__library := __type.parentLibrary;
result := (__library = parentLibrary) or (__library <> nil) and not __library.application;
end;
VIS_PRIVATE,
VIS_SOURCE,
RESERVED_SOURCE: begin
result := __type.parentLibrary = parentLibrary;
end;
else
{ Недостижимый код. Нужен только для того, чтобы избежать сообщений об ошибках от компилятора. }
raise IllegalCompilerObjectStateException.create({ этот пакет имеет неизвестную видимость });
end;
end;
function Package.createClassType(__attributes: int; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int;
const __textSourcePath: UnicodeString): ClassType;
var
__class: ClassType;
__library: &Library;
__programme: Programme;
begin
if __specialSimpleName.length <= 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-argument.empty.type-name'));
end;
if __specialSimpleName.endsWith('[]') then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-argument.ends-with-brackets.type-name'));
end;
__library := parentLibrary;
if (__library <> nil) and (__source <> nil) and (__library.sources.indexOf(__source) < 0) then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'source.not-same-programme'));
end;
__attributes := __attributes and not ATTR_PRIMITIVE;
__programme := parentProgramme;
__class := nil;
if __programme <> nil then begin
__class := __programme.newClassType(self, __attributes, __specialSimpleName, __source, __declarationPosition, __documentationPosition, __textSourcePath);
end;
if __class = nil then begin
__class := ru.malik.elaborarer.avtoo.lang.ClassType.create(self, __attributes, __specialSimpleName, __source, __declarationPosition, __documentationPosition, __textSourcePath);
end;
appendChildItem(__class);
if __programme <> nil then __programme.appendType(__class);
if __library <> nil then __library.appendClass(__class);
if __source <> nil then __source.appendDeclared(__class);
result := __class;
end;
function Package.readComponent(index: int): &Type;
begin
result := inherited readComponent(index) as &Type;
end;
function Package.getChildType(const __specialSimpleName: AnsiString): &Type;
begin
result := inherited getChildItem(__specialSimpleName) as &Type;
end;
function Package.getChildType(const __specialSimpleName: AnsiString; __ignoreCase: boolean): &Type;
begin
result := inherited getChildItem(__specialSimpleName, __ignoreCase) as &Type;
end;
{%endregion}
{%region &Type }
class function &Type.getSpecialCanonicalName(__parentItem: RequiredReflectItem; const __specialSimpleName: AnsiString): AnsiString;
var
name: AnsiString;
begin
if __parentItem <> nil then begin
name := __parentItem.specialCanonicalName;
end else begin
name := '';
end;
if name.length <= 0 then begin
result := __specialSimpleName;
exit;
end;
result := name + '.' + __specialSimpleName;
end;
constructor &Type.create(__parentPackage: Package; __attributes: int; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int);
begin
inherited create(
__parentPackage, __attributes, __specialSimpleName, getSpecialCanonicalName(__parentPackage, __specialSimpleName), __source, __declarationPosition, __documentationPosition
);
fldParentPackage := __parentPackage;
end;
procedure &Type.afterConstruction();
var
width: int;
begin
inherited afterConstruction();
width := computeFieldWidth();
fldFieldWidth := width;
fldStackElements := (width + (-width and $0f)) shr 4;
end;
procedure &Type.makeCompilable();
begin
end;
function &Type.isVisibleFrom(__type: ClassType): boolean;
var
__source: Source;
__package: ReflectItem;
begin
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
if __type.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.package'));
end;
case visibility of
VIS_PUBLIC,
VIS_PUBLISHED: begin
__package := parentPackage;
result := (__package = nil) or __package.isVisibleFrom(__type);
end;
VIS_PROTECTED,
VIS_PACKAGE,
RESERVED_PACKAGE: begin
__package := parentPackage;
result := (__package <> nil) and (__package = __type.parentPackage);
end;
VIS_PRIVATE,
VIS_SOURCE,
RESERVED_SOURCE: begin
__source := source;
__package := parentPackage;
result := (__package <> nil) and (__package = __type.parentPackage) and (__source <> nil) and __source.isSameSource(__type.source);
end;
else
{ Недостижимый код. Нужен только для того, чтобы избежать сообщений об ошибках от компилятора. }
raise IllegalCompilerObjectStateException.create({ этот тип имеет неизвестную видимость });
end;
end;
function &Type.isCompilable(): boolean;
begin
result := true;
end;
function &Type.isNull(): boolean;
begin
result := false;
end;
function &Type.isArray(): boolean;
begin
result := false;
end;
function &Type.isClass(): boolean;
begin
result := false;
end;
function &Type.isStruct(): boolean;
begin
result := false;
end;
function &Type.isService(): boolean;
begin
result := false;
end;
function &Type.isInterface(): boolean;
begin
result := false;
end;
function &Type.isHelper(): boolean;
begin
result := false;
end;
function &Type.isPrimitive(): boolean;
begin
result := false;
end;
function &Type.isVoid(): boolean;
begin
result := false;
end;
function &Type.isBoolean(): boolean;
begin
result := false;
end;
function &Type.isChar(): boolean;
begin
result := false;
end;
function &Type.isInt(): boolean;
begin
result := false;
end;
function &Type.isLong(): boolean;
begin
result := false;
end;
function &Type.isVector(): boolean;
begin
result := false;
end;
function &Type.isNumeric(): boolean;
begin
result := false;
end;
function &Type.isFloating(): boolean;
begin
result := false;
end;
function &Type.isStackable(): boolean;
begin
result := true;
end;
function &Type.toStackable(): int;
begin
result := kind;
end;
function &Type.getRealType(): &Type;
begin
result := self;
end;
{%endregion}
{%region PrimitiveType }
class function PrimitiveType.recompilableNameToKind(const name: AnsiString): int;
begin
if name = 'V' then begin
result := TYP_VOID;
exit;
end;
if name = 'Z' then begin
result := TYP_BOOLEAN;
exit;
end;
if name = 'C' then begin
result := TYP_CHAR;
exit;
end;
if name = 'R' then begin
result := TYP_REAL;
exit;
end;
if name = 'D' then begin
result := TYP_DOUBLE;
exit;
end;
if name = 'D2' then begin
result := TYP_DOUBLE2;
exit;
end;
if name = 'D4' then begin
result := TYP_DOUBLE4;
exit;
end;
if name = 'D8' then begin
result := TYP_DOUBLE8;
exit;
end;
if name = 'F' then begin
result := TYP_FLOAT;
exit;
end;
if name = 'F2' then begin
result := TYP_FLOAT2;
exit;
end;
if name = 'F4' then begin
result := TYP_FLOAT4;
exit;
end;
if name = 'F8' then begin
result := TYP_FLOAT8;
exit;
end;
if name = 'B' then begin
result := TYP_BYTE;
exit;
end;
if name = 'B2' then begin
result := TYP_BYTE2;
exit;
end;
if name = 'B4' then begin
result := TYP_BYTE4;
exit;
end;
if name = 'B8' then begin
result := TYP_BYTE8;
exit;
end;
if name = 'S' then begin
result := TYP_SHORT;
exit;
end;
if name = 'S2' then begin
result := TYP_SHORT2;
exit;
end;
if name = 'S4' then begin
result := TYP_SHORT4;
exit;
end;
if name = 'S8' then begin
result := TYP_SHORT8;
exit;
end;
if name = 'I' then begin
result := TYP_INT;
exit;
end;
if name = 'I2' then begin
result := TYP_INT2;
exit;
end;
if name = 'I4' then begin
result := TYP_INT4;
exit;
end;
if name = 'I8' then begin
result := TYP_INT8;
exit;
end;
if name = 'J' then begin
result := TYP_LONG;
exit;
end;
if name = 'J2' then begin
result := TYP_LONG2;
exit;
end;
if name = 'J4' then begin
result := TYP_LONG4;
exit;
end;
if name = 'J8' then begin
result := TYP_LONG8;
exit;
end;
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('name') ]));
end;
class function PrimitiveType.kindToSpecialSimpleName(__kind: int): AnsiString;
begin
case __kind of
TYP_VOID:
result := 'void';
TYP_BOOLEAN:
result := 'boolean';
TYP_CHAR:
result := 'char';
TYP_REAL:
result := 'real';
TYP_DOUBLE:
result := 'double';
TYP_DOUBLE2:
result := 'double2';
TYP_DOUBLE4:
result := 'double4';
TYP_DOUBLE8:
result := 'double8';
TYP_FLOAT:
result := 'float';
TYP_FLOAT2:
result := 'float2';
TYP_FLOAT4:
result := 'float4';
TYP_FLOAT8:
result := 'float8';
TYP_BYTE:
result := 'byte';
TYP_BYTE2:
result := 'byte2';
TYP_BYTE4:
result := 'byte4';
TYP_BYTE8:
result := 'byte8';
TYP_SHORT:
result := 'short';
TYP_SHORT2:
result := 'short2';
TYP_SHORT4:
result := 'short4';
TYP_SHORT8:
result := 'short8';
TYP_INT:
result := 'int';
TYP_INT2:
result := 'int2';
TYP_INT4:
result := 'int4';
TYP_INT8:
result := 'int8';
TYP_LONG:
result := 'long';
TYP_LONG2:
result := 'long2';
TYP_LONG4:
result := 'long4';
TYP_LONG8:
result := 'long8';
else
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('kind') ]));
end;
end;
class function PrimitiveType.kindToRecompilableName(__kind: int): AnsiString;
begin
case __kind of
TYP_VOID:
result := 'V';
TYP_BOOLEAN:
result := 'Z';
TYP_CHAR:
result := 'C';
TYP_REAL:
result := 'R';
TYP_DOUBLE:
result := 'D';
TYP_DOUBLE2:
result := 'D2';
TYP_DOUBLE4:
result := 'D4';
TYP_DOUBLE8:
result := 'D8';
TYP_FLOAT:
result := 'F';
TYP_FLOAT2:
result := 'F2';
TYP_FLOAT4:
result := 'F4';
TYP_FLOAT8:
result := 'F8';
TYP_BYTE:
result := 'B';
TYP_BYTE2:
result := 'B2';
TYP_BYTE4:
result := 'B4';
TYP_BYTE8:
result := 'B8';
TYP_SHORT:
result := 'S';
TYP_SHORT2:
result := 'S2';
TYP_SHORT4:
result := 'S4';
TYP_SHORT8:
result := 'S8';
TYP_INT:
result := 'I';
TYP_INT2:
result := 'I2';
TYP_INT4:
result := 'I4';
TYP_INT8:
result := 'I8';
TYP_LONG:
result := 'J';
TYP_LONG2:
result := 'J2';
TYP_LONG4:
result := 'J4';
TYP_LONG8:
result := 'J8';
else
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('kind') ]));
end;
end;
function PrimitiveType.isSameType(anot: &Type): boolean;
begin
if anot = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('anot') ]));
end;
result := (anot = self) or (anot is PrimitiveType) and (PrimitiveType(anot).fldKind = fldKind);
end;
function PrimitiveType.getCommonType(__anot: &Type; __isVector: boolean): PrimitiveType;
var
tkn: int;
akn: int;
tvl: int;
tvb: int;
avl: int;
avb: int;
cvb: int;
ckn: int;
prim: PrimitiveType;
__programme: Programme;
begin
if __anot = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('anot') ]));
end;
if not(__anot is PrimitiveType) then begin
result := nil;
exit;
end;
prim := PrimitiveType(__anot);
tkn := fldKind;
akn := prim.fldKind;
tvl := tkn and $03;
tvb := fldVectorBaseKind;
avl := akn and $03;
avb := prim.fldVectorBaseKind;
case tvb of
TYP_VOID: begin
result := nil;
exit;
end;
TYP_BOOLEAN: begin
if avb = TYP_BOOLEAN then begin
result := self;
exit;
end;
result := nil;
exit;
end;
TYP_CHAR: begin
if __isVector then begin
if avb = TYP_CHAR then begin
result := self;
exit;
end;
if (avb = TYP_VOID) or (avb = TYP_BOOLEAN) then begin
result := nil;
exit;
end;
end;
tvl := 0;
tvb := TYP_INT;
end;
end;
case avb of
TYP_VOID: begin
result := nil;
exit;
end;
TYP_BOOLEAN: begin
if tvb = TYP_BOOLEAN then begin
result := prim;
exit;
end;
result := nil;
exit;
end;
TYP_CHAR: begin
if __isVector then begin
if tvb = TYP_CHAR then begin
result := prim;
exit;
end;
if (tvb = TYP_VOID) or (tvb = TYP_BOOLEAN) then begin
result := nil;
exit;
end;
end;
avl := 0;
avb := TYP_INT;
end;
end;
case tvb of
TYP_BYTE: begin
cvb := avb;
end;
TYP_SHORT: begin
if avb = TYP_BYTE then begin
cvb := TYP_SHORT;
end else begin
cvb := avb;
end;
end;
TYP_INT: begin
if (avb >= TYP_BYTE) and (avb <= TYP_SHORT) then begin
cvb := TYP_INT;
end else
if avb = TYP_FLOAT then begin
cvb := TYP_DOUBLE;
end else begin
cvb := avb;
end;
end;
TYP_LONG: begin
if (avb >= TYP_REAL) and (avb <= TYP_FLOAT) then begin
cvb := TYP_REAL;
end else begin
cvb := TYP_LONG;
end;
end;
TYP_FLOAT: begin
if (avb >= TYP_FLOAT) and (avb <= TYP_SHORT) then begin
cvb := TYP_FLOAT;
end else
if (avb >= TYP_DOUBLE) and (avb <= TYP_INT) then begin
cvb := TYP_DOUBLE;
end else begin
cvb := TYP_REAL;
end;
end;
TYP_DOUBLE: begin
if (avb = TYP_REAL) or (avb = TYP_LONG) then begin
cvb := TYP_REAL;
end else begin
cvb := TYP_DOUBLE;
end;
end;
TYP_REAL: begin
cvb := TYP_REAL;
end;
else
result := nil;
exit;
end;
if not __isVector and (cvb >= TYP_BYTE) and (cvb <= TYP_SHORT) then begin
ckn := TYP_INT;
end else begin
ckn := cvb;
end;
inc(ckn, CoInt.max(tvl, avl));
if tkn = ckn then begin
result := self;
exit;
end;
if akn = ckn then begin
result := prim;
exit;
end;
__programme := parentProgramme;
if __programme = nil then begin
result := nil;
exit;
end;
result := __programme.getPrimitiveType(ckn);
end;
function PrimitiveType.getKind(): int;
begin
result := fldKind;
end;
function PrimitiveType.computeFieldWidth(): int;
begin
case fldKind of
TYP_BOOLEAN,
TYP_BYTE:
result := 1;
TYP_CHAR,
TYP_BYTE2,
TYP_SHORT:
result := 2;
TYP_BYTE4,
TYP_SHORT2,
TYP_INT,
TYP_FLOAT:
result := 4;
TYP_BYTE8,
TYP_SHORT4,
TYP_INT2,
TYP_LONG,
TYP_FLOAT2,
TYP_DOUBLE:
result := 8;
TYP_REAL:
result := 10;
TYP_SHORT8,
TYP_INT4,
TYP_LONG2,
TYP_FLOAT4,
TYP_DOUBLE2:
result := 16;
TYP_INT8,
TYP_LONG4,
TYP_FLOAT8,
TYP_DOUBLE4:
result := 32;
TYP_LONG8,
TYP_DOUBLE8:
result := 64;
else
result := 0;
end;
end;
function PrimitiveType.composeRecompilableName(): AnsiString;
begin
result := kindToRecompilableName(fldKind);
end;
function PrimitiveType.composeFasmSimpleName(): AnsiString;
begin
result := specialSimpleName;
end;
function PrimitiveType.composeFasmFullName(): AnsiString;
begin
result := specialSimpleName + '.primitive';
end;
function PrimitiveType.composeFasmFileName(): UnicodeString;
begin
result := specialSimpleName.toUTF16();
end;
constructor PrimitiveType.create(__parentPackage: Package; __kind: int);
var
basekind: int;
__programme: Programme;
begin
inherited create(__parentPackage, VIS_PUBLIC or ATTR_FINAL or ATTR_PRIMITIVE, kindToSpecialSimpleName(__kind), nil, -1, -1);
fldKind := __kind;
if __kind = TYP_VOID then begin
basekind := TYP_VOID;
fldVectorLength := 0;
end else
if (__kind < TYP_REAL) or (__kind >= TYP_VOID + PRIMITIVES_LENGTH) then begin
basekind := __kind;
fldVectorLength := 1;
end else begin
basekind := __kind and not $03;
fldVectorLength := 1 shl (__kind and $03);
end;
fldVectorBaseKind := basekind;
if __kind = basekind then begin
fldVectorBaseType := self;
end else begin
__programme := parentProgramme;
if __programme = nil then begin
fldVectorBaseType := nil;
end else begin
fldVectorBaseType := __programme.getPrimitiveType(basekind);
end;
end;
end;
function PrimitiveType.isAssignableFrom(anot: &Type): boolean;
begin
result := isSameType(anot);
end;
function PrimitiveType.isConvertableFrom(anot: &Type): boolean;
var
tvl: int;
tvb: int;
avl: int;
avb: int;
prim: PrimitiveType;
begin
if anot = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('anot') ]));
end;
if not(anot is PrimitiveType) then begin
result := false;
exit;
end;
prim := PrimitiveType(anot);
tvl := fldVectorLength;
tvb := fldVectorBaseKind;
avl := prim.fldVectorLength;
avb := prim.fldVectorBaseKind;
case tvb of
TYP_BOOLEAN,
TYP_CHAR:
result := avb = tvb;
TYP_BYTE,
TYP_SHORT:
result := (avb >= TYP_BYTE) and (avb <= tvb) and (avl <= tvl);
TYP_INT,
TYP_LONG:
result := (avb = TYP_CHAR) or (avb >= TYP_BYTE) and (avb <= tvb) and (avl <= tvl);
TYP_FLOAT:
result := (avb = TYP_CHAR) or (avb >= TYP_FLOAT) and (avb <= TYP_SHORT) and (avl <= tvl);
TYP_DOUBLE:
result := (avb = TYP_CHAR) or (avb >= TYP_DOUBLE) and (avb <= TYP_INT) and (avl <= tvl);
TYP_REAL:
result := (avb = TYP_CHAR) or (avb >= TYP_REAL) and (avb <= TYP_LONG) and (avl = 1);
else
result := false;
end;
end;
function PrimitiveType.isCompatibleWith(anot: &Type): boolean;
begin
result := isSameType(anot);
end;
function PrimitiveType.isPrimitive(): boolean;
begin
result := true;
end;
function PrimitiveType.isVoid(): boolean;
begin
result := fldKind = TYP_VOID;
end;
function PrimitiveType.isBoolean(): boolean;
begin
result := fldKind = TYP_BOOLEAN;
end;
function PrimitiveType.isChar(): boolean;
begin
result := fldKind = TYP_CHAR;
end;
function PrimitiveType.isInt(): boolean;
var
__kind: int;
begin
__kind := fldKind;
result := (__kind = TYP_CHAR) or (__kind = TYP_BYTE) or (__kind = TYP_SHORT) or (__kind = TYP_INT);
end;
function PrimitiveType.isLong(): boolean;
var
__kind: int;
begin
__kind := fldKind;
result := (__kind = TYP_CHAR) or (__kind = TYP_BYTE) or (__kind = TYP_SHORT) or (__kind = TYP_INT) or (__kind = TYP_LONG);
end;
function PrimitiveType.isVector(): boolean;
var
__kind: int;
begin
__kind := fldKind;
result := (__kind >= TYP_REAL) and (__kind < TYP_VOID + PRIMITIVES_LENGTH) and ((__kind and $03) > 0);
end;
function PrimitiveType.isNumeric(): boolean;
var
__kind: int;
begin
__kind := fldKind;
result := (__kind = TYP_CHAR) or (__kind >= TYP_REAL) and (__kind < TYP_VOID + PRIMITIVES_LENGTH);
end;
function PrimitiveType.isFloating(): boolean;
var
__kind: int;
begin
__kind := fldKind;
result := (__kind >= TYP_REAL) and (__kind < TYP_BYTE);
end;
function PrimitiveType.isStackable(): boolean;
var
__kind: int;
begin
__kind := fldKind;
result := (__kind >= TYP_REAL) and (__kind < TYP_VOID + PRIMITIVES_LENGTH) and (__kind <> TYP_BYTE) and (__kind <> TYP_SHORT);
end;
function PrimitiveType.toStackable(): int;
var
__kind: int;
begin
__kind := fldKind;
if (__kind >= TYP_REAL) and (__kind < TYP_VOID + PRIMITIVES_LENGTH) and (__kind <> TYP_BYTE) and (__kind <> TYP_SHORT) then begin
result := __kind;
exit;
end;
if __kind <> TYP_VOID then begin
result := TYP_INT;
exit;
end;
result := 0;
end;
function PrimitiveType.getScalarCommonType(anot: &Type): &Type;
begin
result := getCommonType(anot, false);
end;
function PrimitiveType.getVectorCommonType(anot: &Type): &Type;
begin
result := getCommonType(anot, true);
end;
{%endregion}
{%region ReferenceType }
function ReferenceType.getCommonType(anot: &Type): ReferenceType;
begin
if anot = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('anot') ]));
end;
if anot is ReferenceType then begin
result := getCommonType(ReferenceType(anot));
exit;
end;
result := nil;
end;
function ReferenceType.composeRecompilableName(): AnsiString;
begin
result := '';
end;
function ReferenceType.composeFasmSimpleName(): AnsiString;
begin
result := '';
end;
function ReferenceType.composeFasmFullName(): AnsiString;
begin
result := '';
end;
function ReferenceType.composeFasmFileName(): UnicodeString;
begin
result := '';
end;
function ReferenceType.computeFieldWidth(): int;
begin
result := 8;
end;
function ReferenceType.getKind(): int;
begin
result := TYP_REF;
end;
function ReferenceType.isConvertableFrom(anot: &Type): boolean;
begin
result := isAssignableFrom(anot);
end;
function ReferenceType.getScalarCommonType(anot: &Type): &Type;
begin
result := getCommonType(anot);
end;
function ReferenceType.getVectorCommonType(anot: &Type): &Type;
begin
result := getCommonType(anot);
end;
{%endregion}
{%region ClassType }
class function ClassType.checkArguments(const arguments: Local_Array1d): Local_Array1d;
var
index: int;
length: int;
buffer: Local_Array1d;
argument: Local;
begin
length := system.length(arguments);
buffer := Local_Array1d(&Array.newTObject1d(length));
&Array.copyObjects(arguments, 0, buffer, 0, length);
if &Array.indexOf(nil, buffer, 0, 0) >= 0 then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument.component'), [
CoAnsiString.create('arguments')
]));
end;
for index := 0 to length - 2 do begin
argument := buffer[index];
if &Array.indexOf(argument, buffer, index + 1, 0) >= 0 then begin
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument.component.two-ones-is-equal'), [
CoAnsiString.create('arguments')
]));
end;
end;
for index := length - 1 downto 0 do if buffer[index].&type = nil then begin
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument.component.uninitialized-property'), [
CoAnsiString.create('arguments'), CoAnsiString.create('type')
]));
end;
result := buffer;
end;
function ClassType.createThisArgument(): Local;
var
__this: Local;
__programme: Programme;
begin
__this := nil;
__programme := parentProgramme;
if __programme <> nil then begin
__this := __programme.newLocal(true, self, SPECNAME_THIS, nil, nil, -1);
end;
if __this = nil then begin
__this := Local.create(true, self, SPECNAME_THIS, nil, nil, -1);
end;
result := __this;
end;
procedure ClassType.initSubtypes();
var
index: int;
count: int;
superclass: ClassType;
stypes: ClassTypeArray;
__programme: Programme;
begin
__programme := parentProgramme;
superclass := fldSuperclassType;
count := __programme.classes.length + __programme.arrays.length;
index := 0;
if superclass <> nil then repeat
if index >= count then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.!error.init-subtypes'));
end;
inc(index);
stypes := superclass.fldSubtypes;
if stypes <> nil then stypes.append(self);
superclass := superclass.fldSuperclassType;
until superclass = nil;
end;
procedure ClassType.insertChildItem(item: ProgrammeItem; position: int);
var
&constructor: InstInit;
begin
if (item <> nil) and not(item is Member) then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-item.not-a-member'));
end;
inherited insertChildItem(item, position);
if (item is Callable) and Callable(item).isNative() then begin
inc(fldNativeCallablesCounter);
end;
if item is ClassInit then begin
fldStaticBlock := ClassInit(item);
end else
if item is InstInit then begin
&constructor := InstInit(item);
if &constructor.arguments.length <= 0 then fldDefaultConstructor := &constructor;
end;
end;
procedure ClassType.removeChildItem(item: ProgrammeItem);
begin
if (item is Callable) and Callable(item).isNative() then begin
dec(fldNativeCallablesCounter);
end;
if fldStaticBlock = item then begin
fldStaticBlock := nil;
end else
if fldDefaultConstructor = item then begin
fldDefaultConstructor := nil;
end;
inherited removeChildItem(item);
end;
function ClassType.composeRecompilableName(): AnsiString;
begin
result := 'L' + specialCanonicalName;
end;
function ClassType.composeFasmSimpleName(): AnsiString;
begin
result := specialCanonicalName;
end;
function ClassType.composeFasmFullName(): AnsiString;
begin
result := specialCanonicalName;
end;
function ClassType.composeFasmFileName(): UnicodeString;
begin
result := specialSimpleName.toUTF16();
end;
function ClassType.getCommonType(anot: ReferenceType): ReferenceType;
begin
if isAssignableFrom(anot) then begin
result := self;
exit;
end;
if anot.isAssignableFrom(self) then begin
result := anot;
exit;
end;
result := nil;
end;
constructor ClassType.create(__parentPackage: Package; __attributes: int; const __specialSimpleName: AnsiString; __source: Source; __declarationPosition, __documentationPosition: int;
const __textSourcePath: UnicodeString);
begin
inherited create(__parentPackage, __attributes, __specialSimpleName, __source, __declarationPosition, __documentationPosition);
fldHelperForPosition := -1;
fldSuperclassPosition := -1;
fldTextSourcePath := __textSourcePath;
if not isHelper() then begin
fldThisArgument := createThisArgument();
fldHelpers := ClassTypeArray.create(false);
end;
__attributes := __attributes and (MASK_TYPE or ATTR_FINAL);
if (__attributes = 0) or (__attributes = ATTR_STRUCT) then begin
fldSubtypes := ClassTypeArray.create(false);
end;
end;
destructor ClassType.destroy;
begin
fldFieldsMap.free();
if not isHelper() then begin
fldThisArgument.free();
fldHelpers.free();
end;
fldSubtypes.free();
inherited destroy;
end;
procedure ClassType.removeStaticBlock();
var
__member: Member;
begin
__member := fldStaticBlock;
if __member <> nil then begin
if not __member.isSynthetic() then dec(fldUserMembersInsertionPosition);
removeChildItem(__member);
end;
end;
procedure ClassType.initHelperFor(target: ClassType; position: int);
begin
if not isHelper() then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.can-not-init-targettype'));
end;
if fldHelperForType <> nil then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.initialized-targettype'));
end;
if target = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('target') ]));
end;
if target.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'target-type.not-same-programme'));
end;
if target.isHelper() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'target-type.is-a-helper'));
end;
fldHelperForPosition := position;
fldHelperForType := target;
fldThisArgument := target.fldThisArgument;
target.fldHelpers.append(self);
end;
procedure ClassType.initSuperclass(superclass: ClassType; position: int);
begin
if isHelper() then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.can-not-init-superclass'));
end;
if fldSuperclassType <> nil then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.initialized-superclass'));
end;
if superclass = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('superclass') ]));
end;
if superclass.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'superclass.not-same-programme'));
end;
if superclass.isHelper() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'superclass.is-a-helper'));
end;
if superclass.isService() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'superclass.is-a-service'));
end;
fldSuperclassPosition := position;
fldSuperclassType := superclass;
end;
procedure ClassType.appendSuperservice(superservice: ClassType; position: int);
var
length: int;
capacity: int;
sposes: int_Array1d;
bposes: int_Array1d;
stypes: ClassType_Array1d;
btypes: ClassType_Array1d;
begin
if isHelper() then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.can-not-add-superservice'));
end;
if superservice = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('superservice') ]));
end;
if superservice.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'superservice.not-same-programme'));
end;
if superservice.isHelper() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'superservice.is-a-helper'));
end;
if not superservice.isService() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'superservice.not-a-service'));
end;
length := fldSuperservicesLength;
stypes := fldSuperservicesTypes;
if (length > 0) and (&Array.indexOf(superservice, stypes, 0, length) >= 0) then begin
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.added-superservice'), [
CoAnsiString.create(superservice.toString())
]));
end;
sposes := fldSuperservicesPositions;
if stypes = nil then begin
sposes := &Array.newInt1d($0f);
stypes := ClassType_Array1d(&Array.newTObject1d($0f));
fldSuperservicesPositions := sposes;
fldSuperservicesTypes := stypes;
end else
if length = system.length(stypes) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (length shl 1) or 1;
bposes := &Array.newInt1d(capacity);
btypes := ClassType_Array1d(&Array.newTObject1d(capacity));
&Array.copyPrimitives(sposes, 0, bposes, 0, length);
&Array.copyObjects(stypes, 0, btypes, 0, length);
fldSuperservicesPositions := bposes;
fldSuperservicesTypes := btypes;
sposes := bposes;
stypes := btypes;
end;
sposes[length] := position;
stypes[length] := superservice;
fldSuperservicesLength := length + 1;
end;
procedure ClassType.appendImpliedSuperservices();
var
tindex: int;
sindex: int;
tlength: int;
slength: int;
capacity: int;
sposes: int_Array1d;
bposes: int_Array1d;
stypes: ClassType_Array1d;
btypes: ClassType_Array1d;
supers: ClassType_Array1d;
superservice: ClassType;
current: ClassType;
begin
if isHelper() then exit;
tindex := -1;
tlength := fldSuperservicesLength;
sposes := fldSuperservicesPositions;
stypes := fldSuperservicesTypes;
current := fldSuperclassType;
if (current = nil) and (tlength > 0) then begin
current := stypes[0];
tindex := 1;
end;
while current <> nil do begin
slength := current.fldSuperservicesLength;
supers := current.fldSuperservicesTypes;
for sindex := 0 to slength - 1 do begin
superservice := supers[sindex];
if (tlength <= 0) or (&Array.indexOf(superservice, stypes, 0, tlength) < 0) then begin
if stypes = nil then begin
sposes := &Array.newInt1d($0f);
stypes := ClassType_Array1d(&Array.newTObject1d($0f));
fldSuperservicesPositions := sposes;
fldSuperservicesTypes := stypes;
end else
if tlength = system.length(stypes) then begin
if tlength = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (tlength shl 1) or 1;
bposes := &Array.newInt1d(capacity);
btypes := ClassType_Array1d(&Array.newTObject1d(capacity));
&Array.copyPrimitives(sposes, 0, bposes, 0, tlength);
&Array.copyObjects(stypes, 0, btypes, 0, tlength);
fldSuperservicesPositions := bposes;
fldSuperservicesTypes := btypes;
sposes := bposes;
stypes := btypes;
end;
sposes[tlength] := -1;
stypes[tlength] := superservice;
inc(tlength);
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := stypes[tindex];
inc(tindex);
end;
end;
end;
fldSuperservicesLength := tlength;
end;
procedure ClassType.markupClass();
var
__isStruct: boolean;
vindex: int;
mindex: int;
oindex: int;
sindex: int;
vlength: int;
mlength: int;
slength: int;
olength: int;
offsetAfter: int;
__instanceSize: int;
members: Member_Array1d;
stypes: ClassType_Array1d;
vmethods: Callable_Array1d;
omethods: Callable_Array1d;
smethods: Callable_Array1d;
buffer: Callable_Array1d;
subtypes: ClassTypeArray;
__fieldsMap: FieldsMap;
superclass: ClassType;
__callable: Callable;
overrides: Callable;
current: ClassType;
__member: Member;
__field: Field;
begin
if isHelper() then exit;
superclass := fldSuperclassType;
if superclass = nil then begin
__fieldsMap := FieldsMap.create();
vmethods := Callable_Array1d(&Array.newTObject1d($0f));
__instanceSize := 0;
vlength := 0;
end else begin
__fieldsMap := superclass.fldFieldsMap;
vmethods := superclass.fldVirtualCallables;
if (__fieldsMap = nil) or (vmethods = nil) then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'superclass.has-no-markup'));
end;
__instanceSize := superclass.fldInstanceSize;
vlength := superclass.fldVirtualLength;
__fieldsMap := __fieldsMap.clone();
buffer := Callable_Array1d(&Array.newTObject1d(int(system.length(vmethods))));
&Array.copyObjects(vmethods, 0, buffer, 0, vlength);
vmethods := buffer;
end;
mlength := getLength();
members := Member_Array1d(&Array.newTObject1d(mlength));
for mindex := mlength - 1 downto 0 do begin
ProgrammeItem_Array1d(members)[mindex] := inherited readComponent(mindex);
end;
{ разметка инстанции }
begin
__isStruct := isStruct();
for mindex := 0 to mlength - 1 do begin
__member := members[mindex];
if not __member.isStatic() and (__member is Field) then begin
__field := Field(__member);
if not __isStruct or (__field.&type is ReferenceType) and (__member.specialSimpleName.length > 0) then begin
offsetAfter := __field.computeInstanceOffset(__instanceSize, __fieldsMap);
if __instanceSize < offsetAfter then __instanceSize := offsetAfter;
end;
end;
end;
if __isStruct then inc(__instanceSize, -__instanceSize and $3f);
fldInstanceSize := __instanceSize;
fldFieldsMap := __fieldsMap;
end;
{ разметка таблицы виртуальных методов }
begin
for vindex := 0 to vlength - 1 do begin
__callable := vmethods[vindex];
if __callable.isVisibleFrom(self, self) then begin
overrides := __callable.overridesIn(self, Callable.CURRENT_TYPE) as Callable;
if overrides <> nil then begin
vmethods[vindex] := overrides;
overrides.setVirtualIndex(vindex);
end;
end;
end;
subtypes := fldSubtypes;
if subtypes <> nil then begin
stypes := subtypes.&array;
slength := subtypes.length;
end else begin
stypes := nil;
slength := 0;
end;
if slength > 0 then begin
olength := 0;
omethods := Callable_Array1d(&Array.newTObject1d(mlength));
for mindex := 0 to mlength - 1 do begin
__member := members[mindex];
if not __member.isStatic() and (__member is Callable) and (__member.visibility > VIS_PRIVATE) and not __member.isFinal() and not __member.isSpecial() then begin
__callable := Callable(__member);
if __callable.virtualIndex < 0 then begin
omethods[olength] := __callable;
inc(olength);
end;
end;
end;
for oindex := 0 to olength - 1 do begin
__callable := omethods[oindex];
for sindex := slength - 1 downto 0 do begin
current := stypes[sindex];
if __callable.isVisibleFrom(current, current) and (__callable.overridesIn(current, Callable.CURRENT_TYPE) <> nil) then begin
if vlength = system.length(vmethods) then begin
if vlength = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := Callable_Array1d(&Array.newTObject1d((vlength shl 1) or 1));
&Array.copyObjects(vmethods, 0, buffer, 0, vlength);
vmethods := buffer;
end;
vmethods[vlength] := __callable;
__callable.setVirtualIndex(vlength);
inc(vlength);
break;
end;
end;
end;
end;
fldVirtualLength := vlength;
fldVirtualCallables := vmethods;
end;
{ разметка таблицы сервисных методов }
if isService() then begin
slength := 0;
smethods := Callable_Array1d(&Array.newTObject1d($0f));
for mindex := 0 to mlength - 1 do begin
__member := members[mindex];
if not __member.isStatic() and (__member is Callable) and (__member.visibility > VIS_PRIVATE) and not __member.isFinal() and not __member.isSpecial() then begin
if slength = system.length(smethods) then begin
buffer := Callable_Array1d(&Array.newTObject1d((slength shl 1) or 1));
&Array.copyObjects(smethods, 0, buffer, 0, slength);
smethods := buffer;
end;
__callable := Callable(__member);
smethods[slength] := __callable;
__callable.setServiceIndex(slength);
inc(slength);
end;
end;
fldServiceLength := slength;
fldServiceCallables := smethods;
end;
end;
procedure ClassType.markupStruct();
var
mindex: int;
mlength: int;
offsetAfter: int;
__structSize: int;
allocatable: AllocatableMember;
superclass: ClassType;
__member: Member;
begin
if isHelper() then exit;
__structSize := 0;
superclass := fldSuperclassType;
if (superclass <> nil) and superclass.isStruct() then begin
if not superclass.fldStructMarked then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'superclass.has-no-markup'));
end;
__structSize := superclass.fldStructSize;
end;
{ разметка структуры }
if isStruct() then begin
mlength := getLength();
for mindex := 0 to mlength - 1 do begin
__member := inherited readComponent(mindex) as Member;
if not __member.isStatic() and (__member is AllocatableMember) then begin
allocatable := AllocatableMember(__member);
if allocatable.parentNested = nil then begin
offsetAfter := allocatable.computeStructOffset(__structSize);
if __structSize < offsetAfter then __structSize := offsetAfter;
end;
end;
end;
fldStructMarked := true;
fldStructSize := __structSize;
end;
end;
function ClassType.isAssignableFrom(anot: &Type): boolean;
begin
if anot = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('anot') ]));
end;
if (anot = self) or anot.isNull() then begin
result := true;
exit;
end;
if not(anot is ru.malik.elaborarer.avtoo.lang.ClassType) then begin
result := false;
exit;
end;
if isService() then begin
result := ru.malik.elaborarer.avtoo.lang.ClassType(anot).isSuperservice(self);
exit;
end;
result := ru.malik.elaborarer.avtoo.lang.ClassType(anot).isSuperclass(self);
end;
function ClassType.isCompatibleWith(anot: &Type): boolean;
var
thisIsFinal: boolean;
thisIsService: boolean;
anotIsFinal: boolean;
anotIsService: boolean;
&type: ClassType;
thisSuperclass: ClassType;
anotSuperclass: ClassType;
begin
if anot = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('anot') ]));
end;
if (anot = self) or anot.isNull() then begin
result := true;
exit;
end;
if not(anot is ru.malik.elaborarer.avtoo.lang.ClassType) then begin
result := false;
exit;
end;
thisIsFinal := isFinal();
thisIsService := isService();
anotIsFinal := anot.isFinal();
anotIsService := anot.isService();
&type := ru.malik.elaborarer.avtoo.lang.ClassType(anot);
thisSuperclass := fldSuperclassType;
anotSuperclass := &type.fldSuperclassType;
if thisIsService then begin
if anotIsService then begin
result := (thisSuperclass = anotSuperclass) or thisSuperclass.isSuperclass(anotSuperclass) or anotSuperclass.isSuperclass(thisSuperclass);
exit;
end;
if anotIsFinal then begin
result := &type.isSuperservice(self);
exit;
end;
result := (thisSuperclass = &type) or thisSuperclass.isSuperclass(&type) or &type.isSuperclass(thisSuperclass);
exit;
end;
if anotIsService then begin
if thisIsFinal then begin
result := isSuperservice(&type);
exit;
end;
result := (self = anotSuperclass) or isSuperclass(anotSuperclass) or anotSuperclass.isSuperclass(self);
exit;
end;
result := (self = &type) or isSuperclass(&type) or &type.isSuperclass(self);
end;
function ClassType.isClass(): boolean;
begin
result := (attributes and MASK_TYPE) = 0;
end;
function ClassType.isStruct(): boolean;
begin
result := (attributes and MASK_TYPE) = ATTR_STRUCT;
end;
function ClassType.isService(): boolean;
begin
result := (attributes and (ATTR_PRIMITIVE or ATTR_SERVICE)) = ATTR_SERVICE;
end;
function ClassType.isInterface(): boolean;
begin
result := (attributes and MASK_TYPE) = ATTR_INTERFACE;
end;
function ClassType.isHelper(): boolean;
begin
result := (attributes and (MASK_BINDING or MASK_TYPE)) = (ATTR_FINAL or ATTR_SERVICE);
end;
function ClassType.getRealType(): ClassType;
begin
if isHelper() then begin
result := fldHelperForType;
exit;
end;
result := self;
end;
function ClassType.createNestedUnion(__declarationPosition, __documentationPosition: int): Union;
begin
if not isStruct() then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.not-a-struct'));
end;
result := AllocatableFactory_inherited_createNestedUnion(__declarationPosition, __documentationPosition);
end;
function ClassType.createNestedStruct(__declarationPosition, __documentationPosition: int): Struct;
begin
if not isStruct() then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.not-a-struct'));
end;
result := AllocatableFactory_inherited_createNestedStruct(__declarationPosition, __documentationPosition);
end;
function ClassType.createStructField(__type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field;
begin
if not isStruct() then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.not-a-struct'));
end;
result := AllocatableFactory_inherited_createStructField(__type, __capacity, __specialSimpleName, __declarationPosition, __documentationPosition);
end;
function ClassType.isFreeThrowableType(): boolean;
var
name: AnsiString;
begin
name := specialCanonicalName;
result :=
(name = PACKNAME_LANG + '.' + TYPENAME_ERROR) or isSuperclass(PACKNAME_LANG + '.' + TYPENAME_ERROR) or
(name = PACKNAME_LANG + '.' + TYPENAME_RUNTIME_EXCEPTION) or isSuperclass(PACKNAME_LANG + '.' + TYPENAME_RUNTIME_EXCEPTION)
;
end;
function ClassType.createStructField(__structOffset: int; __type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field;
var
__field: Field;
__programme: Programme;
begin
if not isStruct() then begin
raise IllegalClassTypeStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'class-type.not-a-struct'));
end;
if __structOffset < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'negative.offset'));
end;
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
__programme := parentProgramme;
if __type.parentProgramme <> __programme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.type'));
end;
if __capacity > LIMIT_FIELD_LENGTH then begin
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'field.length-too-large'), [
CoAnsiString.create(CoInt.toString(LIMIT_FIELD_LENGTH))
]));
end;
if
__type.isVoid() or
__type.isNull() or
(__capacity <= 0) and not __type.isPrimitive() or
(__capacity > 0) and (not(__type is ArrayType) or not ArrayType(__type).componentType.isPrimitive())
then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-suitable.field'));
end;
__field := nil;
if __programme <> nil then begin
__field := __programme.newStructField(self, __structOffset, __type, __capacity, __specialSimpleName, __declarationPosition, __documentationPosition);
end;
if __field = nil then begin
__field := Field.create(self, __structOffset, __type, __capacity, __specialSimpleName, __declarationPosition, __documentationPosition);
end;
appendChildItem(__field);
result := __field;
end;
function ClassType.createClassField(__attributes: int; __type: &Type; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field;
var
position: int;
__field: Field;
__programme: Programme;
begin
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
__programme := parentProgramme;
if __type.parentProgramme <> __programme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.type'));
end;
if __type.isVoid() or __type.isNull() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-suitable.field'));
end;
__field := nil;
if __programme <> nil then begin
__field := __programme.newClassField(self, __attributes, __type, __specialSimpleName, __declarationPosition, __documentationPosition);
end;
if __field = nil then begin
__field := Field.create(self, __attributes, __type, __specialSimpleName, __declarationPosition, __documentationPosition);
end;
if (__attributes and ATTR_SYNTHETIC) <> 0 then begin
appendChildItem(__field);
end else begin
position := fldUserMembersInsertionPosition;
insertChildItem(__field, position);
fldUserMembersInsertionPosition := position + 1;
end;
result := __field;
end;
function ClassType.createStaticBlock(__attributes, __declarationPosition, __documentationPosition: int): ClassInit;
var
position: int;
__staticBlock: ClassInit;
__programme: Programme;
begin
__programme := parentProgramme;
__staticBlock := nil;
if __programme <> nil then begin
__staticBlock := __programme.newStaticBlock(self, __attributes, __declarationPosition, __documentationPosition);
end;
if __staticBlock = nil then begin
__staticBlock := ClassInit.create(self, __attributes, __declarationPosition, __documentationPosition);
end;
if (__attributes and ATTR_SYNTHETIC) <> 0 then begin
appendChildItem(__staticBlock);
end else begin
position := fldUserMembersInsertionPosition;
insertChildItem(__staticBlock, position);
fldUserMembersInsertionPosition := position + 1;
end;
result := __staticBlock;
end;
function ClassType.createConstructor(__attributes: int; const __arguments: Local_Array1d; __declarationPosition, __documentationPosition: int): InstInit;
var
position: int;
buffer: Local_Array1d;
__constructor: InstInit;
__programme: Programme;
begin
buffer := checkArguments(__arguments);
__programme := parentProgramme;
__constructor := nil;
if __programme <> nil then begin
__constructor := __programme.newConstructor(self, __attributes, buffer, __declarationPosition, __documentationPosition);
end;
if __constructor = nil then begin
__constructor := InstInit.create(self, __attributes, buffer, __declarationPosition, __documentationPosition);
end;
if (__attributes and ATTR_SYNTHETIC) <> 0 then begin
appendChildItem(__constructor);
end else begin
position := fldUserMembersInsertionPosition;
insertChildItem(__constructor, position);
fldUserMembersInsertionPosition := position + 1;
end;
result := __constructor;
end;
function ClassType.createMethod(__attributes: int; __type: &Type; const __specialSimpleName: AnsiString; const __arguments: Local_Array1d;
__declarationPosition, __documentationPosition: int): Method;
var
position: int;
suffix: AnsiString;
buffer: Local_Array1d;
__member: ProgrammeItem;
__method: Method;
__programme: Programme;
begin
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
__programme := parentProgramme;
if __type.parentProgramme <> __programme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.type'));
end;
if __type.isNull() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-suitable.method'));
end;
buffer := checkArguments(__arguments);
__method := nil;
if __programme <> nil then begin
__method := __programme.newMethod(self, __attributes, __type, __specialSimpleName, buffer, __declarationPosition, __documentationPosition);
end;
if __method = nil then begin
__method := Method.create(self, __attributes, __type, __specialSimpleName, buffer, __declarationPosition, __documentationPosition);
end;
if (__attributes and ATTR_SYNTHETIC) <> 0 then begin
appendChildItem(__method);
end else begin
position := fldUserMembersInsertionPosition;
insertChildItem(__method, position);
fldUserMembersInsertionPosition := position + 1;
end;
position := __specialSimpleName.lastIndexOf('.');
if position >= 1 then begin
__member := inherited getChildItem(__specialSimpleName.substring(1, position));
inc(position);
while __member <> nil do begin
if __member is &Property then begin
suffix := __specialSimpleName.substring(position);
if suffix = MEMBER_SUFFIX_READ then begin
&Property(__member).setReadSynthetic(__method);
break;
end;
if suffix = MEMBER_SUFFIX_WRITE then begin
&Property(__member).setWriteSynthetic(__method);
break;
end;
if suffix = MEMBER_SUFFIX_INDEX then begin
&Property(__member).setIndexSynthetic(__method);
break;
end;
if suffix = MEMBER_SUFFIX_STORED then begin
&Property(__member).setStoredSynthetic(__method);
end;
break;
end;
__member := __member.nextItem;
end;
end;
result := __method;
end;
function ClassType.createOperator(__attributes: int; __type: &Type; __kind: int; const __arguments: Local_Array1d; __declarationPosition, __documentationPosition: int): &Operator;
var
position: int;
buffer: Local_Array1d;
__operator: &Operator;
__programme: Programme;
begin
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
__programme := parentProgramme;
if __type.parentProgramme <> __programme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.type'));
end;
if __type.isNull() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-suitable.operator'));
end;
buffer := checkArguments(__arguments);
__operator := nil;
if __programme <> nil then begin
__operator := __programme.newOperator(self, __attributes, __type, __kind, buffer, __declarationPosition, __documentationPosition);
end;
if __operator = nil then begin
__operator := &Operator.create(self, __attributes, __type, __kind, buffer, __declarationPosition, __documentationPosition);
end;
if (__attributes and ATTR_SYNTHETIC) <> 0 then begin
appendChildItem(__operator);
end else begin
position := fldUserMembersInsertionPosition;
insertChildItem(__operator, position);
fldUserMembersInsertionPosition := position + 1;
end;
result := __operator;
end;
function ClassType.createProperty(__attributes: int; __type: &Type; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): &Property;
var
position: int;
__property: &Property;
__programme: Programme;
begin
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
__programme := parentProgramme;
if __type.parentProgramme <> __programme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.type'));
end;
if __type.isVoid() or __type.isNull() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-suitable.property'));
end;
__property := nil;
if __programme <> nil then begin
__property := __programme.newProperty(self, __attributes, __type, __specialSimpleName, __declarationPosition, __documentationPosition);
end;
if __property = nil then begin
__property := &Property.create(self, __attributes, __type, __specialSimpleName, __declarationPosition, __documentationPosition);
end;
if (__attributes and ATTR_SYNTHETIC) <> 0 then begin
appendChildItem(__property);
end else begin
position := fldUserMembersInsertionPosition;
insertChildItem(__property, position);
fldUserMembersInsertionPosition := position + 1;
end;
result := __property;
end;
function ClassType.hasNativeCallables(): boolean;
begin
result := fldNativeCallablesCounter > 0;
end;
function ClassType.isSuperclass(&type: ClassType): boolean;
var
current: ClassType;
begin
if &type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
if &type.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.type'));
end;
current := fldSuperclassType;
while current <> nil do begin
if &type = current then begin
result := true;
exit;
end;
current := current.fldSuperclassType;
end;
result := false;
end;
function ClassType.isSuperclass(const __specialCanonicalName: AnsiString): boolean;
var
current: ClassType;
begin
if __specialCanonicalName.length > 0 then begin
current := fldSuperclassType;
while current <> nil do begin
if __specialCanonicalName = current.specialCanonicalName then begin
result := true;
exit;
end;
current := current.fldSuperclassType;
end;
end;
result := false;
end;
function ClassType.isSuperservice(&type: ClassType): boolean;
begin
if &type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
if &type.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.type'));
end;
result := &Array.indexOf(&type, fldSuperservicesTypes, 0, fldSuperservicesLength) >= 0;
end;
function ClassType.isSuperservice(const __specialCanonicalName: AnsiString): boolean;
var
index: int;
types: ClassType_Array1d;
begin
if __specialCanonicalName.length > 0 then begin
types := fldSuperservicesTypes;
for index := fldSuperservicesLength - 1 downto 0 do if __specialCanonicalName = types[index].specialCanonicalName then begin
result := true;
exit;
end;
end;
result := false;
end;
function ClassType.getHelperForPosition(): int;
begin
result := fldHelperForPosition;
end;
function ClassType.getSuperclassPosition(): int;
begin
result := fldSuperclassPosition;
end;
function ClassType.getSuperservicesLength(): int;
begin
result := fldSuperservicesLength;
end;
function ClassType.getSuperservicePositionAt(index: int): int;
begin
if (index < 0) or (index >= fldSuperservicesLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldSuperservicesPositions[index];
end;
function ClassType.getSuperserviceIndex(&type: ClassType): int;
begin
if &type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
if &type.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.type'));
end;
result := &Array.indexOf(&type, fldSuperservicesTypes, 0, fldSuperservicesLength);
end;
function ClassType.virtualCallables(): Callable_Array1d;
var
length: int;
callables: Callable_Array1d;
begin
length := fldVirtualLength;
callables := Callable_Array1d(&Array.newTObject1d(length));
&Array.copyObjects(fldVirtualCallables, 0, callables, 0, length);
result := callables;
end;
function ClassType.serviceCallables(): Callable_Array1d;
var
length: int;
callables: Callable_Array1d;
begin
length := fldServiceLength;
callables := Callable_Array1d(&Array.newTObject1d(length));
&Array.copyObjects(fldServiceCallables, 0, callables, 0, length);
result := callables;
end;
function ClassType.findFieldoids(const __specialSimpleName: AnsiString; __areVisibleFrom: ClassType): Fieldoid_Array1d;
label
break_label0,
break_label1;
var
hindex: int;
tindex: int;
hlength: int;
tlength: int;
helpers: ClassType_Array1d;
types: ClassType_Array1d;
place: ClassType;
current: ClassType;
container: ClassType;
found0: Fieldoid;
found1: Fieldoid;
__member: Member;
begin
place := fldHelperForType;
if place = nil then place := self;
if __areVisibleFrom = nil then begin
__areVisibleFrom := place;
end else
if __areVisibleFrom.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'visibility-type.not-same-programme'));
end;
{ поиск полеоидов в этом типе и его суперклассах, с учётом видимости }
begin
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
if (__member is Fieldoid) and __member.isVisibleFrom(__areVisibleFrom, self) then begin
if found0 <> nil then begin
if not container.isHelper() and not found0.parentType.isHelper() then begin
result := [ found0 ];
exit;
end;
found1 := __member as Fieldoid;
goto break_label0;
end;
found0 := __member as Fieldoid;
end;
end;
end;
current := current.fldSuperclassType;
until current = nil;
break_label0:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск полеоидов в суперсервисах, с учётом видимости }
begin
found0 := nil;
found1 := nil;
types := place.fldSuperservicesTypes;
tlength := place.fldSuperservicesLength;
for tindex := 0 to tlength - 1 do begin
current := types[tindex];
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
if (__member is Fieldoid) and __member.isVisibleFrom(__areVisibleFrom, self) then begin
if found0 <> nil then begin
found1 := __member as Fieldoid;
goto break_label1;
end;
found0 := __member as Fieldoid;
end;
end;
end;
end;
break_label1:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск полеоида в этом типе и его супертипах, без учёта видимости }
begin
tindex := -1;
tlength := place.fldSuperservicesLength;
types := place.fldSuperservicesTypes;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
if __member is Fieldoid then begin
result := [ __member as Fieldoid ];
exit;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
end;
result := nil;
end;
function ClassType.findInterrupts(const __specialSimpleName: AnsiString; __areVisibleFrom: ClassType): Callable_Array1d;
label
break_label0,
break_label1;
var
hindex: int;
tindex: int;
hlength: int;
tlength: int;
helpers: ClassType_Array1d;
types: ClassType_Array1d;
place: ClassType;
current: ClassType;
container: ClassType;
__callable: Callable;
found0: Callable;
found1: Callable;
__member: Member;
begin
place := fldHelperForType;
if place = nil then place := self;
if __areVisibleFrom = nil then begin
__areVisibleFrom := place;
end else
if __areVisibleFrom.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'visibility-type.not-same-programme'));
end;
{ поиск прерываний в этом типе и его суперклассах, с учётом видимости }
begin
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
if not(__member is Callable) then continue;
__callable := Callable(__member);
if __callable.isInterrupt() and __member.isVisibleFrom(__areVisibleFrom, self) then begin
if found0 <> nil then begin
if not container.isHelper() and not found0.parentType.isHelper() then begin
result := [ found0 ];
exit;
end;
found1 := __callable;
goto break_label0;
end;
found0 := __callable;
end;
end;
end;
current := current.fldSuperclassType;
until current = nil;
break_label0:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск прерываний в суперсервисах, с учётом видимости }
begin
found0 := nil;
found1 := nil;
types := place.fldSuperservicesTypes;
tlength := place.fldSuperservicesLength;
for tindex := 0 to tlength - 1 do begin
current := types[tindex];
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
if not(__member is Callable) then continue;
__callable := Callable(__member);
if __callable.isInterrupt() and __member.isVisibleFrom(__areVisibleFrom, self) then begin
if found0 <> nil then begin
found1 := __callable;
goto break_label1;
end;
found0 := __callable;
end;
end;
end;
end;
break_label1:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск прерывания в этом типе и его супертипах, без учёта видимости }
begin
tindex := -1;
tlength := place.fldSuperservicesLength;
types := place.fldSuperservicesTypes;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
if not(__member is Callable) then continue;
__callable := Callable(__member);
if __callable.isInterrupt() then begin
result := [ __callable ];
exit;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
end;
result := nil;
end;
function ClassType.findConstructors(const __arguments: Type_Array1d; __areVisibleFrom: ClassType): InstInit_Array1d;
var
current: ClassType;
first: ProgrammeItem;
__constructor: InstInit;
found0: InstInit;
found1: InstInit;
__member: ProgrammeItem;
begin
if __areVisibleFrom = nil then begin
__areVisibleFrom := self;
end else
if __areVisibleFrom.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'visibility-type.not-same-programme'));
end;
if isHelper() then begin
result := nil;
exit;
end;
{ определение места поиска конструкторов }
current := self;
while not current.isClass() do begin
current := current.fldSuperclassType;
if current = nil then begin
result := nil;
exit;
end;
end;
{ первый конструктор }
first := current.getChildMember(SPECNAME_INST_INIT);
{ поиск конструктора с точно совпадающими типами аргументов и с учётом видимости }
begin
__member := first;
while __member <> nil do begin
if __member is InstInit then begin
__constructor := InstInit(__member);
if __constructor.isVisibleFrom(__areVisibleFrom, self) and __constructor.isIdentityArguments(__arguments) then begin
result := [ __constructor ];
exit;
end;
end;
__member := __member.nextItem;
end;
end;
{ поиск конструкторов с конвертируемыми типами аргументов и с учётом видимости }
begin
found0 := nil;
found1 := nil;
__member := first;
while __member <> nil do begin
if __member is InstInit then begin
__constructor := InstInit(__member);
if __constructor.isVisibleFrom(__areVisibleFrom, self) and __constructor.isConvertableArguments(__arguments) then begin
if found0 <> nil then begin
found1 := __constructor;
break;
end;
found0 := __constructor;
end;
end;
__member := __member.nextItem;
end;
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск конструктора с точно совпадающими типами аргументов и без учёта видимости }
begin
__member := first;
while __member <> nil do begin
if __member is InstInit then begin
__constructor := InstInit(__member);
if __constructor.isIdentityArguments(__arguments) then begin
result := [ __constructor ];
exit;
end;
end;
__member := __member.nextItem;
end;
end;
{ поиск конструкторов с конвертируемыми типами аргументов и без учёта видимости }
begin
found0 := nil;
found1 := nil;
__member := first;
while __member <> nil do begin
if __member is InstInit then begin
__constructor := InstInit(__member);
if __constructor.isConvertableArguments(__arguments) then begin
if found0 <> nil then begin
found1 := __constructor;
break;
end;
found0 := __constructor;
end;
end;
__member := __member.nextItem;
end;
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск конструктора с любыми типами аргументов и без учёта видимости }
if first is InstInit then begin
result := [ InstInit(first) ];
exit;
end;
result := nil;
end;
function ClassType.findMethods(const __specialSimpleName: AnsiString; const __arguments: Type_Array1d; __areVisibleFrom: ClassType): Method_Array1d;
label
break_label0,
break_label1,
break_label2,
break_label3;
var
hindex: int;
tindex: int;
hlength: int;
tlength: int;
helpers: ClassType_Array1d;
types: ClassType_Array1d;
place: ClassType;
current: ClassType;
container: ClassType;
__callable: Method;
found0: Method;
found1: Method;
__member: ProgrammeItem;
begin
place := fldHelperForType;
if place = nil then place := self;
if __areVisibleFrom = nil then begin
__areVisibleFrom := place;
end else
if __areVisibleFrom.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'visibility-type.not-same-programme'));
end;
tlength := place.fldSuperservicesLength;
types := place.fldSuperservicesTypes;
{ поиск методов в этом типе и его супертипах, с точно совпадающими типами аргументов и с учётом видимости }
begin
tindex := -1;
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is Method then begin
__callable := Method(__member);
if __callable.isVisibleFrom(__areVisibleFrom, self) and __callable.isIdentityArguments(__arguments) then begin
if found0 = nil then begin
found0 := __callable;
end else
if not found0.isIdentityArguments(__callable) or container.isHelper() or found0.parentType.isHelper() then begin
found1 := __callable;
goto break_label0;
end;
end;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
break_label0:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск методов в этом типе и его супертипах, с конвертируемыми типами аргументов и с учётом видимости }
begin
tindex := -1;
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is Method then begin
__callable := Method(__member);
if __callable.isVisibleFrom(__areVisibleFrom, self) and __callable.isConvertableArguments(__arguments) then begin
if found0 = nil then begin
found0 := __callable;
end else
if not found0.isIdentityArguments(__callable) or container.isHelper() or found0.parentType.isHelper() then begin
found1 := __callable;
goto break_label1;
end;
end;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
break_label1:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск методов в этом типе и его супертипах, с точно совпадающими типами аргументов и без учёта видимости }
begin
tindex := -1;
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is Method then begin
__callable := Method(__member);
if __callable.isIdentityArguments(__arguments) then begin
if found0 = nil then begin
found0 := __callable;
end else
if not found0.isIdentityArguments(__callable) or container.isHelper() or found0.parentType.isHelper() then begin
found1 := __callable;
goto break_label2;
end;
end;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
break_label2:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск методов в этом типе и его супертипах, с конвертируемыми типами аргументов и без учёта видимости }
begin
tindex := -1;
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is Method then begin
__callable := Method(__member);
if __callable.isConvertableArguments(__arguments) then begin
if found0 = nil then begin
found0 := __callable;
end else
if not found0.isIdentityArguments(__callable) or container.isHelper() or found0.parentType.isHelper() then begin
found1 := __callable;
goto break_label3;
end;
end;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
break_label3:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск метода в этом типе и его супертипах, с любыми типами аргументов и без учёта видимости }
begin
tindex := -1;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is Method then begin
result := [ Method(__member) ];
exit;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
end;
result := nil;
end;
function ClassType.findOperators(__kind: int; const __arguments: Type_Array1d; __areVisibleFrom: ClassType): Operator_Array1d;
label
break_label0,
break_label1,
break_label2,
break_label3;
var
hindex: int;
tindex: int;
hlength: int;
tlength: int;
__specialSimpleName: AnsiString;
helpers: ClassType_Array1d;
types: ClassType_Array1d;
place: ClassType;
current: ClassType;
container: ClassType;
__callable: &Operator;
found0: &Operator;
found1: &Operator;
__member: ProgrammeItem;
begin
__specialSimpleName := &Operator.kindToSpecialSimpleName(__kind);
place := fldHelperForType;
if place = nil then place := self;
if __areVisibleFrom = nil then begin
__areVisibleFrom := place;
end else
if __areVisibleFrom.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'visibility-type.not-same-programme'));
end;
tlength := place.fldSuperservicesLength;
types := place.fldSuperservicesTypes;
{ поиск операторов в этом типе и его супертипах, с точно совпадающими типами аргументов и с учётом видимости }
begin
tindex := -1;
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is &Operator then begin
__callable := &Operator(__member);
if __callable.isVisibleFrom(__areVisibleFrom, self) and __callable.isIdentityArguments(__arguments) then begin
if found0 = nil then begin
found0 := __callable;
end else
if not found0.isIdentityArguments(__callable) or container.isHelper() or found0.parentType.isHelper() then begin
found1 := __callable;
goto break_label0;
end;
end;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
break_label0:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск операторов в этом типе и его супертипах, с конвертируемыми типами аргументов и с учётом видимости }
begin
tindex := -1;
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is &Operator then begin
__callable := &Operator(__member);
if __callable.isVisibleFrom(__areVisibleFrom, self) and __callable.isConvertableArguments(__arguments) then begin
if found0 = nil then begin
found0 := __callable;
end else
if not found0.isIdentityArguments(__callable) or container.isHelper() or found0.parentType.isHelper() then begin
found1 := __callable;
goto break_label1;
end;
end;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
break_label1:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск операторов в этом типе и его супертипах, с точно совпадающими типами аргументов и без учёта видимости }
begin
tindex := -1;
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is &Operator then begin
__callable := &Operator(__member);
if __callable.isIdentityArguments(__arguments) then begin
if found0 = nil then begin
found0 := __callable;
end else
if not found0.isIdentityArguments(__callable) or container.isHelper() or found0.parentType.isHelper() then begin
found1 := __callable;
goto break_label2;
end;
end;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
break_label2:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск операторов в этом типе и его супертипах, с конвертируемыми типами аргументов и без учёта видимости }
begin
tindex := -1;
found0 := nil;
found1 := nil;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is &Operator then begin
__callable := &Operator(__member);
if __callable.isConvertableArguments(__arguments) then begin
if found0 = nil then begin
found0 := __callable;
end else
if not found0.isIdentityArguments(__callable) or container.isHelper() or found0.parentType.isHelper() then begin
found1 := __callable;
goto break_label3;
end;
end;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
break_label3:
if found0 <> nil then begin
if found1 <> nil then begin
result := [ found0, found1 ];
exit;
end;
result := [ found0 ];
exit;
end;
end;
{ поиск оператора в этом типе и его супертипах, с любыми типами аргументов и без учёта видимости }
begin
tindex := -1;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __areVisibleFrom.source.contains(container) and container.isVisibleFrom(__areVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member is &Operator then begin
result := [ &Operator(__member) ];
exit;
end;
__member := __member.nextItem;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
end;
result := nil;
end;
function ClassType.resolveName(const __specialSimpleName: AnsiString; __isVisibleFrom: ClassType; __isVisibleOnly: boolean): Member;
var
hindex: int;
tindex: int;
hlength: int;
tlength: int;
helpers: ClassType_Array1d;
types: ClassType_Array1d;
place: ClassType;
current: ClassType;
container: ClassType;
__member: Member;
begin
place := fldHelperForType;
if place = nil then place := self;
if __isVisibleFrom = nil then begin
__isVisibleFrom := place;
end else
if __isVisibleFrom.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'visibility-type.not-same-programme'));
end;
tlength := place.fldSuperservicesLength;
types := place.fldSuperservicesTypes;
{ поиск члена в этом типе и его супертипах, с учётом видимости }
begin
tindex := -1;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __isVisibleFrom.source.contains(container) and container.isVisibleFrom(__isVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
while __member <> nil do begin
if __member.isVisibleFrom(__isVisibleFrom, self) then begin
result := __member;
exit;
end;
__member := __member.nextItem as Member;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
end;
{ поиск члена в этом типе и его супертипах, без учёта видимости }
if not __isVisibleOnly then begin
tindex := -1;
current := place;
repeat
with current.fldHelpers do begin
helpers := &array;
hlength := length;
end;
for hindex := -1 to hlength - 1 do begin
if hindex < 0 then begin
container := current;
end else begin
container := helpers[hindex];
end;
if (current = container) or __isVisibleFrom.source.contains(container) and container.isVisibleFrom(__isVisibleFrom) then begin
__member := container.getChildMember(__specialSimpleName);
if __member <> nil then begin
result := __member;
exit;
end;
end;
end;
if tindex < 0 then begin
current := current.fldSuperclassType;
if current = nil then tindex := 0;
end;
if tindex >= 0 then begin
if tindex >= tlength then begin
current := nil;
end else begin
current := types[tindex];
inc(tindex);
end;
end;
until current = nil;
end;
result := nil;
end;
function ClassType.readComponent(index: int): Member;
begin
result := inherited readComponent(index) as Member;
end;
function ClassType.readComponent(index: int): ProgrammeItem;
begin
result := inherited readComponent(index) as Member;
end;
function ClassType.readComponent(index: int): TObject;
begin
result := inherited readComponent(index) as Member;
end;
function ClassType.getChildMember(const __specialSimpleName: AnsiString): Member;
begin
result := inherited getChildItem(__specialSimpleName) as Member;
end;
function ClassType.getChildMember(const __specialSimpleName: AnsiString; __ignoreCase: boolean): Member;
begin
result := inherited getChildItem(__specialSimpleName, __ignoreCase) as Member;
end;
function ClassType.getChildFieldoid(const __specialSimpleName: AnsiString): Fieldoid;
var
__member: ProgrammeItem;
begin
__member := inherited getChildItem(__specialSimpleName);
while __member <> nil do begin
if __member is Fieldoid then begin
result := __member as Fieldoid;
exit;
end;
__member := __member.nextItem;
end;
result := nil;
end;
function ClassType.getChildCallable(const __specialSimpleName: AnsiString; const __arguments: Type_Array1d): Callable;
var
__callable: Callable;
__member: ProgrammeItem;
begin
__member := inherited getChildItem(__specialSimpleName);
while __member <> nil do begin
if __member is Callable then begin
__callable := Callable(__member);
if __callable.isIdentityArguments(__arguments) then begin
result := __callable;
exit;
end;
end;
__member := __member.nextItem;
end;
result := nil;
end;
function ClassType.getChildCallable(const __specialSimpleName: AnsiString; const __arguments: TypedItem_Array1d): Callable;
var
__callable: Callable;
__member: ProgrammeItem;
begin
__member := inherited getChildItem(__specialSimpleName);
while __member <> nil do begin
if __member is Callable then begin
__callable := Callable(__member);
if __callable.isIdentityArguments(__arguments) then begin
result := __callable;
exit;
end;
end;
__member := __member.nextItem;
end;
result := nil;
end;
function ClassType.getDefaultConstructor(): InstInit;
begin
result := fldDefaultConstructor;
end;
function ClassType.getStaticBlock(): ClassInit;
begin
result := fldStaticBlock;
end;
function ClassType.getHelperForType(): ClassType;
begin
result := fldHelperForType;
end;
function ClassType.getSuperclassType(): ClassType;
begin
result := fldSuperclassType;
end;
function ClassType.getSuperserviceTypeAt(index: int): ClassType;
begin
if (index < 0) or (index >= fldSuperservicesLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldSuperservicesTypes[index];
end;
{%endregion}
{%region ArrayType }
function ArrayType.composeFasmDimensionsCount(): AnsiString;
var
dimensions: int;
begin
dimensions := fldDimensionsCount;
result := AnsiString.create([ '.', char(int('0') + (dimensions div 10)), char(int('0') + (dimensions mod 10)), 'd' ]);
end;
function ArrayType.composeRecompilableName(): AnsiString;
begin
result := '[' + fldComponentType.recompilableName;
end;
function ArrayType.composeFasmSimpleName(): AnsiString;
begin
result := fldCellType.fasmSimpleName + composeFasmDimensionsCount();
end;
function ArrayType.composeFasmFullName(): AnsiString;
begin
result := fasmSimpleName;
end;
function ArrayType.composeFasmFileName(): UnicodeString;
begin
result := fldCellType.fasmFileName + composeFasmDimensionsCount().toUTF16();
end;
constructor ArrayType.create(__componentType: &Type);
var
&array: ArrayType;
begin
inherited create(__componentType.parentPackage, __componentType.visibility, __componentType.specialSimpleName + '[]', nil, -1, -1, '');
if not(__componentType is ArrayType) then begin
fldDimensionsCount := 1;
fldCellType := __componentType;
end else begin
&array := ArrayType(__componentType);
fldDimensionsCount := &array.fldDimensionsCount + 1;
fldCellType := &array.fldCellType;
end;
fldComponentType := __componentType;
end;
procedure ArrayType.makeCompilable();
var
&array: ArrayType;
__componentType: &Type;
begin
if not fldCompilable then begin
fldCompilable := true;
__componentType := fldComponentType;
while __componentType is ArrayType do begin
&array := ArrayType(__componentType);
&array.fldCompilable := true;
__componentType := &array.fldComponentType;
end;
if __componentType <> nil then begin
__componentType.makeCompilable();
end;
end;
end;
function ArrayType.isCompilable(): boolean;
begin
result := fldCompilable;
end;
function ArrayType.isAssignableFrom(anot: &Type): boolean;
var
dimCount: int;
thisDimensionsCount: int;
anotDimensionsCount: int;
&array: ArrayType;
cell: &Type;
begin
if anot = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('anot') ]));
end;
if (anot = self) or anot.isNull() then begin
result := true;
exit;
end;
if not(anot is ArrayType) then begin
result := false;
exit;
end;
&array := ArrayType(anot);
thisDimensionsCount := fldDimensionsCount;
anotDimensionsCount := &array.fldDimensionsCount;
if thisDimensionsCount > anotDimensionsCount then begin
result := false;
exit;
end;
cell := &array.fldComponentType;
for dimCount := thisDimensionsCount - 1 downto 1 do cell := ArrayType(cell).fldComponentType;
result := fldCellType.isAssignableFrom(cell);
end;
function ArrayType.isCompatibleWith(anot: &Type): boolean;
var
dimCount: int;
thisDimensionsCount: int;
anotDimensionsCount: int;
&array: ArrayType;
typeA: &Type;
typeB: &Type;
begin
if not(anot is ArrayType) then begin
result := inherited isCompatibleWith(anot);
exit;
end;
&array := ArrayType(anot);
thisDimensionsCount := fldDimensionsCount;
anotDimensionsCount := &array.fldDimensionsCount;
if thisDimensionsCount > anotDimensionsCount then begin
typeA := &array.fldCellType;
typeB := fldComponentType;
for dimCount := anotDimensionsCount - 1 downto 1 do typeB := ArrayType(typeB).fldComponentType;
end else begin
typeA := fldCellType;
typeB := &array.fldComponentType;
for dimCount := thisDimensionsCount - 1 downto 1 do typeB := ArrayType(typeB).fldComponentType;
end;
result := typeA.isCompatibleWith(typeB);
end;
function ArrayType.isVisibleFrom(__type: ClassType): boolean;
begin
result := fldCellType.isVisibleFrom(__type);
end;
function ArrayType.isArray(): boolean;
begin
result := true;
end;
{%endregion}
{%region NullType }
function NullType.getCommonType(anot: ReferenceType): ReferenceType;
begin
result := anot;
end;
constructor NullType.create();
begin
inherited create(nil, VIS_PUBLIC or ATTR_FINAL, TYPENAME_NULL, nil, -1, -1);
end;
function NullType.isCompilable(): boolean;
begin
result := false;
end;
function NullType.isAssignableFrom(anot: &Type): boolean;
begin
result := false;
end;
function NullType.isCompatibleWith(anot: &Type): boolean;
begin
result := anot is ReferenceType;
end;
function NullType.isNull(): boolean;
begin
result := true;
end;
{%endregion}
{%region Member }
class function Member.isClassTypeAssignable(&type, anot: ClassType): boolean;
begin
result := (anot = &type) or anot.isSuperclass(&type) or anot.isSuperservice(&type);
end;
class function Member.getSource(item: TableItem): Source;
begin
if item <> nil then begin
result := item.source;
exit;
end;
result := nil;
end;
function Member.Fieldoid_inherited_toString(): AnsiString;
var
enclosing: ClassType;
begin
enclosing := fldParentType;
if enclosing = nil then begin
result := inherited toString();
exit;
end;
result := enclosing.specialCanonicalName + '.' + specialSimpleName;
end;
function Member.Fieldoid_inherited_composeFasmFullName(): AnsiString;
var
mname: AnsiString;
tname: AnsiString;
enclosing: ClassType;
begin
mname := fasmSimpleName;
if mname.length <= 0 then begin
result := '';
exit;
end;
enclosing := fldParentType;
if enclosing = nil then begin
tname := '';
end else begin
tname := enclosing.fasmFullName;
end;
result := tname + '$' + mname;
end;
constructor Member.create(__parentType: ClassType; __attributes: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentType, __attributes, __specialSimpleName, getSource(__parentType), __declarationPosition, __documentationPosition);
fldParentType := __parentType;
if __parentType <> nil then begin
fldParentPackage := __parentType.parentPackage;
end;
end;
function Member.isVisibleFrom(__type: ClassType): boolean;
begin
result := isVisibleFrom(__type, nil);
end;
function Member.isVisibleFrom(__type, __impliedParentType: ClassType): boolean;
var
index: int;
length: int;
src: Source;
pck: TObject;
current: ClassType;
__programme: Programme;
factEnclosingType: ClassType;
realEnclosingType: ClassType;
begin
factEnclosingType := fldParentType;
if factEnclosingType = nil then begin
raise IllegalMemberStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'no-parent-item.member'));
end;
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
__programme := parentProgramme;
if __type.parentProgramme <> __programme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-same-programme.member'));
end;
realEnclosingType := factEnclosingType.getRealType();
if __impliedParentType = nil then begin
__impliedParentType := realEnclosingType;
end else begin
__impliedParentType := __impliedParentType.getRealType();
end;
if __impliedParentType.parentProgramme <> __programme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'implied-parent-type.not-same-programme'));
end;
if not isClassTypeAssignable(realEnclosingType, __impliedParentType) then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'implied-parent-type.not-assignable'));
end;
case visibility of
VIS_PUBLIC,
VIS_PUBLISHED: begin
result := true;
exit;
end;
VIS_PROTECTED: begin
if __type.parentPackage = factEnclosingType.parentPackage then begin
result := true;
exit;
end;
result := not __type.isHelper() and (factEnclosingType = realEnclosingType) and isClassTypeAssignable(realEnclosingType, __type) and isClassTypeAssignable(__type, __impliedParentType);
exit;
end;
VIS_PACKAGE,
RESERVED_PACKAGE: begin
pck := __type.parentPackage;
if (pck <> nil) and (pck = __impliedParentType.parentPackage) then begin
index := -1;
length := __impliedParentType.getSuperservicesLength();
current := __impliedParentType.getSuperclassType();
if (current = nil) and (length > 0) then begin
current := __impliedParentType.getSuperserviceTypeAt(0);
index := 1;
end;
while current <> nil do begin
if
isClassTypeAssignable(realEnclosingType, current) and isClassTypeAssignable(current, __impliedParentType) and
(pck <> current.parentPackage)
then begin
result := false;
exit;
end;
if index < 0 then begin
current := current.getSuperclassType();
if current = nil then index := 0;
end;
if index >= 0 then begin
if index >= length then begin
current := nil;
end else begin
current := __impliedParentType.getSuperserviceTypeAt(index);
inc(index);
end;
end;
end;
result := true;
exit;
end;
end;
VIS_SOURCE,
RESERVED_SOURCE: begin
src := __type.source;
pck := __type.parentPackage;
if (pck <> nil) and (pck = __impliedParentType.parentPackage) and (src <> nil) and src.isSameSource(__impliedParentType.source) then begin
index := -1;
length := __impliedParentType.getSuperservicesLength();
current := __impliedParentType.getSuperclassType();
if (current = nil) and (length > 0) then begin
current := __impliedParentType.getSuperserviceTypeAt(0);
index := 1;
end;
while current <> nil do begin
if
isClassTypeAssignable(realEnclosingType, current) and isClassTypeAssignable(current, __impliedParentType) and
((pck <> current.parentPackage) or not src.isSameSource(current.source))
then begin
result := false;
exit;
end;
if index < 0 then begin
current := current.getSuperclassType();
if current = nil then index := 0;
end;
if index >= 0 then begin
if index >= length then begin
current := nil;
end else begin
current := __impliedParentType.getSuperserviceTypeAt(index);
inc(index);
end;
end;
end;
result := true;
exit;
end;
end;
VIS_PRIVATE: begin
result := (__type = factEnclosingType) and (realEnclosingType = __impliedParentType);
exit;
end;
else
{ Недостижимый код. Нужен только для того, чтобы избежать сообщений об ошибках от компилятора. }
raise IllegalCompilerObjectStateException.create({ этот член имеет неизвестную видимость });
end;
result := false;
end;
function Member.isSpecial(): boolean;
begin
result := false;
end;
function Member.isStatic(): boolean;
begin
result := (attributes and ATTR_STATIC) <> 0;
end;
function Member.isSynthetic(): boolean;
begin
result := (attributes and ATTR_SYNTHETIC) <> 0;
end;
function Member.getParentType(): ClassType;
begin
result := fldParentType;
end;
function Member.getParentPackage(): Package;
begin
result := fldParentPackage;
end;
{%endregion}
{%region AllocatableMember }
class function AllocatableMember.getParentType(item: TObject): ClassType;
begin
if item is ru.malik.elaborarer.avtoo.lang.ClassType then begin
result := ru.malik.elaborarer.avtoo.lang.ClassType(item);
exit;
end;
if item is Member then begin
result := Member(item).parentType;
exit;
end;
result := nil;
end;
function AllocatableMember.computeStructOffset(currentOffset: int): int;
begin
fldStructOffset := currentOffset;
result := currentOffset;
end;
function AllocatableMember.computeInstanceOffset(currentOffset: int; fieldsMap: FieldsMap): int;
begin
fldInstanceOffset := currentOffset;
result := currentOffset;
end;
constructor AllocatableMember.create(__parentItem: AllocatableFactory; __attributes: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
begin
inherited create(getParentType(Lang.cast(__parentItem, TObject)), __attributes, __specialSimpleName, __declarationPosition, __documentationPosition);
fldStructOffset := -1;
fldInstanceOffset := -1;
if Lang.isInstance(__parentItem, NestedAllocatableMember) then begin
fldParentNested := NestedAllocatableMember(Lang.cast(__parentItem, NestedAllocatableMember));
end;
end;
{%endregion}
{%region Field }
function Field.computeStructOffset(currentOffset: int): int;
var
offset: int;
__capacity: int;
__type: &Type;
begin
__type := fldType;
if __type = nil then begin
raise IllegalMemberStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'member.type.not-specified'));
end;
if __type is ArrayType then begin
__type := ArrayType(__type).componentType;
end;
__capacity := fldCapacity;
if __capacity <= 0 then begin
__capacity := 1;
end;
if fldHasStructOffset then begin
offset := inherited structOffset;
end else begin
offset := inherited computeStructOffset(currentOffset);
end;
result := offset + __type.fieldWidth * __capacity;
end;
function Field.computeInstanceOffset(currentOffset: int; fieldsMap: FieldsMap): int;
var
allocatedOffset: int;
fieldWidth: int;
__type: &Type;
begin
__type := fldType;
if __type = nil then begin
raise IllegalMemberStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'member.type.not-specified'));
end;
fieldWidth := __type.fieldWidth;
if fieldsMap = nil then begin
if fieldWidth <= 4 then begin
allocatedOffset := currentOffset + (-currentOffset and $03);
end else
if fieldWidth <= 8 then begin
allocatedOffset := currentOffset + (-currentOffset and $07);
end else begin
allocatedOffset := currentOffset + (-currentOffset and $0f);
end;
end else begin
if fieldWidth <= 4 then begin
allocatedOffset := fieldsMap.allocateDwordAlignedField(fieldWidth);
end else
if fieldWidth <= 8 then begin
allocatedOffset := fieldsMap.allocateQwordAlignedField(fieldWidth);
end else begin
allocatedOffset := fieldsMap.allocateXwordAlignedField(fieldWidth);
end;
end;
result := inherited computeInstanceOffset(allocatedOffset, nil) + fieldWidth;
end;
function Field.composeRecompilableName(): AnsiString;
begin
result := specialSimpleName;
end;
function Field.composeFasmSimpleName(): AnsiString;
begin
result := specialSimpleName;
end;
function Field.composeFasmFullName(): AnsiString;
begin
result := Fieldoid_inherited_composeFasmFullName();
end;
function Field.composeFasmStructName(): AnsiString;
var
name: AnsiString;
begin
name := fasmFullName;
if name.length <= 0 then begin
result := '';
exit;
end;
result := name + '.struct';
end;
constructor Field.create(__parentItem: AllocatableFactory; __type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentItem, VIS_PUBLIC, __specialSimpleName, __declarationPosition, __documentationPosition);
fldCapacity := __capacity;
fldState := COMPUTED;
fldType := __type;
end;
constructor Field.create(__parentType: ClassType; __structOffset: int; __type: &Type; __capacity: int; const __specialSimpleName: AnsiString;
__declarationPosition, __documentationPosition: int);
begin
inherited create(__parentType, VIS_PUBLIC, __specialSimpleName, __declarationPosition, __documentationPosition);
inherited computeStructOffset(__structOffset);
fldHasStructOffset := true;
fldCapacity := __capacity;
fldState := COMPUTED;
fldType := __type;
end;
constructor Field.create(__parentType: ClassType; __attributes: int; __type: &Type; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentType, __attributes, __specialSimpleName, __declarationPosition, __documentationPosition);
fldState := NOT_COMPUTED;
fldType := __type;
end;
procedure Field.afterConstruction();
begin
inherited afterConstruction();
fldFasmStructName := composeFasmStructName();
end;
procedure Field.openComputing();
begin
if fldState <> NOT_COMPUTED then begin
raise IllegalFieldStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'field.not-computed'));
end;
fldState := COMPUTING;
end;
procedure Field.closeComputing();
begin
fldState := COMPUTED;
end;
procedure Field.setComputedValue(__value: Constant);
begin
if fldState <> COMPUTING then begin
raise IllegalFieldStateException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'field.computing'));
end;
fldValue := __value.castTo(fldType);
end;
function Field.toString(): AnsiString;
begin
result := Fieldoid_inherited_toString();
end;
function Field.isConstant(): boolean;
begin
result := ((attributes and (ATTR_STATIC or ATTR_FINAL)) = (ATTR_STATIC or ATTR_FINAL)) and (fldValue <> nil);
end;
function Field.getValue(): Constant;
begin
result := fldValue;
end;
function Field.getType(): &Type;
begin
result := fldType;
end;
{%endregion}
{%region NestedAllocatableMember }
function NestedAllocatableMember.isOwner(): boolean;
begin
result := false;
end;
procedure NestedAllocatableMember.insertChildItem(item: ProgrammeItem; position: int);
begin
if (item <> nil) and not(item is AllocatableMember) then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'adding-item.not-a-allocatable'));
end;
inherited insertChildItem(item, position);
end;
{$WARN 5033 OFF} { позволить функции, состоящие только из одной управляющей конструкции raise }
function NestedAllocatableMember.computeInstanceOffset(currentOffset: int; fieldsMap: FieldsMap): int;
begin
raise UnsupportedOperationException.create(AnsiString.format(
AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'unsupported-operation.compute-instance-offset'), [
CoAnsiString.create(getClass().getCanonicalName())
]
));
end;
{$WARN 5033 ON}
function NestedAllocatableMember.composeRecompilableName(): AnsiString;
begin
result := '';
end;
function NestedAllocatableMember.composeFasmSimpleName(): AnsiString;
begin
result := '';
end;
function NestedAllocatableMember.composeFasmFullName(): AnsiString;
begin
result := '';
end;
constructor NestedAllocatableMember.create(__parentItem: AllocatableFactory; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentItem, VIS_PUBLIC, '', __declarationPosition, __documentationPosition);
end;
function NestedAllocatableMember.createNestedUnion(__declarationPosition, __documentationPosition: int): Union;
begin
result := AllocatableFactory_inherited_createNestedUnion(__declarationPosition, __documentationPosition);
end;
function NestedAllocatableMember.createNestedStruct(__declarationPosition, __documentationPosition: int): Struct;
begin
result := AllocatableFactory_inherited_createNestedStruct(__declarationPosition, __documentationPosition);
end;
function NestedAllocatableMember.createStructField(__type: &Type; __capacity: int; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int): Field;
var
__field: Field;
enclosing: ClassType;
begin
__field := AllocatableFactory_inherited_createStructField(__type, __capacity, __specialSimpleName, __declarationPosition, __documentationPosition);
enclosing := parentType;
if enclosing <> nil then enclosing.appendChildItem(__field);
result := __field;
end;
function NestedAllocatableMember.readComponent(index: int): AllocatableMember;
begin
result := inherited readComponent(index) as AllocatableMember;
end;
function NestedAllocatableMember.readComponent(index: int): ProgrammeItem;
begin
result := inherited readComponent(index) as AllocatableMember;
end;
function NestedAllocatableMember.readComponent(index: int): TObject;
begin
result := inherited readComponent(index) as AllocatableMember;
end;
function NestedAllocatableMember.getChildMember(const __specialSimpleName: AnsiString): AllocatableMember;
begin
result := inherited getChildItem(__specialSimpleName) as AllocatableMember;
end;
function NestedAllocatableMember.getChildMember(const __specialSimpleName: AnsiString; __ignoreCase: boolean): AllocatableMember;
begin
result := inherited getChildItem(__specialSimpleName, __ignoreCase) as AllocatableMember;
end;
{%endregion}
{%region Struct }
function Struct.computeStructOffset(currentOffset: int): int;
var
size: int;
index: int;
length: int;
begin
size := 0;
length := getLength();
for index := 0 to length - 1 do begin
size := readComponent(index).computeStructOffset(currentOffset + size) - currentOffset;
end;
result := inherited computeStructOffset(currentOffset) + size;
end;
{%endregion}
{%region Union }
function Union.computeStructOffset(currentOffset: int): int;
var
temp: int;
size: int;
index: int;
length: int;
begin
size := 0;
length := getLength();
for index := 0 to length - 1 do begin
temp := readComponent(index).computeStructOffset(currentOffset) - currentOffset;
if size < temp then size := temp;
end;
result := inherited computeStructOffset(currentOffset) + size;
end;
{%endregion}
{%region OverriddableMember }
function OverriddableMember.directOverridesIn(&type: ClassType): OverriddableMember;
var
current: ProgrammeItem;
overrides: OverriddableMember;
begin
current := &type.getChildItem(specialSimpleName);
while current <> nil do begin
if current is OverriddableMember then begin
overrides := OverriddableMember(current);
if isOverrides(overrides) then begin
result := overrides;
exit;
end;
end;
current := current.nextItem;
end;
result := nil;
end;
function OverriddableMember.composeRecompilableName(): AnsiString;
begin
result := specialSimpleName;
end;
constructor OverriddableMember.create(__parentType: ClassType; __attributes: int; __type: &Type; const __specialSimpleName: AnsiString; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentType, __attributes, __specialSimpleName, __declarationPosition, __documentationPosition);
fldType := __type;
end;
function OverriddableMember.isOverrides(anot: OverriddableMember): boolean;
begin
if anot = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('anot') ]));
end;
result := (self = anot) or (classType() = anot.classType()) and not isStatic() and not anot.isStatic() and (specialSimpleName = anot.specialSimpleName);
end;
function OverriddableMember.getType(): &Type;
begin
result := fldType;
end;
function OverriddableMember.overridesIn(__type: ClassType; __place: int): OverriddableMember;
var
index: int;
length: int;
current: ClassType;
overrides: OverriddableMember;
begin
if __type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
case __place of
CURRENT_TYPE: begin
result := directOverridesIn(__type);
exit;
end;
SUPERTYPES,
SUPERTYPES + SUPERCLASSES: begin
index := -1;
length := __type.getSuperservicesLength();
current := __type.getSuperclassType();
if (current = nil) and (length > 0) then begin
current := __type.getSuperserviceTypeAt(0);
index := 1;
end;
while current <> nil do begin
overrides := directOverridesIn(current);
if overrides <> nil then begin
result := overrides;
exit;
end;
if index < 0 then begin
current := current.getSuperclassType();
if current = nil then index := 0;
end;
if index >= 0 then begin
if index >= length then begin
current := nil;
end else begin
current := __type.getSuperserviceTypeAt(index);
inc(index);
end;
end;
end;
end;
CURRENT_TYPE + SUPERTYPES,
CURRENT_TYPE + SUPERTYPES + SUPERCLASSES: begin
index := -1;
length := __type.getSuperservicesLength();
current := __type;
repeat
overrides := directOverridesIn(current);
if overrides <> nil then begin
result := overrides;
exit;
end;
if index < 0 then begin
current := current.getSuperclassType();
if current = nil then index := 0;
end;
if index >= 0 then begin
if index >= length then begin
current := nil;
end else begin
current := __type.getSuperserviceTypeAt(index);
inc(index);
end;
end;
until current = nil;
end;
SUPERCLASSES: begin
current := __type.getSuperclassType();
while current <> nil do begin
overrides := directOverridesIn(current);
if overrides <> nil then begin
result := overrides;
exit;
end;
current := current.getSuperclassType();
end;
end;
CURRENT_TYPE + SUPERCLASSES: begin
current := __type;
repeat
overrides := directOverridesIn(current);
if overrides <> nil then begin
result := overrides;
exit;
end;
current := current.getSuperclassType();
until current = nil;
end;
else
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('place') ]));
end;
result := nil;
end;
{%endregion}
{%region Callable }
function Callable.createCode(): Code;
var
__code: Code;
__programme: Programme;
begin
__code := nil;
__programme := parentProgramme;
if __programme <> nil then begin
__code := __programme.newCode(self);
end;
if __code = nil then begin
__code := ru.malik.elaborarer.avtoo.lang.Code.create(self);
end;
result := __code;
end;
procedure Callable.setVirtualIndex(newVirtualIndex: int);
begin
fldVirtualIndex := newVirtualIndex;
end;
procedure Callable.setServiceIndex(newServiceIndex: int);
begin
fldServiceIndex := newServiceIndex;
end;
function Callable.composeFasmFullName(): AnsiString;
var
name: AnsiString;
enclosing: ClassType;
begin
enclosing := parentType;
if enclosing <> nil then begin
name := enclosing.fasmFullName;
end else begin
name := '';
end;
result := name + '$' + fasmSimpleName + fldArgumentsArray.toFasmString();
end;
constructor Callable.create(__parentType: ClassType; __attributes: int; __type: &Type; const __specialSimpleName: AnsiString; const __arguments: Local_Array1d;
__declarationPosition, __documentationPosition: int);
var
index: int;
length: int;
argument: Local;
thisArgument: Local;
__parentProgramme: Programme;
table: HashtableOfAnsiStringToLocal;
begin
inherited create(__parentType, __attributes, __type, __specialSimpleName, __declarationPosition, __documentationPosition);
length := system.length(__arguments);
if ((__attributes and ATTR_STATIC) = 0) and (__parentType <> nil) then begin
thisArgument := __parentType.thisArgument;
end else begin
thisArgument := nil;
end;
if (thisArgument <> nil) or (length > 0) then begin
table := HashtableOfAnsiStringToLocal.create();
end else begin
table := nil;
end;
for index := length - 1 downto 0 do begin
argument := __arguments[index];
table[argument.specialSimpleName] := argument;
end;
if thisArgument <> nil then begin
table[thisArgument.specialSimpleName] := thisArgument;
end;
if __parentType <> nil then begin
__parentProgramme := __parentType.parentProgramme;
end else begin
__parentProgramme := nil;
end;
fldVirtualIndex := -1;
fldServiceIndex := -1;
fldArgumentsStore := __arguments;
fldArgumentsArray := ArgumentArray.create(__parentProgramme, thisArgument, __arguments);
fldArgumentsTable := table;
fldThisArgument := thisArgument;
if (__attributes and (ATTR_ABSTRACT or ATTR_NATIVE)) = 0 then begin
fldCode := createCode();
end;
end;
destructor Callable.destroy;
begin
fldArgumentsArray.free();
fldArgumentsTable.free();
fldCode.free();
inherited destroy;
end;
function Callable.isOverrides(anot: OverriddableMember): boolean;
begin
result := inherited isOverrides(anot) and isIdentityArguments(Callable(anot));
end;
function Callable.canThrown(): boolean;
begin
result := false;
end;
function Callable.canThrown(throwable: ClassType): boolean;
begin
result := (throwable <> nil) and throwable.isFreeThrowableType();
end;
function Callable.isNative(): boolean;
begin
result := (attributes and ATTR_NATIVE) <> 0;
end;
function Callable.isInterrupt(): boolean;
begin
result := (attributes and ATTR_INTERRUPT) <> 0;
end;
function Callable.isSynchronized(): boolean;
begin
result := (attributes and ATTR_SYNCHRONIZED) <> 0;
end;
function Callable.isArgument(argument: Local): boolean;
begin
result := (argument <> nil) and ((argument = fldThisArgument) or (&Array.indexOf(argument, fldArgumentsStore, 0, 0) >= 0));
end;
function Callable.isIdentityArguments(member: Callable): boolean;
var
index: int;
length: int;
sarguments: Local_Array1d;
targuments: TypedItem_Array1d;
begin
if member = nil then begin
result := false;
exit;
end;
sarguments := member.fldArgumentsStore;
length := system.length(sarguments);
targuments := TypedItem_Array1d(&Array.newISimple1d(length));
for index := length - 1 downto 0 do begin
targuments[index] := sarguments[index];
end;
result := isIdentityArguments(targuments);
end;
function Callable.isIdentityArguments(const arguments: Type_Array1d): boolean;
var
index: int;
length: int;
store: Local_Array1d;
begin
store := fldArgumentsStore;
length := system.length(arguments);
if length <> system.length(store) then begin
result := false;
exit;
end;
for index := 0 to length - 1 do begin
if arguments[index] <> store[index].&type then begin
result := false;
exit;
end;
end;
result := true;
end;
function Callable.isIdentityArguments(const arguments: TypedItem_Array1d): boolean;
var
index: int;
length: int;
store: Local_Array1d;
argument: TypedItem;
begin
store := fldArgumentsStore;
length := system.length(arguments);
if length <> system.length(store) then begin
result := false;
exit;
end;
for index := 0 to length - 1 do begin
argument := arguments[index];
if (argument = nil) or (argument.&type <> store[index].&type) then begin
result := false;
exit;
end;
end;
result := true;
end;
function Callable.isAssignableArguments(const arguments: Type_Array1d): boolean;
var
index: int;
length: int;
store: Local_Array1d;
__type: &Type;
begin
store := fldArgumentsStore;
length := system.length(arguments);
if length <> system.length(store) then begin
result := false;
exit;
end;
for index := 0 to length - 1 do begin
__type := arguments[index];
if (__type = nil) or not store[index].&type.isAssignableFrom(__type) then begin
result := false;
exit;
end;
end;
result := true;
end;
function Callable.isConvertableArguments(const arguments: Type_Array1d): boolean;
var
index: int;
length: int;
store: Local_Array1d;
__type: &Type;
begin
store := fldArgumentsStore;
length := system.length(arguments);
if length <> system.length(store) then begin
result := false;
exit;
end;
for index := 0 to length - 1 do begin
__type := arguments[index];
if (__type = nil) or not store[index].&type.isConvertableFrom(__type) then begin
result := false;
exit;
end;
end;
result := true;
end;
function Callable.getArgument(const __specialSimpleName: AnsiString): Local;
var
table: HashtableOfAnsiStringToLocal;
begin
table := fldArgumentsTable;
if table <> nil then begin
result := table[__specialSimpleName];
exit;
end;
result := nil;
end;
{%endregion}
{%region Method }
function Method.composeFasmSimpleName(): AnsiString;
begin
result := specialSimpleName;
end;
procedure Method.appendThrowable(throwable: ClassType; position: int);
var
length: int;
capacity: int;
sposes: int_Array1d;
bposes: int_Array1d;
stypes: ClassType_Array1d;
btypes: ClassType_Array1d;
begin
if throwable = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.Lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('throwable') ]));
end;
if throwable.parentProgramme <> parentProgramme then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'throwable-type.not-same-programme'));
end;
length := fldThrowablesLength;
stypes := fldThrowablesTypes;
if (length > 0) and (&Array.indexOf(throwable, stypes, 0, length) >= 0) then begin
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'throwable-type.already-added'), [
CoAnsiString.create(throwable.toString())
]));
end;
sposes := fldThrowablesPositions;
if stypes = nil then begin
sposes := &Array.newInt1d($0f);
stypes := ClassType_Array1d(&Array.newTObject1d($0f));
fldThrowablesPositions := sposes;
fldThrowablesTypes := stypes;
end else
if length = system.length(stypes) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (length shl 1) or 1;
bposes := &Array.newInt1d(capacity);
btypes := ClassType_Array1d(&Array.newTObject1d(capacity));
&Array.copyPrimitives(sposes, 0, bposes, 0, length);
&Array.copyObjects(stypes, 0, btypes, 0, length);
fldThrowablesPositions := bposes;
fldThrowablesTypes := btypes;
sposes := bposes;
stypes := btypes;
end;
sposes[length] := position;
stypes[length] := throwable;
fldThrowablesLength := length + 1;
if (fldFirstNonFreeThrowableType = nil) and not throwable.isFreeThrowableType() then begin
fldFirstNonFreeThrowableType := throwable;
end;
end;
function Method.canThrown(): boolean;
begin
result := fldFirstNonFreeThrowableType <> nil;
end;
function Method.canThrown(throwable: ClassType): boolean;
var
index: int;
types: ClassType_Array1d;
begin
if throwable = nil then begin
result := false;
exit;
end;
if throwable.isFreeThrowableType() then begin
result := true;
exit;
end;
types := fldThrowablesTypes;
for index := fldThrowablesLength - 1 downto 0 do if types[index].isAssignableFrom(throwable) then begin
result := true;
exit;
end;
result := false;
end;
function Method.toString(): AnsiString;
var
name: AnsiString;
enclosing: ClassType;
begin
enclosing := parentType;
if enclosing <> nil then begin
name := enclosing.specialCanonicalName + '.' + specialSimpleName;
end else begin
name := inherited toString();
end;
result := name + arguments.toString();
end;
function Method.isThrows(throwable: ClassType): boolean;
var
length: int;
types: ClassType_Array1d;
begin
length := fldThrowablesLength;
types := fldThrowablesTypes;
result := (length > 0) and (&Array.indexOf(throwable, types, 0, length) >= 0);
end;
function Method.getThrowablesLength(): int;
begin
result := fldThrowablesLength;
end;
function Method.getThrowablePositionAt(index: int): int;
begin
if (index < 0) or (index >= fldThrowablesLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldThrowablesPositions[index];
end;
function Method.getThrowableTypeAt(index: int): ClassType;
begin
if (index < 0) or (index >= fldThrowablesLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldThrowablesTypes[index];
end;
function Method.firstNonFreeThrowableType(): ClassType;
begin
result := fldFirstNonFreeThrowableType;
end;
{%endregion}
{%region SpecialMethod }
class function SpecialMethod.getVoidType(item: ProgrammeItem): &Type;
var
__programme: Programme;
begin
if item = nil then begin
result := nil;
exit;
end;
__programme := item.parentProgramme;
if __programme = nil then begin
result := nil;
exit;
end;
result := __programme.getPrimitiveType(TYP_VOID);
end;
constructor SpecialMethod.create(__parentType: ClassType; __attributes: int; const __specialSimpleName: AnsiString; const __arguments: Local_Array1d;
__declarationPosition, __documentationPosition: int);
begin
inherited create(__parentType, __attributes, getVoidType(__parentType), __specialSimpleName, __arguments, __declarationPosition, __documentationPosition);
end;
function SpecialMethod.isSpecial(): boolean;
begin
result := true;
end;
function SpecialMethod.isOverrides(anot: OverriddableMember): boolean;
begin
result := false;
end;
{%endregion}
{%region ClassInit }
function ClassInit.composeFasmSimpleName(): AnsiString;
begin
result := FASMNAME_CLASS_INIT;
end;
constructor ClassInit.create(__parentType: ClassType; __attributes, __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentType, __attributes or ATTR_STATIC, SPECNAME_CLASS_INIT, nil, __declarationPosition, __documentationPosition);
end;
procedure ClassInit.appendThrowable(throwable: ClassType; position: int);
begin
raise UnsupportedOperationException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'unsupported-throws.static'));
end;
function ClassInit.toString(): AnsiString;
var
enclosing: ClassType;
begin
enclosing := parentType;
if enclosing = nil then begin
result := VIEWNAME_CLASS_INIT;
exit;
end;
result := enclosing.specialCanonicalName + '.' + VIEWNAME_CLASS_INIT;
end;
{%endregion}
{%region InstInit }
function InstInit.composeFasmSimpleName(): AnsiString;
begin
result := FASMNAME_INST_INIT;
end;
constructor InstInit.create(__parentType: ClassType; __attributes: int; const __arguments: Local_Array1d; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentType, __attributes and not ATTR_STATIC, SPECNAME_INST_INIT, __arguments, __declarationPosition, __documentationPosition);
end;
function InstInit.toString(): AnsiString;
var
enclosing: ClassType;
begin
enclosing := parentType;
if enclosing = nil then begin
result := arguments.toString();
exit;
end;
result := enclosing.specialCanonicalName + arguments.toString();
end;
{%endregion}
{%region &Operator }
class function &Operator.kindToInternalName(kind: int): AnsiString;
begin
case kind of
WRITE_COMPONENT:
result := 'awr';
READ_COMPONENT:
result := 'ard';
INVOKE_VIRTUAL:
result := 'inv';
O_BIT_NOT:
result := 'not';
O_BIT_AND:
result := 'and';
O_BIT_OR:
result := 'or';
O_BIT_XOR:
result := 'xor';
O_SCAL_MUL:
result := 'mul';
O_SCAL_DIV:
result := 'div';
O_SCAL_DIVU:
result := 'divu';
O_SCAL_REM:
result := 'rem';
O_SCAL_REMU:
result := 'remu';
O_SCAL_POS:
result := 'pos';
O_SCAL_ADD:
result := 'add';
O_SCAL_NEG:
result := 'neg';
O_SCAL_SUB:
result := 'sub';
O_SCAL_SHR:
result := 'shr';
O_SCAL_SHRU:
result := 'shru';
O_SCAL_SHL:
result := 'shl';
O_SCAL_GT:
result := 'gt';
O_SCAL_GE:
result := 'ge';
O_SCAL_LT:
result := 'lt';
O_SCAL_LE:
result := 'le';
O_VECT_LUP:
result := 'vlup';
O_VECT_UUP:
result := 'vuup';
O_VECT_PCK:
result := 'vpck';
O_VECT_MUL:
result := 'vmul';
O_VECT_DIV:
result := 'vdiv';
O_VECT_POS:
result := 'vpos';
O_VECT_ADD:
result := 'vadd';
O_VECT_NEG:
result := 'vneg';
O_VECT_SUB:
result := 'vsub';
O_VECT_SHR:
result := 'vshr';
O_VECT_SHRU:
result := 'vshru';
O_VECT_SHL:
result := 'vshl';
O_VECT_GT:
result := 'vgt';
O_VECT_GE:
result := 'vge';
O_VECT_LT:
result := 'vlt';
O_VECT_LE:
result := 'vle';
O_VECT_EQ:
result := 'veq';
O_VECT_NE:
result := 'vne';
O_VECT_HMUL:
result := 'hmul';
O_VECT_SADD:
result := 'sadd';
O_VECT_SSUB:
result := 'ssub';
O_VECT_HMULU:
result := 'hmulu';
O_VECT_SADDU:
result := 'saddu';
O_VECT_SSUBU:
result := 'ssubu';
R_BIT_AND:
result := 'rand';
R_BIT_OR:
result := 'ror';
R_BIT_XOR:
result := 'rxor';
R_SCAL_MUL:
result := 'rmul';
R_SCAL_DIV:
result := 'rdiv';
R_SCAL_DIVU:
result := 'rdivu';
R_SCAL_REM:
result := 'rrem';
R_SCAL_REMU:
result := 'rremu';
R_SCAL_ADD:
result := 'radd';
R_SCAL_SUB:
result := 'rsub';
R_SCAL_SHR:
result := 'rshr';
R_SCAL_SHRU:
result := 'rshru';
R_SCAL_SHL:
result := 'rshl';
R_SCAL_GT:
result := 'rgt';
R_SCAL_GE:
result := 'rge';
R_SCAL_LT:
result := 'rlt';
R_SCAL_LE:
result := 'rle';
R_VECT_MUL:
result := 'rvmul';
R_VECT_DIV:
result := 'rvdiv';
R_VECT_ADD:
result := 'rvadd';
R_VECT_SUB:
result := 'rvsub';
R_VECT_SHR:
result := 'rvshr';
R_VECT_SHRU:
result := 'rvshru';
R_VECT_SHL:
result := 'rvshl';
R_VECT_GT:
result := 'rvgt';
R_VECT_GE:
result := 'rvge';
R_VECT_LT:
result := 'rvlt';
R_VECT_LE:
result := 'rvle';
R_VECT_EQ:
result := 'rveq';
R_VECT_NE:
result := 'rvne';
R_VECT_HMUL:
result := 'rhmul';
R_VECT_SADD:
result := 'rsadd';
R_VECT_SSUB:
result := 'rssub';
R_VECT_HMULU:
result := 'rhmulu';
R_VECT_SADDU:
result := 'rsaddu';
R_VECT_SSUBU:
result := 'rssubu';
else
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('kind') ]));
end;
end;
class function &Operator.symbolToKind(const __symbol: AnsiString): int;
begin
if __symbol = '[]=' then begin
result := WRITE_COMPONENT;
exit;
end;
if __symbol = '[]' then begin
result := READ_COMPONENT;
exit;
end;
if __symbol = '()' then begin
result := INVOKE_VIRTUAL;
exit;
end;
if __symbol = '~' then begin
result := O_BIT_NOT;
exit;
end;
if __symbol = '&' then begin
result := O_BIT_AND;
exit;
end;
if __symbol = '|' then begin
result := O_BIT_OR;
exit;
end;
if __symbol = '^' then begin
result := O_BIT_XOR;
exit;
end;
if __symbol = '*' then begin
result := O_SCAL_MUL;
exit;
end;
if __symbol = '/' then begin
result := O_SCAL_DIV;
exit;
end;
if __symbol = '//' then begin
result := O_SCAL_DIVU;
exit;
end;
if __symbol = '%' then begin
result := O_SCAL_REM;
exit;
end;
if __symbol = '%%' then begin
result := O_SCAL_REMU;
exit;
end;
if __symbol = '+' then begin
result := O_SCAL_ADD;
exit;
end;
if __symbol = '-' then begin
result := O_SCAL_SUB;
exit;
end;
if __symbol = '>>' then begin
result := O_SCAL_SHR;
exit;
end;
if __symbol = '>>>' then begin
result := O_SCAL_SHRU;
exit;
end;
if __symbol = '<<' then begin
result := O_SCAL_SHL;
exit;
end;
if __symbol = '>' then begin
result := O_SCAL_GT;
exit;
end;
if __symbol = '>=' then begin
result := O_SCAL_GE;
exit;
end;
if __symbol = '<' then begin
result := O_SCAL_LT;
exit;
end;
if __symbol = '<=' then begin
result := O_SCAL_LE;
exit;
end;
if __symbol = '####' then begin
result := O_VECT_LUP;
exit;
end;
if __symbol = '^^^^' then begin
result := O_VECT_UUP;
exit;
end;
if __symbol = '@@@@' then begin
result := O_VECT_PCK;
exit;
end;
if __symbol = '****' then begin
result := O_VECT_MUL;
exit;
end;
if __symbol = '////' then begin
result := O_VECT_DIV;
exit;
end;
if __symbol = '++++' then begin
result := O_VECT_ADD;
exit;
end;
if __symbol = '----' then begin
result := O_VECT_SUB;
exit;
end;
if __symbol = '>>>>' then begin
result := O_VECT_SHR;
exit;
end;
if __symbol = '>>>>>' then begin
result := O_VECT_SHRU;
exit;
end;
if __symbol = '<<<<' then begin
result := O_VECT_SHL;
exit;
end;
if __symbol = '|>>|' then begin
result := O_VECT_GT;
exit;
end;
if __symbol = '|>=|' then begin
result := O_VECT_GE;
exit;
end;
if __symbol = '|<<|' then begin
result := O_VECT_LT;
exit;
end;
if __symbol = '|<=|' then begin
result := O_VECT_LE;
exit;
end;
if __symbol = '|==|' then begin
result := O_VECT_EQ;
exit;
end;
if __symbol = '|!=|' then begin
result := O_VECT_NE;
exit;
end;
if __symbol = '|**|' then begin
result := O_VECT_HMUL;
exit;
end;
if __symbol = '|++|' then begin
result := O_VECT_SADD;
exit;
end;
if __symbol = '|--|' then begin
result := O_VECT_SSUB;
exit;
end;
if __symbol = '#**#' then begin
result := O_VECT_HMULU;
exit;
end;
if __symbol = '#++#' then begin
result := O_VECT_SADDU;
exit;
end;
if __symbol = '#--#' then begin
result := O_VECT_SSUBU;
exit;
end;
if __symbol = '&`' then begin
result := R_BIT_AND;
exit;
end;
if __symbol = '|`' then begin
result := R_BIT_OR;
exit;
end;
if __symbol = '^`' then begin
result := R_BIT_XOR;
exit;
end;
if __symbol = '*`' then begin
result := R_SCAL_MUL;
exit;
end;
if __symbol = '/`' then begin
result := R_SCAL_DIV;
exit;
end;
if __symbol = '//`' then begin
result := R_SCAL_DIVU;
exit;
end;
if __symbol = '%`' then begin
result := R_SCAL_REM;
exit;
end;
if __symbol = '%%`' then begin
result := R_SCAL_REMU;
exit;
end;
if __symbol = '+`' then begin
result := R_SCAL_ADD;
exit;
end;
if __symbol = '-`' then begin
result := R_SCAL_SUB;
exit;
end;
if __symbol = '>>`' then begin
result := R_SCAL_SHR;
exit;
end;
if __symbol = '>>>`' then begin
result := R_SCAL_SHRU;
exit;
end;
if __symbol = '<<`' then begin
result := R_SCAL_SHL;
exit;
end;
if __symbol = '>`' then begin
result := R_SCAL_GT;
exit;
end;
if __symbol = '>=`' then begin
result := R_SCAL_GE;
exit;
end;
if __symbol = '<`' then begin
result := R_SCAL_LT;
exit;
end;
if __symbol = '<=`' then begin
result := R_SCAL_LE;
exit;
end;
if __symbol = '****`' then begin
result := R_VECT_MUL;
exit;
end;
if __symbol = '////`' then begin
result := R_VECT_DIV;
exit;
end;
if __symbol = '++++`' then begin
result := R_VECT_ADD;
exit;
end;
if __symbol = '----`' then begin
result := R_VECT_SUB;
exit;
end;
if __symbol = '>>>>`' then begin
result := R_VECT_SHR;
exit;
end;
if __symbol = '>>>>>`' then begin
result := R_VECT_SHRU;
exit;
end;
if __symbol = '<<<<`' then begin
result := R_VECT_SHL;
exit;
end;
if __symbol = '|>>|`' then begin
result := R_VECT_GT;
exit;
end;
if __symbol = '|>=|`' then begin
result := R_VECT_GE;
exit;
end;
if __symbol = '|<<|`' then begin
result := R_VECT_LT;
exit;
end;
if __symbol = '|<=|`' then begin
result := R_VECT_LE;
exit;
end;
if __symbol = '|==|`' then begin
result := R_VECT_EQ;
exit;
end;
if __symbol = '|!=|`' then begin
result := R_VECT_NE;
exit;
end;
if __symbol = '|**|`' then begin
result := R_VECT_HMUL;
exit;
end;
if __symbol = '|++|`' then begin
result := R_VECT_SADD;
exit;
end;
if __symbol = '|--|`' then begin
result := R_VECT_SSUB;
exit;
end;
if __symbol = '#**#`' then begin
result := R_VECT_HMULU;
exit;
end;
if __symbol = '#++#`' then begin
result := R_VECT_SADDU;
exit;
end;
if __symbol = '#--#`' then begin
result := R_VECT_SSUBU;
exit;
end;
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('__symbol') ]));
end;
class function &Operator.specialSimpleNameToKind(const name: AnsiString): int;
var
length: int;
__symbol: AnsiString;
begin
__symbol := '';
length := name.length;
if (length > 0) and (name[1] = '<') or (name[length] = '>') then begin
__symbol := name.substring(2, length);
end;
if __symbol = 'awr' then begin
result := WRITE_COMPONENT;
exit;
end;
if __symbol = 'ard' then begin
result := READ_COMPONENT;
exit;
end;
if __symbol = 'inv' then begin
result := INVOKE_VIRTUAL;
exit;
end;
if __symbol = 'not' then begin
result := O_BIT_NOT;
exit;
end;
if __symbol = 'and' then begin
result := O_BIT_AND;
exit;
end;
if __symbol = 'or' then begin
result := O_BIT_OR;
exit;
end;
if __symbol = 'xor' then begin
result := O_BIT_XOR;
exit;
end;
if __symbol = 'mul' then begin
result := O_SCAL_MUL;
exit;
end;
if __symbol = 'div' then begin
result := O_SCAL_DIV;
exit;
end;
if __symbol = 'divu' then begin
result := O_SCAL_DIVU;
exit;
end;
if __symbol = 'rem' then begin
result := O_SCAL_REM;
exit;
end;
if __symbol = 'remu' then begin
result := O_SCAL_REMU;
exit;
end;
if __symbol = 'pos' then begin
result := O_SCAL_POS;
exit;
end;
if __symbol = 'add' then begin
result := O_SCAL_ADD;
exit;
end;
if __symbol = 'neg' then begin
result := O_SCAL_NEG;
exit;
end;
if __symbol = 'sub' then begin
result := O_SCAL_SUB;
exit;
end;
if __symbol = 'shr' then begin
result := O_SCAL_SHR;
exit;
end;
if __symbol = 'shru' then begin
result := O_SCAL_SHRU;
exit;
end;
if __symbol = 'shl' then begin
result := O_SCAL_SHL;
exit;
end;
if __symbol = 'gt' then begin
result := O_SCAL_GT;
exit;
end;
if __symbol = 'ge' then begin
result := O_SCAL_GE;
exit;
end;
if __symbol = 'lt' then begin
result := O_SCAL_LT;
exit;
end;
if __symbol = 'le' then begin
result := O_SCAL_LE;
exit;
end;
if __symbol = 'vlup' then begin
result := O_VECT_LUP;
exit;
end;
if __symbol = 'vuup' then begin
result := O_VECT_UUP;
exit;
end;
if __symbol = 'vpck' then begin
result := O_VECT_PCK;
exit;
end;
if __symbol = 'vmul' then begin
result := O_VECT_MUL;
exit;
end;
if __symbol = 'vdiv' then begin
result := O_VECT_DIV;
exit;
end;
if __symbol = 'vpos' then begin
result := O_VECT_POS;
exit;
end;
if __symbol = 'vadd' then begin
result := O_VECT_ADD;
exit;
end;
if __symbol = 'vneg' then begin
result := O_VECT_NEG;
exit;
end;
if __symbol = 'vsub' then begin
result := O_VECT_SUB;
exit;
end;
if __symbol = 'vshr' then begin
result := O_VECT_SHR;
exit;
end;
if __symbol = 'vshru' then begin
result := O_VECT_SHRU;
exit;
end;
if __symbol = 'vshl' then begin
result := O_VECT_SHL;
exit;
end;
if __symbol = 'vgt' then begin
result := O_VECT_GT;
exit;
end;
if __symbol = 'vge' then begin
result := O_VECT_GE;
exit;
end;
if __symbol = 'vlt' then begin
result := O_VECT_LT;
exit;
end;
if __symbol = 'vle' then begin
result := O_VECT_LE;
exit;
end;
if __symbol = 'veq' then begin
result := O_VECT_EQ;
exit;
end;
if __symbol = 'vne' then begin
result := O_VECT_NE;
exit;
end;
if __symbol = 'hmul' then begin
result := O_VECT_HMUL;
exit;
end;
if __symbol = 'sadd' then begin
result := O_VECT_SADD;
exit;
end;
if __symbol = 'ssub' then begin
result := O_VECT_SSUB;
exit;
end;
if __symbol = 'hmulu' then begin
result := O_VECT_HMULU;
exit;
end;
if __symbol = 'saddu' then begin
result := O_VECT_SADDU;
exit;
end;
if __symbol = 'ssubu' then begin
result := O_VECT_SSUBU;
exit;
end;
if __symbol = 'rand' then begin
result := R_BIT_AND;
exit;
end;
if __symbol = 'ror' then begin
result := R_BIT_OR;
exit;
end;
if __symbol = 'rxor' then begin
result := R_BIT_XOR;
exit;
end;
if __symbol = 'rmul' then begin
result := R_SCAL_MUL;
exit;
end;
if __symbol = 'rdiv' then begin
result := R_SCAL_DIV;
exit;
end;
if __symbol = 'rdivu' then begin
result := R_SCAL_DIVU;
exit;
end;
if __symbol = 'rrem' then begin
result := R_SCAL_REM;
exit;
end;
if __symbol = 'rremu' then begin
result := R_SCAL_REMU;
exit;
end;
if __symbol = 'radd' then begin
result := R_SCAL_ADD;
exit;
end;
if __symbol = 'rsub' then begin
result := R_SCAL_SUB;
exit;
end;
if __symbol = 'rshr' then begin
result := R_SCAL_SHR;
exit;
end;
if __symbol = 'rshru' then begin
result := R_SCAL_SHRU;
exit;
end;
if __symbol = 'rshl' then begin
result := R_SCAL_SHL;
exit;
end;
if __symbol = 'rgt' then begin
result := R_SCAL_GT;
exit;
end;
if __symbol = 'rge' then begin
result := R_SCAL_GE;
exit;
end;
if __symbol = 'rlt' then begin
result := R_SCAL_LT;
exit;
end;
if __symbol = 'rle' then begin
result := R_SCAL_LE;
exit;
end;
if __symbol = 'rvmul' then begin
result := R_VECT_MUL;
exit;
end;
if __symbol = 'rvdiv' then begin
result := R_VECT_DIV;
exit;
end;
if __symbol = 'rvadd' then begin
result := R_VECT_ADD;
exit;
end;
if __symbol = 'rvsub' then begin
result := R_VECT_SUB;
exit;
end;
if __symbol = 'rvshr' then begin
result := R_VECT_SHR;
exit;
end;
if __symbol = 'rvshru' then begin
result := R_VECT_SHRU;
exit;
end;
if __symbol = 'rvshl' then begin
result := R_VECT_SHL;
exit;
end;
if __symbol = 'rvgt' then begin
result := R_VECT_GT;
exit;
end;
if __symbol = 'rvge' then begin
result := R_VECT_GE;
exit;
end;
if __symbol = 'rvlt' then begin
result := R_VECT_LT;
exit;
end;
if __symbol = 'rvle' then begin
result := R_VECT_LE;
exit;
end;
if __symbol = 'rveq' then begin
result := R_VECT_EQ;
exit;
end;
if __symbol = 'rvne' then begin
result := R_VECT_NE;
exit;
end;
if __symbol = 'rhmul' then begin
result := R_VECT_HMUL;
exit;
end;
if __symbol = 'rsadd' then begin
result := R_VECT_SADD;
exit;
end;
if __symbol = 'rssub' then begin
result := R_VECT_SSUB;
exit;
end;
if __symbol = 'rhmulu' then begin
result := R_VECT_HMULU;
exit;
end;
if __symbol = 'rsaddu' then begin
result := R_VECT_SADDU;
exit;
end;
if __symbol = 'rssubu' then begin
result := R_VECT_SSUBU;
exit;
end;
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('symbol') ]));
end;
class function &Operator.kindToSymbol(kind: int): AnsiString;
begin
case kind of
WRITE_COMPONENT:
result := '[]=';
READ_COMPONENT:
result := '[]';
INVOKE_VIRTUAL:
result := '()';
O_BIT_NOT:
result := '~';
O_BIT_AND:
result := '&';
O_BIT_OR:
result := '|';
O_BIT_XOR:
result := '^';
O_SCAL_MUL:
result := '*';
O_SCAL_DIV:
result := '/';
O_SCAL_DIVU:
result := '//';
O_SCAL_REM:
result := '%';
O_SCAL_REMU:
result := '%%';
O_SCAL_POS,
O_SCAL_ADD:
result := '+';
O_SCAL_NEG,
O_SCAL_SUB:
result := '-';
O_SCAL_SHR:
result := '>>';
O_SCAL_SHRU:
result := '>>>';
O_SCAL_SHL:
result := '<<';
O_SCAL_GT:
result := '>';
O_SCAL_GE:
result := '>=';
O_SCAL_LT:
result := '<';
O_SCAL_LE:
result := '<=';
O_VECT_LUP:
result := '####';
O_VECT_UUP:
result := '^^^^';
O_VECT_PCK:
result := '@@@@';
O_VECT_MUL:
result := '****';
O_VECT_DIV:
result := '////';
O_VECT_POS,
O_VECT_ADD:
result := '++++';
O_VECT_NEG,
O_VECT_SUB:
result := '----';
O_VECT_SHR:
result := '>>>>';
O_VECT_SHRU:
result := '>>>>>';
O_VECT_SHL:
result := '<<<<';
O_VECT_GT:
result := '|>>|';
O_VECT_GE:
result := '|>=|';
O_VECT_LT:
result := '|<<|';
O_VECT_LE:
result := '|<=|';
O_VECT_EQ:
result := '|==|';
O_VECT_NE:
result := '|!=|';
O_VECT_HMUL:
result := '|**|';
O_VECT_SADD:
result := '|++|';
O_VECT_SSUB:
result := '|--|';
O_VECT_HMULU:
result := '#**#';
O_VECT_SADDU:
result := '#++#';
O_VECT_SSUBU:
result := '#--#';
R_BIT_AND:
result := '&`';
R_BIT_OR:
result := '|`';
R_BIT_XOR:
result := '^`';
R_SCAL_MUL:
result := '*`';
R_SCAL_DIV:
result := '/`';
R_SCAL_DIVU:
result := '//`';
R_SCAL_REM:
result := '%`';
R_SCAL_REMU:
result := '%%`';
R_SCAL_ADD:
result := '+`';
R_SCAL_SUB:
result := '-`';
R_SCAL_SHR:
result := '>>`';
R_SCAL_SHRU:
result := '>>>`';
R_SCAL_SHL:
result := '<<`';
R_SCAL_GT:
result := '>`';
R_SCAL_GE:
result := '>=`';
R_SCAL_LT:
result := '<`';
R_SCAL_LE:
result := '<=`';
R_VECT_MUL:
result := '****`';
R_VECT_DIV:
result := '////`';
R_VECT_ADD:
result := '++++`';
R_VECT_SUB:
result := '----`';
R_VECT_SHR:
result := '>>>>`';
R_VECT_SHRU:
result := '>>>>>`';
R_VECT_SHL:
result := '<<<<`';
R_VECT_GT:
result := '|>>|`';
R_VECT_GE:
result := '|>=|`';
R_VECT_LT:
result := '|<<|`';
R_VECT_LE:
result := '|<=|`';
R_VECT_EQ:
result := '|==|`';
R_VECT_NE:
result := '|!=|`';
R_VECT_HMUL:
result := '|**|`';
R_VECT_SADD:
result := '|++|`';
R_VECT_SSUB:
result := '|--|`';
R_VECT_HMULU:
result := '#**#`';
R_VECT_SADDU:
result := '#++#`';
R_VECT_SSUBU:
result := '#--#`';
else
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('kind') ]));
end;
end;
class function &Operator.kindToSpecialSimpleName(kind: int): AnsiString;
var
name: AnsiString;
begin
name := kindToInternalName(kind);
result := '<' + name + '>';
end;
function &Operator.composeFasmSimpleName(): AnsiString;
begin
result := '$' + kindToInternalName(fldKind) + '$';
end;
constructor &Operator.create(__parentType: ClassType; __attributes: int; __type: &Type; __kind: int; const __arguments: Local_Array1d; __declarationPosition, __documentationPosition: int);
begin
inherited create(__parentType, __attributes, __type, kindToSpecialSimpleName(__kind), __arguments, __declarationPosition, __documentationPosition);
fldKind := __kind;
fldSymbol := kindToSymbol(__kind);
end;
function &Operator.toString(): AnsiString;
var
name: AnsiString;
enclosing: ClassType;
begin
enclosing := parentType;
if enclosing <> nil then begin
name := enclosing.specialCanonicalName + '.';
end else begin
name := '';
end;
result := name + VIEWNAME_OPERATOR + fldSymbol + arguments.toString();
end;
{%endregion}
{%region &Property }
procedure &Property.setReadSynthetic(newReadSynthetic: Method);
begin
fldReadSynthetic := newReadSynthetic;
end;
procedure &Property.setWriteSynthetic(newWriteSynthetic: Method);
begin
fldWriteSynthetic := newWriteSynthetic;
end;
procedure &Property.setIndexSynthetic(newIndexSynthetic: Method);
begin
fldIndexSynthetic := newIndexSynthetic;
end;
procedure &Property.setStoredSynthetic(newStoredSynthetic: Method);
begin
fldStoredSynthetic := newStoredSynthetic;
end;
function &Property.composeFasmSimpleName(): AnsiString;
begin
result := specialSimpleName;
end;
function &Property.composeFasmFullName(): AnsiString;
begin
result := Fieldoid_inherited_composeFasmFullName();
end;
function &Property.toString(): AnsiString;
begin
result := Fieldoid_inherited_toString();
end;
function &Property.hasRead(): boolean;
begin
result := fldReadSynthetic <> nil;
end;
function &Property.hasWrite(): boolean;
begin
result := fldWriteSynthetic <> nil;
end;
function &Property.hasIndex(): boolean;
begin
result := fldIndexSynthetic <> nil;
end;
function &Property.hasStored(): boolean;
begin
result := fldStoredSynthetic <> nil;
end;
{%endregion}
{%region Local }
function Local.composeRecompilableName(): AnsiString;
begin
result := specialSimpleName;
end;
function Local.composeFasmSimpleName(): AnsiString;
begin
result := specialSimpleName;
end;
constructor Local.create(__isFinal: boolean; __type: &Type; const __specialSimpleName: AnsiString; __value: Constant; __source: Source; __declarationPosition: int);
begin
inherited create(nil, __specialSimpleName, __source, __declarationPosition, -1);
fldFinal := __isFinal;
fldType := __type;
fldValue := __value;
end;
function Local.toString(): AnsiString;
var
__value: Constant;
begin
__value := fldValue;
if not fldFinal or (__value = nil) then begin
result := inherited toString();
exit;
end;
result := inherited toString() + ' = ' + __value.toString();
end;
function Local.isConstant(): boolean;
begin
result := fldFinal and (fldValue <> nil);
end;
function Local.getValue(): Constant;
begin
result := fldValue;
end;
function Local.getType(): &Type;
begin
result := fldType;
end;
function Local.isFinal(): boolean;
begin
result := fldFinal;
end;
{%endregion}
{%region CallableItem }
procedure CallableItem.setPosition(newPosition: int);
var
__sequence: LexemeSequence;
begin
fldPosition := newPosition;
__sequence := fldSequence;
if (__sequence = nil) or (newPosition < 0) or (newPosition >= __sequence.getLength()) then begin
fldLocation := Vector.newInt2(-1, -1);
exit;
end;
fldLocation := __sequence.getLexemeLocation(newPosition);
end;
constructor CallableItem.create(__sequence: LexemeSequence);
begin
inherited create();
fldPosition := -1;
fldLocation := Vector.newInt2(-1, -1);
fldSequence := __sequence;
end;
function CallableItem.readComponent(index: int): Node;
begin
result := getNodeAt(index);
end;
function CallableItem.readComponent(index: int): TObject;
begin
result := getNodeAt(index);
end;
{%endregion}
{%region Code }
class function Code.getLexemeSequence(item: TableItem): LexemeSequence;
var
src: TObject;
begin
if item = nil then begin
result := nil;
exit;
end;
src := Lang.cast(item.source, TObject);
if not(src is LexemeSequence) then begin
result := nil;
exit;
end;
result := LexemeSequence(src);
end;
function Code.createNode(): Node;
var
__node: Node;
__programme: Programme;
begin
__node := nil;
__programme := fldParentProgramme;
if __programme <> nil then begin
__node := __programme.newNode(self);
end;
if __node = nil then begin
__node := Node.create(self);
end;
result := __node;
end;
function Code.getDebugLineIndices(): IntArray;
begin
result := fldDebugLineIndicesArray as IntArray;
end;
function Code.orderOf(node: Node): int;
var
length: int;
begin
length := fldInstructionsLength;
if (length <= 0) or (node = nil) then begin
result := -1;
exit;
end;
result := &Array.indexOf(node, fldInstructionsNodes, 0, length);
end;
function Code.getNodeAt(index: int): Node;
var
length: int;
begin
length := fldInstructionsLength;
if (index < -length) or (index >= length) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
if index < 0 then begin
result := fldInstructionsNodes[index + length];
exit;
end;
result := fldInstructionsNodes[index];
end;
constructor Code.create(__parentCallable: Callable);
begin
inherited create(getLexemeSequence(__parentCallable));
fldInstructionsNodes := Node_Array1d(&Array.newTObject1d($0f));
fldNodesArray := NodeArray.create();
fldLocalsArray := LocalArray.create(nil);
fldDebugLineIndicesArray := CodeLineIndexArray.create();
fldParentCallable := __parentCallable;
if __parentCallable <> nil then begin
fldParentProgramme := __parentCallable.parentProgramme;
end;
end;
destructor Code.destroy;
begin
fldNodesArray.free();
fldLocalsArray.free();
fldDebugLineIndicesArray.free();
inherited destroy;
end;
procedure Code.afterConstruction();
var
__root: Node;
begin
__root := createNode();
fldRoot := __root;
fldNodesArray.append(__root);
end;
procedure Code.replaceJumpNode(oldJumpNode, newJumpNode: Node);
var
index: int;
__length: int;
__array: Node_Array1d;
begin
if oldJumpNode = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('oldJumpNode') ]));
end;
if newJumpNode = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('newJumpNode') ]));
end;
with fldNodesArray do begin
__length := length;
__array := &array;
end;
for index := __length - 1 downto 0 do begin
__array[index].replaceJumpNode(oldJumpNode, newJumpNode);
end;
end;
procedure Code.assignOrder(node: Node; order: int);
var
index: int;
length: int;
__nodes: Node_Array1d;
buffer: Node_Array1d;
begin
if node = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('node') ]));
end;
if fldNodesArray.indexOf(node) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'specified-node.not-owned-by-code'));
end;
__nodes := fldInstructionsNodes;
length := fldInstructionsLength;
if length <= 0 then begin
index := -1;
end else begin
index := &Array.indexOf(node, __nodes, 0, length);
end;
if order < 0 then order := 0;
if order > length then order := length;
if index < 0 then begin
if length = system.length(__nodes) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := Node_Array1d(&Array.newTObject1d((length shl 1) or 1));
&Array.copyObjects(__nodes, 0, buffer, 0, length);
fldInstructionsNodes := buffer;
__nodes := buffer;
end;
fldInstructionsLength := length + 1;
&Array.copyObjects(__nodes, order, __nodes, order + 1, length - order);
end else
if order <= index then begin
&Array.copyObjects(__nodes, order, __nodes, order + 1, index - order);
end else begin
dec(order);
&Array.copyObjects(__nodes, index + 1, __nodes, index, order - index);
end;
__nodes[order] := node;
end;
procedure Code.clearOrder(node: Node);
var
index: int;
length: int;
__nodes: Node_Array1d;
begin
if node = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('node') ]));
end;
if fldNodesArray.indexOf(node) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'specified-node.not-owned-by-code'));
end;
__nodes := fldInstructionsNodes;
length := fldInstructionsLength;
if length <= 0 then begin
index := -1;
end else begin
index := &Array.indexOf(node, __nodes, 0, length);
end;
if index >= 0 then begin
dec(length);
&Array.copyObjects(__nodes, index + 1, __nodes, index, length - index);
__nodes[length] := nil;
fldInstructionsLength := length;
end;
end;
procedure Code.removeChilds(node: Node);
var
__nodes: NodeArray;
begin
if node = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('node') ]));
end;
__nodes := fldNodesArray;
if __nodes.indexOf(node) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'specified-node.not-owned-by-code'));
end;
fldInstructionsLength := NodeArray.removeChildsFrom(fldInstructionsNodes, fldInstructionsLength, node);
__nodes.removeChilds(node);
node.deleteChilds();
end;
procedure Code.removeNode(node: Node);
var
index: int;
owning: Node;
__nodes: NodeArray;
begin
if node = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('node') ]));
end;
__nodes := fldNodesArray;
if __nodes.indexOf(node) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'specified-node.not-owned-by-code'));
end;
owning := node.parentNode;
if owning = nil then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'specified-node.is-root-node'));
end;
index := node.index;
if node.isEmpty() then begin
fldInstructionsLength := NodeArray.removeItemFrom(fldInstructionsNodes, fldInstructionsLength, node);
__nodes.remove(node);
end else begin
fldInstructionsLength := NodeArray.removeNodeFrom(fldInstructionsNodes, fldInstructionsLength, node);
__nodes.removeNode(node);
end;
owning.deleteChild(index);
end;
procedure Code.moveNode(node: Node; index: int);
var
owning: Node;
begin
if node = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('node') ]));
end;
if fldNodesArray.indexOf(node) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'specified-node.not-owned-by-code'));
end;
owning := node.parentNode;
if owning = nil then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'specified-node.is-root-node'));
end;
owning.moveChild(node.index, index);
end;
procedure Code.moveNode(node, parent: Node; index: int);
var
owning: Node;
__nodes: NodeArray;
begin
if node = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('node') ]));
end;
__nodes := fldNodesArray;
if __nodes.indexOf(node) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'specified-node.not-owned-by-code'));
end;
owning := node.parentNode;
if owning = nil then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'specified-node.is-root-node'));
end;
if parent = nil then begin
parent := owning;
end;
if __nodes.indexOf(parent) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'parent-node.not-owned-by-code'));
end;
if (parent = node) or parent.isParent(node) then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'parent-node.illegal'));
end;
if owning = parent then begin
owning.moveChild(node.index, index);
exit;
end;
owning.deleteChild(node.index);
parent.insertChild(index, node);
end;
function Code.createDebugIndex(lineIndex: int): int;
begin
result := CodeLineIndexArray(fldDebugLineIndicesArray).append(lineIndex);
end;
function Code.createWithLocal(&type: ClassType; value: Constant): Local;
var
index: int;
begin
index := fldWithLocalIndex;
fldWithLocalIndex := index + 1;
result := createLocal(true, &type, 'with.' + CoInt.toString(index), value, -1);
end;
function Code.createMonitorLocal(&type: ClassType; value: Constant): Local;
var
index: int;
begin
index := fldMonitorLocalIndex;
fldMonitorLocalIndex := index + 1;
result := createLocal(true, &type, 'monitor.' + CoInt.toString(index), value, -1);
end;
function Code.createLocal(isFinal: boolean; &type: &Type; const specialSimpleName: AnsiString; value: Constant; declarationPosition: int): Local;
var
__local: Local;
__source: Source;
__programme: Programme;
__sequence: LexemeSequence;
begin
if &type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('type') ]));
end;
if &type.isVoid() or &type.isNull() then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'type.not-suitable.variable'));
end;
if specialSimpleName.length <= 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-argument.empty.item-name'));
end;
__sequence := sequence;
if __sequence is Source then begin
__source := __sequence as Source;
end else begin
__source := nil;
end;
__local := nil;
__programme := fldParentProgramme;
if __programme <> nil then begin
__local := __programme.newLocal(isFinal, &type, specialSimpleName, value, __source, declarationPosition);
end;
if __local = nil then begin
__local := Local.create(isFinal, &type, specialSimpleName, value, __source, declarationPosition);
end;
fldLocalsArray.append(__local);
result := __local;
end;
function Code.createAndInsertNode(parent: Node; index: int): Node;
var
__node: Node;
__nodes: NodeArray;
begin
__nodes := fldNodesArray;
if parent = nil then begin
parent := fldRoot;
end else
if __nodes.indexOf(parent) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'parent-node.not-owned-by-code'));
end;
__node := createNode();
parent.insertChild(index, __node);
__nodes.append(__node);
result := __node;
end;
function Code.createAndPrependNode(parent: Node): Node;
var
__node: Node;
__nodes: NodeArray;
begin
__nodes := fldNodesArray;
if parent = nil then begin
parent := fldRoot;
end else
if __nodes.indexOf(parent) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'parent-node.not-owned-by-code'));
end;
__node := createNode();
parent.insertChild(0, __node);
__nodes.append(__node);
result := __node;
end;
function Code.createAndAppendNode(parent: Node): Node;
var
__node: Node;
__nodes: NodeArray;
begin
__nodes := fldNodesArray;
if parent = nil then begin
parent := fldRoot;
end else
if __nodes.indexOf(parent) < 0 then begin
raise IllegalArgumentException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'parent-node.not-owned-by-code'));
end;
__node := createNode();
parent.insertChild(CoInt.MAX_VALUE, __node);
__nodes.append(__node);
result := __node;
end;
function Code.hasJumpsTo(node: Node): boolean;
var
index: int;
current: Node;
__nodes: Node_Array1d;
begin
if node <> nil then begin
__nodes := fldInstructionsNodes;
for index := fldInstructionsLength - 1 downto 0 do begin
current := __nodes[index];
if (current <> node) and current.hasJumpsTo(node) then begin
result := true;
exit;
end;
end;
end;
result := false;
end;
function Code.isEmpty(): boolean;
begin
result := fldInstructionsLength <= 0;
end;
function Code.getLength(): int;
begin
result := fldInstructionsLength;
end;
function Code.clone(): Node_Array1d;
var
length: int;
begin
length := fldInstructionsLength;
result := Node_Array1d(&Array.newTObject1d(length));
&Array.copyObjects(fldInstructionsNodes, 0, result, 0, length);
end;
{%endregion}
{%region Node }
class function Node.getLexemeSequence(code: Code): LexemeSequence;
begin
if code <> nil then begin
result := code.sequence;
exit;
end;
result := nil;
end;
procedure Node.setEndPoint(newEndPoint: boolean);
begin
if not newEndPoint or (fldJumpCasesLength <= 0) and (fldJumpDefault = nil) then begin
fldEndPoint := newEndPoint;
end;
end;
procedure Node.setSpecialState(index: int; newSpecialState: boolean);
var
state: int;
begin
state := fldSpecialState and not(1 shl index);
if newSpecialState then state := state or (1 shl index);
if state <> %10 then begin
fldSpecialState := state;
exit;
end;
fldSpecialState := %11 * index;
end;
function Node.getSpecialState(index: int): boolean;
begin
result := (fldSpecialState and (1 shl index)) <> 0;
end;
function Node.getIndex(): int;
var
length: int;
parent: Node;
begin
parent := fldParentNode;
if parent = nil then begin
result := -1;
exit;
end;
length := parent.fldChildsLength;
if length <= 0 then begin
result := -1;
exit;
end;
result := &Array.indexOf(self, parent.fldChildsNodes, 0, length);
end;
function Node.getOrder(): int;
var
parent: Code;
begin
parent := fldParentCode;
if parent = nil then begin
result := -1;
exit;
end;
result := parent.orderOf(self);
end;
function Node.getJumpDefault(): Node;
var
__order: int;
__node: Node;
__code: Code;
begin
__node := fldJumpDefault;
if __node <> nil then begin
result := __node;
exit;
end;
if fldEndPoint then begin
result := nil;
exit;
end;
__code := fldParentCode;
if __code <> nil then begin
__order := __code.orderOf(self) + 1;
if (__order > 0) and (__order < __code.getLength()) then begin
result := __code.readComponent(__order);
exit;
end;
end;
result := nil;
end;
procedure Node.moveChild(oldIndex, newIndex: int);
var
length: int;
nodes: Node_Array1d;
__node: Node;
begin
length := fldChildsLength;
if (oldIndex < 0) or (oldIndex >= length) or (newIndex < 0) or (newIndex > length) then begin
raise IndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'out-of-bounds.child-node-index'));
end;
if newIndex > oldIndex then begin
dec(newIndex);
end;
if newIndex <> oldIndex then begin
nodes := fldChildsNodes;
__node := nodes[oldIndex];
if oldIndex > newIndex then begin
&Array.copyObjects(nodes, newIndex, nodes, newIndex + 1, oldIndex - newIndex);
end else begin
&Array.copyObjects(nodes, oldIndex + 1, nodes, oldIndex, newIndex - oldIndex);
end;
nodes[newIndex] := __node;
end;
end;
procedure Node.insertChild(index: int; child: Node);
var
length: int;
nodes: Node_Array1d;
buffer: Node_Array1d;
begin
if child = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('child') ]));
end;
nodes := fldChildsNodes;
if nodes = nil then begin
nodes := Node_Array1d(&Array.newTObject1d($0f));
fldChildsNodes := nodes;
fldChildsLength := 1;
nodes[0] := child;
end else begin
length := fldChildsLength;
if index < 0 then index := 0;
if index > length then index := length;
if length = system.length(nodes) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := Node_Array1d(&Array.newTObject1d((length shl 1) or 1));
&Array.copyObjects(nodes, 0, buffer, 0, length);
fldChildsNodes := buffer;
nodes := buffer;
end;
&Array.copyObjects(nodes, index, nodes, index + 1, length - index);
fldChildsLength := length + 1;
nodes[index] := child;
end;
child.fldParentNode := self;
end;
procedure Node.deleteChild(index: int);
var
length: int;
nodes: Node_Array1d;
begin
length := fldChildsLength;
if (index < 0) or (index >= length) then begin
raise IndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'out-of-bounds.child-node-index'));
end;
dec(length);
nodes := fldChildsNodes;
&Array.copyObjects(nodes, index + 1, nodes, index, length - index);
nodes[length] := nil;
fldChildsLength := length;
end;
procedure Node.deleteChilds();
begin
fldChildsNodes := nil;
fldChildsLength := 0;
end;
procedure Node.setType(newType: &Type);
begin
fldType := newType;
end;
procedure Node.setWeak(newWeak: boolean);
begin
fldWeak := newWeak;
end;
procedure Node.setInstruction(newInstruction: int);
begin
fldInstruction := newInstruction;
end;
procedure Node.setReference1(newReference1: TObject);
var
isRefCount: boolean;
begin
if fldIsRefCount1 then RefCountObject(fldReference1)._release();
isRefCount := newReference1 is RefCountObject;
fldReference1 := newReference1;
fldIsRefCount1 := isRefCount;
if isRefCount then RefCountObject(newReference1)._addref();
end;
procedure Node.setReference2(newReference2: TObject);
var
isRefCount: boolean;
begin
if fldIsRefCount2 then RefCountObject(fldReference2)._release();
isRefCount := newReference2 is RefCountObject;
fldReference2 := newReference2;
fldIsRefCount2 := isRefCount;
if isRefCount then RefCountObject(newReference2)._addref();
end;
procedure Node.setOperand1(newOperand1: TableItem);
begin
fldOperand1 := newOperand1;
end;
procedure Node.setOperand2(newOperand2: TableItem);
begin
fldOperand2 := newOperand2;
end;
procedure Node.setOperandC(newOperandC: Constant);
begin
fldOperandC := newOperandC;
end;
procedure Node.setJumpDefault(newJumpDefault: Node);
begin
if newJumpDefault <> nil then begin
fldEndPoint := false;
end;
fldJumpDefault := newJumpDefault;
end;
procedure Node.setJumpIsFalse(newJumpIsFalse: Node);
begin
setJumpCase(0, newJumpIsFalse);
end;
procedure Node.setJumpIsTrue(newJumpIsTrue: Node);
begin
setJumpDefault(newJumpIsTrue);
end;
function Node.getJumpIsFalse(): Node;
begin
result := getJumpCase(0);
end;
function Node.getJumpIsTrue(): Node;
begin
result := fldJumpDefault;
end;
function Node.getNodeAt(index: int): Node;
var
length: int;
begin
length := fldChildsLength;
if (index < -length) or (index >= length) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
if index < 0 then begin
result := fldChildsNodes[index + length];
exit;
end;
result := fldChildsNodes[index];
end;
constructor Node.create(__parentCode: Code);
begin
inherited create(getLexemeSequence(__parentCode));
fldDebugIndex := -1;
fldLabelIndex := -1;
fldInstruction := -1;
fldStackElements := -1;
fldParentCode := __parentCode;
end;
destructor Node.destroy;
begin
if fldIsRefCount1 then RefCountObject(fldReference1)._release();
if fldIsRefCount2 then RefCountObject(fldReference2)._release();
inherited destroy;
end;
procedure Node.replaceJumpNode(oldJumpNode, newJumpNode: Node);
var
__index: int;
length: int;
nodes: Node_Array1d;
begin
if oldJumpNode = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('oldJumpNode') ]));
end;
if newJumpNode = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('newJumpNode') ]));
end;
if fldJumpDefault = oldJumpNode then begin
fldJumpDefault := newJumpNode;
end;
nodes := fldJumpCasesNodes;
length := fldJumpCasesLength;
__index := 0;
while __index < length do begin
__index := &Array.indexOf(oldJumpNode, nodes, __index, length - __index);
if __index < 0 then break;
nodes[__index] := newJumpNode;
inc(__index);
end;
end;
procedure Node.setJumpCase(valueOfCase: int; jumpIsCase: Node);
var
next: int;
count: int;
__index: int;
length: int;
capacity: int;
svalues: int_Array1d;
bvalues: int_Array1d;
snodes: Node_Array1d;
bnodes: Node_Array1d;
begin
length := fldJumpCasesLength;
svalues := fldJumpCasesValues;
snodes := fldJumpCasesNodes;
if jumpIsCase = nil then begin
if length > 0 then begin
__index := &Array.indexOf(valueOfCase, svalues, 0, length);
if __index >= 0 then begin
next := __index + 1;
dec(length);
count := length - __index;
&Array.copyPrimitives(svalues, next, svalues, __index, count);
&Array.copyObjects(snodes, next, snodes, __index, count);
svalues[length] := 0;
snodes[length] := nil;
fldJumpCasesLength := length;
end;
end;
exit;
end;
if length <= 0 then begin
if svalues = nil then begin
svalues := &Array.newInt1d($0f);
fldJumpCasesValues := svalues;
end;
if snodes = nil then begin
snodes := Node_Array1d(&Array.newTObject1d($0f));
fldJumpCasesNodes := snodes;
end;
svalues[0] := valueOfCase;
snodes[0] := jumpIsCase;
fldEndPoint := false;
fldJumpCasesLength := 1;
exit;
end;
__index := &Array.indexOf(valueOfCase, svalues, 0, length);
if __index >= 0 then begin
snodes[__index] := jumpIsCase;
exit;
end;
if length = system.length(snodes) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
capacity := (length shl 1) or 1;
bvalues := &Array.newInt1d(capacity);
bnodes := Node_Array1d(&Array.newTObject1d(capacity));
&Array.copyPrimitives(svalues, 0, bvalues, 0, length);
&Array.copyObjects(snodes, 0, bnodes, 0, length);
fldJumpCasesValues := bvalues;
fldJumpCasesNodes := bnodes;
svalues := bvalues;
snodes := bnodes;
end;
snodes[length] := jumpIsCase;
svalues[length] := valueOfCase;
fldJumpCasesLength := length + 1;
end;
procedure Node.clearJumpCases();
var
length: int;
begin
length := fldJumpCasesLength;
if length > 0 then begin
&Array.fillPrimitives(fldJumpCasesValues, 0, length, 0);
&Array.fillObjects(fldJumpCasesNodes, 0, length, nil);
fldJumpCasesLength := 0;
end;
end;
function Node.setData(__position, __instruction: int): Node;
begin
setPosition(__position);
setType(nil);
setInstruction(__instruction);
setReference1(nil);
setReference2(nil);
setOperand1(nil);
setOperand2(nil);
setOperandC(nil);
result := self;
end;
function Node.setData(__position, __instruction: int; __reference1: TObject): Node;
begin
setPosition(__position);
setType(nil);
setInstruction(__instruction);
setReference1(__reference1);
setReference2(nil);
setOperand1(nil);
setOperand2(nil);
setOperandC(nil);
result := self;
end;
function Node.setData(__position, __instruction: int; __reference1, __reference2: TObject): Node;
begin
setPosition(__position);
setType(nil);
setInstruction(__instruction);
setReference1(__reference1);
setReference2(__reference2);
setOperand1(nil);
setOperand2(nil);
setOperandC(nil);
result := self;
end;
function Node.setData(__position: int; __type: &Type; __instruction: int): Node;
begin
setPosition(__position);
setType(__type);
setInstruction(__instruction);
setReference1(nil);
setReference2(nil);
setOperand1(nil);
setOperand2(nil);
setOperandC(nil);
result := self;
end;
function Node.setData(__position: int; __type: &Type; __instruction: int; __operandC: Constant): Node;
begin
setPosition(__position);
setType(__type);
setInstruction(__instruction);
setReference1(nil);
setReference2(nil);
setOperand1(nil);
setOperand2(nil);
setOperandC(__operandC);
result := self;
end;
function Node.setData(__position: int; __type: &Type; __instruction: int; __operand1: TableItem): Node;
begin
setPosition(__position);
setType(__type);
setInstruction(__instruction);
setReference1(nil);
setReference2(nil);
setOperand1(__operand1);
setOperand2(nil);
setOperandC(nil);
result := self;
end;
function Node.setData(__position: int; __type: &Type; __instruction: int; __operand1, __operand2: TableItem): Node;
begin
setPosition(__position);
setType(__type);
setInstruction(__instruction);
setReference1(nil);
setReference2(nil);
setOperand1(__operand1);
setOperand2(__operand2);
setOperandC(nil);
result := self;
end;
function Node.setData(__position: int; __type: &Type; __instruction: int; __operand1: TableItem; __operandC: Constant): Node;
begin
setPosition(__position);
setType(__type);
setInstruction(__instruction);
setReference1(nil);
setReference2(nil);
setOperand1(__operand1);
setOperand2(nil);
setOperandC(__operandC);
result := self;
end;
function Node.hasJumpsTo(node: Node): boolean;
var
length: int;
begin
if node <> nil then begin
if getJumpDefault() = node then begin
result := true;
exit;
end;
length := fldJumpCasesLength;
if (length > 0) and (&Array.indexOf(node, fldJumpCasesNodes, 0, length) >= 0) then begin
result := true;
exit;
end;
end;
result := false;
end;
function Node.isEmpty(): boolean;
begin
result := fldChildsLength <= 0;
end;
function Node.getLength(): int;
begin
result := fldChildsLength;
end;
function Node.isParent(node: Node): boolean;
var
current: Node;
begin
if (node <> nil) and (node <> self) then begin
current := fldParentNode;
while current <> nil do begin
if current = node then begin
result := true;
exit;
end;
current := current.fldParentNode;
end;
end;
result := false;
end;
function Node.minOrder(): int;
label
break_label0;
var
morder: int;
__index: int;
__order: int;
__code: Code;
__node: Node;
parent: Node;
target: Node;
begin
__code := fldParentCode;
if __code = nil then begin
result := -1;
exit;
end;
morder := -1;
__node := self;
parent := nil;
__index := -1;
target := fldParentNode;
repeat
__order := __code.orderOf(__node);
if (__order >= 0) and ((morder < 0) or (__order < morder)) then begin
morder := __order;
end;
if __node.fldChildsLength > 0 then begin
parent := __node;
__index := 0;
__node := parent.fldChildsNodes[0];
continue;
end;
if parent = nil then break;
inc(__index);
if __index < parent.fldChildsLength then begin
__node := parent.fldChildsNodes[__index];
continue;
end;
repeat
__index := parent.getIndex() + 1;
parent := parent.fldParentNode;
if parent = target then goto break_label0;
if __index < parent.fldChildsLength then begin
__node := parent.fldChildsNodes[__index];
break;
end;
until false;
until false;
break_label0:
result := morder;
end;
function Node.maxOrder(): int;
label
break_label0;
var
morder: int;
__index: int;
__order: int;
__code: Code;
__node: Node;
parent: Node;
target: Node;
begin
__code := fldParentCode;
if __code = nil then begin
result := -1;
exit;
end;
morder := -1;
__node := self;
parent := nil;
__index := -1;
target := fldParentNode;
repeat
__order := __code.orderOf(__node);
if __order > morder then begin
morder := __order;
end;
if __node.fldChildsLength > 0 then begin
parent := __node;
__index := 0;
__node := parent.fldChildsNodes[0];
continue;
end;
if parent = nil then break;
inc(__index);
if __index < parent.fldChildsLength then begin
__node := parent.fldChildsNodes[__index];
continue;
end;
repeat
__index := parent.getIndex() + 1;
parent := parent.fldParentNode;
if parent = target then goto break_label0;
if __index < parent.fldChildsLength then begin
__node := parent.fldChildsNodes[__index];
break;
end;
until false;
until false;
break_label0:
result := morder;
end;
function Node.getJumpCasesLength(): int;
begin
result := fldJumpCasesLength;
end;
function Node.getJumpCaseValueAt(index: int): int;
var
values: int_Array1d;
begin
values := fldJumpCasesValues;
if (values = nil) or (index < 0) or (index >= fldJumpCasesLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := values[index];
end;
function Node.getJumpCaseNodeAt(index: int): Node;
var
nodes: Node_Array1d;
begin
nodes := fldJumpCasesNodes;
if (nodes = nil) or (index < 0) or (index >= fldJumpCasesLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := nodes[index];
end;
function Node.getJumpCase(valueOfCase: int): Node;
var
length: int;
__index: int;
begin
length := fldJumpCasesLength;
if length <= 0 then begin
result := nil;
exit;
end;
__index := &Array.indexOf(valueOfCase, fldJumpCasesValues, 0, length);
if __index < 0 then begin
result := nil;
exit;
end;
result := fldJumpCasesNodes[__index];
end;
{%endregion}
{%region SourceException }
function SourceException.toString(): AnsiString;
var
__relativePath: AnsiString;
begin
__relativePath := fldRelativePath.toUTF8();
if __relativePath.length <= 0 then begin
__relativePath := AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'value.source.unknown');
end;
result := message +
CoAnsiString.LINE_ENDING + AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'property.source') + __relativePath
;
end;
function SourceException.clone(): Throwable;
var
copy: SourceException;
begin
copy := SourceException(inherited clone());
copy.fldRelativePath := fldRelativePath;
result := copy;
end;
{%endregion}
{%region BinarySourceException }
procedure BinarySourceException.setPosition(newPosition: int);
var
chunks: ChunkArray;
__source: BinarySource;
begin
fldPosition := newPosition;
__source := fldSource;
if __source = nil then exit;
chunks := __source.chunks;
if (chunks <> nil) and (newPosition >= 0) and (newPosition < chunks.getLength()) then begin
fldOffset := chunks.readComponent(newPosition).offset;
end;
end;
procedure BinarySourceException.setSource(newSource: BinarySource);
begin
fldSource := newSource;
if newSource <> nil then begin
fldRelativePath := newSource.relativePath;
end;
end;
function BinarySourceException.toString(): AnsiString;
var
__offset: AnsiString;
begin
__offset := '0x' + CoInt.toHexString(fldOffset);
result := inherited toString() +
CoAnsiString.LINE_ENDING + AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'property.offset') + __offset
;
end;
function BinarySourceException.clone(): Throwable;
var
copy: BinarySourceException;
begin
copy := BinarySourceException(inherited clone());
copy.fldOffset := fldOffset;
copy.fldPosition := fldPosition;
copy.fldSource := fldSource;
result := copy;
end;
{%endregion}
{%region TextSourceException }
procedure TextSourceException.setPosition(newPosition: int);
var
location: int2;
__source: LexemeSequence;
begin
fldPosition := newPosition;
__source := fldSource;
if (__source <> nil) and (newPosition >= 0) and (newPosition < __source.getLength()) then begin
location := __source.getLexemeLocation(newPosition);
fldLineIndex := location[0];
fldCharIndex := location[1];
end;
end;
procedure TextSourceException.setSource(newSource: TextSource);
begin
fldSource := newSource;
if newSource <> nil then begin
fldRelativePath := newSource.relativePath;
end;
end;
function TextSourceException.toString(): AnsiString;
var
__lineNumber: AnsiString;
__charNumber: AnsiString;
begin
__lineNumber := CoInt.toString(fldLineIndex + 1);
__charNumber := CoInt.toString(fldCharIndex + 1);
result := inherited toString() +
CoAnsiString.LINE_ENDING + AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'property.line') + __lineNumber +
CoAnsiString.LINE_ENDING + AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'property.char') + __charNumber
;
end;
function TextSourceException.clone(): Throwable;
var
copy: TextSourceException;
begin
copy := TextSourceException(inherited clone());
copy.fldPosition := fldPosition;
copy.fldLineIndex := fldLineIndex;
copy.fldCharIndex := fldCharIndex;
copy.fldSource := fldSource;
result := copy;
end;
{%endregion}
{%region ConstantItem }
function ConstantItem.composeRecompilableName(): AnsiString;
begin
result := '';
end;
function ConstantItem.composeFasmSimpleName(): AnsiString;
begin
result := '';
end;
constructor ConstantItem.create();
begin
inherited create(nil, '', nil, -1, -1);
end;
constructor ConstantItem.create(&type: PrimitiveType; const value: boolean);
begin
create();
fldValue := ConstantValue.create(&type, value);
end;
constructor ConstantItem.create(&type: PrimitiveType; const value: uchar);
begin
create();
fldValue := ConstantValue.create(&type, value);
end;
constructor ConstantItem.create(&type: PrimitiveType; const value: long8);
begin
create();
fldValue := ConstantValue.create(&type, value);
end;
constructor ConstantItem.create(&type: PrimitiveType; const value: double8);
begin
create();
fldValue := ConstantValue.create(&type, value);
end;
constructor ConstantItem.create(&type: PrimitiveType; const value: real);
begin
create();
fldValue := ConstantValue.create(&type, value);
end;
constructor ConstantItem.create(&type: ReferenceType; const value: TObject);
begin
create();
fldValue := ConstantValue.create(&type, value);
end;
constructor ConstantItem.create(&type: ReferenceType; const value: IUnknown);
begin
create();
fldValue := ConstantValue.create(&type, value);
end;
destructor ConstantItem.destroy;
begin
fldValue.free();
inherited destroy;
end;
function ConstantItem._addref(): int; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
begin
result := fldValue._addref();
end;
function ConstantItem._release(): int; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
begin
result := fldValue._release();
if result = 0 then begin
fldValue := nil;
destroy;
end;
end;
function ConstantItem.toString(): AnsiString;
begin
result := fldValue.toString();
end;
function ConstantItem.getKind(): int;
begin
result := fldValue.getKind();
end;
function ConstantItem.isNaN(): boolean;
begin
result := fldValue.isNaN();
end;
function ConstantItem.isInfinite(): boolean;
begin
result := fldValue.isInfinite();
end;
function ConstantItem.asChar(): char;
begin
result := fldValue.asChar();
end;
function ConstantItem.asUChar(): uchar;
begin
result := fldValue.asUChar();
end;
function ConstantItem.asByte(): byte;
begin
result := fldValue.asByte();
end;
function ConstantItem.asByte2(): byte2;
begin
result := fldValue.asByte2();
end;
function ConstantItem.asByte4(): byte4;
begin
result := fldValue.asByte4();
end;
function ConstantItem.asByte8(): byte8;
begin
result := fldValue.asByte8();
end;
function ConstantItem.asShort(): short;
begin
result := fldValue.asShort();
end;
function ConstantItem.asShort2(): short2;
begin
result := fldValue.asShort2();
end;
function ConstantItem.asShort4(): short4;
begin
result := fldValue.asShort4();
end;
function ConstantItem.asShort8(): short8;
begin
result := fldValue.asShort8();
end;
function ConstantItem.asInt(): int;
begin
result := fldValue.asInt();
end;
function ConstantItem.asInt2(): int2;
begin
result := fldValue.asInt2();
end;
function ConstantItem.asInt4(): int4;
begin
result := fldValue.asInt4();
end;
function ConstantItem.asInt8(): int8;
begin
result := fldValue.asInt8();
end;
function ConstantItem.asLong(): long;
begin
result := fldValue.asLong();
end;
function ConstantItem.asLong2(): long2;
begin
result := fldValue.asLong2();
end;
function ConstantItem.asLong4(): long4;
begin
result := fldValue.asLong4();
end;
function ConstantItem.asLong8(): long8;
begin
result := fldValue.asLong8();
end;
function ConstantItem.asFloat(): float;
begin
result := fldValue.asFloat();
end;
function ConstantItem.asFloat2(): float2;
begin
result := fldValue.asFloat2();
end;
function ConstantItem.asFloat4(): float4;
begin
result := fldValue.asFloat4();
end;
function ConstantItem.asFloat8(): float8;
begin
result := fldValue.asFloat8();
end;
function ConstantItem.asDouble(): double;
begin
result := fldValue.asDouble();
end;
function ConstantItem.asDouble2(): double2;
begin
result := fldValue.asDouble2();
end;
function ConstantItem.asDouble4(): double4;
begin
result := fldValue.asDouble4();
end;
function ConstantItem.asDouble8(): double8;
begin
result := fldValue.asDouble8();
end;
function ConstantItem.asReal(): real;
begin
result := fldValue.asReal();
end;
function ConstantItem.isNull(): boolean;
begin
result := fldValue.isNull();
end;
function ConstantItem.isClass(): boolean;
begin
result := fldValue.isClass();
end;
function ConstantItem.isString(): boolean;
begin
result := fldValue.isString();
end;
function ConstantItem.isPackage(): boolean;
begin
result := fldValue.isPackage();
end;
function ConstantItem.isBoolean(): boolean;
begin
result := fldValue.isBoolean();
end;
function ConstantItem.isNumeric(): boolean;
begin
result := fldValue.isNumeric();
end;
function ConstantItem.isReference(): boolean;
begin
result := fldValue.isReference();
end;
function ConstantItem.isReflective(): boolean;
begin
result := fldValue.isReflective();
end;
function ConstantItem.isDefaultValue(): boolean;
begin
result := fldValue.isDefaultValue();
end;
function ConstantItem.asBoolean(): boolean;
begin
result := fldValue.asBoolean();
end;
function ConstantItem.asObject(): TObject;
begin
result := fldValue.asObject();
end;
function ConstantItem.asInterface(): IUnknown;
begin
result := fldValue.asInterface();
end;
function ConstantItem.castTo(&type: &Type): Constant;
begin
result := fldValue.castTo(&type, self);
end;
function ConstantItem.getType(): &Type;
begin
result := fldValue.getType();
end;
{%endregion}
{%region ConstantValue }
procedure ConstantValue.checkTypeKind(kind: int);
begin
if fldTypeKind <> kind then begin
raise IllegalConstantTypeException.create(AResource.readUnitResourceAsAnsiString(ru.malik.elaborarer.avtoo.lang.UNIT_NAME, 'illegal-type.constant'));
end;
end;
constructor ConstantValue.create(&type: PrimitiveType; const value: boolean);
begin
inherited create();
fldTypeKind := TYP_BOOLEAN;
fldClassKind := KIND_BOOLEAN;
fldBoolean := value;
fldType := &type;
end;
constructor ConstantValue.create(&type: PrimitiveType; const value: uchar);
begin
inherited create();
fldTypeKind := TYP_NUMERIC;
fldClassKind := KIND_UCHAR;
fldUChar := value;
fldIntegral := int(value);
fldFloating := int(value);
fldReal := int(value);
fldType := &type;
end;
constructor ConstantValue.create(&type: PrimitiveType; const value: long8);
begin
inherited create();
fldTypeKind := TYP_NUMERIC;
case &type.kind of
AVTOOConstants.TYP_BYTE:
fldClassKind := KIND_BYTE;
AVTOOConstants.TYP_BYTE2:
fldClassKind := KIND_BYTE2;
AVTOOConstants.TYP_BYTE4:
fldClassKind := KIND_BYTE4;
AVTOOConstants.TYP_BYTE8:
fldClassKind := KIND_BYTE8;
AVTOOConstants.TYP_SHORT:
fldClassKind := KIND_SHORT;
AVTOOConstants.TYP_SHORT2:
fldClassKind := KIND_SHORT2;
AVTOOConstants.TYP_SHORT4:
fldClassKind := KIND_SHORT4;
AVTOOConstants.TYP_SHORT8:
fldClassKind := KIND_SHORT8;
AVTOOConstants.TYP_INT:
fldClassKind := KIND_INT;
AVTOOConstants.TYP_INT2:
fldClassKind := KIND_INT2;
AVTOOConstants.TYP_INT4:
fldClassKind := KIND_INT4;
AVTOOConstants.TYP_INT8:
fldClassKind := KIND_INT8;
AVTOOConstants.TYP_LONG:
fldClassKind := KIND_LONG;
AVTOOConstants.TYP_LONG2:
fldClassKind := KIND_LONG2;
AVTOOConstants.TYP_LONG4:
fldClassKind := KIND_LONG4;
AVTOOConstants.TYP_LONG8:
fldClassKind := KIND_LONG8;
end;
fldUChar := uchar(value[0]);
fldIntegral := value;
fldFloating := Cast.toDouble8(value);
fldReal := CoLong.toReal(value[0]);
fldType := &type;
end;
constructor ConstantValue.create(&type: PrimitiveType; const value: double8);
begin
inherited create();
fldTypeKind := TYP_NUMERIC;
case &type.kind of
AVTOOConstants.TYP_FLOAT:
fldClassKind := KIND_FLOAT;
AVTOOConstants.TYP_FLOAT2:
fldClassKind := KIND_FLOAT2;
AVTOOConstants.TYP_FLOAT4:
fldClassKind := KIND_FLOAT4;
AVTOOConstants.TYP_FLOAT8:
fldClassKind := KIND_FLOAT8;
AVTOOConstants.TYP_DOUBLE:
fldClassKind := KIND_DOUBLE;
AVTOOConstants.TYP_DOUBLE2:
fldClassKind := KIND_DOUBLE2;
AVTOOConstants.TYP_DOUBLE4:
fldClassKind := KIND_DOUBLE4;
AVTOOConstants.TYP_DOUBLE8:
fldClassKind := KIND_DOUBLE8;
end;
fldUChar := uchar(CoDouble.toInt(value[0]));
fldIntegral := Cast.toLong8(value);
fldFloating := value;
fldReal := value[0];
fldType := &type;
end;
constructor ConstantValue.create(&type: PrimitiveType; const value: real);
begin
inherited create();
fldTypeKind := TYP_NUMERIC;
fldClassKind := KIND_REAL;
fldUChar := uchar(CoReal.toInt(value));
fldIntegral := CoReal.toLong(value);
fldFloating := CoReal.toDouble(value);
fldReal := value;
fldType := &type;
end;
constructor ConstantValue.create(&type: ReferenceType; const value: TObject);
begin
inherited create();
fldTypeKind := TYP_REFERENCE;
fldClassKind := 0;
fldObject := value;
fldType := &type;
end;
constructor ConstantValue.create(&type: ReferenceType; const value: IUnknown);
begin
inherited create();
fldTypeKind := TYP_REFERENCE;
fldClassKind := 0;
fldObject := value as TObject;
fldInterface := value;
fldType := &type;
end;
function ConstantValue.toString(): AnsiString;
var
kind: int;
index: int;
length: int;
cvalue: int;
bvalue: byte8;
svalue: short8;
ivalue: int8;
lvalue: long8;
fvalue: float8;
dvalue: double8;
form: AnsiString;
data: Value_Array1d;
ovalue: TObject;
begin
kind := fldClassKind;
case kind of
KIND_BOOLEAN: begin
if fldBoolean then begin
result := 'true';
end else begin
result := 'false';
end;
end;
KIND_UCHAR: begin
cvalue := int(fldUChar);
if (cvalue >= $0021) and (cvalue <= $007f) then begin
result := '''' + char(cvalue) + '''';
end else begin
result := '''\u' + CoInt.toLeadZeroString(cvalue, 4, $10) + '''';
end;
end;
KIND_BYTE: begin
result := CoInt.toString(byte(fldIntegral[0]));
end;
KIND_SHORT: begin
result := CoInt.toString(short(fldIntegral[0])) + 'S';
end;
KIND_INT: begin
result := CoInt.toString(int(fldIntegral[0])) + 'I';
end;
KIND_LONG: begin
result := CoLong.toString(fldIntegral[0]) + 'L';
end;
KIND_FLOAT: begin
result := CoFloat.toString(CoDouble.toFloat(fldFloating[0])) + 'F';
end;
KIND_DOUBLE: begin
result := CoDouble.toString(fldFloating[0]) + 'D';
end;
KIND_REAL: begin
result := CoReal.toString(fldReal);
end;
KIND_BYTE2,
KIND_BYTE4,
KIND_BYTE8: begin
kind := kind and 3;
length := 1 shl kind;
bvalue := Cast.toByte8(fldIntegral);
data := Value_Array1d(&Array.newIUnknown1d(length));
for index := length - 1 downto 0 do begin
data[index] := CoByte.create(bvalue[index]);
end;
if kind = 1 then begin
form := 'new byte2 { %0%, %1% }';
end else
if kind = 2 then begin
form := 'new byte4 { %0%, %1%, %2%, %3% }';
end else begin
form := 'new byte8 { %0%, %1%, %2%, %3%, %4%, %5%, %6%, %7% }';
end;
result := AnsiString.format(form, data);
end;
KIND_SHORT2,
KIND_SHORT4,
KIND_SHORT8: begin
kind := kind and 3;
length := 1 shl kind;
svalue := Cast.toShort8(fldIntegral);
data := Value_Array1d(&Array.newIUnknown1d(length));
for index := length - 1 downto 0 do begin
data[index] := CoShort.create(svalue[index]);
end;
if kind = 1 then begin
form := 'new short2 { %0%, %1% }';
end else
if kind = 2 then begin
form := 'new short4 { %0%, %1%, %2%, %3% }';
end else begin
form := 'new short8 { %0%, %1%, %2%, %3%, %4%, %5%, %6%, %7% }';
end;
result := AnsiString.format(form, data);
end;
KIND_INT2,
KIND_INT4,
KIND_INT8: begin
kind := kind and 3;
length := 1 shl kind;
ivalue := Cast.toInt8(fldIntegral);
data := Value_Array1d(&Array.newIUnknown1d(length));
for index := length - 1 downto 0 do begin
data[index] := CoInt.create(ivalue[index]);
end;
if kind = 1 then begin
form := 'new int2 { %0%, %1% }';
end else
if kind = 2 then begin
form := 'new int4 { %0%, %1%, %2%, %3% }';
end else begin
form := 'new int8 { %0%, %1%, %2%, %3%, %4%, %5%, %6%, %7% }';
end;
result := AnsiString.format(form, data);
end;
KIND_LONG2,
KIND_LONG4,
KIND_LONG8: begin
kind := kind and 3;
length := 1 shl kind;
lvalue := fldIntegral;
data := Value_Array1d(&Array.newIUnknown1d(length));
for index := length - 1 downto 0 do begin
data[index] := CoLong.create(lvalue[index]);
end;
if kind = 1 then begin
form := 'new long2 { %0%, %1% }';
end else
if kind = 2 then begin
form := 'new long4 { %0%, %1%, %2%, %3% }';
end else begin
form := 'new long8 { %0%, %1%, %2%, %3%, %4%, %5%, %6%, %7% }';
end;
result := AnsiString.format(form, data);
end;
KIND_FLOAT2,
KIND_FLOAT4,
KIND_FLOAT8: begin
kind := kind and 3;
length := 1 shl kind;
fvalue := Cast.toFloat8(fldFloating);
data := Value_Array1d(&Array.newIUnknown1d(length));
for index := length - 1 downto 0 do begin
data[index] := CoFloat.create(fvalue[index]);
end;
if kind = 1 then begin
form := 'new float2 { %0%, %1% }';
end else
if kind = 2 then begin
form := 'new float4 { %0%, %1%, %2%, %3% }';
end else begin
form := 'new float8 { %0%, %1%, %2%, %3%, %4%, %5%, %6%, %7% }';
end;
result := AnsiString.format(form, data);
end;
KIND_DOUBLE2,
KIND_DOUBLE4,
KIND_DOUBLE8: begin
kind := kind and 3;
length := 1 shl kind;
dvalue := fldFloating;
data := Value_Array1d(&Array.newIUnknown1d(length));
for index := length - 1 downto 0 do begin
data[index] := CoDouble.create(dvalue[index]);
end;
if kind = 1 then begin
form := 'new double2 { %0%, %1% }';
end else
if kind = 2 then begin
form := 'new double4 { %0%, %1%, %2%, %3% }';
end else begin
form := 'new double8 { %0%, %1%, %2%, %3%, %4%, %5%, %6%, %7% }';
end;
result := AnsiString.format(form, data);
end;
else
ovalue := fldObject;
if ovalue = nil then begin
result := 'null';
end else
if ovalue is CoUnicodeString then begin
result := '"' + ovalue.toString() + '"';
end else
if ovalue is Package then begin
result := RequiredReflectItem(ovalue).specialCanonicalName + '.package';
end else
if ovalue is &Type then begin
result := RequiredReflectItem(ovalue).specialCanonicalName + '.class';
end else begin
result := ovalue.toString();
end;
end;
end;
function ConstantValue.getKind(): int;
begin
result := fldClassKind;
end;
function ConstantValue.isNaN(): boolean;
begin
case fldClassKind of
KIND_FLOAT,
KIND_DOUBLE: begin
result := CoDouble.isNaN(fldFloating[0]);
end;
KIND_FLOAT2,
KIND_DOUBLE2: begin
result := VCoDouble2.isNaN(Cast.toDouble2(fldFloating));
end;
KIND_FLOAT4,
KIND_DOUBLE4: begin
result := VCoDouble4.isNaN(Cast.toDouble4(fldFloating));
end;
KIND_FLOAT8,
KIND_DOUBLE8: begin
result := VCoDouble8.isNaN(fldFloating);
end;
else
result := false;
end;
end;
function ConstantValue.isInfinite(): boolean;
begin
case fldClassKind of
KIND_FLOAT,
KIND_DOUBLE: begin
result := CoDouble.isInfinite(fldFloating[0]);
end;
KIND_FLOAT2,
KIND_DOUBLE2: begin
result := VCoDouble2.isInfinite(Cast.toDouble2(fldFloating));
end;
KIND_FLOAT4,
KIND_DOUBLE4: begin
result := VCoDouble4.isInfinite(Cast.toDouble4(fldFloating));
end;
KIND_FLOAT8,
KIND_DOUBLE8: begin
result := VCoDouble8.isInfinite(fldFloating);
end;
else
result := false;
end;
end;
function ConstantValue.asChar(): char;
begin
checkTypeKind(TYP_NUMERIC);
result := char(fldUChar);
end;
function ConstantValue.asUChar(): uchar;
begin
checkTypeKind(TYP_NUMERIC);
result := fldUChar;
end;
function ConstantValue.asByte8(): byte8;
begin
checkTypeKind(TYP_NUMERIC);
result := Cast.toByte8(fldIntegral);
end;
function ConstantValue.asShort8(): short8;
begin
checkTypeKind(TYP_NUMERIC);
result := Cast.toShort8(fldIntegral);
end;
function ConstantValue.asInt8(): int8;
begin
checkTypeKind(TYP_NUMERIC);
result := Cast.toInt8(fldIntegral);
end;
function ConstantValue.asLong8(): long8;
begin
checkTypeKind(TYP_NUMERIC);
result := fldIntegral;
end;
function ConstantValue.asFloat8(): float8;
begin
checkTypeKind(TYP_NUMERIC);
result := Cast.toFloat8(fldFloating);
end;
function ConstantValue.asDouble8(): double8;
begin
checkTypeKind(TYP_NUMERIC);
result := fldFloating;
end;
function ConstantValue.asReal(): real;
begin
checkTypeKind(TYP_NUMERIC);
result := fldReal;
end;
function ConstantValue.isNull(): boolean;
begin
result := (fldTypeKind = TYP_REFERENCE) and (fldObject = nil);
end;
function ConstantValue.isClass(): boolean;
begin
result := (fldTypeKind = TYP_REFERENCE) and (fldObject is &Type);
end;
function ConstantValue.isString(): boolean;
begin
result := (fldTypeKind = TYP_REFERENCE) and (fldObject is CoUnicodeString);
end;
function ConstantValue.isPackage(): boolean;
begin
result := (fldTypeKind = TYP_REFERENCE) and (fldObject is Package);
end;
function ConstantValue.isBoolean(): boolean;
begin
result := fldTypeKind = TYP_BOOLEAN;
end;
function ConstantValue.isNumeric(): boolean;
begin
result := fldTypeKind = TYP_NUMERIC;
end;
function ConstantValue.isReference(): boolean;
begin
result := fldTypeKind = TYP_REFERENCE;
end;
function ConstantValue.isReflective(): boolean;
begin
result := (fldTypeKind = TYP_REFERENCE) and (fldObject is RequiredReflectItem);
end;
function ConstantValue.isDefaultValue(): boolean;
var
kind: int;
begin
case fldTypeKind of
TYP_BOOLEAN: begin
result := not fldBoolean;
end;
TYP_NUMERIC: begin
kind := fldClassKind;
if kind = KIND_UCHAR then begin
result := fldUChar = #$0000;
end else
if (kind >= KIND_BYTE) and (kind <= KIND_LONG8) then begin
result := fldIntegral = 0;
end else
if (kind >= KIND_FLOAT) and (kind <= KIND_DOUBLE8) then begin
result := VCoDouble8.toLong8Bits(fldFloating) = 0;
end else begin
result := VCoReal.toLong2Bits(fldReal) = 0;
end;
end;
else
result := fldObject = nil;
end;
end;
function ConstantValue.asBoolean(): boolean;
begin
checkTypeKind(TYP_BOOLEAN);
result := fldBoolean;
end;
function ConstantValue.asObject(): TObject;
begin
checkTypeKind(TYP_REFERENCE);
result := fldObject;
end;
function ConstantValue.asInterface(): IUnknown;
begin
checkTypeKind(TYP_REFERENCE);
result := fldInterface;
end;
function ConstantValue.castTo(&type: &Type; item: ConstantItem): ConstantItem;
var
kind: int;
prim: PrimitiveType;
rvalue: IUnknown;
begin
if &type = nil then begin
raise NullPointerException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'null-pointer.argument'), [ CoAnsiString.create('oldJumpNode') ]));
end;
if &type is PrimitiveType then begin
prim := PrimitiveType(&type);
kind := prim.kind;
if kind = AVTOOConstants.TYP_BOOLEAN then begin
checkTypeKind(TYP_BOOLEAN);
end else
if kind > AVTOOConstants.TYP_BOOLEAN then begin
checkTypeKind(TYP_NUMERIC);
end;
if &type = fldType then begin
result := item;
exit;
end;
case kind of
AVTOOConstants.TYP_BOOLEAN: begin
result := ConstantItem.create(prim, fldBoolean);
exit;
end;
AVTOOConstants.TYP_CHAR: begin
result := ConstantItem.create(prim, fldUChar);
exit;
end;
AVTOOConstants.TYP_BYTE: begin
result := ConstantItem.create(prim, long8(byte(fldIntegral[0])));
exit;
end;
AVTOOConstants.TYP_BYTE2: begin
result := ConstantItem.create(prim, long8(Cast.toByte2(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_BYTE4: begin
result := ConstantItem.create(prim, long8(Cast.toByte4(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_BYTE8: begin
result := ConstantItem.create(prim, long8(Cast.toByte8(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_SHORT: begin
result := ConstantItem.create(prim, long8(short(fldIntegral[0])));
exit;
end;
AVTOOConstants.TYP_SHORT2: begin
result := ConstantItem.create(prim, long8(Cast.toShort2(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_SHORT4: begin
result := ConstantItem.create(prim, long8(Cast.toShort4(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_SHORT8: begin
result := ConstantItem.create(prim, long8(Cast.toShort8(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_INT: begin
result := ConstantItem.create(prim, long8(int(fldIntegral[0])));
exit;
end;
AVTOOConstants.TYP_INT2: begin
result := ConstantItem.create(prim, long8(Cast.toInt2(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_INT4: begin
result := ConstantItem.create(prim, long8(Cast.toInt4(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_INT8: begin
result := ConstantItem.create(prim, long8(Cast.toInt8(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_LONG: begin
result := ConstantItem.create(prim, long8(fldIntegral[0]));
exit;
end;
AVTOOConstants.TYP_LONG2: begin
result := ConstantItem.create(prim, long8(Cast.toLong2(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_LONG4: begin
result := ConstantItem.create(prim, long8(Cast.toLong4(fldIntegral)));
exit;
end;
AVTOOConstants.TYP_LONG8: begin
result := ConstantItem.create(prim, fldIntegral);
exit;
end;
AVTOOConstants.TYP_FLOAT: begin
result := ConstantItem.create(prim, double8(CoDouble.toFloat(fldFloating[0])));
exit;
end;
AVTOOConstants.TYP_FLOAT2: begin
result := ConstantItem.create(prim, double8(Cast.toFloat2(fldFloating)));
exit;
end;
AVTOOConstants.TYP_FLOAT4: begin
result := ConstantItem.create(prim, double8(Cast.toFloat4(fldFloating)));
exit;
end;
AVTOOConstants.TYP_FLOAT8: begin
result := ConstantItem.create(prim, double8(Cast.toFloat8(fldFloating)));
exit;
end;
AVTOOConstants.TYP_DOUBLE: begin
result := ConstantItem.create(prim, double8(fldFloating[0]));
exit;
end;
AVTOOConstants.TYP_DOUBLE2: begin
result := ConstantItem.create(prim, double8(Cast.toDouble2(fldFloating)));
exit;
end;
AVTOOConstants.TYP_DOUBLE4: begin
result := ConstantItem.create(prim, double8(Cast.toDouble4(fldFloating)));
exit;
end;
AVTOOConstants.TYP_DOUBLE8: begin
result := ConstantItem.create(prim, fldFloating);
exit;
end;
AVTOOConstants.TYP_REAL: begin
result := ConstantItem.create(prim, fldReal);
exit;
end;
end;
end else
if &type is ru.malik.elaborarer.avtoo.lang.ClassType then begin
checkTypeKind(TYP_REFERENCE);
if &type = fldType then begin
result := item;
exit;
end;
if &type.isAssignableFrom(fldType) then begin
rvalue := fldInterface;
if rvalue <> nil then begin
result := ConstantItem.create(ReferenceType(&type), rvalue);
exit;
end;
result := ConstantItem.create(ReferenceType(&type), fldObject);
exit;
end;
end;
raise IllegalArgumentException.create(AnsiString.format(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'illegal-argument'), [ CoAnsiString.create('type') ]));
end;
function ConstantValue.getType(): &Type;
begin
result := fldType;
end;
{%endregion}
{%region ChunkByteArrayInputStream }
procedure ChunkByteArrayInputStream.setPosition(newPosition: int);
begin
fldPosition := newPosition shl 1;
end;
function ChunkByteArrayInputStream.getPosition(): int;
begin
result := fldPosition shr 1;
end;
{%endregion}
{%region ProgrammeLibraryKey }
constructor ProgrammeLibraryKey.create(&library: &Library);
begin
create(&library.fileSystem, &library.directoryPath);
end;
constructor ProgrammeLibraryKey.create(fileSystem: FileSystem; const directoryPath: UnicodeString);
begin
inherited create();
fldHash := fileSystem.getHashCode() xor (CoUnicodeString.create(directoryPath) as RefCountInterface).getHashCode();
fldDirectoryPath := directoryPath;
fldFileSystem := fileSystem;
end;
function ProgrammeLibraryKey.equals(anot: TObject): boolean;
var
akey: ProgrammeLibraryKey;
begin
if anot = self then begin
result := true;
exit;
end;
if not(anot is ProgrammeLibraryKey) then begin
result := false;
exit;
end;
akey := ProgrammeLibraryKey(anot);
result := (akey.fldFileSystem = fldFileSystem) and (akey.fldDirectoryPath = fldDirectoryPath);
end;
function ProgrammeLibraryKey.getHashCode(): long;
begin
result := fldHash;
end;
{%endregion}
{%region CodeLineIndexArray }
constructor CodeLineIndexArray.create();
begin
inherited create();
fldArray := &Array.newInt1d($0f);
end;
function CodeLineIndexArray.getLength(): int;
begin
result := fldLength;
end;
function CodeLineIndexArray.readComponent(index: int): int;
begin
if (index < 0) or (index >= fldLength) then begin
raise ArrayIndexOutOfBoundsException.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, 'out-of-bounds.array-index'));
end;
result := fldArray[index];
end;
function CodeLineIndexArray.append(item: int): int;
var
length: int;
sarray: int_Array1d;
buffer: int_Array1d;
begin
sarray := fldArray;
length := fldLength;
if length = system.length(sarray) then begin
if length = CoInt.MAX_VALUE then begin
raise BufferTooLargeError.create(AResource.readUnitResourceAsAnsiString(pascalx.lang.UNIT_NAME, '!error.buffer-too-large'));
end;
buffer := &Array.newInt1d((length shl 1) or 1);
&Array.copyPrimitives(sarray, 0, buffer, 0, length);
fldArray := buffer;
sarray := buffer;
end;
sarray[length] := item;
fldLength := length + 1;
result := length;
end;
{%endregion}
{%region} initialization
Lang.registerInterfaces([
typeInfo(Measureable),
typeInfo(IntArray),
typeInfo(ObjectArray),
typeInfo(SimpleArray),
typeInfo(UnknownArray),
typeInfo(MutableObjectArray),
typeInfo(Source),
typeInfo(TypedItem),
typeInfo(TypedMember),
typeInfo(ValuedItem),
typeInfo(AllocatableFactory),
typeInfo(Fieldoid),
typeInfo(Constant)
]);
{%endregion}
end.