Skip to content

Commit

Permalink
Some type/runtime type worrk.
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbetros committed Oct 15, 2017
1 parent d8e527a commit 3cf8c80
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 44 deletions.
13 changes: 12 additions & 1 deletion Test.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.10
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{DAEF99B5-22F0-4885-B45B-9B600B857E1C}"
EndProject
Expand Down Expand Up @@ -156,6 +156,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spruce", "..\XSharp\source\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XSharp.x86", "..\XSharp\source\XSharp.x86\XSharp.x86.csproj", "{D0EABA08-88C9-4F7C-BCA9-361B58B20D67}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Compiler.Tests.TypeSystem", "Tests\Cosmos.Compiler.Tests.TypeSystem\Cosmos.Compiler.Tests.TypeSystem.csproj", "{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -589,6 +591,14 @@ Global
{D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Release|Any CPU.Build.0 = Release|Any CPU
{D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Release|x86.ActiveCfg = Release|Any CPU
{D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Release|x86.Build.0 = Release|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Debug|x86.ActiveCfg = Debug|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Debug|x86.Build.0 = Debug|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Release|Any CPU.Build.0 = Release|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Release|x86.ActiveCfg = Release|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -663,6 +673,7 @@ Global
{929EE8ED-6AD3-4442-A0C1-EC70665F2DCF} = {99192440-2DD7-4E71-B730-D44A73F46533}
{FF46829E-B612-4D36-80BE-ED04521AD91A} = {E9CD521E-C386-466D-B5F7-A5EB19A61625}
{D0EABA08-88C9-4F7C-BCA9-361B58B20D67} = {E9CD521E-C386-466D-B5F7-A5EB19A61625}
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34} = {ECEA7778-E786-4317-90B9-A2D4427CB91C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4418C803-277E-448F-A0A0-52788FA215AD}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\source\Cosmos.System2\Cosmos.System2.csproj" />
<ProjectReference Include="..\Cosmos.TestRunner.TestController\Cosmos.TestRunner.TestController.csproj" />
</ItemGroup>

</Project>
39 changes: 39 additions & 0 deletions Tests/Cosmos.Compiler.Tests.TypeSystem/Kernel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Cosmos.TestRunner;
using System;
using Sys = Cosmos.System;

namespace Cosmos.Compiler.Tests.TypeSystem
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Starting BCL tests now please wait...");
}

protected override void Run()
{
try
{
mDebugger.Send("Run");

string xString = "a";
Type xType = xString.GetType();
if (xType == typeof(string))
{
mDebugger.Send("Type is a string.");
}

TestController.Completed();
}
catch (Exception e)
{
mDebugger.Send("Exception occurred: " + e.Message);
mDebugger.Send(e.Message);
Console.WriteLine("Exception occurred");
Console.WriteLine(e.Message);
TestController.Failed();
}
}
}
}
184 changes: 184 additions & 0 deletions source/Cosmos.Core/CosmosRuntimeType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
using System;
using System.Globalization;
using System.Reflection;

namespace Cosmos.Core
{
public class CosmosRuntimeType : Type
{
internal uint mTypeId;

public CosmosRuntimeType(uint aTypeId)
: this()
{
mTypeId = aTypeId;
}

protected CosmosRuntimeType()
{
Name = "";
FullName = "";
Namespace = "";
AssemblyQualifiedName = "";
GUID = Guid.Empty;
Module = null;
Assembly = null;
UnderlyingSystemType = null;
BaseType = null;
}

public override string Name { get; }
public override string FullName { get; }
public override string Namespace { get; }
public override string AssemblyQualifiedName { get; }
public override Guid GUID { get; }
public override Module Module { get; }
public override Assembly Assembly { get; }
public override Type UnderlyingSystemType { get; }
public override Type BaseType { get; }

protected override bool IsArrayImpl()
{
throw new NotImplementedException();
}

protected override bool IsByRefImpl()
{
throw new NotImplementedException();
}

protected override bool IsCOMObjectImpl()
{
throw new NotImplementedException();
}

protected override bool IsPointerImpl()
{
throw new NotImplementedException();
}

protected override bool IsPrimitiveImpl()
{
throw new NotImplementedException();
}

protected override bool HasElementTypeImpl()
{
throw new NotImplementedException();
}

public override Type GetElementType()
{
throw new NotImplementedException();
}

// Attributes
public override object[] GetCustomAttributes(bool inherit)
{
throw new NotImplementedException();
}

public override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
throw new NotImplementedException();
}

public override bool IsDefined(Type attributeType, bool inherit)
{
throw new NotImplementedException();
}

protected override TypeAttributes GetAttributeFlagsImpl()
{
throw new NotImplementedException();
}

// Constructor
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
throw new NotImplementedException();
}

