From a08322e1c17cfbc99c0285c07075496ae9456e04 Mon Sep 17 00:00:00 2001 From: miks1965 Date: Sat, 6 Jan 2018 00:29:19 +0300 Subject: [PATCH] bug fix #641 --- Configuration/GlobalAssemblyInfo.cs | 4 +- Configuration/Version.defs | 2 +- .../PascalABCParserNewSaushkin/ABCPascal.cs | 11 ++- .../PascalABCParserNewSaushkin/ABCPascal.lex | 5 ++ .../ABCPascalYacc.cs | 16 ++-- Parsers/PascalABCParserNewSaushkin/PABC.ymc | 1 + ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/CompilationSamples/FormsABC.pas | 2 +- TestSuite/CompilationSamples/graph3d.pas | 78 ++++++++++++++----- 9 files changed, 87 insertions(+), 34 deletions(-) diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 7445c2731..7275e24c0 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -5,7 +5,7 @@ using System.Runtime.CompilerServices; [assembly: AssemblyDelaySign(false)] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PascalABC.NET Compiler")] -[assembly: AssemblyCopyright("Copyright © 2005-2018 by Ivan Bondarev, Stanislav Mihalkovich")] +[assembly: AssemblyCopyright("Copyright © 2005-2017 by Ivan Bondarev, Stanislav Mihalkovich")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion(RevisionClass.FullVersion)] @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "3"; public const string Build = "0"; - public const string Revision = "1608"; + public const string Revision = "1610"; 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 cd4144dde..5c185db46 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=3 -%REVISION%=1608 +%REVISION%=1610 %COREVERSION%=0 %MAJOR%=3 diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index fc56a88f6..1e750f08f 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs @@ -1,9 +1,9 @@ // // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 -// Machine: IVAN-PC -// DateTime: 29.12.2017 22:14:05 -// UserName: Ivan +// Machine: DESKTOP-A6LT9RI +// DateTime: 06.01.2018 0:16:05 +// UserName: ????????? // GPLEX input file // GPLEX frame file // @@ -2145,6 +2145,11 @@ if (parsertools.build_tree_for_formatter) { if (!Defines.Contains(directiveparam)) Defines.Add(directiveparam); + } + else if (directivename == "UNDEF") + { + if (Defines.Contains(directiveparam)) + Defines.Remove(directiveparam); } break; case 54: diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.lex b/Parsers/PascalABCParserNewSaushkin/ABCPascal.lex index e278c8828..c8e877be9 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.lex +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.lex @@ -110,6 +110,11 @@ UNICODEARROW \x890 if (!Defines.Contains(directiveparam)) Defines.Add(directiveparam); } + else if (directivename == "UNDEF") + { + if (Defines.Contains(directiveparam)) + Defines.Remove(directiveparam); + } } {OneLineCmnt} { diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index de0564253..3b4c783ab 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -1,9 +1,9 @@ // (see accompanying GPPGcopyright.rtf) // GPPG version 1.3.6 -// Machine: IVAN-PC -// DateTime: 29.12.2017 22:14:07 -// UserName: Ivan +// Machine: DESKTOP-A6LT9RI +// DateTime: 06.01.2018 0:16:05 +// UserName: ????????? // Input file // options: no-lines gplex @@ -4035,8 +4035,8 @@ public partial class GPPGParser: ShiftReduceParser identifier, tkArrow, lambda_function_body { var idList = new ident_list(ValueStack[ValueStack.Depth-3].id, LocationStack[LocationStack.Depth-3]); - var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]); - CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan); + var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]); + CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan); } break; case 391: // typed_var_init_expression -> tkRoundOpen, tkRoundClose, lambda_type_ref, @@ -4061,7 +4061,7 @@ public partial class GPPGParser: ShiftReduceParser identifier, tkArrow, lambda_function_body { var idList = new ident_list(ValueStack[ValueStack.Depth-3].id, LocationStack[LocationStack.Depth-3]); - var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]); - CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan); + var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]); + CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan); } break; case 801: // func_decl_lambda -> tkRoundOpen, tkRoundClose, lambda_type_ref_noproctype, diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index 9b6434b4e..9f8f689bc 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -184,5 +184,6 @@ script= + diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index de897cef8..9170016cd 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.3.0.1608' +!define VERSION '3.3.0.1610' diff --git a/TestSuite/CompilationSamples/FormsABC.pas b/TestSuite/CompilationSamples/FormsABC.pas index 986fef6ab..13597da4d 100644 --- a/TestSuite/CompilationSamples/FormsABC.pas +++ b/TestSuite/CompilationSamples/FormsABC.pas @@ -79,7 +79,7 @@ type procedure SetText(t: string) := b.Text := t; public event Click: procedure; - constructor Create(text: string); + constructor Create(text: string := ''); property Width: integer read GetW write SetW; property Text: string read GetText write SetText; end; diff --git a/TestSuite/CompilationSamples/graph3d.pas b/TestSuite/CompilationSamples/graph3d.pas index 6613a2e59..d1833fb39 100644 --- a/TestSuite/CompilationSamples/graph3d.pas +++ b/TestSuite/CompilationSamples/graph3d.pas @@ -1617,22 +1617,67 @@ type function Clone := (inherited Clone) as RectangleT; end; - FileModelT = class(Object3D) + FileModelT = class(ObjectWithChildren3D) private + fn: string; + procedure SetMP(mat: GMaterial) := (model as MeshVisual3D).FaceMaterial := mat; + procedure SetMaterial(mat: GMaterial) := Invoke(SetMP, mat); + function GetMaterial: GMaterial := Invoke&(()->(model as MeshVisual3D).FaceMaterial); + public + //property Color: GColor write SetColor; + property Material: GMaterial read GetMaterial write SetMaterial; // не работает почему-то на запись + {procedure SetVP(v: boolean) := (model as FileModelVisual3D).Visibility := v; procedure SetV(v: boolean) := Invoke(SetVP, v); function GetV: boolean := Invoke&(()->(model as FileModelVisual3D).Visibility);} protected - function CreateObject: Object3D; override := new FileModelT(X, Y, Z, (model as FileModelVisual3D).Source); + function CreateObject: Object3D; override := new FileModelT(X, Y, Z, fn, Material.Clone); public - constructor(x, y, z: real; fname: string); + constructor(x, y, z: real; fname: string; mat: GMaterial); begin - var a := new FileModelVisual3D; - a.Source := fname; - CreateBase0(a, x, y, z); + model := new MeshVisual3D(); + + var fs := System.IO.File.OpenRead(fname); + fn := fname; + + var ext := System.IO.Path.GetExtension(fname); + ext := ext?.ToLower; + + var r: ModelReader; + + case ext of + '.off': begin + r := new offreader(nil); + (model as MeshVisual3D).FaceMaterial := mat; + (model as MeshVisual3D).EdgeDiameter := 0; + (model as MeshVisual3D).VertexRadius := 0; + end; + '.3ds': r := new studioreader(nil); + '.lwo': r := new lworeader(nil); + '.stl': r := new stlreader(nil); + '.obj','.objx': r := new objreader(nil); + end; + + r.DefaultMaterial := mat; + //r.DefaultMaterial := Colors.Gray; + if ext = '.off' then + begin + (r as offreader).Load(fs); + (model as MeshVisual3D).Mesh := (r as offreader).CreateMesh; + end + else + begin + var md := r.Read(fs); + (model as MeshVisual3D).Content := md; + end; + + fs.Close; + + {var a := new FileModelVisual3D; + a.Source := fname;} + CreateBase0(model, x, y, z); end; - //property Visible: boolean read GetV write SetV; function Clone := (inherited Clone) as FileModelT; end; @@ -2430,16 +2475,16 @@ function Text3D(p: Point3D; text: string; height: real; c: Color) := Text3D(p.x, function Text3D(x, y, z: real; text: string; height: real) := Text3D(x, y, z, text, height, 'Arial', Colors.Black); function Text3D(p: Point3D; text: string; height: real) := Text3D(p.x, p.y, p.z, text, height, 'Arial', Colors.Black); -function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; c: Material) := Invoke&(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, c)); -function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, c); -function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material) := Rectangle3D(x, y, z, l, w, normal, OrtX, c); -function Rectangle3D(x, y, z, l, w: real; c: Material) := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, c); -function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, c); -function Rectangle3D(p: Point3D; l, w: real; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, c); +function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; c: Material): RectangleT := Invoke&(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, c)); +function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; c: Material): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, c); +function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material): RectangleT := Rectangle3D(x, y, z, l, w, normal, OrtX, c); +function Rectangle3D(x, y, z, l, w: real; c: Material): RectangleT := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, c); +function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, c); +function Rectangle3D(p: Point3D; l, w: real; c: Material): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, c); /// Загружает модель из файла .obj, .3ds, .lwo, .objz, .stl, .off -function FileModel3D(x, y, z: real; fname: string) := Invoke&(()->FileModelT.Create(x, y, z, fname)); -function FileModel3D(p: Point3D; fname: string) := FileModel3D(p.x, p.y, p.z, fname); +function FileModel3D(x, y, z: real; fname: string; c: Material): FileModelT := Invoke&(()->FileModelT.Create(x, y, z, fname, c)); +function FileModel3D(p: Point3D; fname: string; c: Material): FileModelT := FileModel3D(p.x, p.y, p.z, fname, c); function Prism(x, y, z: real; Sides: integer; Radius, Height: real; c: Material): PrismT := Invoke&(()->PrismT.Create(x, y, z, Sides, Radius, Height, c)); function Prism(p: Point3D; Sides: integer; Radius, Height: real; c: Material): PrismT := Prism(p.X, p.Y, p.Z, Sides, Radius, Height, c); @@ -2525,9 +2570,6 @@ begin var s := System.IO.File.OpenRead('boxcube.off'); off.Load(s); - //var mmm := new ModelVisual3D; - //mmm.Model := off.CreateMeshGeometry3D; - var m1 := new MeshVisual3D(); m1.FaceMaterial := Colors.Green; m1.EdgeDiameter := 0;