This commit is contained in:
Бондарев Иван 2018-09-16 14:22:36 +02:00
parent 0636dd2ee0
commit b189591fc4
5 changed files with 664 additions and 166 deletions

View file

@ -652,8 +652,11 @@ namespace CodeCompletion
{
//throw new Exception("The method or operation is not implemented.");
_roof_dereference.dereferencing_value.visit(this);
if (returned_scope != null && returned_scope is PointerScope)
returned_scope = (returned_scope as PointerScope).ref_type;
TypeScope ts = returned_scope as TypeScope;
while (ts is TypeSynonim)
ts = (ts as TypeSynonim).actType;
if (ts is PointerScope)
returned_scope = (ts as PointerScope).ref_type;
else returned_scope = null;
}
@ -912,8 +915,10 @@ namespace CodeCompletion
}
}
else indexes.Add((TypeScope)entry_scope.FindName(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name));
returned_scope = new ArrayScope(of_type as TypeScope,indexes.ToArray());
TypeScope ts = of_type as TypeScope;
if (of_type is ProcScope)
ts = new ProcType(of_type as ProcScope);
returned_scope = new ArrayScope(ts as TypeScope,indexes.ToArray());
returned_scope.topScope = cur_scope;
if (_array_type.indexers == null) (returned_scope as ArrayScope).is_dynamic_arr = true;
returned_scope.loc = get_location(_array_type);
@ -1859,7 +1864,10 @@ namespace CodeCompletion
//else
if (returned_scope != null && returned_scope is TypeScope)
{
if (!(_type_declaration.type_def is named_type_reference) && !(returned_scope is CompiledScope && _type_declaration.type_def is enum_type_definition))
/*if (!(_type_declaration.type_def is named_type_reference) && !(_type_declaration.type_def is sequence_type)
&& !(_type_declaration.type_def is sequence_type) && !(_type_declaration.type_def is array_type)
&& !(returned_scope is CompiledScope && _type_declaration.type_def is enum_type_definition))*/
if (_type_declaration.type_def is class_definition)
{
//(ret_tn as TypeScope).name = _type_declaration.type_name.name;
returned_scope.si.name = _type_declaration.type_name.name;
@ -3541,7 +3549,10 @@ namespace CodeCompletion
{
//throw new Exception("The method or operation is not implemented.");
_set_type_definition.of_type.visit(this);
returned_scope = new SetScope(returned_scope as TypeScope);
TypeScope ts = returned_scope as TypeScope;
if (returned_scope is ProcScope)
ts = new ProcType(returned_scope as ProcScope);
returned_scope = new SetScope(ts);
returned_scope.topScope = cur_scope;
}

View file

@ -0,0 +1,204 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
///--
unit PABCExtensions;
uses PABCSystem;
//{{{doc: Начало секции подпрограмм для типизированных файлов для документации }}}
// -----------------------------------------------------
//>> Подпрограммы для работы с типизированными файлами # Subroutines for typed files
// -----------------------------------------------------
/// Открывает типизированный файл и возвращает значение для инициализации файловой переменной
function OpenBinary<T>(fname: string): file of T;
begin
PABCSystem.Reset(Result, fname);
end;
/// Создаёт или обнуляет типизированный файл и возвращает значение для инициализации файловой переменной
function CreateBinary<T>(fname: string): file of T;
begin
PABCSystem.Rewrite(Result, fname);
end;
/// Открывает типизированный файл и возвращает значение для инициализации файловой переменной
function OpenFile<T>(fname: string): file of T;
begin
PABCSystem.Reset(Result, fname);
end;
/// Создаёт или обнуляет типизированный файл и возвращает значение для инициализации файловой переменной
function CreateFile<T>(fname: string): file of T;
begin
PABCSystem.Rewrite(Result, fname);
end;
/// Открывает типизированный файл целых и возвращает значение для инициализации файловой переменной
function OpenFileInteger(fname: string): file of integer;
begin
Result := OpenFile&<integer>(fname);
end;
/// Открывает типизированный файл вещественных и возвращает значение для инициализации файловой переменной
function OpenFileReal(fname: string): file of real;
begin
Result := OpenFile&<real>(fname);
end;
/// Создаёт или обнуляет типизированный файл целых и возвращает значение для инициализации файловой переменной
function CreateFileInteger(fname: string): file of integer;
begin
Result := CreateFile&<integer>(fname);
end;
/// Создаёт или обнуляет типизированный файл вещественных и возвращает значение для инициализации файловой переменной
function CreateFileReal(fname: string): file of real;
begin
Result := CreateFile&<real>(fname);
end;
/// Открывает типизированный файл, возвращает последовательность его элементов и закрывает его
procedure WriteElements<T>(fname: string; ss: sequence of T);
begin
var f := CreateBinary&<T>(fname);
foreach var x in ss do
f.Write(x);
f.Close
end;
// -----------------------------------------------------
//>> Методы расширения типизированных файлов # Extension methods for typed files
// -----------------------------------------------------
/// Устанавливает текущую позицию файлового указателя в типизированном файле на элемент с номером n
function Seek<T>(Self: file of T; n: int64): file of T; extensionmethod;
begin
PABCSystem.Seek(Self, n);
Result := Self;
end;
/// Считывает и возвращает следующий элемент типизированного файла
function Read<T>(Self: file of T): T; extensionmethod;
begin
PABCSystem.Read(Self, Result);
end;
/// Считывает и возвращает два следующих элемента типизированного файла в виде кортежа
function Read2<T>(Self: file of T): (T,T); extensionmethod;
begin
var a,b: T;
PABCSystem.Read(Self, a);
PABCSystem.Read(Self, b);
Result := (a,b);
end;
/// Считывает и возвращает три следующих элемента типизированного файла в виде кортежа
function Read3<T>(Self: file of T): (T,T,T); extensionmethod;
begin
var a,b,c: T;
PABCSystem.Read(Self, a);
PABCSystem.Read(Self, b);
PABCSystem.Read(Self, c);
Result := (a,b,c);
end;
/// Возвращает последовательность элементов открытого типизированного файла от текущего элемента до конечного
function ReadElements<T>(Self: file of T): sequence of T; extensionmethod;
begin
while not Self.Eof do
begin
var x := Self.Read;
yield x;
end;
end;
/// Открывает типизированный файл, возвращает последовательность его элементов и закрывает его
function ReadElements<T>(fname: string): sequence of T;
begin
var f := OpenBinary&<T>(fname);
while not f.Eof do
begin
var x := f.Read;
yield x;
end;
f.Close
end;
/// Записывает данные в типизированный файл
procedure Write<T>(Self: file of T; params vals: array of T); extensionmethod;
begin
foreach var x in vals do
PABCSystem.Write(Self, x);
end;
/// Открывает существующий типизированный файл
procedure Reset<T>(Self: file of T); extensionmethod;
begin
PABCSystem.Reset(Self);
end;
/// Создает новый или обнуляет существующий типизированный файл
procedure Rewrite<T>(Self: file of T); extensionmethod;
begin
PABCSystem.Rewrite(Self);
end;
//{{{--doc: Конец секции подпрограмм для типизированных файлов для документации }}}
// -----------------------------------------------------
//>> Функции, создающие HashSet и SortedSet по встроенным множествам # Function for creation HashSet and SortedSet from set of T
// -----------------------------------------------------
{/// Создает HashSet по встроенному множеству
function HSet<T>(s: set of T): HashSet<T>;
begin
Result := new HashSet<T>;
foreach var x in s do
Result += x;
end;
/// Создает SortedSet по встроенному множеству
function SSet<T>(s: set of T): SortedSet<T>;
begin
Result := new SortedSet<T>;
foreach var x in s do
Result += x;
end;}
//------------------------------------------------------------------------------
// Операции для procedure
//------------------------------------------------------------------------------
///--
function operator*(p: procedure; n: integer): procedure; extensionmethod;
begin
Result := () -> for var i:=1 to n do p
end;
///--
function operator*(n: integer; p: procedure): procedure; extensionmethod;
begin
Result := () -> for var i:=1 to n do p
end;
var __initialized: boolean;
procedure __InitModule;
begin
end;
procedure __InitModule__;
begin
if not __initialized then
begin
__initialized := true;
__InitPABCSystem;
__InitModule;
end;
end;
begin
__InitModule;
end.

File diff suppressed because it is too large Load diff

View file

@ -29,4 +29,7 @@ begin
end;
var ptr: myptr;
var r{@var r: real;@} := ptr^;
var i: myint;
var ptr2{@var ptr2: ^myint;@} := @i;
var i2{@var i2: myint;@} := ptr2^;
end.

View file

@ -0,0 +1,25 @@
type
// set of
T1{@type T1 = set of procedure@} = set of procedure; // set of
T2{@type T2 = set of function: byte@} = set of function: byte; // set of
// sequence of
T7{@type T7 = sequence of procedure@} = sequence of procedure;
T8{@type T8 = sequence of function: byte@} = sequence of function: byte;
// array of
T9{@type T9 = array of procedure@} = array of procedure;
T10{@type T10 = array of function: byte@} = array of function: byte;
T3{@type T3 = file of integer@} = file of integer;
T4{@type T4 = array[1..5] of procedure@} = array[1..5] of procedure;
T5{@class T5@} = class
end;
T6{@record T6@} = record
end;
T11{@type T11 = List<integer>@} = List<integer>;
T12{@type T12 = T5@} = T5;
T13{@type T13 = 1..10@} = 1..10;
T14{@type T14 = sequence of Tuple<procedure,procedure>@} = sequence of (procedure, procedure);
begin
end.