This commit is contained in:
miks1965 2018-08-20 00:57:36 +03:00
commit 79585149f3
5 changed files with 60 additions and 10 deletions

View file

@ -7369,7 +7369,8 @@ namespace PascalABCCompiler.NETGenerator
box_awaited = true;
use_stn4 = true;
}
//if (ctn4 != null && ctn4.is_value_type && (ctn4 is ICommonTypeNode || ctn4 is ICompiledTypeNode && !TypeFactory.IsStandType((ctn4 as ICompiledTypeNode).compiled_type)) && ctn3 is ICompiledTypeNode && (ctn3 as ICompiledTypeNode).compiled_type != TypeFactory.ObjectType)
// box_awaited = false;
if (!(real_parameters[i] is INullConstantNode))
{
ti = helper.GetTypeReference(ctn);

View file

@ -432,7 +432,7 @@ namespace GPPGParserScanner
{
string s = match.Value.Replace("{", "").Replace("}", "");
int colon_pos = s.IndexOf(':');
if (colon_pos != -1)
if (colon_pos != -1 && s.IndexOf('?') == -1)
{
var_formats.Add(ind, s.Substring(colon_pos));
s = s.Substring(0, colon_pos);

23
TestSuite/records12.pas Normal file
View file

@ -0,0 +1,23 @@
type
r1=record
x,y:integer;
class function operator implicit(a:r1):string := a.x.ToString + a.y.ToString;
end;
procedure test(o: object);
begin
assert(string(o) = '57');
end;
procedure test2(o: object);
begin
assert(string(r1(o)) = '57');
end;
begin
var a:r1;
(a.x,a.y) := (5,7);
test(string(a));
test2(a);
test2(object(a));
end.

View file

@ -677,7 +677,8 @@ namespace PascalABCCompiler.TreeConverter
if ((ret is base_function_call))
(ret as base_function_call).IsExplicitConversion = true;
ret.type = to;
ret.conversion_type = conv_type;
if (ptc.first.convertion_method is basic_function_node)
ret.conversion_type = conv_type;
return ret;
}
@ -2361,19 +2362,37 @@ namespace PascalABCCompiler.TreeConverter
}
}
}
else if (to_ii != null && from.semantic_node_type == semantic_node_type.delegated_method && (from as delegated_methods).proper_methods[0].ret_type is lambda_any_type_node)
{
delegate_internal_interface to_dii = (delegate_internal_interface)to_ii;
if (to_dii.invoke_method.return_value_type != null)
{
to = to_dii.invoke_method.return_value_type;
if (to == SystemLibrary.SystemLibrary.integer_type)
return 94;
else if (to == SystemLibrary.SystemLibrary.int64_type)
return 96;
else if (to == SystemLibrary.SystemLibrary.double_type)
return 98;
else
return 1000;
}
}
type_compare tc = type_table.compare_types(from, to);
if (tc == type_compare.non_comparable_type)
return 1000;
if (!from.IsInterface && to.IsInterface)
return 2;
return 200;
if (tc == type_compare.less_type)
return 1;
{
return 100;
}
if (tc == type_compare.greater_type)
return 3;
return 300;
return 1000;
}
private function_node is_exist_eq_return_value_method(function_node fn, function_node_list funcs)
{
fn = find_eq_return_value_method_in_list(fn, funcs);

View file

@ -151,7 +151,7 @@ namespace VisualPascalABC
{
string meth = construct_header(procs[i] as CodeCompletion.ProcRealization, VisualPABCSingleton.MainForm.UserOptions.CursorTabCount);
sb.Append(meth);
sb.Append('\n');
//sb.Append('\n');
}
return sb.ToString();
}
@ -169,8 +169,15 @@ namespace VisualPascalABC
int off = textArea.Document.PositionToOffset(new TextLocation(procs[i].GetPosition().column - 1, procs[i].GetPosition().line - 1));
string meth = textArea.Document.GetText(off, textArea.Document.PositionToOffset(new TextLocation(procs[i].GetPosition().end_column - 1, procs[i].GetPosition().end_line - 1)) - off + 1);
meth = construct_header(meth, procs[i], VisualPABCSingleton.MainForm.UserOptions.CursorTabCount);
sb.Append(meth);
if (i < procs.Length - 1) sb.Append('\n');
if (i < procs.Length - 1)
{
sb.Append(meth);
sb.Append('\n');
}
else
sb.Append(meth.Trim());
}
return sb.ToString();
}