fix non virtual calls to virtual methods.

This commit is contained in:
mterwoord_cp 2009-10-07 15:54:37 +00:00
parent 8f1178d019
commit 07276bf2fa
4 changed files with 32 additions and 13 deletions

View file

@ -1,4 +1,5 @@
//#define OUTPUT_ELF // leave the use of the following directive in: it eases a LOT during development, as it lets you use gdb for debugging
#define OUTPUT_ELF
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;

View file

@ -8,6 +8,7 @@ using System.Security.Cryptography;
using System.Reflection; using System.Reflection;
using System.Diagnostics; using System.Diagnostics;
using Cosmos.Sys.Network; using Cosmos.Sys.Network;
using Cosmos.Hardware;
namespace MatthijsTest namespace MatthijsTest
{ {
@ -26,15 +27,27 @@ namespace MatthijsTest
var xBoot = new Cosmos.Sys.Boot(); var xBoot = new Cosmos.Sys.Boot();
xBoot.Execute(); xBoot.Execute();
Console.WriteLine("Echoing started.");
do //TCPIPStack.Init();
//TCPIPStack.ConfigIP(
var xCount = 0;
for (int i = 0; i < Device.Devices.Count; i++)
{ {
var xString = Console.ReadLine(); var xItem = Device.Devices[i];
if (xString.Length > 2) if (xItem == null)
{ {
Console.WriteLine(xString); Console.WriteLine("NULL item!");
continue;
} }
} while (true); var xType = Device.Devices[i].Type;
if (Device.Devices[i].Type == Device.DeviceType.Network)
{
xCount++;
}
}
Console.Write("Network cards found: ");
Console.WriteLine(xCount.ToString());
} }
} }

View file

@ -64,10 +64,10 @@ namespace Cosmos.IL2CPU.X86.IL {
} }
public static void DoExecute(Assembler Assembler, MethodInfo aCurrentMethod, MethodBase aTargetMethod, uint aTargetMethodUID, int aCurrentPosition) { public static void DoExecute(Assembler Assembler, MethodInfo aCurrentMethod, MethodBase aTargetMethod, uint aTargetMethodUID, int aCurrentPosition) {
if (aTargetMethod.IsVirtual) { //if (aTargetMethod.IsVirtual) {
Callvirt.DoExecute(Assembler, aCurrentMethod, aTargetMethod, aTargetMethodUID, aCurrentPosition); // Callvirt.DoExecute(Assembler, aCurrentMethod, aTargetMethod, aTargetMethodUID, aCurrentPosition);
return; // return;
} //}
var xMethodInfo = aTargetMethod as System.Reflection.MethodInfo; var xMethodInfo = aTargetMethod as System.Reflection.MethodInfo;
string xCurrentMethodLabel = MethodInfoLabelGenerator.GenerateLabelName(aCurrentMethod.MethodBase); string xCurrentMethodLabel = MethodInfoLabelGenerator.GenerateLabelName(aCurrentMethod.MethodBase);
@ -77,7 +77,8 @@ namespace Cosmos.IL2CPU.X86.IL {
if (aTargetMethod.IsStatic || !aTargetMethod.IsVirtual || aTargetMethod.IsFinal) { if (aTargetMethod.IsStatic || !aTargetMethod.IsVirtual || aTargetMethod.IsFinal) {
xNormalAddress = MethodInfoLabelGenerator.GenerateLabelName(aTargetMethod); xNormalAddress = MethodInfoLabelGenerator.GenerateLabelName(aTargetMethod);
} else { } else {
throw new Exception("Call: non-concrete method called!"); xNormalAddress = MethodInfoLabelGenerator.GenerateLabelName(aTargetMethod);
//throw new Exception("Call: non-concrete method called!");
} }
var xParameters = aTargetMethod.GetParameters(); var xParameters = aTargetMethod.GetParameters();
int xArgCount = xParameters.Length; int xArgCount = xParameters.Length;

View file

@ -543,6 +543,10 @@ namespace Cosmos.IL2CPU {
if (xVirtMethod != null) { if (xVirtMethod != null) {
Queue(xVirtMethod, aMethod, "Virtual Base"); Queue(xVirtMethod, aMethod, "Virtual Base");
mVirtuals.Add(xVirtMethod); mVirtuals.Add(xVirtMethod);
if (aMethod.Name == "ToString")
{
Console.Write("");
}
// List changes as we go, cant be foreach // List changes as we go, cant be foreach
for (int i = 0; i < mItemsList.Count; i++) { for (int i = 0; i < mItemsList.Count; i++) {