Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/feature/xSharpCompiler'
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertvanderHulst committed Nov 30, 2020
2 parents 80d4583 + 27ebaf8 commit f923339
Show file tree
Hide file tree
Showing 97 changed files with 4,498 additions and 2,185 deletions.
8 changes: 7 additions & 1 deletion Roslyn/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,13 @@ private void LookupMembersInClass(
{
break;
}

#if XSHARP
// in the VO dialect the constructor call does not have to be chained.
// When resolving SUPER() calls we only want to consider the immediate parent level
// These are compiled into method calls like SUPER:.ctor(......)
if (name == WellKnownMemberNames.InstanceConstructorName)
break;
#endif
currentType = currentType.GetNextBaseTypeNoUseSiteDiagnostics(basesBeingResolved, this.Compilation, ref visited);
if ((object)currentType != null)
{
Expand Down
16 changes: 8 additions & 8 deletions Roslyn/src/Compilers/CSharp/Portable/Syntax/CSharpSyntaxNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ public override string Language
return result;
}
// Generate special source code for entities that we want to ignore.
if (this.XGenerated && node == null)
{
var source = Text.SourceText.From("/// <exclude/>");
var lexer = new Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.Lexer(source, CSharpParseOptions.Default);
var list = lexer.LexSyntaxLeadingTrivia();
lexer.Dispose();
return list;
}
//if (this.XGenerated && node == null )
//{
// var source = Text.SourceText.From("/// <exclude/>");
// var lexer = new Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.Lexer(source, CSharpParseOptions.Default);
// var list = lexer.LexSyntaxLeadingTrivia();
// lexer.Dispose();
// return list;
//}
#endif
var firstToken = this.GetFirstToken(includeZeroWidth: true);
return firstToken.LeadingTrivia;
Expand Down
7 changes: 6 additions & 1 deletion Tests/Applications/C312/Prg/C312.prg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
// Mote that this is copy & paste from Arne's code, so PCALL does not
// appear in the SDK only, but people have been uisng this as well!
// Note that this also needs /vo6
#include "VOWin32APILibrary.vh"
#define ICC_DATE_CLASSES 0x00000100
#define ICC_USEREX_CLASSES 0x00000200
#define ICC_COOL_CLASSES 0x00000400
#define ICC_INTERNET_CLASSES 0x00000800
#define ICC_LINK_CLASS 0x00008000

GLOBAL gpfnInitCommonControlsEx AS InitCommonControlsEx PTR
FUNCTION InitCommonControlsEx(lpicex AS PTR) AS LOGIC STRICT
RETURN FALSE
Expand Down
7 changes: 6 additions & 1 deletion Tests/Applications/C333/Prg/C333.prg
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// 312. PCALL with class field
// note: vulcan does not require /vo6 for this to compile. But it's not a big deal if we do require it in x#

#include "VOWin32APILibrary.vh"
#define ICC_DATE_CLASSES 0x00000100
#define ICC_USEREX_CLASSES 0x00000200
#define ICC_COOL_CLASSES 0x00000400
#define ICC_INTERNET_CLASSES 0x00000800
#define ICC_LINK_CLASS 0x00008000


FUNCTION Start() AS VOID
TestClass{}:DoTest()
Expand Down
57 changes: 54 additions & 3 deletions Tests/Applications/C381/Prg/C381.prg
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
#include "VOGUIClasses.vh"
#include "VOSystemLibrary.vh"
#include "VOWin32APILibrary.vh"
#region Help defines
#define HH_DISPLAY_TOPIC 0x0000
#define HH_HELP_FINDER 0x0000
#define HH_DISPLAY_TOC 0x0001
#define HH_DISPLAY_INDEX 0x0002
#define HH_DISPLAY_SEARCH 0x0003
#define HH_SET_WIN_TYPE 0x0004
#define HH_GET_WIN_TYPE 0x0005
#define HH_GET_WIN_HANDLE 0x0006
#define HH_ENUM_INFO_TYPE 0x0007
#define HH_SET_INFO_TYPE 0x0008
#define HH_SYNC 0x0009
#define HH_RESERVED1 0x000A
#define HH_RESERVED2 0x000B
#define HH_RESERVED3 0x000C
#define HH_KEYWORD_LOOKUP 0x000D
#define HH_DISPLAY_TEXT_POPUP 0x000E
#define HH_HELP_CONTEXT 0x000F
#define HH_TP_HELP_CONTEXTMENU 0x0010
#define HH_TP_HELP_WM_HELP 0x0011
#define HH_CLOSE_ALL 0x0012
#define HH_ALINK_LOOKUP 0x0013
#define HH_GET_LAST_ERROR 0x0014
#define HH_ENUM_CATEGORY 0x0015
#define HH_ENUM_CATEGORY_IT 0x0016
#define HH_RESET_IT_FILTER 0x0017
#define HH_SET_INCLUSIVE_FILTER 0x0018
#define HH_SET_EXCLUSIVE_FILTER 0x0019
#define HH_INITIALIZE 0x001C
#define HH_UNINITIALIZE 0x001D
#define HH_PRETRANSLATEMESSAGE 0x00fd
#define HH_SET_GLOBAL_PROPERTY 0x00fc
#define HELP_CONTEXT 0x0001L
#define HELP_QUIT 0x0002L
#define HELP_INDEX 0x0003L
#define HELP_CONTENTS 0x0003L
#define HELP_HELPONHELP 0x0004L
#define HELP_SETINDEX 0x0005L
#define HELP_SETCONTENTS 0x0005L
#define HELP_CONTEXTPOPUP 0x0008L
#define HELP_FORCEFILE 0x0009L
#define HELP_KEY 0x0101L
#define HELP_COMMAND 0x0102L
#define HELP_PARTIALKEY 0x0105L
#define HELP_MULTIKEY 0x0201L
#define HELP_SETWINPOS 0x0203L
#define HELP_CONTEXTMENU 0x000a
#define HELP_FINDER 0x000b
#define HELP_WM_HELP 0x000c
#define HELP_SETPOPUP_POS 0x000d
#define HELP_TCARD 0x8000
#define HELP_TCARD_DATA 0x0010
#define HELP_TCARD_OTHER_CALLER 0x0011
#endregion
PARTIAL CLASS HelpDisplay INHERIT VObject
PROTECT cFileName AS STRING
PROTECT wError AS LONGINT //RvdH 070205 changed from WORD to LONG
Expand Down
2 changes: 1 addition & 1 deletion Tests/Applications/C443/Prg/C443.prg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "VOWin32APILibrary.vh"
#include "test.xh"
#define dddd 1

// 443. error XS9003: Pre-processor: Identifier expected
Expand Down
1 change: 1 addition & 0 deletions Tests/Applications/C443/Prg/test.xh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Dummy file
4 changes: 2 additions & 2 deletions Tests/Applications/C468/Prg/C468.prg
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// After the error happens once, then _ALL_ following compiles result to the same error
// (btw, this was occuring also in the past from time to time, but in beta10 it is always reproducible)

#include "VOSystemLibrary.vh"
#include "VOSystemClasses.vh"
//#include "VOSystemLibrary.vh"
//#include "VOSystemClasses.vh"

FUNCTION Start() AS VOID
? "just something to keep the compiler parsing"
Expand Down
4 changes: 2 additions & 2 deletions Tests/Applications/C468/Prg/C468a.prg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "VOSystemClasses.vh"
#include "VOSystemLibrary.vh"
//#include "VOSystemClasses.vh"
//#include "VOSystemLibrary.vh"

FUNCTION TestA() AS INT
? "just something to keep the compiler parsing"
Expand Down
2 changes: 1 addition & 1 deletion Tests/Applications/C468/Prg/C468b.prg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "VOSystemLibrary.vh"
//#include "VOSystemLibrary.vh"

FUNCTION TestB() AS INT
? "just something to keep the compiler parsing"
Expand Down
2 changes: 1 addition & 1 deletion Tests/Applications/C584/Prg/C584.prg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Typically reported for directives like the following one, found in the DBCmds.vh
*/

#include "DBCmds.vh"
#include "DBCmd.xh"
FUNCTION Start( ) AS VOID
LOCAL cDbf AS STRING
cDbf := System.Environment.CurrentDirectory + "\C584.dbf"
Expand Down
11 changes: 6 additions & 5 deletions Tests/Applications/C747/Prg/C747.prg
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// 747. System.ExecutionEngineException
// Problem happens only with /vo11+ enabled and when the target is set to x86
// Problem happens only with /vo11+ enabled and when the target is set to x86
// https://github.com/X-Sharp/XSharpPublic/issues/511
FUNCTION Start( ) AS VOID
LOCAL dNullable AS Nullable<Decimal>
LOCAL dValue AS Decimal

dNullable := 1m

//
dValue := dNullable:Value // ok
? dValue
xAssert(dValue == 1m)
Expand All @@ -15,9 +16,9 @@ FUNCTION Start( ) AS VOID
xAssert(dValue == 1m)

// Note that c# does not allow this syntax at all, requires a cast or using :Value
dValue := dNullable // System.ExecutionEngineException
? dValue
xAssert(dValue == 1m)
//dValue := dNullable // System.ExecutionEngineException
//? dValue
//xAssert(dValue == 1m)
RETURN

PROC xAssert(l AS LOGIC)
Expand Down
21 changes: 21 additions & 0 deletions Tests/Applications/C748/Prg/C748.prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 748. error XS1628: Cannot use ref, out, or in parameter 'n' inside an anonymous method, lambda expression, query expression, or local function
FUNCTION Start() AS VOID
LOCAL n := 1 AS INT
TestClass.TestMethod(REF n)
? n
xAssert(n == 2)

PUBLIC CLASS TestClass
// error XS1628: Cannot use ref, out, or in parameter 'n' inside an anonymous method, lambda expression, query expression, or local function
STATIC METHOD TestMethod(n REF INT) AS VOID
n := 2
END CLASS


PROC xAssert(l AS LOGIC)
IF .not. l
THROW Exception{"Incorrect result in line " + System.Diagnostics.StackTrace{TRUE}:GetFrame(1):GetFileLineNumber():ToString()}
END IF
? "Assertion passed"
RETURN

44 changes: 44 additions & 0 deletions Tests/Applications/R743/Prg/R743.prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FUNCTION Start() AS VOID

LOCAL cFileName AS STRING

LOCAL aStruct AS ARRAY

cFileName := "memotest"

RddSetDefault("DBFCDX")

aStruct := { ;
{ "MEMO1","M",0,0 } ,;
{ "MEMO2","M",1,0 } ,;
{ "MEMO3","M",10,0 } ,;
{ "MEMO4","M",111,0 } ;
}

DbCreate(cFileName,aStruct)

DbUseArea(,,cFileName)

DbAppend()

FieldPut(1,"memo1")

FieldPut(2,"memo2")

FieldPut(3,"memo3")

FieldPut(4,"memo4")

XAssert(FieldGet(1) == "memo1")
XAssert(FieldGet(2) == "memo2")
XAssert(FieldGet(3) == "memo3")
XAssert(FieldGet(4) == "memo4")

DbCloseArea()
PROC xAssert(l AS LOGIC)
IF .not. l
THROW Exception{"Incorrect result in line " + System.Diagnostics.StackTrace{TRUE}:GetFrame(1):GetFileLineNumber():ToString()}
END IF
? "Assertion passed"
RETURN

60 changes: 60 additions & 0 deletions Tests/Applications/R744/Prg/R744.prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// R744 Constructor Chaining
// the constructor inside TestInherited1 calls the parameterless constructor of System.Object
// and skips the constructors of the Test level. So the field val is not initialized.
FUNCTION Start() AS VOID STRICT
Console.WriteLine("No initialization of fields. No Warning or error of invalid super call")
TestInherited1{""}

Console.WriteLine("Initialization of fields in the base class is called after the Super call")

TestInherited2{""}

Wait

RETURN

CLASS Test

HIDDEN val := "initialized" AS STRING

PROTECTED METHOD Print() AS VOID STRICT
Console.WriteLine(val)

RETURN

CONSTRUCTOR(test1 AS STRING) AS VOID STRICT
Print()
RETURN


CONSTRUCTOR(test1 AS LONG) AS VOID STRICT
Print()
RETURN


END CLASS

CLASS TestInherited1 INHERIT Test

CONSTRUCTOR(test1 AS STRING) AS VOID STRICT

Print()


SUPER() //invalid super call. This should report an error

RETURN

END CLASS

CLASS TestInherited2 INHERIT Test

CONSTRUCTOR(test1 AS STRING) AS VOID STRICT

Print()

SUPER(test1)

RETURN

END CLASS
30 changes: 30 additions & 0 deletions Tests/Applications/R747/Prg/R747.prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// R747. System.ExecutionEngineException
// Problem happens only with /vo11+ enabled and when the target is set to x86
// https://github.com/X-Sharp/XSharpPublic/issues/511
FUNCTION Start( ) AS VOID
LOCAL dNullable AS Nullable<Decimal>
LOCAL dValue AS Decimal

dNullable := 1m
//
dValue := dNullable:Value // ok
? dValue
xAssert(dValue == 1m)

dValue := (Decimal)dNullable // ok
? dValue
xAssert(dValue == 1m)

// Note that c# does not allow this syntax at all, requires a cast or using :Value
dValue := dNullable // System.ExecutionEngineException
? dValue
xAssert(dValue == 1m)
RETURN

PROC xAssert(l AS LOGIC)
IF .not. l
THROW Exception{"Incorrect result in line " + System.Diagnostics.StackTrace{TRUE}:GetFrame(1):GetFileLineNumber():ToString()}
END IF
? "Assertion passed"
RETURN

28 changes: 28 additions & 0 deletions Tests/Applications/R748/Prg/R748.prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

FUNCTION Start( ) AS VOID
? "Hello"
LOCAL l = GetDesktopWindow()
xAssert(l!= 0)
VAR sb := System.Text.StringBuilder{255}
XAssert(GetSystemDirectory(sb, sb.Capacity+1) != 0)
? sb.ToString()
xAssert(sb.ToString().ToLower().Contains("system32"))
WAIT
RETURN



DECLARE INTEGER GetActiveWindow IN user32
DECLARE INTEGER GetDesktopWindow IN user32
DECLARE INTEGER MessageBox IN USER32 INTEGER , STRING , STRING , LONG
DECLARE INTEGER GetSystemDirectoryA IN Kernel32 AS GetSystemDirectory System.Text.StringBuilder buffer, LONG numchars
// declaration with STRING @ will generate a compiler error
//DECLARE INTEGER GetSystemDirectory IN Kernel32 STRING @, LONG


PROC xAssert(l AS LOGIC)
IF .not. l
THROW Exception{"Incorrect result in line " + System.Diagnostics.StackTrace{TRUE}:GetFrame(1):GetFileLineNumber():ToString()}
END IF
? "Assertion passed"
RETURN
Loading

0 comments on commit f923339

Please sign in to comment.