bug fix issue #14
This commit is contained in:
parent
28551ebc74
commit
c3669a66e2
|
|
@ -1061,6 +1061,8 @@ namespace PascalABCCompiler.Parsers
|
|||
parameters.Add(old_parameters[ind]);
|
||||
ind++;
|
||||
}
|
||||
else
|
||||
parameters.Add(generic_arg.Name);
|
||||
}
|
||||
else
|
||||
//parameters.Add(GetShortTypeName(generic_arg, false));
|
||||
|
|
@ -1088,7 +1090,8 @@ namespace PascalABCCompiler.Parsers
|
|||
else
|
||||
sb.Append(parameters[0] + "->()");
|
||||
}
|
||||
|
||||
if (sb.Length == 0)
|
||||
sb.Append(t.Name);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
|
|
|||
14
TestSuite/callnoparams.pas
Normal file
14
TestSuite/callnoparams.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
function f: integer;
|
||||
begin
|
||||
Result := 10;
|
||||
end;
|
||||
begin
|
||||
var s := 'aaa bbb';
|
||||
var arr := s.Split;
|
||||
assert(arr[1] = 'bbb');
|
||||
var i := f;
|
||||
assert(i = 10);
|
||||
assert(s.Count = s.Length);
|
||||
var j := s.Count;
|
||||
assert(j = s.Count);
|
||||
end.
|
||||
|
|
@ -357,6 +357,37 @@ namespace PascalABCCompiler.TreeConverter
|
|||
throw new CanNotReferenceToNonStaticMethodWithType(fn.name, loc);
|
||||
}
|
||||
|
||||
public expression_node create_method_call(function_node fn, location loc, expression_node obj, params expression_node[] exprs)
|
||||
{
|
||||
if (fn.compile_time_executor != null)
|
||||
{
|
||||
expression_node ex = fn.compile_time_executor(loc, exprs);
|
||||
if (ex != null)
|
||||
{
|
||||
return ex;
|
||||
}
|
||||
}
|
||||
|
||||
switch (fn.semantic_node_type)
|
||||
{
|
||||
case semantic_node_type.common_method_node:
|
||||
{
|
||||
common_method_node cmn = (common_method_node)fn;
|
||||
|
||||
return create_common_method_call(cmn, loc, obj, exprs);
|
||||
}
|
||||
|
||||
case semantic_node_type.compiled_function_node:
|
||||
{
|
||||
compiled_function_node cfn = (compiled_function_node)fn;
|
||||
|
||||
return create_compiled_function_call(cfn, loc, obj, exprs);
|
||||
}
|
||||
|
||||
default: throw new CompilerInternalError("Unknown function type");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Этот метод вызывается если мы встречаем простой вызов функии, например f(1).
|
||||
/// Он определяет является ли эта функция методом класса, вложенной функцией и т.д. и создает соответствующее обращение.
|
||||
|
|
|
|||
|
|
@ -8430,7 +8430,18 @@ namespace PascalABCCompiler.TreeConverter
|
|||
&& (fn.parameters[fn.parameters.Count - 1].is_params || fn.parameters[fn.parameters.Count - 1].default_value != null))
|
||||
{
|
||||
fn = convertion_data_and_alghoritms.select_function(bfc.parameters, new SymbolInfo(fn), bfc.location);
|
||||
bfc = convertion_data_and_alghoritms.create_simple_function_call(fn, bfc.location, bfc.parameters.ToArray()) as base_function_call;
|
||||
if (fn.polymorphic_state == SemanticTree.polymorphic_state.ps_static || fn is common_namespace_function_node || fn is basic_function_node)
|
||||
bfc = convertion_data_and_alghoritms.create_simple_function_call(fn, bfc.location, bfc.parameters.ToArray()) as base_function_call;
|
||||
else
|
||||
{
|
||||
expression_node obj = null;
|
||||
if (bfc is common_method_call)
|
||||
obj = (bfc as common_method_call).obj;
|
||||
else if (bfc is compiled_function_call)
|
||||
obj = (bfc as compiled_function_call).obj;
|
||||
bfc = convertion_data_and_alghoritms.create_method_call(fn, bfc.location, obj, bfc.parameters.ToArray()) as base_function_call;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue