-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial predefined doubles implementation
- Loading branch information
1 parent
aa9822d
commit 79d6eb1
Showing
4 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
Underanalyzer/Decompiler/AST/Nodes/PredefinedDoubleNode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using Underanalyzer.Decompiler.GameSpecific; | ||
|
||
namespace Underanalyzer.Decompiler.AST; | ||
|
||
/// <summary> | ||
/// Represents a predefined double constant in the AST, with one single part. | ||
/// </summary> | ||
public class PredefinedDoubleSingleNode : IExpressionNode, IConditionalValueNode | ||
{ | ||
public string Value { get; } | ||
public double OriginalValue { get; } | ||
|
||
public bool Duplicated { get; set; } = false; | ||
public bool Group { get; set; } = false; | ||
public IGMInstruction.DataType StackType { get; set; } = IGMInstruction.DataType.Double; | ||
|
||
public string ConditionalTypeName => "PredefinedDouble"; | ||
public string ConditionalValue => Value; | ||
|
||
public PredefinedDoubleSingleNode(string value, double originalValue) | ||
{ | ||
Value = value; | ||
OriginalValue = originalValue; | ||
} | ||
|
||
public IExpressionNode Clean(ASTCleaner cleaner) | ||
{ | ||
return this; | ||
} | ||
|
||
public virtual void Print(ASTPrinter printer) | ||
{ | ||
printer.Write(Value); | ||
} | ||
|
||
public IExpressionNode ResolveMacroType(ASTCleaner cleaner, IMacroType type) | ||
{ | ||
if (type is IMacroTypeConditional conditional) | ||
{ | ||
return conditional.Resolve(cleaner, this); | ||
} | ||
return null; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Represents a predefined double constant in the AST, with multiple parts. | ||
/// </summary> | ||
public class PredefinedDoubleMultiNode : PredefinedDoubleSingleNode, IMultiExpressionNode | ||
{ | ||
public PredefinedDoubleMultiNode(string value, double originalValue) : base(value, originalValue) | ||
{ | ||
} | ||
|
||
public override void Print(ASTPrinter printer) | ||
{ | ||
if (Group) | ||
{ | ||
printer.Write('('); | ||
} | ||
base.Print(printer); | ||
if (Group) | ||
{ | ||
printer.Write(')'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters