Find spot for typeclass template params inferrence and add required params for inference function
This commit is contained in:
parent
98718a60e1
commit
862d8004d6
|
|
@ -186,7 +186,7 @@ begin
|
|||
var l1 := Arr(1,3,5,7,8);
|
||||
var l2 := Arr(1,3,5,7,8);
|
||||
|
||||
writeln(ArrayEq&[integer](l1, l2));
|
||||
writeln(ArrayEq(l1, l2));
|
||||
end;
|
||||
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -1846,7 +1846,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
|
||||
function_node inst = generic_convertions.DeduceFunction(func, parameters,
|
||||
is_alone_method_defined, loc, syntax_nodes_parameters);
|
||||
is_alone_method_defined, syntax_tree_visitor.context, loc, syntax_nodes_parameters);
|
||||
if (inst == null)
|
||||
{
|
||||
set_of_possible_functions.remove_at(i);
|
||||
|
|
|
|||
|
|
@ -1384,7 +1384,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
function_node inst = null;
|
||||
try
|
||||
{
|
||||
inst = generic_convertions.DeduceFunction(cmfn, parameters, true, loc);
|
||||
inst = generic_convertions.DeduceFunction(cmfn, parameters, true, context, loc);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -1473,7 +1473,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
function_node inst = null;
|
||||
try
|
||||
{
|
||||
inst = generic_convertions.DeduceFunction(cfn, parameters, true, loc);
|
||||
inst = generic_convertions.DeduceFunction(cfn, parameters, true, context, loc);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -735,7 +735,7 @@ namespace PascalABCCompiler.TreeRealization
|
|||
return result;
|
||||
}
|
||||
|
||||
public static function_node DeduceFunction(function_node func, expressions_list fact, bool alone, location loc, List<SyntaxTree.expression> syntax_nodes_parameters = null)
|
||||
public static function_node DeduceFunction(function_node func, expressions_list fact, bool alone, compilation_context context, location loc, List<SyntaxTree.expression> syntax_nodes_parameters = null)
|
||||
{
|
||||
parameter_list formal = func.parameters;
|
||||
int formal_count = formal.Count;
|
||||
|
|
@ -832,8 +832,11 @@ namespace PascalABCCompiler.TreeRealization
|
|||
}
|
||||
|
||||
var continue_trying_to_infer_types = true;
|
||||
Dictionary<string, delegate_internal_interface> formal_delegates = null;
|
||||
Dictionary<string, delegate_internal_interface> formal_delegates = null;
|
||||
|
||||
var testIsTypeclassRestricted = func.Attributes?.Any(x => x.AttributeType.name == "__TypeclassRestrictedFunctionAttribute");
|
||||
var isTypeclassRestricted = testIsTypeclassRestricted.HasValue && testIsTypeclassRestricted.Value;
|
||||
var typeclasses = func.get_generic_params_list().Where(t => t.Attributes != null && t.Attributes.Any(a => a.AttributeType != null && a.AttributeType.name == "__TypeclassGenericParameter"));
|
||||
while (continue_trying_to_infer_types) //Продолжаем пытаться вычислить типы до тех пор пока состояние о выведенных типах не будет отличаться от состояния на предыдущей итерации
|
||||
{
|
||||
var previous_deduce_state = deduced // Текущее состояние выведенных на данный момент типов. Простой список индексов с уже выведенными типами из массива deduced
|
||||
|
|
@ -916,6 +919,12 @@ namespace PascalABCCompiler.TreeRealization
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isTypeclassRestricted)
|
||||
{
|
||||
//context.CurrentScope.SymbolTable
|
||||
}
|
||||
|
||||
var current_deduce_state = deduced //текущее состояние выведенных типов
|
||||
.Select((t, ii) => new {Type = t, Index = ii})
|
||||
.Where(t => t.Type != null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue