parent
eb7bff3077
commit
ebd2823d29
|
|
@ -698,7 +698,7 @@ namespace CodeFormatters
|
||||||
|| sn is foreach_stmt || sn is var_statement || sn is try_stmt || sn is goto_statement
|
|| sn is foreach_stmt || sn is var_statement || sn is try_stmt || sn is goto_statement
|
||||||
|| sn is with_statement || sn is case_node || sn is function_header || sn is procedure_header
|
|| sn is with_statement || sn is case_node || sn is function_header || sn is procedure_header
|
||||||
|| sn is constructor || sn is destructor || sn is type_declarations || sn is consts_definitions_list
|
|| sn is constructor || sn is destructor || sn is type_declarations || sn is consts_definitions_list
|
||||||
|| sn is label_definitions || sn is class_definition || sn is uses_list || sn is uses_closure || sn is unit_name || sn is program_name ||
|
|| sn is label_definitions || sn is class_definition || sn is uses_list || sn is uses_closure || sn is unit_or_namespace || sn is unit_name || sn is program_name ||
|
||||||
sn is new_expr || sn is raise_stmt || sn is interface_node || sn is implementation_node
|
sn is new_expr || sn is raise_stmt || sn is interface_node || sn is implementation_node
|
||||||
|| sn is lock_stmt || sn is loop_stmt || sn is simple_property || sn is read_accessor_name || sn is write_accessor_name
|
|| sn is lock_stmt || sn is loop_stmt || sn is simple_property || sn is read_accessor_name || sn is write_accessor_name
|
||||||
|| sn is formal_parameters || sn is bracket_expr || sn is record_const || sn is array_const || sn is exception_handler
|
|| sn is formal_parameters || sn is bracket_expr || sn is record_const || sn is array_const || sn is exception_handler
|
||||||
|
|
@ -1451,7 +1451,9 @@ namespace CodeFormatters
|
||||||
public override void visit(uses_list _uses_list)
|
public override void visit(uses_list _uses_list)
|
||||||
{
|
{
|
||||||
//sb.Append("uses");
|
//sb.Append("uses");
|
||||||
IncOffset(tab + "uses".Length - 1);
|
IncOffset();
|
||||||
|
if (options.AggressiveMode == 1)
|
||||||
|
insert_newline_after_prev = true;
|
||||||
for (int i = 0; i < _uses_list.units.Count; i++)
|
for (int i = 0; i < _uses_list.units.Count; i++)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
|
|
@ -1459,7 +1461,7 @@ namespace CodeFormatters
|
||||||
visit_node(_uses_list.units[i]);
|
visit_node(_uses_list.units[i]);
|
||||||
}
|
}
|
||||||
insert_newline_after_prev = true;
|
insert_newline_after_prev = true;
|
||||||
DecOffset(tab + "uses".Length - 1);
|
DecOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void visit(unit_module _unit_module)
|
public override void visit(unit_module _unit_module)
|
||||||
|
|
|
||||||
|
|
@ -7908,7 +7908,7 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
if (value.indices == null)
|
if (value.indices == null)
|
||||||
{
|
{
|
||||||
value.index.visit(this);
|
value.index.visit(this);
|
||||||
if (from is IBasicFunctionCallNode && (from as IBasicFunctionCallNode).real_parameters[0] == to)
|
if (from is IBasicFunctionCallNode && (from as IBasicFunctionCallNode).real_parameters[0] == to && current_index_lb == null)
|
||||||
{
|
{
|
||||||
index_lb = il.DeclareLocal(helper.GetTypeReference(value.index.type).tp);
|
index_lb = il.DeclareLocal(helper.GetTypeReference(value.index.type).tp);
|
||||||
il.Emit(OpCodes.Stloc, index_lb);
|
il.Emit(OpCodes.Stloc, index_lb);
|
||||||
|
|
@ -9029,7 +9029,10 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
is_addr = false;
|
is_addr = false;
|
||||||
is_dot_expr = false;
|
is_dot_expr = false;
|
||||||
TypeInfo ti = helper.GetTypeReference(value.array.type);
|
TypeInfo ti = helper.GetTypeReference(value.array.type);
|
||||||
|
LocalBuilder tmp_current_index_lb = current_index_lb;
|
||||||
|
current_index_lb = null;
|
||||||
value.array.visit(this);
|
value.array.visit(this);
|
||||||
|
current_index_lb = tmp_current_index_lb;
|
||||||
bool string_getter = temp_is_addr && ti.tp == TypeFactory.StringType;
|
bool string_getter = temp_is_addr && ti.tp == TypeFactory.StringType;
|
||||||
LocalBuilder pin_lb = null;
|
LocalBuilder pin_lb = null;
|
||||||
var indices = value.indices;
|
var indices = value.indices;
|
||||||
|
|
|
||||||
20
TestSuite/arrays11.pas
Normal file
20
TestSuite/arrays11.pas
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
type TRec = record
|
||||||
|
k: array[0..1, 0..1] of integer;
|
||||||
|
end;
|
||||||
|
var
|
||||||
|
k: array[0..1, 0..1] of integer;
|
||||||
|
a: array[0..10] of integer;
|
||||||
|
a2: array[1..2] of TRec;
|
||||||
|
|
||||||
|
begin
|
||||||
|
a[5] := 1;
|
||||||
|
k[0, 1] := 100;
|
||||||
|
k[a[5] mod 2][1] += 1;
|
||||||
|
assert(k[a[5], 1] = 1);
|
||||||
|
k[a[5] mod 2, 1] += 1;
|
||||||
|
assert(k[a[5], 1] = 2);
|
||||||
|
k[0, a[a[1] + 4] mod 2] += 1;
|
||||||
|
assert(k[0, a[4] mod 2] = 1);
|
||||||
|
a2[a[5]].k[a[5] mod 2,1] += 1;
|
||||||
|
assert(a2[a[5]].k[a[5] mod 2,1] = 1);
|
||||||
|
end.
|
||||||
|
|
@ -16,4 +16,10 @@ begin
|
||||||
assert(i = 2);
|
assert(i = 2);
|
||||||
a2[test] += a2[test];
|
a2[test] += a2[test];
|
||||||
assert(i = 4);
|
assert(i = 4);
|
||||||
|
a2[test mod 3] += 1;
|
||||||
|
assert(i = 5);
|
||||||
|
a2[a[test]] := 0;
|
||||||
|
a2[a[test]] += 1;
|
||||||
|
assert(a2[a[test]] = 1);
|
||||||
|
assert(i = 8);
|
||||||
end.
|
end.
|
||||||
17
TestSuite/extensionmethods29.pas
Normal file
17
TestSuite/extensionmethods29.pas
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
type
|
||||||
|
A = class end;
|
||||||
|
|
||||||
|
var i: integer;
|
||||||
|
|
||||||
|
procedure D<T>(self: T; var a: T); extensionmethod;begin i := 1 end;
|
||||||
|
|
||||||
|
procedure D(self: A; var b: A; var c: A); extensionmethod;begin i := 2 end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
var t := new A;
|
||||||
|
var b, c: A;
|
||||||
|
t.D(b);
|
||||||
|
assert(i = 1);
|
||||||
|
t.D(b, c);
|
||||||
|
assert(i = 2);
|
||||||
|
end.
|
||||||
|
|
@ -886,6 +886,7 @@ namespace SymbolTable
|
||||||
((to.symbol_kind == symbol_kind.sk_overload_function) && (add.symbol_kind == symbol_kind.sk_overload_function))
|
((to.symbol_kind == symbol_kind.sk_overload_function) && (add.symbol_kind == symbol_kind.sk_overload_function))
|
||||||
||
|
||
|
||||||
((to.symbol_kind == symbol_kind.sk_overload_procedure) && (add.symbol_kind == symbol_kind.sk_overload_procedure))
|
((to.symbol_kind == symbol_kind.sk_overload_procedure) && (add.symbol_kind == symbol_kind.sk_overload_procedure))
|
||||||
|
|| to.sym_info != add.sym_info && to.sym_info is PascalABCCompiler.TreeRealization.function_node && add.sym_info is PascalABCCompiler.TreeRealization.function_node && (to.sym_info as PascalABCCompiler.TreeRealization.function_node).is_extension_method && (add.sym_info as PascalABCCompiler.TreeRealization.function_node).is_extension_method
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue