flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Dufilie (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (FLEX-34984) for-each loops cross-compile incorrectly
Date Fri, 11 Dec 2015 06:12:11 GMT

     [ https://issues.apache.org/jira/browse/FLEX-34984?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Andy Dufilie updated FLEX-34984:
--------------------------------
    Description: 
When you write a for-each loop, the iterable gets re-evaluated on every iteration.

Example code:
{code}
for each (var item:Object in Test.getItems()) {
	Test.doSomething(item);
}
{code}
Cross-compiled:
{code}
  for (var foreachiter0 in Test.getItems()) 
  {
  var item = Test.getItems()[foreachiter0];
  {
    Test.doSomething(item);
  }}
{code}

It should not call Test.getItems() on every loop iteration. Instead, it should generate a
new local variable prior to entering the loop to store the result.

I believe the offending code is reduce_forLoop() in JSGeneratingReducer.java:

https://github.com/apache/flex-falcon/blob/808fd1601a0228883b06d061d0f6bd101888284e/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGeneratingReducer.java#L3426

  was:
When you write a for-each loop, the iterable gets re-evaluated on every iteration.

Example code:
{code}
	for each (var item:Object in Test.getItems()) {
		Test.doSomething(item);
	}
{code}
Cross-compiled:
{code}
  for (var foreachiter0 in Test.getItems()) 
  {
  var item = Test.getItems()[foreachiter0];
  {
    Test.doSomething(item);
  }}
{code}

It should not call Test.getItems() on every loop iteration. Instead, it should generate a
new local variable prior to entering the loop to store the result.

I believe the offending code is reduce_forLoop() in JSGeneratingReducer.java:

https://github.com/apache/flex-falcon/blob/808fd1601a0228883b06d061d0f6bd101888284e/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGeneratingReducer.java#L3426


> for-each loops cross-compile incorrectly
> ----------------------------------------
>
>                 Key: FLEX-34984
>                 URL: https://issues.apache.org/jira/browse/FLEX-34984
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: Falcon, FlexJS
>    Affects Versions: Apache FlexJS 0.5.0
>            Reporter: Andy Dufilie
>
> When you write a for-each loop, the iterable gets re-evaluated on every iteration.
> Example code:
> {code}
> for each (var item:Object in Test.getItems()) {
> 	Test.doSomething(item);
> }
> {code}
> Cross-compiled:
> {code}
>   for (var foreachiter0 in Test.getItems()) 
>   {
>   var item = Test.getItems()[foreachiter0];
>   {
>     Test.doSomething(item);
>   }}
> {code}
> It should not call Test.getItems() on every loop iteration. Instead, it should generate
a new local variable prior to entering the loop to store the result.
> I believe the offending code is reduce_forLoop() in JSGeneratingReducer.java:
> https://github.com/apache/flex-falcon/blob/808fd1601a0228883b06d061d0f6bd101888284e/compiler.js/src/org/apache/flex/compiler/internal/as/codegen/JSGeneratingReducer.java#L3426



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message