From c3041fd6f1028d0a2e361706e95610634fa86c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Thu, 28 Dec 2017 11:31:05 +0100 Subject: [PATCH] bug fix #618 --- TestSuite/CompilationSamples/PABCSystem.pas | 57 +++++++------------ TestSuite/implicitexplicit4.pas | 4 ++ .../TreeConversion/syntax_tree_visitor.cs | 3 + bin/Lib/PABCSystem.pas | 3 +- 4 files changed, 28 insertions(+), 39 deletions(-) create mode 100644 TestSuite/implicitexplicit4.pas diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 1f85dbf09..f5807b68a 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -104,6 +104,9 @@ type /// Представляет произвольно большое целое число BigInteger = System.Numerics.BigInteger; + + /// Представляет дату и время + DateTime = System.DateTime; /// Представляет комплексное число Complex = System.Numerics.Complex; @@ -3251,7 +3254,7 @@ begin end; //------------------------------------------------------------------------------ -// Operations for String +// Операции для string и char //------------------------------------------------------------------------------ procedure string.operator+=(var left: string; right: string); begin @@ -3344,6 +3347,13 @@ end; function string.operator in(substr: string; str: string) := str.Contains(substr); +procedure operator+=(var left: StringBuilder; right: string); extensionmethod := left.Append(right); + +function operator implicit(s: string): StringBuilder; extensionmethod; +begin + Result := new StringBuilder(s); +end; + //------------------------------------------------------------------------------ // Операции для array of T //------------------------------------------------------------------------------ @@ -3663,50 +3673,23 @@ function BigInteger.operator-(p: BigInteger) := BigInteger.Negate(p); //------------------------------------------------------------------------------ // Операции для Complex //------------------------------------------------------------------------------ -function operator-(Self: Complex): Complex; extensionmethod; -begin - Result := Complex.Negate(Self); -end; +function operator-(Self: Complex): Complex; extensionmethod := Complex.Negate(Self); -function operator implicit(c: (real,real)): Complex; extensionmethod; -begin - Result := Cplx(c[0],c[1]); -end; +function operator implicit(c: (real,real)): Complex; extensionmethod := Cplx(c[0],c[1]); -function operator implicit(c: (real,integer)): Complex; extensionmethod; -begin - Result := Cplx(c[0],c[1]); -end; +function operator implicit(c: (real,integer)): Complex; extensionmethod := Cplx(c[0],c[1]); -function operator implicit(c: (integer,real)): Complex; extensionmethod; -begin - Result := Cplx(c[0],c[1]); -end; +function operator implicit(c: (integer,real)): Complex; extensionmethod := Cplx(c[0],c[1]); -function operator implicit(c: (integer,integer)): Complex; extensionmethod; -begin - Result := Cplx(c[0],c[1]); -end; +function operator implicit(c: (integer,integer)): Complex; extensionmethod := Cplx(c[0],c[1]); -procedure operator+=(var c: Complex; x: Complex); extensionmethod; -begin - c := c + x; -end; +procedure operator+=(var c: Complex; x: Complex); extensionmethod := c := c + x; -procedure operator*=(var c: Complex; x: Complex); extensionmethod; -begin - c := c * x; -end; +procedure operator*=(var c: Complex; x: Complex); extensionmethod := c := c * x; -procedure operator-=(var c: Complex; x: Complex); extensionmethod; -begin - c := c - x; -end; +procedure operator-=(var c: Complex; x: Complex); extensionmethod := c := c - x; -procedure operator/=(var c: Complex; x: Complex); extensionmethod; -begin - c := c / x; -end; +procedure operator/=(var c: Complex; x: Complex); extensionmethod := c := c / x; //------------------------------------------------------------------------------ // Операции для sequence of T diff --git a/TestSuite/implicitexplicit4.pas b/TestSuite/implicitexplicit4.pas new file mode 100644 index 000000000..fa163fdee --- /dev/null +++ b/TestSuite/implicitexplicit4.pas @@ -0,0 +1,4 @@ +begin + var sb: StringBuilder := 'abc'; + assert(sb.ToString() = 'abc'); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 0f76dc2fc..3221213a6 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -13619,6 +13619,9 @@ namespace PascalABCCompiler.TreeConverter case semantic_node_type.basic_function_call: constant = new basic_function_call_as_constant(exprc as basic_function_call, loc); break; + case semantic_node_type.common_namespace_function_call: + constant = new common_namespace_function_call_as_constant(exprc as common_namespace_function_call, loc); + break; default: constant = exprc as constant_node; break; diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index aa2c85402..f5807b68a 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -3352,8 +3352,7 @@ procedure operator+=(var left: StringBuilder; right: string); extensionmethod := function operator implicit(s: string): StringBuilder; extensionmethod; begin Result := new StringBuilder(s); -end; - +end; //------------------------------------------------------------------------------ // Операции для array of T