Skip to content

Commit

Permalink
[Compiler] Fix for instance keyword, #/issues/1115
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertvanderHulst committed Sep 16, 2022
1 parent f55f979 commit 64c50de
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
15 changes: 11 additions & 4 deletions Tests/Applications/C868/Prg/C868.prg
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
FUNCTION Start() AS VOID
LOCAL o AS TestClass
o := TestClass{}
? o:iInstance
o:iInstance := 123
? o:iInstance
// ? o:iInstance
// o:iInstance := 123
// ? o:iInstance

CLASS TestClass
INSTANCE iInstance := 555 AS INT

INSTANCE iInstance := 555 AS INT
END CLASS

CLASS SubClass INHERIT TestClass
CONSTRUCTOR
SUPER()
iInstance := 444
END CLASS
18 changes: 9 additions & 9 deletions Tests/xSharp Tests.viproj
Original file line number Diff line number Diff line change
Expand Up @@ -114631,7 +114631,7 @@ Target = 0
Platform = AnyCPU
Language = XSharp
Runtime = CLR4
Dialect = VO
Dialect = Vulcan
Folder = %ProjectPath%\Applications\C868\
PrgSubFolder = \Prg
ResourcesSubFolder =
Expand Down Expand Up @@ -114663,8 +114663,8 @@ FileType = Code
CopyToBin = 0
[C868 - INSTANCE iVars are incorrectly treated as public vars References]
ReferenceGAC = CLR4,System,1,0,4.0.0.0
ReferenceGAC = CLR4,XSharp.Core,1,0,2.6.0.0
ReferenceGAC = CLR4,XSharp.RT,1,0,2.6.0.0
ReferenceGAC = XSharp.Core,1,0,2.6.0.0
ReferenceGAC = XSharp.RT,1,0,2.6.0.0
[C868 - INSTANCE iVars are incorrectly treated as public vars Resources]
[C868 - INSTANCE iVars are incorrectly treated as public vars Native Resources]
[C868 - INSTANCE iVars are incorrectly treated as public vars License files]
Expand Down Expand Up @@ -114741,7 +114741,7 @@ GalleryName =
GalleryPage =
GalleryDefaultName =
Target = 0
Platform = AnyCPU
Platform = x86
Language = XSharp
Runtime = CLR4
Dialect = VO
Expand Down Expand Up @@ -114776,8 +114776,8 @@ FileType = Code
CopyToBin = 0
[C869 - IVarGetInfo() returns incorrect results References]
ReferenceGAC = CLR4,System,1,0,4.0.0.0
ReferenceGAC = CLR4,XSharp.Core,1,0,2.6.0.0
ReferenceGAC = CLR4,XSharp.RT,1,0,2.6.0.0
ReferenceBrowse = C:\XSharp\DevRt\Binaries\Debug\XSharp.Core.dll,1,1
ReferenceBrowse = C:\XSharp\DevRt\Binaries\Debug\XSharp.RT.dll,1,1
[C869 - IVarGetInfo() returns incorrect results Resources]
[C869 - IVarGetInfo() returns incorrect results Native Resources]
[C869 - IVarGetInfo() returns incorrect results License files]
Expand Down Expand Up @@ -114854,7 +114854,7 @@ GalleryName =
GalleryPage =
GalleryDefaultName =
Target = 0
Platform = AnyCPU
Platform = x86
Language = XSharp
Runtime = CLR4
Dialect = VO
Expand Down Expand Up @@ -114889,8 +114889,8 @@ FileType = Code
CopyToBin = 0
[C870 - Default() function with NULL_OBJECT incompatibility with VO References]
ReferenceGAC = CLR4,System,1,0,4.0.0.0
ReferenceGAC = CLR4,XSharp.Core,1,0,2.6.0.0
ReferenceGAC = CLR4,XSharp.RT,1,0,2.6.0.0
ReferenceBrowse = C:\XSharp\DevRt\Binaries\Debug\XSharp.RT.dll,1,1
ReferenceBrowse = C:\XSharp\DevRt\Binaries\Debug\XSharp.Core.dll,1,1
[C870 - Default() function with NULL_OBJECT incompatibility with VO Resources]
[C870 - Default() function with NULL_OBJECT incompatibility with VO Native Resources]
[C870 - Default() function with NULL_OBJECT incompatibility with VO License files]
Expand Down
4 changes: 2 additions & 2 deletions XSharp/src/Common/BuildNumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#ifdef RUNTIME
#define VERSION_NUMBER "2.6.0.0"
#else
#define VERSION_NUMBER "2.13.2.1"
#define VERSION_NUMBER "2.13.2.2"
#endif

