jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
groovy
  • groovy
  • GROOVY-2503 MOP 2.0 design inflluencing issues
  • GROOVY-3478

Patch: Dynamic type promotion

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Sub-task Sub-task
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: 3.0
  • Component/s: None
  • Labels:
    None
  • Environment:
    N/A
  • Testcase included:
    yes
  • Patch Submitted:
    Yes
  • Number of attachments :
    1

Description

groovy:000> 1000 * 1000000000
===> 1000000000000

More info in mail thread http://www.nabble.com/Patch:-Dynamic-type-promotion-td22976282.html

Patch attached. Diffstat:

main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java        |   23 -
main/org/codehaus/groovy/runtime/InvokerHelper.java               |   20 -
main/org/codehaus/groovy/runtime/typehandling/BigIntegerMath.java |   26 +
main/org/codehaus/groovy/runtime/typehandling/IntegerMath.java    |   70 ++++
main/org/codehaus/groovy/runtime/typehandling/LongMath.java       |   85 ++++--
main/org/codehaus/groovy/runtime/typehandling/NumberMath.java     |   90 ++++--
test/groovy/operator/IntegerOperatorsTest.groovy                  |  141 +++++++++-
7 files changed, 369 insertions(+), 86 deletions(-)

I'll also keep an updated patch available at http://dl.getdropbox.com/u/283098/patches/groovy_dynamic_type_promotion.patch

Here's an overview of the patch:

  • Added test cases to IntegerOperatorsTest.groovy
  • Modified NumberMath toBigInteger and toBigDecimal methods to call into DefaultGroovyMethods versions
  • Modified IntegerMath to support dynamic type promotion for abs, add, subtract, multiply, unary minus and left shift.
  • Modified BigIntegerMath to support left shift and right shift. It does not support unsigned right shift (>>>).
  • Modified LongMath to support dynamic type promotion for abs, add, subtract, multiply, unary minus and left shift. Also changed a few "new Long" to "Long.valueOf" since it can be faster.
  • Modified DefaultGroovyMethods.abs to call into NumberMath. Optimized toBigInteger so that it doesn't do unnecessary string conversions. Tweaked a few comments.
  • Modified InvokerHelper.unaryMinus. Tweaked some valueOf.
  • Modified semantics for the shift operators. It's now type coerced/promoted the same as other binary operators. Negative shifts are not allowed.
  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    groovy_dynamic_type_promotion.patch
    19/Apr/09 5:45 PM
    26 kB
    Olov Lassus

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Guillaume Laforge made changes - 20/Apr/09 4:09 AM
Field Original Value New Value
Fix Version/s 1.7-beta-1 [ 14014 ]
Fix Version/s 1.6.2 [ 15151 ]
Guillaume Laforge made changes - 24/Apr/09 3:48 PM
Fix Version/s 1.6.3 [ 15251 ]
Fix Version/s 1.6.2 [ 15151 ]
Guillaume Laforge made changes - 13/May/09 9:16 AM
Fix Version/s 1.6.3 [ 15251 ]
Guillaume Laforge made changes - 31/Jul/09 12:09 PM
Fix Version/s 1.7-beta-1 [ 14014 ]
Fix Version/s 1.7-beta-x [ 15538 ]
blackdrag blackdrag made changes - 16/Aug/12 10:05 AM
Fix Version/s 1.8.x [ 15750 ]
Fix Version/s 2.x [ 17013 ]
Fix Version/s 1.7.x [ 15538 ]
blackdrag blackdrag made changes - 18/Jan/13 2:24 PM
Parent GROOVY-2503 [ 61571 ]
Issue Type Improvement [ 4 ] Sub-task [ 7 ]
blackdrag blackdrag made changes - 18/Jan/13 2:25 PM
Fix Version/s 3.0 [ 13489 ]
Fix Version/s 1.8.x [ 15750 ]
Fix Version/s 2.x [ 17013 ]

People

  • Assignee:
    Unassigned
    Reporter:
    Olov Lassus
Vote (0)
Watch (2)

Dates

  • Created:
    19/Apr/09 5:45 PM
    Updated:
    18/Jan/13 2:25 PM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.