Skip to content

Commit

Permalink
(#354) TODO sweep, better typoe checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Nov 21, 2023
1 parent 44c0f1a commit 72ced1b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 19 additions & 6 deletions Cesium.CodeGen/Extensions/TypeSystemEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,31 @@ private static bool TypesCorrespond(TypeSystem typeSystem, TypeReference type1,
return type1 is PointerType pt && pt.ElementType.IsEqualTo(typeSystem.Void);
}

if (!type2.IsGenericInstance) return false;
type2 = type2.GetElementType();
if (type2 is not GenericInstanceType type2Instance) return false;
var type2Definition = type2.GetElementType();
if (type1.IsPointer)
{
// TODO: Analyze the generic argument.
return type2.FullName == CPtrFullTypeName;
if (type2Definition.FullName != CPtrFullTypeName)
{
// Non-pointer gets compared to a pointer.
return false;
}

var pointed1 = ((PointerType)type1).ElementType;
var pointed2 = type2Instance.GenericArguments.Single();
return TypesCorrespond(typeSystem, pointed1, pointed2);
}

if (type1.IsFunctionPointer)
{
// TODO: Analyze the generic argument.
return type2.FullName == FuncPtrFullTypeName;
if (type2Definition.FullName != FuncPtrFullTypeName)
{
// A function pointer gets compared to not a function pointer.
return false;
}

// TODO: Compare the function type signatures here.
return true;
}

throw new AssertException("Impossible: type1 should be either a pointer or a function pointer.");
Expand Down
2 changes: 0 additions & 2 deletions Cesium.Test.Framework/CSharpCompilationUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ public static class CSharpCompilationUtil
private const string _projectName = "TestProject";

/// <summary>Semaphore that controls the amount of simultaneously running tests.</summary>
// TODO: Should not be static, make a fixture.
private static readonly SemaphoreSlim _testSemaphore = new(Environment.ProcessorCount);

// TODO: Support references
public static async Task<string> CompileCSharpAssembly(
ITestOutputHelper output,
TargetRuntimeDescriptor runtime,
Expand Down

0 comments on commit 72ced1b

Please sign in to comment.