// This is the file version number, which is ignored by .NET but used by Windows installer to determine
// whether one file is newer than another.
// This typically would change if we're generating a patch, otherwise it should be the same as VERSION_NUMBER
#define FILEVERSION_NUMBER "2.13.2.1"
#define FILEVERSION_NUMBER "2.13.2.2"
#define INFORMATIONAL_NUMBER "2.13b GA"

#ifdef __DEBUG__
Expand Down
4 changes: 2 additions & 2 deletions XSharp/src/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ internal class Constants
#if RUNTIME
internal const string Version = "2.6.0.0";
#else
internal const string Version = "2.13.2.1";
internal const string Version = "2.13.2.2";
#endif
internal const string FileVersion = "2.13.2.1";
internal const string FileVersion = "2.13.2.2";
internal const string ProductVersion = "2.13b GA";
internal const string PublicKey = "ed555a0467764586";
internal const string Copyright = "Copyright © XSharp BV 2015-2022";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Antlr4.Runtime;
using Antlr4.Runtime.Tree;
using LanguageService.CodeAnalysis.XSharp.SyntaxParser;
using System.Security.Policy;

namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax
{
Expand Down Expand Up @@ -1107,7 +1108,7 @@ public static SyntaxToken SyntaxKeyword(this IToken token)
r = SyntaxFactory.MakeToken(SyntaxKind.GlobalKeyword, text);
break;
case XSharpParser.INSTANCE:
r = SyntaxFactory.MakeToken(SyntaxKind.ProtectedKeyword, text);
r = SyntaxFactory.MakeToken(SyntaxKind.None);
break;
case XSharpParser.ASCENDING:
r = SyntaxFactory.MakeToken(SyntaxKind.AscendingKeyword, text);
Expand Down Expand Up @@ -1718,15 +1719,18 @@ private static SyntaxToken makeGeneratedToken(SyntaxKind kind)
token.XGenerated = true;
return token;
}
public static void FixDefaultVisibility(this SyntaxListBuilder list)
public static void FixDefaultVisibility(this SyntaxListBuilder list, bool isInstance = false)
{
for (int i = 0; i < list.Count; i++)
{
var item = list[i];
if (SyntaxFacts.IsAccessibilityModifier((SyntaxKind)item.RawKind))
return;
}
list.Add(makeGeneratedToken(SyntaxKind.PublicKeyword));
if (isInstance)
list.Add(makeGeneratedToken(SyntaxKind.ProtectedKeyword));
else
list.Add(makeGeneratedToken(SyntaxKind.PublicKeyword));
}

public static bool CanBeVirtual(this SyntaxListBuilder list)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5107,13 +5107,16 @@ public override void ExitClassModifiers([NotNull] XP.ClassModifiersContext conte
public override void ExitClassvarModifiers([NotNull] XP.ClassvarModifiersContext context)
{
SyntaxListBuilder modifiers = _pool.Allocate();
bool isInstance = false;
foreach (var m in context._Tokens)
{
modifiers.AddCheckUnique(m.SyntaxKeyword());
if (m.Type == XP.FIXED && context._FIXED == null)
context._FIXED = m;
if (m.Type == XP.INSTANCE)
isInstance = true;
}
modifiers.FixDefaultVisibility();
modifiers.FixDefaultVisibility(isInstance);
context.PutList(modifiers.ToList<SyntaxToken>());
_pool.Free(modifiers);
}
Expand Down

0 comments on commit 64c50de

Please sign in to comment.