Skip to content
Snippets Groups Projects
Commit 13311493 authored by MaZiFAU's avatar MaZiFAU
Browse files

Minor Bugfix and Unsupported cases for AnonymousTypes

parent 0db8aa88
No related branches found
No related tags found
No related merge requests found
......@@ -222,15 +222,16 @@ public static class MMTConstants
Product },
{ MakeType,
MakeTypeType },
// needed?
//{ MakeTypeType,
// MakeTypeType },
{ MakeTypeType,
MakeTypeType },
};
public static readonly IReadOnlyDictionary<string, string> TypeOF_TO_HeterogenApplication = HeterogenApplication_TO_TypeOF.ReverseKeyVal();
public static readonly IReadOnlyDictionary<string, string> HomogenApplication_TO_TypeOF = new Dictionary<string, string> {
{ ListApplicant,
ListType },
{ ListType,
ListType },
};
public static readonly IReadOnlyDictionary<string, string> TypeOF_TO_HomogenApplication = HomogenApplication_TO_TypeOF.ReverseKeyVal();
......
......@@ -289,7 +289,9 @@ void ThrowArgumentException(ExpressionType expression_cast, int expected)
int free_params = lambda_lambda.Parameters.Count() - lambda_applicant.Length;
if (free_params <= 0)
return Expression.Lambda(
Expression.Invoke(lambda_lambda, lambda_applicant[..^Math.Max(0, free_params)]),
Expression.Invoke(
lambda_lambda,
lambda_applicant.Select(app => app.Body).Take(lambda_lambda.Parameters.Count())),
found_bound_params
);
......
......@@ -82,7 +82,10 @@ public static SOMDoc SOMDocType(Type type)
type = typeof(Tuple);
if (type.HasElementType) // pretend its a List
type = typeof(List<>); // Dictionary does not like Generics
type = typeof(List<>);
if (type.IsGenericType) // Dictionary does not like Assembled Generics
type = type.GetGenericTypeDefinition();
if (FuncExtensions.IsFuncType(type, out _))
......@@ -93,6 +96,13 @@ public static SOMDoc SOMDocType(Type type)
? new OMA(new OMS(uri), args)
: new OMS(uri);
if (type.IsAnonymousType())
return new OMA(
new OMS(MMTConstants.MakeTypeType),
type.GetFields()
.Select(mem => new OML_Member(mem.Name, SOMDocType(mem.FieldType), null))
.ToArray());
throw new NotImplementedException($"For Type {type}");
}
......@@ -554,7 +564,7 @@ protected internal override Type ToType(Type[] args, (string name, Type type)[]
{
if (FactRecorder.AllFacts.TryGetValue(uri, out Fact found))
return found.GetType();
if (MMTConstants.HeterogenApplication_TO_TypeOF.TryGetValue(uri, out string s_type))
{
Type type = MMTConstants.OMS_TO_TYPE[s_type];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment