Ongoing adding of tests, fixing of IL interpreter.

This commit is contained in:
Matthijs ter Woord 2015-06-27 18:33:52 +02:00
parent 09e9a3abcb
commit cb5aae2c00
17 changed files with 112 additions and 112 deletions

View file

@ -67,7 +67,7 @@
<Project>{839edc9d-6d2e-4892-a7f0-17861ba9fa0c}</Project>
<Name>SimpleStructsAndArraysTest</Name>
</ProjectReference>
<ProjectReference Include="..\Staging\VGACompilerCrash\VGACompilerCrash.csproj">
<ProjectReference Include="..\VGACompilerCrash\VGACompilerCrash.csproj">
<Project>{21915a7e-cc84-4836-8b87-857b6149d496}</Project>
<Name>VGACompilerCrash</Name>
</ProjectReference>

View file

@ -15,10 +15,10 @@ namespace Cosmos.TestRunner.Console
xEngine.AddKernel(typeof(Cosmos.Compiler.Tests.SimpleWriteLine.Kernel.Kernel).Assembly.Location);
xEngine.AddKernel(typeof(SimpleStructsAndArraysTest.Kernel).Assembly.Location);
xEngine.AddKernel(typeof(VGACompilerCrash.Kernel).Assembly.Location);
// known bugs, therefor disabled for now:
//xEngine.AddKernel(typeof(VGACompilerCrash.Kernel).Assembly.Location);
xEngine.OutputHandler = new OutputHandlerXml(@"c:\data\CosmosTests.xml");
//xEngine.OutputHandler = new OutputHandlerConsole();

View file

@ -1,59 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Cosmos.HAL;
using Sys = Cosmos.System;
namespace VGACompilerCrash
{
public class Kernel : Sys.Kernel
{
public static VGAScreen screen = new VGAScreen();
public void startGraphics()
{
//screen.SetGraphicsMode(VGAScreen.ScreenSize.Size320x200,VGAScreen.ColorDepth.BitDepth8);
//screen.Clear(0);
}
protected override void BeforeRun()
{
Console.WriteLine("Successfully Loaded.");
}
protected override void Run()
{
Console.WriteLine("Welcome. Please login with the administrative credentials provided to you.");
//LOGIN
string username = "";
string password = "";
bool loggedIn = false;
int attempts = 0;
while (!loggedIn)
{
Console.Write("Username:");
username = Console.ReadLine();
Console.Write("Password:");
password = Console.ReadLine();
if (username == "root" && password == "password")
loggedIn = true;
else { attempts++; Console.WriteLine("Error: password mismatch. Try again."); }
if (attempts >= 3)
{
Console.WriteLine("Too many attempts. Please power down."); //add ACPI.Shutdown later
while (!loggedIn) { }
}
}
//END LOGIN
while (loggedIn)
{
Console.Write(">: ");
var input = Console.ReadLine();
if (input == "startx")
{
startGraphics();
}
}
}
}
}

View file

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;
using Cosmos.TestRunner;
using Sys = Cosmos.System;
namespace VGACompilerCrash
{
public class Kernel : Sys.Kernel
{
public static Sys.VGAScreen screen = new Sys.VGAScreen();
public void startGraphics()
{
//screen.SetGraphicsMode(VGAScreen.ScreenSize.Size320x200,VGAScreen.ColorDepth.BitDepth8);
//screen.Clear(0);
}
protected override void BeforeRun()
{
Console.WriteLine("Successfully Loaded.");
}
protected override void Run()
{
Assert.IsTrue(true, "Fake assert");
// the actual testing is done via Sys.VGAScreen
TestController.Completed();
}
}
}

View file

@ -36,7 +36,6 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Cosmos.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
<Reference Include="Cosmos.System, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
<Reference Include="Cosmos.Debug.Kernel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
@ -44,9 +43,13 @@
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\source\Cosmos.HAL\Cosmos.HAL.csproj">
<Project>{6A991D03-1435-4005-9809-B8BACDF3B021}</Project>
<Name>Cosmos.HAL</Name>
<ProjectReference Include="..\..\source\Cosmos.System\Cosmos.System.csproj">
<Project>{3def0461-08ab-471a-8f03-a9c556652a0f}</Project>
<Name>Cosmos.System</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos.TestRunner.TestController\Cosmos.TestRunner.TestController.csproj">
<Project>{E6D3B644-C487-472D-A978-C1A82D0C099B}</Project>
<Name>Cosmos.TestRunner.TestController</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View file

@ -62,7 +62,7 @@ namespace Cosmos.IL2CPU.X86.IL
public static void DoExecute(Cosmos.Assembler.Assembler Assembler, Type aDeclaringType, string xFieldId, bool aDerefExternalField, bool debugEnabled) {
var xOffset = GetFieldOffset(aDeclaringType, xFieldId);
var xFields = GetFieldsInfo(aDeclaringType);
var xFields = GetFieldsInfo(aDeclaringType, false);
var xFieldInfo = (from item in xFields
where item.Id == xFieldId
select item).Single();

View file

@ -25,7 +25,7 @@ namespace Cosmos.IL2CPU.X86.IL
// DEBUG VERIFICATION: leave it here for now. we have issues with fields ordering. if that changes, we need to change the code below!
#region Debug verification
var xFields = GetFieldsInfo(typeof(string)).Where(i => !i.IsStatic).ToArray();
var xFields = GetFieldsInfo(typeof(string), false).Where(i => !i.IsStatic).ToArray();
if (xFields[0].Id != "System.Int32 System.String.m_stringLength"
|| xFields[0].Offset != 0) {
throw new Exception("Fields changed!");

View file

@ -20,7 +20,7 @@ namespace Cosmos.IL2CPU.X86.IL {
var xType = aMethod.MethodBase.DeclaringType;
int xExtraOffset = aNeedsGC ? 12 : 0;
var xFields = GetFieldsInfo(aDeclaringObject);
var xFields = GetFieldsInfo(aDeclaringObject, false);
var xFieldInfo = (from item in xFields
where item.Id == aFieldId
select item).Single();

View file

@ -161,7 +161,7 @@ namespace Cosmos.IL2CPU {
return (uint)xSla.Size;
}
}
return (uint)(from item in GetFieldsInfo(aType)
return (uint)(from item in GetFieldsInfo(aType, false)
select (int)item.Size).Sum();
}
return 4;
@ -198,9 +198,14 @@ namespace Cosmos.IL2CPU {
};
}
private static void DoGetFieldsInfo(Type aType, List<X86.IL.FieldInfo> aFields) {
private static void DoGetFieldsInfo(Type aType, List<X86.IL.FieldInfo> aFields, bool includeStatic) {
var xCurList = new Dictionary<string, X86.IL.FieldInfo>();
var xFields = (from item in aType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)
var xBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
if (includeStatic)
{
xBindingFlags |= BindingFlags.Static;
}
var xFields = (from item in aType.GetFields(xBindingFlags)
orderby item.Name, item.DeclaringType.ToString()
select item).ToArray();
for (int i = 0; i < xFields.Length; i++) {
@ -247,13 +252,18 @@ namespace Cosmos.IL2CPU {
}
if (aType.BaseType != null) {
DoGetFieldsInfo(aType.BaseType, aFields);
DoGetFieldsInfo(aType.BaseType, aFields, includeStatic);
}
}
public static List<X86.IL.FieldInfo> GetFieldsInfo(Type aType) {
public static List<X86.IL.FieldInfo> GetFieldsInfo(Type aType, bool includeStatic)
{
if (aType.FullName == "System.Drawing.Color")
{
Console.Write("");
}
var xResult = new List<X86.IL.FieldInfo>(16);
DoGetFieldsInfo(aType, xResult);
DoGetFieldsInfo(aType, xResult, includeStatic);
xResult.Reverse();
uint xOffset = 0;
foreach (var xInfo in xResult) {
@ -303,7 +313,7 @@ namespace Cosmos.IL2CPU {
}
protected static uint GetStorageSize(Type aType) {
return (from item in GetFieldsInfo(aType)
return (from item in GetFieldsInfo(aType, false)
where !item.IsStatic
orderby item.Offset descending
select item.Offset + item.Size).FirstOrDefault();
@ -401,7 +411,7 @@ namespace Cosmos.IL2CPU {
public static FieldInfo ResolveField(Type aDeclaringType, string aField, bool aOnlyInstance)
{
var xFields = GetFieldsInfo(aDeclaringType);
var xFields = GetFieldsInfo(aDeclaringType, false);
var xFieldInfo = (from item in xFields
where item.Id == aField
&& (!aOnlyInstance || item.IsStatic == false)

View file

@ -394,7 +394,14 @@ namespace Cosmos.IL2CPU {
{
aStack.Pop();
}
DoInterpretStackTypes(ref aSituationChanged);
try
{
DoInterpretStackTypes(ref aSituationChanged);
}
catch (Exception E)
{
throw new Exception("Error interpreting stacktypes for " + this, E);
}
foreach (var xPushItem in StackPushTypes)
{
aStack.Push(xPushItem);

View file

@ -193,10 +193,6 @@ namespace Cosmos.IL2CPU.ILOpCodes {
{
expectedType = expectedType.GetEnumUnderlyingType();
}
else if (Value.DeclaringType.IsValueType)
{
expectedType = typeof(void*);
}
if (StackPopTypes[0] == expectedType ||
StackPopTypes[0] == Value.FieldType)
{

View file

@ -95,7 +95,6 @@ namespace Cosmos.IL2CPU.ILOpCodes {
switch (OpCode)
{
case Code.Initobj:
StackPopTypes[0] = typeof(void*);
return;
case Code.Ldobj:
StackPushTypes[0] = Value;

View file

@ -99,6 +99,7 @@
<Compile Include="Network\TempDictionary.cs" />
<Compile Include="Network\UdpClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VGAScreen.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Console.html" />

View file

@ -0,0 +1,12 @@
using System;
using HALVGAScreen =Cosmos.HAL.VGAScreen;
namespace Cosmos.System
{
[Obsolete("This class has not been properly converted to the final cosmos architecture!")]
public class VGAScreen
{
private HALVGAScreen mScreen = new HALVGAScreen();
// todo: this class needs to wrap HALVGAScreen
}
}

View file

@ -227,14 +227,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.TestRunner.TestContr
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Staging", "Staging", "{25C3C6E4-1EDD-4542-A663-CAC7A1F40B3A}"
EndProject
Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "VGACompilerCrashBoot", "..\Tests\Staging\VGACompilerCrash\VGACompilerCrashBoot.Cosmos", "{78AC2B12-8185-4033-80F0-DA5BF874BE5E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VGACompilerCrash", "..\Tests\Staging\VGACompilerCrash\VGACompilerCrash.csproj", "{21915A7E-CC84-4836-8B87-857B6149D496}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleStructsAndArraysTest", "..\Tests\SimpleStructsAndArraysTest\SimpleStructsAndArraysTest.csproj", "{839EDC9D-6D2E-4892-A7F0-17861BA9FA0C}"
EndProject
Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "SimpleStructsAndArraysTestBoot", "..\Tests\SimpleStructsAndArraysTest\SimpleStructsAndArraysTestBoot.Cosmos", "{431643CB-006C-49EF-8E0F-1540F994C936}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VGACompilerCrash", "..\Tests\VGACompilerCrash\VGACompilerCrash.csproj", "{21915A7E-CC84-4836-8B87-857B6149D496}"
EndProject
Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "VGACompilerCrashBoot", "..\Tests\VGACompilerCrash\VGACompilerCrashBoot.Cosmos", "{78AC2B12-8185-4033-80F0-DA5BF874BE5E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1132,30 +1132,6 @@ Global
{E6D3B644-C487-472D-A978-C1A82D0C099B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E6D3B644-C487-472D-A978-C1A82D0C099B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E6D3B644-C487-472D-A978-C1A82D0C099B}.Release|x86.ActiveCfg = Release|Any CPU
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|Any CPU.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|Itanium.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|Mixed Platforms.Build.0 = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|x86.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|x86.Build.0 = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|Any CPU.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|Itanium.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|Mixed Platforms.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|Mixed Platforms.Build.0 = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|x86.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|x86.Build.0 = Debug|x86
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Itanium.ActiveCfg = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|x86.ActiveCfg = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Any CPU.Build.0 = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Itanium.ActiveCfg = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|x86.ActiveCfg = Release|Any CPU
{839EDC9D-6D2E-4892-A7F0-17861BA9FA0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{839EDC9D-6D2E-4892-A7F0-17861BA9FA0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{839EDC9D-6D2E-4892-A7F0-17861BA9FA0C}.Debug|Itanium.ActiveCfg = Debug|Any CPU
@ -1180,6 +1156,30 @@ Global
{431643CB-006C-49EF-8E0F-1540F994C936}.Release|Mixed Platforms.Build.0 = Debug|x86
{431643CB-006C-49EF-8E0F-1540F994C936}.Release|x86.ActiveCfg = Debug|x86
{431643CB-006C-49EF-8E0F-1540F994C936}.Release|x86.Build.0 = Debug|x86
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Itanium.ActiveCfg = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Debug|x86.ActiveCfg = Debug|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Any CPU.Build.0 = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Itanium.ActiveCfg = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{21915A7E-CC84-4836-8B87-857B6149D496}.Release|x86.ActiveCfg = Release|Any CPU
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|Any CPU.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|Itanium.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|Mixed Platforms.Build.0 = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|x86.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Debug|x86.Build.0 = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|Any CPU.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|Itanium.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|Mixed Platforms.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|Mixed Platforms.Build.0 = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|x86.ActiveCfg = Debug|x86
{78AC2B12-8185-4033-80F0-DA5BF874BE5E}.Release|x86.Build.0 = Debug|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1267,9 +1267,9 @@ Global
{78304B1E-C323-4A78-9E7D-2578E58311B6} = {79173AE7-4596-4D33-866F-6F94A2314BE8}
{E6D3B644-C487-472D-A978-C1A82D0C099B} = {79173AE7-4596-4D33-866F-6F94A2314BE8}
{25C3C6E4-1EDD-4542-A663-CAC7A1F40B3A} = {A06B122A-4AB7-4090-B41A-35028A293450}
{78AC2B12-8185-4033-80F0-DA5BF874BE5E} = {25C3C6E4-1EDD-4542-A663-CAC7A1F40B3A}
{21915A7E-CC84-4836-8B87-857B6149D496} = {25C3C6E4-1EDD-4542-A663-CAC7A1F40B3A}
{839EDC9D-6D2E-4892-A7F0-17861BA9FA0C} = {F104F6BC-EF8E-4408-A786-D570D7565231}
{431643CB-006C-49EF-8E0F-1540F994C936} = {F104F6BC-EF8E-4408-A786-D570D7565231}
{21915A7E-CC84-4836-8B87-857B6149D496} = {F104F6BC-EF8E-4408-A786-D570D7565231}
{78AC2B12-8185-4033-80F0-DA5BF874BE5E} = {F104F6BC-EF8E-4408-A786-D570D7565231}
EndGlobalSection
EndGlobal