public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

// Event
public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

public override EventInfo[] GetEvents(BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

// Field
public override FieldInfo GetField(string name, BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

public override FieldInfo[] GetFields(BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

// Member
public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
{
throw new NotImplementedException();
}

// Method
protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
throw new NotImplementedException();
}

public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

// Property
protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
{
throw new NotImplementedException();
}

public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

// Nested Type
public override Type GetNestedType(string name, BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

public override Type[] GetNestedTypes(BindingFlags bindingAttr)
{
throw new NotImplementedException();
}

// Interface
public override Type GetInterface(string name, bool ignoreCase)
{
throw new NotImplementedException();
}

public override Type[] GetInterfaces()
{
throw new NotImplementedException();
}
}
}
7 changes: 4 additions & 3 deletions source/Cosmos.Core_Plugs/System/ObjectImpl.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Cosmos.Core;
using Cosmos.Debug.Kernel;
using Cosmos.IL2CPU.API;
using Cosmos.IL2CPU.API.Attribs;
using System;

namespace Cosmos.Core_Plugs.System
{
Expand All @@ -21,9 +21,10 @@ public static void Ctor(object aThis)
{
}

public static Type GetType(object aThis)
public static unsafe Type GetType([ObjectPointerAccess] uint* aThis)
{
return null;
uint xType = *aThis;
return new CosmosRuntimeType(xType);
}

public static int GetHashCode(object aThis)
Expand Down
6 changes: 3 additions & 3 deletions source/Cosmos.Core_Plugs/System/RuntimeTypeHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace Cosmos.Core_Plugs.System
[Plug(Target = typeof(global::System.RuntimeTypeHandle))]
public static class RuntimeTypeHandleImpl
{
//[PlugMethod(Signature = "System_Void__System_RuntimeTypeHandle__ctor_System_Void__")]
public static unsafe void Ctor(RuntimeTypeHandle aThis, void* aValue)
{
}

public static void Cctor() {
//
public static void Cctor()
{
//
}
}
}
39 changes: 39 additions & 0 deletions source/Cosmos.Core_Plugs/System/TypeImpl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Cosmos.Core;
using Cosmos.Debug.Kernel;
using Cosmos.IL2CPU.API.Attribs;
using System;

namespace Cosmos.Core_Plugs.System
{
[Plug(Target = typeof(Type))]
public unsafe class TypeImpl
{
private static Debugger mDebugger = new Debugger("Core", "Type Plug");

public static void CCtor()
{
}

[PlugMethod(Signature = "System_Type__System_Type_GetTypeFromHandle_System_RuntimeTypeHandle_")]
public static Type GetTypeFromHandle(ulong aHandle)
{
uint x = (uint)(aHandle >> 32);
uint* y = (uint*)x;
uint xTypeId = *y;
var xType = new CosmosRuntimeType(xTypeId);
return xType;
}

public static bool op_Equality(CosmosRuntimeType aLeft, CosmosRuntimeType aRight)
{
return aLeft.mTypeId == aRight.mTypeId;
}

public static bool op_Inequality(CosmosRuntimeType aLeft, CosmosRuntimeType aRight)
{
mDebugger.Send("Type.GetInequality");

return aLeft.mTypeId != aRight.mTypeId;
}
}
}
37 changes: 0 additions & 37 deletions source/Cosmos.System2_Plugs/System/TypeImpl.cs

This file was deleted.

0 comments on commit 3cf8c80

Please sign in to comment.