Skip to content

Commit

Permalink
Allow macro type name definitions to be null again
Browse files Browse the repository at this point in the history
  • Loading branch information
colinator27 committed Jul 10, 2024
1 parent bfe77cd commit a64b27e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void ReadContents(ref Utf8JsonReader reader, JsonSerializerOptions
throw new JsonException();
}

private static void ReadMacroNameList(ref Utf8JsonReader reader, JsonSerializerOptions options, Action<string, IMacroType> define)
private static void ReadMacroNameList(ref Utf8JsonReader reader, JsonSerializerOptions options, Action<string, IMacroType?> define)
{
if (reader.TokenType != JsonTokenType.StartObject)
{
Expand All @@ -78,7 +78,7 @@ private static void ReadMacroNameList(ref Utf8JsonReader reader, JsonSerializerO

// Read and define macro type
reader.Read();
define(propertyName, converter.Read(ref reader, typeof(IMacroType), options) ?? throw new JsonException());
define(propertyName, converter.Read(ref reader, typeof(IMacroType), options));
}

throw new JsonException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace Underanalyzer.Decompiler.GameSpecific;
/// </summary>
public class NameMacroTypeResolver : IMacroTypeResolver
{
private Dictionary<string, IMacroType> Variables { get; }
private Dictionary<string, IMacroType> FunctionArguments { get; }
private Dictionary<string, IMacroType> FunctionReturn { get; }
private Dictionary<string, IMacroType?> Variables { get; }
private Dictionary<string, IMacroType?> FunctionArguments { get; }
private Dictionary<string, IMacroType?> FunctionReturn { get; }

/// <summary>
/// Initializes an empty name resolver.
Expand All @@ -31,9 +31,9 @@ public NameMacroTypeResolver()
/// <summary>
/// Initializes a name resolver with pre-populated data.
/// </summary>
public NameMacroTypeResolver(Dictionary<string, IMacroType> variables,
Dictionary<string, IMacroType> functionArguments,
Dictionary<string, IMacroType> functionReturn)
public NameMacroTypeResolver(Dictionary<string, IMacroType?> variables,
Dictionary<string, IMacroType?> functionArguments,
Dictionary<string, IMacroType?> functionReturn)
{
Variables = new(variables);
FunctionArguments = new(functionArguments);
Expand All @@ -43,23 +43,23 @@ public NameMacroTypeResolver(Dictionary<string, IMacroType> variables,
/// <summary>
/// Defines a variable's macro type for this resolver.
/// </summary>
public void DefineVariableType(string name, IMacroType type)
public void DefineVariableType(string name, IMacroType? type)
{
Variables[name] = type;
}

/// <summary>
/// Defines a function's arguments macro type for this resolver.
/// </summary>
public void DefineFunctionArgumentsType(string name, IMacroType type)
public void DefineFunctionArgumentsType(string name, IMacroType? type)
{
FunctionArguments[name] = type;
}

/// <summary>
/// Defines a function's return macro type for this resolver.
/// </summary>
public void DefineFunctionReturnType(string name, IMacroType type)
public void DefineFunctionReturnType(string name, IMacroType? type)
{
FunctionReturn[name] = type;
}
Expand Down

0 comments on commit a64b27e

Please sign in to comment.