Merge branch 'master' into features/typeclasses-another-approach

# Conflicts:
#	Parsers/PascalABCParserNewSaushkin/ABCPascal.cs
#	Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs
This commit is contained in:
Bogdan Voloshin 2018-04-10 17:25:40 +03:00
commit 95cf30dba5
17 changed files with 213 additions and 17 deletions

View file

@ -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<ProcScope> lst = new List<ProcScope>();
List<ProcScope> meths = null;
TypeScope tmp_ts = ts;

View file

@ -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;

View file

@ -1,4 +1,4 @@
%MINOR%=3
%REVISION%=1650
%COREVERSION%=5
%REVISION%=1657
%MINOR%=3
%MAJOR%=3

View file

@ -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);

View file

@ -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(".");

View file

@ -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)

View file

@ -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, @$);

View file

@ -5355,10 +5355,13 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
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,LocationStack[LocationStack.Depth-2]);
if (fe.format1 == null)
fe.format1 = new int32_const(int.MaxValue,LocationStack[LocationStack.Depth-2]);
if (!parsertools.build_tree_for_formatter)
{
if (fe.expr == null)
fe.expr = new int32_const(int.MaxValue,LocationStack[LocationStack.Depth-2]);
if (fe.format1 == null)
fe.format1 = new int32_const(int.MaxValue,LocationStack[LocationStack.Depth-2]);
}
CurrentSemanticValue.ex = new slice_expr(ValueStack[ValueStack.Depth-4].ex as addressed_value,fe.expr,fe.format1,fe.format2,CurrentLocationSpan);
}
else CurrentSemanticValue.ex = new indexer(ValueStack[ValueStack.Depth-4].ex as addressed_value,el, CurrentLocationSpan);

View file

@ -1 +1 @@
!define VERSION '3.3.5.1650'
!define VERSION '3.3.5.1657'

View file

@ -35,6 +35,7 @@ type
TupleReal3 = (real, real, real);
Point3D = Point3D;
Point = System.Windows.Point;
Ray3D = HelixToolkit.Wpf.Ray3D;
var
hvp: HelixViewport3D;
@ -1044,6 +1045,7 @@ type
end;
da := AddDoubleAnimByName(sb, angle, seconds, ttname, AxisAngleRotation3D.AngleProperty, wait);
var (d1,d2) := (da.BeginTime,da.Duration);
end;
public
@ -2371,6 +2373,26 @@ begin
Result := obj
end;
function FindNearestPoint(x,y: real; var p: Point3D): boolean;
begin
var p1 := hvp.FindNearestPoint(Pnt(x,y));
Result := p1.HasValue;
if p1.HasValue then
p := p1.Value
else p := P3D(0,0,0);
end;
function GetRay(x,y: real): Ray3D := hvp.Viewport.GetRay(Pnt(x,y));
function PlaneIntersection(x,y: real; p: Point3D; v: Vector3D; var pr: Point3D): boolean;
begin
var p1 := GetRay(x,y).PlaneIntersection(p,v);
Result := p1.HasValue;
if p1.HasValue then
pr := p1.Value
else pr := P3D(0,0,0);
end;
function DefaultMaterialColor := RandomColor;
function DefaultMaterial := MaterialHelper.CreateMaterial(DefaultMaterialColor);

View file

@ -0,0 +1,5 @@
begin
var a := arr(1,2,3);
a[:2].println;
a[2:].println
end.

View file

@ -0,0 +1,8 @@
type t1<T> = class end;
procedure p1(self:t1<T>); extensionmethod := exit;
begin
var a := new t1<byte>;
a.p1{@(расширение) procedure t1<T>.p1();@};
end.

54
TestSuite/lock1.pas Normal file
View file

@ -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.

6
TestSuite/question5.pas Normal file
View file

@ -0,0 +1,6 @@
function f1 := 1;
function f2 := 0;
begin
var i := true ? f1 : f2;
assert(i = 1);
end.

View file

@ -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);

View file

@ -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;

View file

@ -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);