-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(interpreter) Remove unused methods #491
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -786,100 +786,6 @@ public override VoidObject VisitVarStmt(Stmt.Var stmt) | |
return VoidObject.Void; | ||
} | ||
|
||
private static ITypeReference? GreaterType(ITypeReference leftTypeReference, ITypeReference rightTypeReference) | ||
{ | ||
// TODO: Return the number of bits here or something instead. Also, think about whether we need to special-case | ||
// TODO: signed and unsigned integers. | ||
var leftMaxValue = GetApproximateMaxValue(leftTypeReference.ClrType); | ||
var rightMaxValue = GetApproximateMaxValue(rightTypeReference.ClrType); | ||
|
||
if (leftMaxValue == null || rightMaxValue == null) | ||
{ | ||
return null; | ||
} | ||
|
||
if (leftMaxValue > rightMaxValue) | ||
{ | ||
return leftTypeReference; | ||
} | ||
else | ||
{ | ||
return rightTypeReference; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Returns the approximate max value for the given type. | ||
/// | ||
/// The "approximate" part is important to understand how to properly use this method. Do _not_ use it in | ||
/// case you need an exact value. It is only suited for "size comparisons", to determine which one of two | ||
/// values that uses the "larger" type. For example, Double is larger than Single; Double is also larger | ||
/// than Decimal (even though the latter has a higher level of precision). Because of this, an example of | ||
/// types for which this method will return an approximate, inexact return value is Decimal. | ||
/// </summary> | ||
/// <param name="type">A Type.</param> | ||
/// <returns>The approximate max value for the given type.</returns> | ||
/// <exception cref="ArgumentOutOfRangeException">The given type is not supported by this method.</exception> | ||
private static double? GetApproximateMaxValue(Type? type) | ||
{ | ||
var typeCode = Type.GetTypeCode(type); | ||
|
||
switch (typeCode) | ||
{ | ||
case TypeCode.Empty: | ||
case TypeCode.DBNull: | ||
case TypeCode.Char: | ||
case TypeCode.Boolean: | ||
case TypeCode.DateTime: | ||
case TypeCode.String: | ||
// The types above are unsuitable for arithmetic operations. We might at some point consider | ||
// relaxing this and supporting Ruby-like things, like '*' * 10 to produce '**********'. | ||
// However, after having used Ruby for a long time, our conclusion is that such constructs are | ||
// rarely used and even though they add a bit of elegance/syntactic sugar to the expressiveness | ||
// of the language, the cost in terms of added complexity might not be worth it. | ||
return null; | ||
|
||
case TypeCode.Object: | ||
if (type == typeof(BigInteger)) | ||
{ | ||
// Note: this is insanely wrong. It means that Double, Decimal and BigInteger are currently | ||
// treated as "same size". The end result is that expressions like `5.0 ** 31` will return a | ||
// `double`, not a `BigInteger`. `10.0 ** 309` will return positive infinity, where `10 ** 309` | ||
// will return a large number. I'm not even sure what the "proper" semantics here would be | ||
// actually. | ||
return Convert.ToDouble(Decimal.MaxValue); | ||
} | ||
|
||
return null; | ||
|
||
case TypeCode.SByte: | ||
return SByte.MaxValue; | ||
case TypeCode.Byte: | ||
return Byte.MaxValue; | ||
case TypeCode.Int16: | ||
return Int16.MaxValue; | ||
case TypeCode.UInt16: | ||
return UInt16.MaxValue; | ||
case TypeCode.Int32: | ||
return Int32.MaxValue; | ||
case TypeCode.UInt32: | ||
return UInt32.MaxValue; | ||
case TypeCode.Int64: | ||
return Int64.MaxValue; | ||
case TypeCode.UInt64: | ||
return UInt64.MaxValue; | ||
case TypeCode.Single: | ||
return Single.MaxValue; | ||
case TypeCode.Double: | ||
return Double.MaxValue; | ||
case TypeCode.Decimal: | ||
// Note: this will likely loose some precision. | ||
return Convert.ToDouble(Decimal.MaxValue); | ||
default: | ||
throw new ArgumentException($"{typeCode} is not supported"); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused since 3dda89d. |
||
|
||
private static void ResolveExplicitTypes(ITypeReference typeReference) | ||
{ | ||
if (typeReference.TypeSpecifier == null) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused since de3ff2e.