diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index a9efd6fe7..538cc9344 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -369,6 +369,8 @@ namespace CodeCompletion { if (ts is TypeSynonim) return GetExtensionMethods((ts as TypeSynonim).actType); + if (ts.original_type != null) + return GetExtensionMethods(ts.original_type); List lst = new List(); List meths = null; TypeScope tmp_ts = ts; diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index eb0511095..228722f13 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "3"; public const string Build = "5"; - public const string Revision = "1650"; + public const string Revision = "1657"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index 5a7d2f5a4..66e43e818 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=3 -%REVISION%=1650 %COREVERSION%=5 +%REVISION%=1657 +%MINOR%=3 %MAJOR%=3 diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index 2390dc7b8..3333e6422 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -10399,7 +10399,9 @@ namespace PascalABCCompiler.NETGenerator il.Emit(OpCodes.Stloc, lb); il.Emit(OpCodes.Call, _monitor_enter); il.BeginExceptionBlock(); + bool safe_block = EnterSafeBlock(); ConvertStatement(value.Body); + LeaveSafeBlock(safe_block); il.BeginFinallyBlock(); il.Emit(OpCodes.Ldloc, lb); il.Emit(OpCodes.Call, _monitor_exit); diff --git a/ParserTools/ParserTools/DefaultLanguageInformation.cs b/ParserTools/ParserTools/DefaultLanguageInformation.cs index ce8306eff..3fb021b0e 100644 --- a/ParserTools/ParserTools/DefaultLanguageInformation.cs +++ b/ParserTools/ParserTools/DefaultLanguageInformation.cs @@ -1801,7 +1801,7 @@ namespace PascalABCCompiler.Parsers if (extensionType == null) sb.Append(GetShortTypeName(scope.CompiledMethod.GetParameters()[0].ParameterType)); } - if (scope.Name != "Invoke") + //if (scope.Name != "Invoke") { if (extensionType == null) sb.Append("."); diff --git a/ParserTools/SyntaxTreeVisitors/SyntaxTreeComparer.cs b/ParserTools/SyntaxTreeVisitors/SyntaxTreeComparer.cs index 48212a423..520792a4e 100644 --- a/ParserTools/SyntaxTreeVisitors/SyntaxTreeComparer.cs +++ b/ParserTools/SyntaxTreeVisitors/SyntaxTreeComparer.cs @@ -658,12 +658,27 @@ namespace PascalABCCompiler.SyntaxTree CompareInternal(left as function_lambda_definition, right as function_lambda_definition); else if (left is tuple_node) CompareInternal(left as tuple_node, right as tuple_node); + else if (left is slice_expr) + CompareInternal(left as slice_expr, right as slice_expr); else throw new NotImplementedException(left.GetType().ToString()); } } + public void CompareInternal(slice_expr left, slice_expr right) + { + if (left == null && right != null || left != null && right == null) + throw_not_equal(left, right); + if (left != null && right != null) + { + CompareInternal(left.v, right.v); + CompareInternal(left.from, right.from); + CompareInternal(left.step, right.step); + CompareInternal(left.to, right.to); + } + } + public void CompareInternal(expression_as_statement left, expression_as_statement right) { if (left == null && right != null || left != null && right == null) diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index f218fab5e..a33a84362 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -3254,10 +3254,13 @@ variable if (el.Count==1 && el.expressions[0] is format_expr) { var fe = el.expressions[0] as format_expr; - if (fe.expr == null) - fe.expr = new int32_const(int.MaxValue,@3); - if (fe.format1 == null) - fe.format1 = new int32_const(int.MaxValue,@3); + if (!parsertools.build_tree_for_formatter) + { + if (fe.expr == null) + fe.expr = new int32_const(int.MaxValue,@3); + if (fe.format1 == null) + fe.format1 = new int32_const(int.MaxValue,@3); + } $$ = new slice_expr($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$); } else $$ = new indexer($1 as addressed_value,el, @$); diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index 2260b118e..a554f5b83 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -5355,10 +5355,13 @@ public partial class GPPGParser: ShiftReduceParser = class end; + +procedure p1(self:t1); extensionmethod := exit; + +begin + var a := new t1; + a.p1{@(расширение) procedure t1.p1();@}; +end. \ No newline at end of file diff --git a/TestSuite/lock1.pas b/TestSuite/lock1.pas new file mode 100644 index 000000000..c9844baf8 --- /dev/null +++ b/TestSuite/lock1.pas @@ -0,0 +1,54 @@ +type t1 = class end;//любой ссылочный тип + +var i: integer; + +procedure p1; +begin + lock new t1 do + begin + i := 1; + exit; + end; +end; + +procedure p2; +begin + loop 1 do + lock new t1 do + begin + i := 2; + continue; + end; +end; + +procedure p3; +begin + loop 1 do + lock new t1 do + begin + i := 3; + break; + end; +end; + +procedure p4; +label l1; +begin + lock new t1 do + begin + i := 4; + goto l1; + end; + l1: +end; + +begin + p1; + assert(i = 1); + p2; + assert(i = 2); + p3; + assert(i = 3); + p4; + assert(i = 4); +end. \ No newline at end of file diff --git a/TestSuite/question5.pas b/TestSuite/question5.pas new file mode 100644 index 000000000..8378330fb --- /dev/null +++ b/TestSuite/question5.pas @@ -0,0 +1,6 @@ +function f1 := 1; +function f2 := 0; +begin + var i := true ? f1 : f2; + assert(i = 1); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 2fbfead5d..b1cdb35b1 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -1120,7 +1120,7 @@ namespace PascalABCCompiler.TreeConverter } #endif - function_node fn = ((function_node)(sic.sym_info)); + function_node fn = (function_node)sic.sym_info; if (convertion_data_and_alghoritms.is_exist_eq_method_in_list(fn, funcs) == null) { //break; @@ -1186,7 +1186,7 @@ namespace PascalABCCompiler.TreeConverter } else { - if ((sil == null) && (sil2 != null)) + if (sil == null && sil2 != null) { sil = sil2; } @@ -16777,7 +16777,8 @@ namespace PascalABCCompiler.TreeConverter condition = convertion_data_and_alghoritms.convert_type(condition, SystemLibrary.SystemLibrary.bool_type); expression_node left = convert_strong(node.ret_if_true); expression_node right = convert_strong(node.ret_if_false); - + try_convert_typed_expression_to_function_call(ref left); + try_convert_typed_expression_to_function_call(ref right); /*var typeComparisonResult = type_table.compare_types(left.type, right.type); if (typeComparisonResult == type_compare.greater_type) right = convertion_data_and_alghoritms.convert_type(right, left.type); diff --git a/bin/Lib/Controls.pas b/bin/Lib/Controls.pas index 9ac8e9366..7e26b9a43 100644 --- a/bin/Lib/Controls.pas +++ b/bin/Lib/Controls.pas @@ -221,6 +221,7 @@ type begin element := new Slider; sl.ValueChanged += procedure(o,e) -> ValueChangedP; + sl.TickPlacement := System.Windows.Controls.Primitives.TickPlacement.BottomRight; sl.Minimum := min; sl.Maximum := max; sl.Value := val; diff --git a/bin/Lib/Graph3D.pas b/bin/Lib/Graph3D.pas index 16f6c8104..0d54aaecf 100644 --- a/bin/Lib/Graph3D.pas +++ b/bin/Lib/Graph3D.pas @@ -34,7 +34,11 @@ type TupleInt3 = (integer, integer, integer); TupleReal3 = (real, real, real); Point3D = Point3D; + Vector3D = Vector3D; Point = System.Windows.Point; + Ray3D = HelixToolkit.Wpf.Ray3D; + Line3D = class(Ray3D) end; + Plane3D = HelixToolkit.Wpf.Plane3D; var hvp: HelixViewport3D; @@ -2017,6 +2021,25 @@ type constructor(x, y, z, Length: real; m: GMaterial) := CreateBase(new OctahedronVisual3D(Length), x, y, z, m); function Clone := (inherited Clone) as OctahedronT; end; + + TriangleVisual3D = class(MeshElement3D) + private + p1,p2,p3: Point3D; + public + constructor(pp1,pp2,pp3: Point3D); + begin + (p1, p2, p3) := (pp1,pp2,pp3); + Material := Colors.Red; + OnGeometryChanged; + end; + function Tessellate(): MeshGeometry3D; override; + begin + var pmb := new PanelModelBuilder(); + pmb.AddPanel(p1.X, p1.Y, p1.Z, p2.X, p2.Y, p2.Z, p3.X, p3.Y, p3.Z, p1.X, p1.Y, p1.Z); + Result := pmb.ToMeshGeometry3D + end; + end; + PrismVisual3D = class(MeshElement3D) private @@ -2362,7 +2385,7 @@ type end; end; -function FindObject3D(x,y: real): Object3D; +function FindNearestObject(x,y: real): Object3D; begin Result := nil; var v := hvp.FindNearestVisual(new Point(x,y)); @@ -2371,6 +2394,54 @@ begin Result := obj end; +var BadPoint := P3D(real.MaxValue,real.MaxValue,real.MaxValue); + +function FindNearestObjectPoint(x,y: real): Point3D; +begin + var p1 := hvp.FindNearestPoint(Pnt(x,y)); + if p1.HasValue then + Result := p1.Value + else Result := BadPoint; +end; + +function Plane(p: Point3D; normal: Vector3D): Plane3D := new Plane3D(p,normal); +function Ray(p: Point3D; v: Vector3D): Ray3D := new Ray3D(p,v); +function Line(p: Point3D; v: Vector3D): Line3D := new Line3D(p,v); +function Line(p1,p2: Point3D): Line3D := new Line3D(p1,p2-p1); + +var + PlaneXY := Plane(Origin,OrtZ); + PlaneYZ := Plane(Origin,OrtX); + PlaneXZ := Plane(Origin,OrtY); + XAxis := Ray(Origin,OrtX); + YAxis := Ray(Origin,OrtY); + ZAxis := Ray(Origin,OrtZ); + +function GetRay(x,y: real): Ray3D := hvp.Viewport.GetRay(Pnt(x,y)); + +function PointOnPlane(Self: Plane3D; x,y: real): Point3D; extensionmethod; +begin + var r := GetRay(x,y); + //Println(r); + var p1 := r.PlaneIntersection(Self.Position,Self.Normal); + if p1.HasValue then + Result := p1.Value + else Result := BadPoint; +end; + +function NearestPointOnLine(Self: Ray3D; x,y: real): Point3D; extensionmethod; +begin + var ray := GetRay(x,y); + var a := Self.Direction; + var b := ray.Direction; + var ab := Vector3D.CrossProduct(a,b); + var planeNormal := Vector3D.CrossProduct(b,ab); + var p := Self.PlaneIntersection(ray.Origin,planeNormal); + if p.HasValue then + Result := p.Value + else Result := BadPoint; +end; + function DefaultMaterialColor := RandomColor; function DefaultMaterial := MaterialHelper.CreateMaterial(DefaultMaterialColor); @@ -2482,11 +2553,14 @@ function Segment3D(p1, p2: Point3D; thickness: real := 1.2; c: Color := GrayColo function Torus(x, y, z, Diameter, TubeDiameter: real; m: Material := DefaultMaterial): TorusT := Inv(()->TorusT.Create(x,y,z,Diameter, TubeDiameter, m)); function Torus(p: Point3D; Diameter, TubeDiameter: real; m: Material := DefaultMaterial): TorusT := Torus(p.x,p.y,p.z,Diameter,TubeDiameter,m); +function Triangle(p1,p2,p3: Point3D): TriangleVisual3D := Inv(()->TriangleVisual3D.Create(p1,p2,p3)); + function MyH(x, y, z, Length: real; c: Color): MyAnyT := Inv(()->MyAnyT.Create(x, y, z, Length, c)); function MyH(x, y, z, Length: real; c: Material): MyAnyT := Inv(()->MyAnyT.Create(x, y, z, Length, c)); function Any(x, y, z: real; c: Color): AnyT := Inv(()->AnyT.Create(x, y, z, c)); + procedure ProbaP; begin //var m := MaterialHelper.CreateMaterial(Brushes.Green,100,100);