This commit is contained in:
Бондарев Иван 2017-05-25 11:44:01 +02:00
parent 819c41c2f3
commit 32404786fb
6 changed files with 33 additions and 23 deletions

View file

@ -1,5 +1,5 @@
#reference 'System.Windows.Forms.dll'
#reference 'System.Drawing.dll'
{$reference 'System.Windows.Forms.dll'}
{$reference 'System.Drawing.dll'}
uses System, System.Windows.Forms;

View file

@ -1,5 +1,5 @@
#reference 'System.Windows.Forms.dll'
#reference 'System.Drawing.dll'
{$reference 'System.Windows.Forms.dll'}
{$reference 'System.Drawing.dll'}
uses System, System.Windows.Forms;

View file

@ -0,0 +1,14 @@
type
c1 = class
seq1: sequence of integer;
constructor create;
begin
var a := Arr(3.1, 3.7);
seq1 := a.Select(b -> Round(b));
end;
end;
begin
var obj := new c1;
assert(obj.seq1.ToArray[1] = 4);
end.

View file

@ -278,7 +278,12 @@ namespace PascalABCCompiler.TreeConverter
{
syntax_tree_visitor.AddError(loc, ErrString, values);
}
internal bool can_call_inherited_ctor_call(statements_list lst)
{
return lst.statements.Count == 0;
}
public void reset()
{
_cmn = null;

View file

@ -100,7 +100,12 @@ namespace PascalABCCompiler.TreeConverter
{
return statement_list_stack.pop();
}
internal statements_list statement_list_stack_first()
{
return statement_list_stack.first();
}
public type_constructor type_constructor
{
get
@ -436,7 +441,7 @@ namespace PascalABCCompiler.TreeConverter
common_constructor_call ccc = new common_constructor_call((common_method_node)fn, loc);
//(ssyy) По-видимому, здесь всегда можно присваивать false, так как при создании нового объекта мы сюда не заходим...
ccc._new_obj_awaited = false;
if (!syntax_tree_visitor.context.allow_inherited_ctor_call)
if (!syntax_tree_visitor.context.allow_inherited_ctor_call && !syntax_tree_visitor.context.can_call_inherited_ctor_call(statement_list_stack_first()))
{
if (syntax_tree_visitor.inherited_ident_processing)
syntax_tree_visitor.AddError(new SimpleSemanticError(loc, "INHERITED_CONSTRUCTOR_CALL_MUST_BE_FIRST"));
@ -490,7 +495,7 @@ namespace PascalABCCompiler.TreeConverter
compiled_constructor_call ccc = new compiled_constructor_call(ccn, loc);
ccc.parameters.AddRange(exprs);
ccc._new_obj_awaited = false;
if (!syntax_tree_visitor.context.allow_inherited_ctor_call)
if (!syntax_tree_visitor.context.allow_inherited_ctor_call && !syntax_tree_visitor.context.can_call_inherited_ctor_call(statement_list_stack_first()))
{
throw new SimpleSemanticError(loc, "INHERITED_CONSTRUCTOR_CALL_MUST_BE_FIRST");
}

View file

@ -15485,7 +15485,7 @@ namespace PascalABCCompiler.TreeConverter
}
else
{
if (!context.allow_inherited_ctor_call)
if (!context.allow_inherited_ctor_call && !context.can_call_inherited_ctor_call(convertion_data_and_alghoritms.statement_list_stack_first()))
AddError(loc, "INHERITED_CONSTRUCTOR_CALL_MUST_BE_FIRST");
expressions_list exprs = new expressions_list();
foreach (common_parameter cp in cfn.parameters)
@ -16308,31 +16308,17 @@ namespace PascalABCCompiler.TreeConverter
convertion_data_and_alghoritms.statement_list_stack_push(stl);
for (var i=0; i< _statement_list.subnodes.Count; i++) // SSM 13.10.16 - поменял т.к. собираюсь менять узлы в процессе обхода
//foreach (statement syntax_statement in _statement_list.subnodes)
{
statement syntax_statement = _statement_list.subnodes[i];
try
{
// SSM выкинул эти три строки - теперь внутриблочные описания обрабатываются как обычные операторы.
// При этом в конце visit(var_statement) стоит вызов ret.reset(), который возвращает нулевой semantic_statement - и всё работает эквивалентно
//if (syntax_statement is SyntaxTree.var_statement)
// visit(syntax_statement as SyntaxTree.var_statement); // Добавление в текущий statements_list происходит опосредованно !!
//else if (MustVisitBody) // MustVisitBody - всегда True!!!
//{
//(ssyy) TODO Сделать по-другому!!!
statement_node semantic_statement = convert_strong(syntax_statement);
//(ssyy) Проверка для C
if (semantic_statement != null)
{
//Обработать по другому - комментарий не мой - SSM
//if (context.CurrentScope.AddStatementsToFront)
// stl.statements.AddElementFirst(semantic_statement);
//else
stl.statements.AddElement(semantic_statement);
}
context.allow_inherited_ctor_call = false;
//}
}
catch (Errors.Error ex)
{