bug fix #671
This commit is contained in:
parent
490697a3e9
commit
64a33a0d38
19
TestSuite/CompilationSamples/CreateElementFromMatrix.pas
Normal file
19
TestSuite/CompilationSamples/CreateElementFromMatrix.pas
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
{function GetElementFromMatrix(fname: string; i, j: integer): integer;
|
||||||
|
begin
|
||||||
|
assert((fname <> '') and (i > 0) and (j > 0));
|
||||||
|
try
|
||||||
|
var f := OpenBinary&<integer>(fname);
|
||||||
|
try
|
||||||
|
var arr := f.Elements.ToArray;
|
||||||
|
var size := round(sqrt(f.FileSize));
|
||||||
|
finally
|
||||||
|
f.Close;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
writeln('File Error');
|
||||||
|
end;
|
||||||
|
end;}
|
||||||
|
|
||||||
|
begin
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
@ -122,6 +122,7 @@ function InvokeString(d: Func0<string>): string := Invoke&<String>(d);
|
||||||
function InvokeReal(d: Func0<real>): real := Invoke&<Real>(d);
|
function InvokeReal(d: Func0<real>): real := Invoke&<Real>(d);
|
||||||
function InvokeBoolean(d: Func0<boolean>): boolean := Invoke&<boolean>(d);
|
function InvokeBoolean(d: Func0<boolean>): boolean := Invoke&<boolean>(d);
|
||||||
function InvokeInteger(d: Func0<integer>): integer := Invoke&<integer>(d);
|
function InvokeInteger(d: Func0<integer>): integer := Invoke&<integer>(d);
|
||||||
|
function Inv<T>(p: ()->T): T := Invoke&<T>(p); // Теперь это работает!
|
||||||
|
|
||||||
function wplus := SystemParameters.WindowResizeBorderThickness.Left + SystemParameters.WindowResizeBorderThickness.Right;
|
function wplus := SystemParameters.WindowResizeBorderThickness.Left + SystemParameters.WindowResizeBorderThickness.Right;
|
||||||
|
|
||||||
|
|
@ -426,7 +427,7 @@ type
|
||||||
function GetPos: Point3D := Invoke&<Point3D>(()->P3D(transltransform.OffsetX, transltransform.OffsetY, transltransform.OffsetZ));
|
function GetPos: Point3D := Invoke&<Point3D>(()->P3D(transltransform.OffsetX, transltransform.OffsetY, transltransform.OffsetZ));
|
||||||
|
|
||||||
protected
|
protected
|
||||||
function CreateObject: Object3D; virtual;
|
function CreateObject: Object3D; virtual; // нужно для клонирования
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
@ -629,6 +630,8 @@ type
|
||||||
begin
|
begin
|
||||||
CreateBase0(m, x, y, z);
|
CreateBase0(m, x, y, z);
|
||||||
m.Material := mat;
|
m.Material := mat;
|
||||||
|
//MaterialHelper.ChangeOpacity(mat,0.1);
|
||||||
|
//MaterialHelper.ChangeOpacity(BackMaterial,0.1);
|
||||||
//m.BackMaterial := nil;
|
//m.BackMaterial := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -1183,17 +1186,14 @@ function MyAnimation.&Then(second: MyAnimation): MyAnimation := Self + second;
|
||||||
type
|
type
|
||||||
SphereT = class(ObjectWithMaterial3D)
|
SphereT = class(ObjectWithMaterial3D)
|
||||||
private
|
private
|
||||||
procedure SetR(r: real);
|
function Model := inherited model as SphereVisual3D;
|
||||||
begin
|
procedure SetRP(r: real) := Model.Radius := r;
|
||||||
var m := model as SphereVisual3D;
|
procedure SetR(r: real) := Invoke(SetRP,r);
|
||||||
Invoke(()->begin m.Radius := r end);
|
function GetR: real := InvokeReal(()->Model.Radius);
|
||||||
end;
|
|
||||||
|
|
||||||
function GetR: real := InvokeReal(()->(model as SphereVisual3D).Radius);
|
|
||||||
function NewVisualObject(r: real): SphereVisual3D;
|
function NewVisualObject(r: real): SphereVisual3D;
|
||||||
begin
|
begin
|
||||||
var sph := new SphereVisual3D;
|
var sph := new SphereVisual3D;
|
||||||
sph.Center := P3D(0, 0, 0);
|
sph.Center := Origin;
|
||||||
sph.Radius := r;
|
sph.Radius := r;
|
||||||
Result := sph;
|
Result := sph;
|
||||||
end;
|
end;
|
||||||
|
|
@ -1211,25 +1211,25 @@ type
|
||||||
private
|
private
|
||||||
function Model := inherited model as EllipsoidVisual3D;
|
function Model := inherited model as EllipsoidVisual3D;
|
||||||
procedure SetRXP(r: real) := Model.RadiusX := r;
|
procedure SetRXP(r: real) := Model.RadiusX := r;
|
||||||
procedure SetRX(r: real) := Invoke(SetRXP, x);
|
procedure SetRX(r: real) := Invoke(SetRXP, r);
|
||||||
function GetRX: real := InvokeReal(()->Model.RadiusX);
|
function GetRX: real := InvokeReal(()->Model.RadiusX);
|
||||||
procedure SetRYP(r: real) := Model.RadiusY := r;
|
procedure SetRYP(r: real) := Model.RadiusY := r;
|
||||||
procedure SetRY(r: real) := Invoke(SetRYP, x);
|
procedure SetRY(r: real) := Invoke(SetRYP, r);
|
||||||
function GetRY: real := InvokeReal(()->Model.RadiusY);
|
function GetRY: real := InvokeReal(()->Model.RadiusY);
|
||||||
procedure SetRZP(r: real) := Model.RadiusZ := r;
|
procedure SetRZP(r: real) := Model.RadiusZ := r;
|
||||||
procedure SetRZ(r: real) := Invoke(SetRZP, x);
|
procedure SetRZ(r: real) := Invoke(SetRZP, r);
|
||||||
function GetRZ: real := InvokeReal(()->Model.RadiusZ);
|
function GetRZ: real := InvokeReal(()->Model.RadiusZ);
|
||||||
function NewVisualObject(rx, ry, rz: real): HelixToolkit.Wpf.EllipsoidVisual3D;
|
function NewVisualObject(rx, ry, rz: real): EllipsoidVisual3D;
|
||||||
begin
|
begin
|
||||||
var ell := new EllipsoidVisual3D;
|
var ell := new EllipsoidVisual3D;
|
||||||
ell.Center := P3D(0, 0, 0);
|
ell.Center := Origin;
|
||||||
ell.RadiusX := rx;
|
ell.RadiusX := rx;
|
||||||
ell.RadiusY := ry;
|
ell.RadiusY := ry;
|
||||||
ell.RadiusZ := rz;
|
ell.RadiusZ := rz;
|
||||||
Result := ell;
|
Result := ell;
|
||||||
end;
|
end;
|
||||||
protected
|
protected
|
||||||
function CreateObject: Object3D; override := new EllipsoidT(X, Y, Z, RadiusX, RadiusY, RadiusZ, Material);
|
function CreateObject: Object3D; override := new EllipsoidT(X, Y, Z, RadiusX, RadiusY, RadiusZ, Material.Clone);
|
||||||
public
|
public
|
||||||
constructor(x, y, z, rx, ry, rz: real; m: GMaterial) := CreateBase(NewVisualObject(rx, ry, rz), x, y, z, m);
|
constructor(x, y, z, rx, ry, rz: real; m: GMaterial) := CreateBase(NewVisualObject(rx, ry, rz), x, y, z, m);
|
||||||
|
|
||||||
|
|
@ -1239,6 +1239,29 @@ type
|
||||||
function Clone := (inherited Clone) as EllipsoidT;
|
function Clone := (inherited Clone) as EllipsoidT;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
CubeT = class(ObjectWithMaterial3D)
|
||||||
|
private
|
||||||
|
function model := inherited model as CubeVisual3D;
|
||||||
|
procedure SetWP(r: real) := model.SideLength := r;
|
||||||
|
procedure SetW(r: real) := Invoke(SetWP, r);
|
||||||
|
function GetW: real := InvokeReal(()->model.SideLength);
|
||||||
|
private
|
||||||
|
function NewVisualObject(w: real): CubeVisual3D;
|
||||||
|
begin
|
||||||
|
var bx := new CubeVisual3D;
|
||||||
|
bx.Center := Origin;
|
||||||
|
bx.SideLength := w;
|
||||||
|
Result := bx;
|
||||||
|
end;
|
||||||
|
protected
|
||||||
|
function CreateObject: Object3D; override := new CubeT(X, Y, Z, SideLength, Material.Clone);
|
||||||
|
public
|
||||||
|
constructor(x, y, z, w: real; m: GMaterial) := CreateBase(NewVisualObject(w), x, y, z, m);
|
||||||
|
|
||||||
|
property SideLength: real read GetW write SetW;
|
||||||
|
function Clone := (inherited Clone) as CubeT;
|
||||||
|
end;
|
||||||
|
|
||||||
BoxT = class(ObjectWithMaterial3D)
|
BoxT = class(ObjectWithMaterial3D)
|
||||||
private
|
private
|
||||||
function model := inherited model as BoxVisual3D;
|
function model := inherited model as BoxVisual3D;
|
||||||
|
|
@ -1255,14 +1278,13 @@ type
|
||||||
function GetL: real := InvokeReal(()->model.Length);
|
function GetL: real := InvokeReal(()->model.Length);
|
||||||
|
|
||||||
procedure SetSzP(r: Size3D) := (model.Length, model.Width, model.Height) := (r.X, r.Y, r.Z);
|
procedure SetSzP(r: Size3D) := (model.Length, model.Width, model.Height) := (r.X, r.Y, r.Z);
|
||||||
|
|
||||||
procedure SetSz(r: Size3D) := Invoke(SetSzP, r);
|
procedure SetSz(r: Size3D) := Invoke(SetSzP, r);
|
||||||
function GetSz: Size3D := Invoke&<Size3D>(()->begin Result := Sz3D(model.Length, model.Width, model.Height) end);
|
function GetSz: Size3D := Inv(()->Sz3D(model.Length, model.Width, model.Height));
|
||||||
private
|
private
|
||||||
function NewVisualObject(l, w, h: real): BoxVisual3D;
|
function NewVisualObject(l, w, h: real): BoxVisual3D;
|
||||||
begin
|
begin
|
||||||
var bx := new BoxVisual3D;
|
var bx := new BoxVisual3D;
|
||||||
bx.Center := P3D(0, 0, 0);
|
bx.Center := Origin;
|
||||||
(bx.Width, bx.Height, bx.Length) := (w, h, l);
|
(bx.Width, bx.Height, bx.Length) := (w, h, l);
|
||||||
Result := bx;
|
Result := bx;
|
||||||
end;
|
end;
|
||||||
|
|
@ -2330,124 +2352,120 @@ type
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// function Inv<T>(p: ()->T): T := Invoke&<T>(p); // посмотреть, почему не выводится!
|
function DefaultMaterialColor := RandomColor;
|
||||||
|
|
||||||
var DefaultMaterialColor := Colors.Red;
|
|
||||||
function DefaultMaterial := MaterialHelper.CreateMaterial(DefaultMaterialColor);
|
function DefaultMaterial := MaterialHelper.CreateMaterial(DefaultMaterialColor);
|
||||||
|
|
||||||
function Group(x, y, z: integer): GroupT := Invoke&<GroupT>(()->GroupT.Create(x, y, z));
|
function Group(x, y, z: integer): GroupT := Inv(()->GroupT.Create(x, y, z));
|
||||||
function Group(p: Point3D): GroupT := Invoke&<GroupT>(()->GroupT.Create(p.x, p.y, p.z));
|
function Group(p: Point3D): GroupT := Inv(()->GroupT.Create(p.x, p.y, p.z));
|
||||||
function Group: GroupT := Invoke&<GroupT>(()->GroupT.Create(0, 0, 0));
|
function Group: GroupT := Inv(()->GroupT.Create(0, 0, 0));
|
||||||
function Group(params lst: array of Object3D): GroupT := Invoke&<GroupT>(()->GroupT.Create(0, 0, 0, lst));
|
function Group(params lst: array of Object3D): GroupT := Inv(()->GroupT.Create(0, 0, 0, lst));
|
||||||
function Group(en: sequence of Object3D): GroupT := Invoke&<GroupT>(()->GroupT.Create(0, 0, 0, en));
|
function Group(en: sequence of Object3D): GroupT := Inv(()->GroupT.Create(0, 0, 0, en));
|
||||||
|
|
||||||
function Sphere(x, y, z, r: real; m: Material := DefaultMaterial): SphereT := Invoke&<SphereT>(()->SphereT.Create(x, y, z, r, m));
|
function Sphere(x, y, z, Radius: real; m: Material := DefaultMaterial): SphereT := Inv(()->SphereT.Create(x, y, z, Radius, m));
|
||||||
function Sphere(center: Point3D; r: real; m: Material := DefaultMaterial) := Sphere(center.x, center.y, center.z, r, m);
|
function Sphere(center: Point3D; Radius: real; m: Material := DefaultMaterial) := Sphere(center.x, center.y, center.z, Radius, m);
|
||||||
|
|
||||||
function Ellipsoid(x, y, z, rx, ry, rz: real; m: Material := DefaultMaterial): EllipsoidT := Invoke&<EllipsoidT>(()->EllipsoidT.Create(x, y, z, rx, ry, rz, m));
|
function Ellipsoid(x, y, z, RadiusX, RadiusY, RadiusZ: real; m: Material := DefaultMaterial): EllipsoidT := Inv(()->EllipsoidT.Create(x, y, z, RadiusX, RadiusY, RadiusZ, m));
|
||||||
function Ellipsoid(center: Point3D; rx, ry, rz: real; m: Material := DefaultMaterial): EllipsoidT := Ellipsoid(center.x, center.y, center.z, rx, ry, rz, m);
|
function Ellipsoid(center: Point3D; RadiusX, RadiusY, RadiusZ: real; m: Material := DefaultMaterial) := Ellipsoid(center.x, center.y, center.z, RadiusX, RadiusY, RadiusZ, m);
|
||||||
|
|
||||||
function Box(x, y, z, l, w, h: real; m: Material := DefaultMaterial): BoxT := Invoke&<BoxT>(()->BoxT.Create(x, y, z, l, w, h, m));
|
function Cube(x, y, z, SideLength: real; m: Material := DefaultMaterial): CubeT := Inv(()->CubeT.Create(x, y, z, SideLength, m));
|
||||||
function Box(center: Point3D; sz: Size3D; m: Material := DefaultMaterial): BoxT := Invoke&<BoxT>(()->BoxT.Create(center.x, center.y, center.z, sz.X, sz.Y, sz.z, m));
|
function Cube(center: Point3D; SideLength: real; m: Material := DefaultMaterial): CubeT := Cube(center.x, center.y, center.z, SideLength, m);
|
||||||
|
|
||||||
function Cube(x, y, z, w: real; m: Material := DefaultMaterial): BoxT := Box(x, y, z, w, w, w, m);
|
function Box(x, y, z, SizeX, SizeY, SizeZ: real; m: Material := DefaultMaterial): BoxT := Inv(()->BoxT.Create(x, y, z, SizeX, SizeY, SizeZ, m));
|
||||||
function Cube(center: Point3D; w: real; m: Material := DefaultMaterial): BoxT := Box(center.x, center.y, center.z, w, w, w, m);
|
function Box(center: Point3D; sz: Size3D; m: Material := DefaultMaterial): BoxT := Inv(()->BoxT.Create(center.x, center.y, center.z, sz.X, sz.Y, sz.z, m));
|
||||||
|
|
||||||
const
|
const arhl = 3; ard = 0.2;
|
||||||
arhl = 3;
|
|
||||||
ard = 0.2;
|
|
||||||
|
|
||||||
function Arrow(x, y, z, vx, vy, vz, diameter, hl: real; c: Material := DefaultMaterial): ArrowT := Invoke&<ArrowT>(()->ArrowT.Create(x, y, z, vx, vy, vz, diameter, hl, c));
|
function Arrow(x, y, z, vx, vy, vz, diameter, hl: real; m: Material := DefaultMaterial): ArrowT := Inv(()->ArrowT.Create(x, y, z, vx, vy, vz, diameter, hl, m));
|
||||||
function Arrow(x, y, z, vx, vy, vz, diameter: real; c: Material := DefaultMaterial) := Arrow(x, y, z, vx, vy, vz, diameter, arhl, c);
|
function Arrow(x, y, z, vx, vy, vz, diameter: real; m: Material := DefaultMaterial) := Arrow(x, y, z, vx, vy, vz, diameter, arhl, m);
|
||||||
function Arrow(x, y, z, vx, vy, vz: real; c: Material := DefaultMaterial): ArrowT := Arrow(x, y, z, vx, vy, vz, ard, arhl, c);
|
function Arrow(x, y, z, vx, vy, vz: real; m: Material := DefaultMaterial) := Arrow(x, y, z, vx, vy, vz, ard, arhl, m);
|
||||||
function Arrow(p: Point3D; v: Vector3D; diameter, hl: real; c: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, hl, c);
|
function Arrow(p: Point3D; v: Vector3D; diameter, hl: real; m: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, hl, m);
|
||||||
function Arrow(p: Point3D; v: Vector3D; diameter: real; c: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, arhl, c);
|
function Arrow(p: Point3D; v: Vector3D; diameter: real; m: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, arhl, m);
|
||||||
function Arrow(p: Point3D; v: Vector3D; c: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, ard, arhl, c);
|
function Arrow(p: Point3D; v: Vector3D; m: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, ard, arhl, m);
|
||||||
|
|
||||||
function TruncatedConeAux(x, y, z, height, baseradius, topradius: real; sides: integer; topcap: boolean; c: Material) := Invoke&<TruncatedConeT>(()->TruncatedConeT.Create(x, y, z, height, baseradius, topradius, sides, topcap, c));
|
function TruncatedConeAux(x, y, z, Height, Radius, TopRadius: real; sides: integer; topcap: boolean; c: Material) := Inv(()->TruncatedConeT.Create(x, y, z, Height, Radius, TopRadius, sides, topcap, c));
|
||||||
|
|
||||||
const maxsides = 37;
|
const maxsides = 37;
|
||||||
|
|
||||||
///--
|
///--
|
||||||
function TruncatedCone(x, y, z, height, baseradius, topradius: real; topcap: boolean; c: Material := DefaultMaterial): TruncatedConeT := TruncatedConeAux(x, y, z, height, baseradius, topradius, maxsides, topcap, c);
|
function TruncatedCone(x, y, z, Height, Radius, TopRadius: real; topcap: boolean; m: Material := DefaultMaterial): TruncatedConeT := TruncatedConeAux(x, y, z, Height, Radius, TopRadius, maxsides, topcap, m);
|
||||||
function TruncatedCone(x, y, z, height, baseradius, topradius: real; c: Material := DefaultMaterial) := TruncatedCone(x, y, z, height, baseradius, topradius, True, c);
|
function TruncatedCone(x, y, z, Height, Radius, TopRadius: real; m: Material := DefaultMaterial) := TruncatedCone(x, y, z, Height, Radius, TopRadius, True, m);
|
||||||
///--
|
///--
|
||||||
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; topcap: boolean; c: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, topcap, c);
|
function TruncatedCone(p: Point3D; Height, Radius, TopRadius: real; topcap: boolean; m: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, Height, Radius, TopRadius, topcap, m);
|
||||||
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; c: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, True, c);
|
function TruncatedCone(p: Point3D; Height, Radius, TopRadius: real; m: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, Height, Radius, TopRadius, True, m);
|
||||||
|
|
||||||
///--
|
///--
|
||||||
function Cylinder(x, y, z, height, radius: real; topcap: boolean; c: Material := DefaultMaterial): CylinderT := Invoke&<CylinderT>(()->CylinderT.Create(x, y, z, height, radius, maxsides, topcap, c));
|
function Cylinder(x, y, z, Height, Radius: real; topcap: boolean; m: Material := DefaultMaterial): CylinderT := Inv(()->CylinderT.Create(x, y, z, Height, Radius, maxsides, topcap, m));
|
||||||
function Cylinder(x, y, z, height, radius: real; c: Material := DefaultMaterial) := Cylinder(x, y, z, height, radius, True, c);
|
function Cylinder(x, y, z, Height, Radius: real; m: Material := DefaultMaterial) := Cylinder(x, y, z, Height, Radius, True, m);
|
||||||
///--
|
///--
|
||||||
function Cylinder(p: Point3D; height, radius: real; topcap: boolean; c: Material := DefaultMaterial) := Cylinder(p.x, p.y, p.z, height, radius, topcap, c);
|
function Cylinder(p: Point3D; Height, Radius: real; topcap: boolean; m: Material := DefaultMaterial) := Cylinder(p.x, p.y, p.z, Height, Radius, topcap, m);
|
||||||
function Cylinder(p: Point3D; height, radius: real; c: Material := DefaultMaterial) := Cylinder(p.x, p.y, p.z, height, radius, True, c);
|
function Cylinder(p: Point3D; Height, Radius: real; m: Material := DefaultMaterial) := Cylinder(p.x, p.y, p.z, Height, Radius, True, m);
|
||||||
|
|
||||||
function Tube(x, y, z, height, radius, innerradius: real; c: Material := DefaultMaterial): PipeT := Invoke&<PipeT>(()->PipeT.Create(x, y, z, height, radius, innerradius, c));
|
function Tube(x, y, z, Height, Radius, InnerRadius: real; m: Material := DefaultMaterial): PipeT := Inv(()->PipeT.Create(x, y, z, Height, Radius, InnerRadius, m));
|
||||||
function Tube(p: Point3D; height, radius, innerradius: real; c: Material := DefaultMaterial) := Tube(p.x, p.y, p.z, height, radius, innerradius, c);
|
function Tube(p: Point3D; Height, Radius, InnerRadius: real; m: Material := DefaultMaterial) := Tube(p.x, p.y, p.z, Height, Radius, InnerRadius, m);
|
||||||
|
|
||||||
function Cone(x, y, z, height, radius: real; c: Material := DefaultMaterial): TruncatedConeT := TruncatedCone(x, y, z, height, radius, 0, True, c);
|
function Cone(x, y, z, Height, Radius: real; m: Material := DefaultMaterial): TruncatedConeT := TruncatedCone(x, y, z, Height, Radius, 0, True, m);
|
||||||
function Cone(p: Point3D; height, radius: real; c: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, height, radius, 0, True, c);
|
function Cone(p: Point3D; Height, Radius: real; m: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, Height, Radius, 0, True, m);
|
||||||
|
|
||||||
function Teapot(x, y, z: real; c: Material := DefaultMaterial): TeapotT := Invoke&<TeapotT>(()->TeapotT.Create(x, y, z, c));
|
function Teapot(x, y, z: real; c: Material := DefaultMaterial): TeapotT := Inv(()->TeapotT.Create(x, y, z, c));
|
||||||
function Teapot(p: Point3D; c: Material := DefaultMaterial) := Teapot(p.x, p.y, p.z, c);
|
function Teapot(p: Point3D; c: Material := DefaultMaterial) := Teapot(p.x, p.y, p.z, c);
|
||||||
|
|
||||||
function BillboardText(x, y, z: real; text: string; fontsize: real := 12): BillboardTextT := Invoke&<BillboardTextT>(()->BillboardTextT.Create(x, y, z, text, fontsize));
|
function BillboardText(x, y, z: real; Text: string; Fontsize: real := 12): BillboardTextT := Inv(()->BillboardTextT.Create(x, y, z, text, fontsize));
|
||||||
function BillboardText(p: Point3D; text: string; fontsize: real := 12) := BillboardText(P.x, p.y, p.z, text, fontsize);
|
function BillboardText(p: Point3D; Text: string; Fontsize: real := 12) := BillboardText(P.x, p.y, p.z, text, fontsize);
|
||||||
|
|
||||||
function CoordinateSystem(arrowslength, diameter: real): CoordinateSystemT := Invoke&<CoordinateSystemT>(()->CoordinateSystemT.Create(0, 0, 0, arrowslength, diameter));
|
function CoordinateSystem(ArrowsLength, Diameter: real): CoordinateSystemT := Inv(()->CoordinateSystemT.Create(0, 0, 0, arrowslength, diameter));
|
||||||
function CoordinateSystem(arrowslength: real) := CoordinateSystem(arrowslength, arrowslength / 10);
|
function CoordinateSystem(ArrowsLength: real) := CoordinateSystem(arrowslength, arrowslength / 10);
|
||||||
|
|
||||||
function Text3D(x, y, z: real; text: string; height: real; fontname: string := 'Arial'; c: Color := Colors.Black): TextT := Invoke&<TextT>(()->TextT.Create(x, y, z, text, height, fontname, c));
|
function Text3D(x, y, z: real; Text: string; Height: real; fontname: string := 'Arial'; c: Color := Colors.Black): TextT := Inv(()->TextT.Create(x, y, z, text, height, fontname, c));
|
||||||
function Text3D(p: Point3D; text: string; height: real; fontname: string := 'Arial'; c: Color := Colors.Black) := Text3D(P.x, p.y, p.z, text, height, fontname, c);
|
function Text3D(p: Point3D; Text: string; Height: real; fontname: string := 'Arial'; c: Color := Colors.Black) := Text3D(P.x, p.y, p.z, text, height, fontname, c);
|
||||||
function Text3D(x, y, z: real; text: string; height: real; c: Color) := Text3D(x, y, z, text, height, 'Arial', c);
|
function Text3D(x, y, z: real; Text: string; Height: real; c: Color) := Text3D(x, y, z, text, height, 'Arial', c);
|
||||||
function Text3D(p: Point3D; text: string; height: real; c: Color) := Text3D(p.x, p.y, p.z, text, height, 'Arial', c);
|
function Text3D(p: Point3D; Text: string; Height: real; c: Color) := Text3D(p.x, p.y, p.z, text, height, 'Arial', c);
|
||||||
|
|
||||||
function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; c: Material := DefaultMaterial): RectangleT := Invoke&<RectangleT>(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, c));
|
function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; m: Material := DefaultMaterial): RectangleT := Inv(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, m));
|
||||||
function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; c: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, c);
|
function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; m: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, m);
|
||||||
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material := DefaultMaterial): RectangleT := Rectangle3D(x, y, z, l, w, normal, OrtX, c);
|
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; m: Material := DefaultMaterial): RectangleT := Rectangle3D(x, y, z, l, w, normal, OrtX, m);
|
||||||
function Rectangle3D(x, y, z, l, w: real; c: Material := DefaultMaterial): RectangleT := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, c);
|
function Rectangle3D(x, y, z, l, w: real; m: Material := DefaultMaterial): RectangleT := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, m);
|
||||||
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, c);
|
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; m: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, m);
|
||||||
function Rectangle3D(p: Point3D; l, w: real; c: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, c);
|
function Rectangle3D(p: Point3D; l, w: real; m: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, m);
|
||||||
|
|
||||||
/// Загружает модель из файла .obj, .3ds, .lwo, .objz, .stl, .off
|
/// Загружает модель из файла .obj, .3ds, .lwo, .objz, .stl, .off
|
||||||
function FileModel3D(x, y, z: real; fname: string; c: Material): FileModelT := Invoke&<FileModelT>(()->FileModelT.Create(x, y, z, fname, c));
|
function FileModel3D(x, y, z: real; fname: string; m: Material): FileModelT := Inv(()->FileModelT.Create(x, y, z, fname, m));
|
||||||
function FileModel3D(p: Point3D; fname: string; c: Material): FileModelT := FileModel3D(p.x, p.y, p.z, fname, c);
|
function FileModel3D(p: Point3D; fname: string; m: Material): FileModelT := FileModel3D(p.x, p.y, p.z, fname, m);
|
||||||
|
|
||||||
function Prism(x, y, z: real; Sides: integer; Radius, Height: real; c: Material := DefaultMaterial): PrismT := Invoke&<PrismT>(()->PrismT.Create(x, y, z, Sides, Radius, Height, c));
|
function Prism(x, y, z: real; Sides: integer; Height, Radius: real; m: Material := DefaultMaterial): PrismT := Inv(()->PrismT.Create(x, y, z, Sides, Radius, Height, m));
|
||||||
function Prism(p: Point3D; Sides: integer; Radius, Height: real; c: Material := DefaultMaterial): PrismT := Prism(p.X, p.Y, p.Z, Sides, Radius, Height, c);
|
function Prism(p: Point3D; Sides: integer; Height, Radius: real; m: Material := DefaultMaterial): PrismT := Prism(p.X, p.Y, p.Z, Sides, Radius, Height, m);
|
||||||
|
|
||||||
function PrismWireFrame(x, y, z: real; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := Invoke&<PrismTWireFrame>(()->PrismTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
function PrismWireFrame(x, y, z: real; Sides: integer; Height, Radius: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := Inv(()->PrismTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
||||||
function PrismWireFrame(p: Point3D; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := PrismWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
function PrismWireFrame(p: Point3D; Sides: integer; Height, Radius: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := PrismWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
||||||
|
|
||||||
function Pyramid(x, y, z: real; Sides: integer; Radius, Height: real; c: Material := DefaultMaterial): PyramidT := Invoke&<PyramidT>(()->PyramidT.Create(x, y, z, Sides, Radius, Height, c));
|
function Pyramid(x, y, z: real; Sides: integer; Height, Radius: real; m: Material := DefaultMaterial): PyramidT := Inv(()->PyramidT.Create(x, y, z, Sides, Radius, Height, m));
|
||||||
function Pyramid(p: Point3D; Sides: integer; Radius, Height: real; c: Material := DefaultMaterial): PyramidT := Pyramid(p.X, p.Y, p.Z, Sides, Radius, Height, c);
|
function Pyramid(p: Point3D; Sides: integer; Height, Radius: real; m: Material := DefaultMaterial): PyramidT := Pyramid(p.X, p.Y, p.Z, Sides, Radius, Height, m);
|
||||||
|
|
||||||
function PyramidWireFrame(x, y, z: real; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := Invoke&<PyramidTWireFrame>(()->PyramidTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
function PyramidWireFrame(x, y, z: real; Sides: integer; Height, Radius: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := Inv(()->PyramidTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
||||||
function PyramidWireFrame(p: Point3D; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := PyramidWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
function PyramidWireFrame(p: Point3D; Sides: integer; Height, Radius: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := PyramidWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
||||||
|
|
||||||
function Lego(x, y, z: real; col, r, h: integer; c: Material := DefaultMaterial): LegoT := Invoke&<LegoT>(()->LegoT.Create(x, y, z, col, r, h, c));
|
function Lego(x, y, z: real; col, r, h: integer; m: Material := DefaultMaterial): LegoT := Inv(()->LegoT.Create(x, y, z, col, r, h, m));
|
||||||
|
|
||||||
function Icosahedron(x, y, z, R: real; c: Material := DefaultMaterial): IcosahedronT := Invoke&<IcosahedronT>(()->IcosahedronT.Create(x, y, z, 4*R/Sqrt(2)/Sqrt(5+Sqrt(5)), c));
|
function Icosahedron(x, y, z, r: real; m: Material := DefaultMaterial): IcosahedronT := Inv(()->IcosahedronT.Create(x, y, z, 4*R/Sqrt(2)/Sqrt(5+Sqrt(5)), m));
|
||||||
function Dodecahedron(x, y, z, R: real; c: Material := DefaultMaterial): DodecahedronT := Invoke&<DodecahedronT>(()->DodecahedronT.Create(x, y, z, R*4/Sqrt(3)/(1+Sqrt(5)), c));
|
function Dodecahedron(x, y, z, r: real; m: Material := DefaultMaterial): DodecahedronT := Inv(()->DodecahedronT.Create(x, y, z, R*4/Sqrt(3)/(1+Sqrt(5)), m));
|
||||||
function Tetrahedron(x, y, z, R: real; c: Material := DefaultMaterial): TetrahedronT := Invoke&<TetrahedronT>(()->TetrahedronT.Create(x, y, z, 4*R/Sqrt(6), c));
|
function Tetrahedron(x, y, z, r: real; m: Material := DefaultMaterial): TetrahedronT := Inv(()->TetrahedronT.Create(x, y, z, 4*R/Sqrt(6), m));
|
||||||
function Octahedron(x, y, z, R: real; c: Material := DefaultMaterial): OctahedronT := Invoke&<OctahedronT>(()->OctahedronT.Create(x, y, z, R*Sqrt(2), c));
|
function Octahedron(x, y, z, r: real; m: Material := DefaultMaterial): OctahedronT := Inv(()->OctahedronT.Create(x, y, z, R*Sqrt(2), m));
|
||||||
function Icosahedron(p: Point3D; R: real; c: Material := DefaultMaterial): IcosahedronT := Icosahedron(p.X,p.Y,p.Z,R,c);
|
function Icosahedron(p: Point3D; r: real; m: Material := DefaultMaterial): IcosahedronT := Icosahedron(p.X,p.Y,p.Z,R,m);
|
||||||
function Dodecahedron(p: Point3D; R: real; c: Material := DefaultMaterial): DodecahedronT := Dodecahedron(p.X,p.Y,p.Z,R,c);
|
function Dodecahedron(p: Point3D; r: real; m: Material := DefaultMaterial): DodecahedronT := Dodecahedron(p.X,p.Y,p.Z,R,m);
|
||||||
function Tetrahedron(p: Point3D; R: real; c: Material := DefaultMaterial): TetrahedronT := Tetrahedron(p.X,p.Y,p.Z,R,c);
|
function Tetrahedron(p: Point3D; r: real; m: Material := DefaultMaterial): TetrahedronT := Tetrahedron(p.X,p.Y,p.Z,R,m);
|
||||||
function Octahedron(p: Point3D; R: real; c: Material := DefaultMaterial): OctahedronT := Octahedron(p.X,p.Y,p.Z,R,c);
|
function Octahedron(p: Point3D; r: real; m: Material := DefaultMaterial): OctahedronT := Octahedron(p.X,p.Y,p.Z,R,m);
|
||||||
|
|
||||||
function Segments3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create(points, thickness, c));
|
function Segments3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Inv(()->SegmentsT.Create(points, thickness, c));
|
||||||
function Polyline3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create(points.Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
function Polyline3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Inv(()->SegmentsT.Create(points.Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
||||||
function Polygon3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create((points+points.First).Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
function Polygon3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Inv(()->SegmentsT.Create((points+points.First).Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
||||||
function Segment3D(p1, p2: Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create(Seq(p1,p2), thickness, c));
|
function Segment3D(p1, p2: Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Inv(()->SegmentsT.Create(Seq(p1,p2), thickness, c));
|
||||||
|
|
||||||
function Torus(x, y, z, Diameter, TubeDianeter: real; c: Material := DefaultMaterial): TorusT := Invoke&<TorusT>(()->TorusT.Create(x,y,z,Diameter, TubeDianeter, c));
|
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, TubeDianeter: real; c: Material := DefaultMaterial): TorusT := Torus(p.x,p.y,p.z,Diameter,TubeDianeter,c);
|
function Torus(p: Point3D; Diameter, TubeDiameter: real; m: Material := DefaultMaterial): TorusT := Torus(p.x,p.y,p.z,Diameter,TubeDiameter,m);
|
||||||
|
|
||||||
function MyH(x, y, z, Length: real; c: Color): MyAnyT := Invoke&<MyAnyT>(()->MyAnyT.Create(x, y, z, Length, c));
|
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 := Invoke&<MyAnyT>(()->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 := Invoke&<AnyT>(()->AnyT.Create(x, y, z, c));
|
function Any(x, y, z: real; c: Color): AnyT := Inv(()->AnyT.Create(x, y, z, c));
|
||||||
|
|
||||||
procedure ProbaP;
|
procedure ProbaP;
|
||||||
begin
|
begin
|
||||||
|
|
|
||||||
52
TestSuite/CompilationSamples/Робот.pas
Normal file
52
TestSuite/CompilationSamples/Робот.pas
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
///Исполнитель Робот действует на прямоугольном клеточном поле. Между некоторыми клетками, а также по периметру поля находятся стены.
|
||||||
|
///Основная цель Робота – закрасить указанные клетки и переместиться в конечную клетку.
|
||||||
|
unit Робот;
|
||||||
|
|
||||||
|
uses Robot,RobotField;
|
||||||
|
|
||||||
|
procedure Вправо := Right;
|
||||||
|
procedure Влево := Left;
|
||||||
|
procedure Вверх := Up;
|
||||||
|
procedure Вниз := Down;
|
||||||
|
procedure Закрасить := Paint;
|
||||||
|
function СправаСвободно := FreeFromRight;
|
||||||
|
function СлеваСвободно := FreeFromLeft;
|
||||||
|
function СверхуСвободно := FreeFromUp;
|
||||||
|
function СнизуСвободно := FreeFromDown;
|
||||||
|
function СправаСтена := WallFromRight;
|
||||||
|
function СлеваСтена := WallFromLeft;
|
||||||
|
function СверхуСтена := WallFromUp;
|
||||||
|
function СнизуСтена := WallFromDown;
|
||||||
|
function КлеткаНеЗакрашена := CellIsFree;
|
||||||
|
function КлеткаЗакрашена := CellIsPainted;
|
||||||
|
procedure Задание(имя: string) := Task(имя);
|
||||||
|
procedure СтандартноеПоле := StandardField;
|
||||||
|
procedure Поле(n,m: integer) := Field(n,m);
|
||||||
|
|
||||||
|
begin
|
||||||
|
HelpStr :=
|
||||||
|
'Разработчик исполнителя Робот: Михалкович С.С., 2002-17 '#10#13#10#13+
|
||||||
|
'Команды исполнителя Робот:'#10#13+
|
||||||
|
' Вправо'#10#13+
|
||||||
|
' Влево'#10#13
|
||||||
|
' Вверх'#10#13+
|
||||||
|
' Вниз'#10#13
|
||||||
|
' Закрасить - закрасить текущую клетку'#10#13
|
||||||
|
' Задание(имя) - вызвать задание с указанным именем'#10#13
|
||||||
|
' СтандартноеПоле - вызвать стандартное поле'#10#13
|
||||||
|
' Поле(n,m) - вызвать поле размера n на m'#10#13
|
||||||
|
'Условия, проверяемые исполнителем Робот:'#10#13
|
||||||
|
' СправаСтена'#10#13
|
||||||
|
' СлеваСтена'#10#13
|
||||||
|
' СверхуСтена'#10#13
|
||||||
|
' СнизуСтена'#10#13
|
||||||
|
' СправаСвободно'#10#13
|
||||||
|
' СлеваСвободно'#10#13
|
||||||
|
' СверхуСвободно'#10#13
|
||||||
|
' СнизуСвободно'#10#13
|
||||||
|
' КлеткаЗакрашена'#10#13
|
||||||
|
' КлеткаНеЗакрашена'#10#13;
|
||||||
|
end.
|
||||||
29
TestSuite/CompilationSamples/Чертежник.pas
Normal file
29
TestSuite/CompilationSamples/Чертежник.pas
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
///Исполнитель Чертежник предназначен для построения рисунков и чертежей на плоскости с координатами.
|
||||||
|
///Чертежник имеет перо, которое он может поднимать, опускать и перемещать. При перемещении опущенного пера за ним остается след.
|
||||||
|
unit Чертежник;
|
||||||
|
|
||||||
|
uses Drawman,DrawManField;
|
||||||
|
|
||||||
|
procedure ОпуститьПеро := PenDown;
|
||||||
|
procedure ПоднятьПеро := PenUp;
|
||||||
|
procedure КТочке(x,y: integer) := ToPoint(x,y);
|
||||||
|
procedure НаВектор(a,b: integer) := OnVector(a,b);
|
||||||
|
procedure Задание(имя: string) := Task(имя);
|
||||||
|
procedure СтандартноеПоле := StandardField;
|
||||||
|
procedure Поле(n,m: integer) := Field(n,m);
|
||||||
|
|
||||||
|
begin
|
||||||
|
HelpStr := 'Разработчик исполнителя Чертежник: Михалкович С.С., 2002-17 '#10#13#10#13+
|
||||||
|
'Команды исполнителя Чертежник:'#10#13+
|
||||||
|
' ОпуститьПеро'#10#13+
|
||||||
|
' ПоднятьПеро'#10#13
|
||||||
|
' КТочке(x,y) - переместиться в точку с координатами (x,y)'#10#13+
|
||||||
|
' НаВектор(a,b) - переместиться из текущей точки на вектор (a,b)'#10#13
|
||||||
|
' a>0 - вправо, a<0 - влево, b>0 - вверх, b<0 - вниз'#10#13
|
||||||
|
' Задание(name) - вызвать задание с указанным именем'#10#13
|
||||||
|
' СтандартноеПоле - вызвать стандартное поле'#10#13
|
||||||
|
' Поле(n,m) - вызвать поле размера n на m'#10#13#10#13;
|
||||||
|
end.
|
||||||
55
TestSuite/case6.pas
Normal file
55
TestSuite/case6.pas
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
begin
|
||||||
|
var i := 0;
|
||||||
|
case $F0000000 of
|
||||||
|
$F0000000: i := 1;
|
||||||
|
else
|
||||||
|
i := 2;
|
||||||
|
end;
|
||||||
|
assert(i = 1);
|
||||||
|
i := 0;
|
||||||
|
var ui64 := uint64.MaxValue;
|
||||||
|
case ui64 of
|
||||||
|
uint64.MaxValue: i := 1;
|
||||||
|
-2: i := 3;
|
||||||
|
else
|
||||||
|
i := 2;
|
||||||
|
end;
|
||||||
|
assert(i = 1);
|
||||||
|
i := 0;
|
||||||
|
ui64 := 2;
|
||||||
|
case ui64 of
|
||||||
|
2: i := 1;
|
||||||
|
else
|
||||||
|
i := 2;
|
||||||
|
end;
|
||||||
|
assert(i = 1);
|
||||||
|
i := 0;
|
||||||
|
var i64 := int64.MaxValue;
|
||||||
|
case i64 of
|
||||||
|
int64.MaxValue: i := 1;
|
||||||
|
uint64.MaxValue: i := 2;
|
||||||
|
end;
|
||||||
|
assert(i = 1);
|
||||||
|
i := 0;
|
||||||
|
i64 := 2;
|
||||||
|
case i64 of
|
||||||
|
2: i := 1;
|
||||||
|
else
|
||||||
|
i := 2;
|
||||||
|
end;
|
||||||
|
assert(i = 1);
|
||||||
|
i64 := 100;
|
||||||
|
i := 0;
|
||||||
|
case i64 of
|
||||||
|
5..int64.MaxValue: i := 1;
|
||||||
|
1..4: i := 2;
|
||||||
|
end;
|
||||||
|
assert(i = 1);
|
||||||
|
ui64 := 100;
|
||||||
|
i := 0;
|
||||||
|
case ui64 of
|
||||||
|
5..uint64.MaxValue: i := 1;
|
||||||
|
1..4: i := 2;
|
||||||
|
end;
|
||||||
|
assert(i = 1);
|
||||||
|
end.
|
||||||
11
TestSuite/intellisense_tests/preprocessor1.pas
Normal file
11
TestSuite/intellisense_tests/preprocessor1.pas
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
procedure p1(b: byte);
|
||||||
|
begin
|
||||||
|
{$ifdef def1}
|
||||||
|
var x: integer;
|
||||||
|
{$else}
|
||||||
|
b{@parameter b: byte;@}.ToString;
|
||||||
|
{$endif}
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
||||||
|
|
@ -9747,6 +9747,80 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
return scn;
|
return scn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long_const_node convert_long_const_to_switch(expression_node switch_expr, location loc)
|
||||||
|
{
|
||||||
|
convertion_data_and_alghoritms.convert_type(switch_expr, SystemLibrary.SystemLibrary.int64_type, loc);
|
||||||
|
if (switch_expr is long_const_node)
|
||||||
|
return switch_expr as long_const_node;
|
||||||
|
//switch_expr = convertion_data_and_alghoritms.create_simple_function_call(oti.value_to_int,
|
||||||
|
// loc, switch_expr);
|
||||||
|
long_const_node icn = null;//switch_expr as constant_node;
|
||||||
|
|
||||||
|
if (switch_expr is byte_const_node)
|
||||||
|
icn = new long_const_node((switch_expr as byte_const_node).constant_value, loc);
|
||||||
|
else if (switch_expr is sbyte_const_node)
|
||||||
|
icn = new long_const_node((long)((switch_expr as sbyte_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is short_const_node)
|
||||||
|
icn = new long_const_node((long)((switch_expr as short_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is ushort_const_node)
|
||||||
|
icn = new long_const_node((long)((switch_expr as ushort_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is uint_const_node)
|
||||||
|
icn = new long_const_node((long)((switch_expr as uint_const_node).constant_value),loc);
|
||||||
|
else if (switch_expr is int_const_node)
|
||||||
|
icn = new long_const_node((long)((switch_expr as int_const_node).constant_value),loc);
|
||||||
|
else if (switch_expr is ulong_const_node)
|
||||||
|
icn = new long_const_node((long)((switch_expr as ulong_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is enum_const_node)
|
||||||
|
icn = new long_const_node((switch_expr as enum_const_node).constant_value, loc);
|
||||||
|
else if (switch_expr is static_compiled_variable_reference && (switch_expr as static_compiled_variable_reference).var.compiled_field.IsLiteral)
|
||||||
|
icn = new long_const_node((long)(switch_expr as static_compiled_variable_reference).var.compiled_field.GetRawConstantValue(), loc);
|
||||||
|
//учти здесь модет быть и long!
|
||||||
|
//-DarkStar Add
|
||||||
|
if (icn == null)
|
||||||
|
{
|
||||||
|
AddError(loc, "CONSTANT_EXPRESSION_EXPECTED");
|
||||||
|
}
|
||||||
|
return icn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ulong_const_node convert_ulong_const_to_switch(expression_node switch_expr, location loc)
|
||||||
|
{
|
||||||
|
convertion_data_and_alghoritms.convert_type(switch_expr, SystemLibrary.SystemLibrary.uint64_type, loc);
|
||||||
|
if (switch_expr is ulong_const_node)
|
||||||
|
return switch_expr as ulong_const_node;
|
||||||
|
//switch_expr = convertion_data_and_alghoritms.create_simple_function_call(oti.value_to_int,
|
||||||
|
// loc, switch_expr);
|
||||||
|
ulong_const_node icn = null;//switch_expr as constant_node;
|
||||||
|
|
||||||
|
if (switch_expr is byte_const_node)
|
||||||
|
icn = new ulong_const_node((switch_expr as byte_const_node).constant_value, loc);
|
||||||
|
else if (switch_expr is sbyte_const_node)
|
||||||
|
icn = new ulong_const_node((ulong)((switch_expr as sbyte_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is short_const_node)
|
||||||
|
icn = new ulong_const_node((ulong)((switch_expr as short_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is ushort_const_node)
|
||||||
|
icn = new ulong_const_node((ulong)((switch_expr as ushort_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is int_const_node)
|
||||||
|
icn = new ulong_const_node((ulong)((switch_expr as int_const_node).constant_value),loc);
|
||||||
|
else if (switch_expr is uint_const_node)
|
||||||
|
icn = new ulong_const_node((ulong)((switch_expr as uint_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is long_const_node)
|
||||||
|
icn = new ulong_const_node((ulong)((switch_expr as long_const_node).constant_value),loc);
|
||||||
|
else if (switch_expr is char_const_node)
|
||||||
|
icn = new ulong_const_node((ulong)((switch_expr as char_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is enum_const_node)
|
||||||
|
icn = new ulong_const_node((ulong)((switch_expr as enum_const_node).constant_value), loc);
|
||||||
|
else if (switch_expr is static_compiled_variable_reference && (switch_expr as static_compiled_variable_reference).var.compiled_field.IsLiteral)
|
||||||
|
icn = new ulong_const_node((ulong)(switch_expr as static_compiled_variable_reference).var.compiled_field.GetRawConstantValue(), loc);
|
||||||
|
//учти здесь модет быть и long!
|
||||||
|
//-DarkStar Add
|
||||||
|
if (icn == null)
|
||||||
|
{
|
||||||
|
AddError(loc, "CONSTANT_EXPRESSION_EXPECTED");
|
||||||
|
}
|
||||||
|
return icn;
|
||||||
|
}
|
||||||
|
|
||||||
private int_const_node convert_const_to_switch(expression_node switch_expr,
|
private int_const_node convert_const_to_switch(expression_node switch_expr,
|
||||||
ordinal_type_interface oti, type_node case_expr_type, location loc)
|
ordinal_type_interface oti, type_node case_expr_type, location loc)
|
||||||
{
|
{
|
||||||
|
|
@ -9765,12 +9839,6 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
icn = new int_const_node(Convert.ToInt32((switch_expr as short_const_node).constant_value), loc);
|
icn = new int_const_node(Convert.ToInt32((switch_expr as short_const_node).constant_value), loc);
|
||||||
else if (switch_expr is ushort_const_node)
|
else if (switch_expr is ushort_const_node)
|
||||||
icn = new int_const_node(Convert.ToInt32((switch_expr as ushort_const_node).constant_value), loc);
|
icn = new int_const_node(Convert.ToInt32((switch_expr as ushort_const_node).constant_value), loc);
|
||||||
/*else if (switch_expr is uint_const_node)
|
|
||||||
icn = new int_const_node(Convert.ToInt32((switch_expr as uint_const_node).constant_value),loc);
|
|
||||||
else if (switch_expr is long_const_node)
|
|
||||||
icn = new int_const_node(Convert.ToInt32((switch_expr as long_const_node).constant_value),loc);
|
|
||||||
else if (switch_expr is ulong_const_node)
|
|
||||||
icn = new int_const_node(Convert.ToInt32((switch_expr as ulong_const_node).constant_value),loc);*/
|
|
||||||
else if (switch_expr is bool_const_node)
|
else if (switch_expr is bool_const_node)
|
||||||
icn = new int_const_node(Convert.ToInt32((switch_expr as bool_const_node).constant_value), loc);
|
icn = new int_const_node(Convert.ToInt32((switch_expr as bool_const_node).constant_value), loc);
|
||||||
else if (switch_expr is char_const_node)
|
else if (switch_expr is char_const_node)
|
||||||
|
|
@ -9779,7 +9847,6 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
icn = new int_const_node((switch_expr as enum_const_node).constant_value, loc);
|
icn = new int_const_node((switch_expr as enum_const_node).constant_value, loc);
|
||||||
else if (switch_expr is static_compiled_variable_reference && (switch_expr as static_compiled_variable_reference).var.compiled_field.IsLiteral)
|
else if (switch_expr is static_compiled_variable_reference && (switch_expr as static_compiled_variable_reference).var.compiled_field.IsLiteral)
|
||||||
icn = new int_const_node((int)(switch_expr as static_compiled_variable_reference).var.compiled_field.GetRawConstantValue(), loc);
|
icn = new int_const_node((int)(switch_expr as static_compiled_variable_reference).var.compiled_field.GetRawConstantValue(), loc);
|
||||||
|
|
||||||
//учти здесь модет быть и long!
|
//учти здесь модет быть и long!
|
||||||
//-DarkStar Add
|
//-DarkStar Add
|
||||||
if (icn == null)
|
if (icn == null)
|
||||||
|
|
@ -9803,7 +9870,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
{
|
{
|
||||||
AddError(new OrdinalOrStringTypeExpected(en.location));
|
AddError(new OrdinalOrStringTypeExpected(en.location));
|
||||||
}
|
}
|
||||||
if (ii != null)
|
if (ii != null && en.type != SystemLibrary.SystemLibrary.int64_type && en.type != SystemLibrary.SystemLibrary.uint64_type)
|
||||||
{
|
{
|
||||||
ordinal_type_interface oti = (ordinal_type_interface)ii;
|
ordinal_type_interface oti = (ordinal_type_interface)ii;
|
||||||
en = convertion_data_and_alghoritms.create_simple_function_call(oti.value_to_int, en.location, en);
|
en = convertion_data_and_alghoritms.create_simple_function_call(oti.value_to_int, en.location, en);
|
||||||
|
|
@ -9859,7 +9926,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
sn.default_statement = else_statement;
|
sn.default_statement = else_statement;
|
||||||
return_value(sn);
|
return_value(sn);
|
||||||
}
|
}
|
||||||
else
|
else if (en.type == SystemLibrary.SystemLibrary.string_type)
|
||||||
{
|
{
|
||||||
if_node main_ifn = null;
|
if_node main_ifn = null;
|
||||||
if_node ifn = null;
|
if_node ifn = null;
|
||||||
|
|
@ -9919,6 +9986,179 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
ifn.else_body = else_statement;
|
ifn.else_body = else_statement;
|
||||||
return_value(main_ifn);
|
return_value(main_ifn);
|
||||||
}
|
}
|
||||||
|
else if (en.type == SystemLibrary.SystemLibrary.int64_type)
|
||||||
|
{
|
||||||
|
if_node main_ifn = null;
|
||||||
|
if_node ifn = null;
|
||||||
|
basic_function_node int64_eq_meth = SystemLibrary.SystemLibrary.int64_type.find_first_in_type("=", true).sym_info as basic_function_node;
|
||||||
|
|
||||||
|
Dictionary<long, long> case_constants = new Dictionary<long, long>();
|
||||||
|
foreach (SyntaxTree.case_variant cv in _case_node.conditions.variants)
|
||||||
|
{
|
||||||
|
convertion_data_and_alghoritms.check_node_parser_error(cv);
|
||||||
|
location loc = get_location(cv);
|
||||||
|
expression_node eq_node = null;
|
||||||
|
List<basic_function_call> eq_calls = new List<basic_function_call>();
|
||||||
|
foreach (SyntaxTree.expression expr in cv.conditions.expressions)
|
||||||
|
{
|
||||||
|
SyntaxTree.diapason_expr diap = expr as SyntaxTree.diapason_expr;
|
||||||
|
if (diap == null)
|
||||||
|
{
|
||||||
|
expression_node cn = convert_strong(expr);
|
||||||
|
long_const_node scn = convert_long_const_to_switch(cn, cn.location);
|
||||||
|
if (!case_constants.ContainsKey(scn.constant_value))
|
||||||
|
case_constants.Add(scn.constant_value, scn.constant_value);
|
||||||
|
else
|
||||||
|
AddError(cn.location, "CASE_CONSTANT_VARIANT_COINCIDE_WITH_ANOTHER");
|
||||||
|
basic_function_call eq_call = new basic_function_call(int64_eq_meth, cn.location);
|
||||||
|
eq_call.parameters.AddElement(en);
|
||||||
|
eq_call.parameters.AddElement(cn);
|
||||||
|
eq_calls.Add(eq_call);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
expression_node left_cn = convert_strong(diap.left);
|
||||||
|
expression_node right_cn = convert_strong(diap.right);
|
||||||
|
long_const_node left_scn = convert_long_const_to_switch(left_cn, left_cn.location);
|
||||||
|
long_const_node right_scn = convert_long_const_to_switch(right_cn, right_cn.location);
|
||||||
|
if (left_scn.constant_value > right_scn.constant_value)
|
||||||
|
{
|
||||||
|
AddError(get_location(diap.right), "LEFT_RANGE_GREATER_THEN_RIGHT");
|
||||||
|
}
|
||||||
|
basic_function_node int64_greq_meth = SystemLibrary.SystemLibrary.int64_type.find_first_in_type(">=", true).sym_info as basic_function_node;
|
||||||
|
basic_function_node int64_leq_meth = SystemLibrary.SystemLibrary.int64_type.find_first_in_type("<=", true).sym_info as basic_function_node;
|
||||||
|
basic_function_call greq_call = new basic_function_call(int64_greq_meth, left_cn.location);
|
||||||
|
greq_call.parameters.AddElement(en);
|
||||||
|
greq_call.parameters.AddElement(left_cn);
|
||||||
|
basic_function_call leq_call = new basic_function_call(int64_leq_meth, right_cn.location);
|
||||||
|
leq_call.parameters.AddElement(en);
|
||||||
|
leq_call.parameters.AddElement(right_cn);
|
||||||
|
basic_function_node in_diap_meth = SystemLibrary.SystemLibrary.bool_type.find_first_in_type("and", true).sym_info as basic_function_node;
|
||||||
|
basic_function_call in_diap_call = new basic_function_call(in_diap_meth, left_cn.location);
|
||||||
|
in_diap_call.parameters.AddElement(greq_call);
|
||||||
|
in_diap_call.parameters.AddElement(leq_call);
|
||||||
|
eq_calls.Add(in_diap_call);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (basic_function_call eq_call in eq_calls)
|
||||||
|
{
|
||||||
|
if (eq_node == null)
|
||||||
|
eq_node = eq_call;
|
||||||
|
else
|
||||||
|
eq_node = new basic_function_call(SystemLibrary.SystemLibrary.bool_or as basic_function_node, null, eq_node, eq_call);
|
||||||
|
}
|
||||||
|
context.enter_code_block_with_bind();
|
||||||
|
CheckToEmbeddedStatementCannotBeADeclaration(cv.exec_if_true);
|
||||||
|
statement_node stmn = convert_strong(cv.exec_if_true);
|
||||||
|
context.leave_code_block();
|
||||||
|
if (ifn != null)
|
||||||
|
{
|
||||||
|
ifn.else_body = new if_node(eq_node, stmn, null, loc);
|
||||||
|
ifn = ifn.else_body as if_node;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ifn = new if_node(eq_node, stmn, null, loc);
|
||||||
|
if (main_ifn == null)
|
||||||
|
main_ifn = ifn;
|
||||||
|
}
|
||||||
|
context.enter_code_block_with_bind();
|
||||||
|
CheckToEmbeddedStatementCannotBeADeclaration(_case_node.else_statement);
|
||||||
|
statement_node else_statement = convert_weak(_case_node.else_statement);
|
||||||
|
context.leave_code_block();
|
||||||
|
if (ifn == null)
|
||||||
|
{
|
||||||
|
ifn = new if_node(en, new statements_list(null), null, get_location(_case_node));
|
||||||
|
main_ifn = ifn;
|
||||||
|
}
|
||||||
|
ifn.else_body = else_statement;
|
||||||
|
return_value(main_ifn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if_node main_ifn = null;
|
||||||
|
if_node ifn = null;
|
||||||
|
basic_function_node uint64_eq_meth = SystemLibrary.SystemLibrary.uint64_type.find_first_in_type("=", true).sym_info as basic_function_node;
|
||||||
|
Dictionary<ulong, ulong> case_constants = new Dictionary<ulong, ulong>();
|
||||||
|
foreach (SyntaxTree.case_variant cv in _case_node.conditions.variants)
|
||||||
|
{
|
||||||
|
convertion_data_and_alghoritms.check_node_parser_error(cv);
|
||||||
|
location loc = get_location(cv);
|
||||||
|
expression_node eq_node = null;
|
||||||
|
List<basic_function_call> eq_calls = new List<basic_function_call>();
|
||||||
|
foreach (SyntaxTree.expression expr in cv.conditions.expressions)
|
||||||
|
{
|
||||||
|
SyntaxTree.diapason_expr diap = expr as SyntaxTree.diapason_expr;
|
||||||
|
if (diap == null)
|
||||||
|
{
|
||||||
|
expression_node cn = convert_strong(expr);
|
||||||
|
ulong_const_node scn = convert_ulong_const_to_switch(cn, cn.location);
|
||||||
|
if (!case_constants.ContainsKey(scn.constant_value))
|
||||||
|
case_constants.Add(scn.constant_value, scn.constant_value);
|
||||||
|
else
|
||||||
|
AddError(cn.location, "CASE_CONSTANT_VARIANT_COINCIDE_WITH_ANOTHER");
|
||||||
|
basic_function_call eq_call = new basic_function_call(uint64_eq_meth, cn.location);
|
||||||
|
eq_call.parameters.AddElement(en);
|
||||||
|
eq_call.parameters.AddElement(cn);
|
||||||
|
eq_calls.Add(eq_call);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
expression_node left_cn = convert_strong(diap.left);
|
||||||
|
expression_node right_cn = convert_strong(diap.right);
|
||||||
|
ulong_const_node left_scn = convert_ulong_const_to_switch(left_cn, left_cn.location);
|
||||||
|
ulong_const_node right_scn = convert_ulong_const_to_switch(right_cn, right_cn.location);
|
||||||
|
if (left_scn.constant_value > right_scn.constant_value)
|
||||||
|
{
|
||||||
|
AddError(get_location(diap.right), "LEFT_RANGE_GREATER_THEN_RIGHT");
|
||||||
|
}
|
||||||
|
basic_function_node uint64_greq_meth = SystemLibrary.SystemLibrary.uint64_type.find_first_in_type(">=", true).sym_info as basic_function_node;
|
||||||
|
basic_function_node uint64_leq_meth = SystemLibrary.SystemLibrary.uint64_type.find_first_in_type("<=", true).sym_info as basic_function_node;
|
||||||
|
basic_function_call greq_call = new basic_function_call(uint64_greq_meth, left_cn.location);
|
||||||
|
greq_call.parameters.AddElement(en);
|
||||||
|
greq_call.parameters.AddElement(left_cn);
|
||||||
|
basic_function_call leq_call = new basic_function_call(uint64_leq_meth, right_cn.location);
|
||||||
|
leq_call.parameters.AddElement(en);
|
||||||
|
leq_call.parameters.AddElement(right_cn);
|
||||||
|
basic_function_node in_diap_meth = SystemLibrary.SystemLibrary.bool_type.find_first_in_type("and", true).sym_info as basic_function_node;
|
||||||
|
basic_function_call in_diap_call = new basic_function_call(in_diap_meth, left_cn.location);
|
||||||
|
in_diap_call.parameters.AddElement(greq_call);
|
||||||
|
in_diap_call.parameters.AddElement(leq_call);
|
||||||
|
eq_calls.Add(in_diap_call);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (basic_function_call eq_call in eq_calls)
|
||||||
|
{
|
||||||
|
if (eq_node == null)
|
||||||
|
eq_node = eq_call;
|
||||||
|
else
|
||||||
|
eq_node = new basic_function_call(SystemLibrary.SystemLibrary.bool_or as basic_function_node, null, eq_node, eq_call);
|
||||||
|
}
|
||||||
|
context.enter_code_block_with_bind();
|
||||||
|
CheckToEmbeddedStatementCannotBeADeclaration(cv.exec_if_true);
|
||||||
|
statement_node stmn = convert_strong(cv.exec_if_true);
|
||||||
|
context.leave_code_block();
|
||||||
|
if (ifn != null)
|
||||||
|
{
|
||||||
|
ifn.else_body = new if_node(eq_node, stmn, null, loc);
|
||||||
|
ifn = ifn.else_body as if_node;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ifn = new if_node(eq_node, stmn, null, loc);
|
||||||
|
if (main_ifn == null)
|
||||||
|
main_ifn = ifn;
|
||||||
|
}
|
||||||
|
context.enter_code_block_with_bind();
|
||||||
|
CheckToEmbeddedStatementCannotBeADeclaration(_case_node.else_statement);
|
||||||
|
statement_node else_statement = convert_weak(_case_node.else_statement);
|
||||||
|
context.leave_code_block();
|
||||||
|
if (ifn == null)
|
||||||
|
{
|
||||||
|
ifn = new if_node(en, new statements_list(null), null, get_location(_case_node));
|
||||||
|
main_ifn = ifn;
|
||||||
|
}
|
||||||
|
ifn.else_body = else_statement;
|
||||||
|
return_value(main_ifn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void visit(SyntaxTree.case_variant _case_variant)
|
public override void visit(SyntaxTree.case_variant _case_variant)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue