Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Extract Method introduces invalid syntax
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

legalize
Tomato Guru

USA
119 Posts

Posted - Jun 16 2014 :  10:56:55 AM  Show Profile  Reply with Quote
See test suite at http://d3dgraphicspipeline.codeplex.com/releases/view/39824
int (*Method2(int x))()
{
    int (*result)();
    if (x < 0)
    {
        // #TEST#: EM2 Extract Method on next line
        result = Function1;
    }
    else
    {
        result = Function2;
    }
    return result;
}

Extracted method looks like this:
int (* MyMethod(int (* result)
{
    result = Function1;
    return result;
}

The syntax is invalid.
There is no need to pass in result as an argument to the extracted method.

http://legalizeadulthood.wordpress.com

legalize
Tomato Guru

USA
119 Posts

Posted - Jun 16 2014 :  10:59:33 AM  Show Profile  Reply with Quote
Similar problem when the type is a pointer to member function:

void (Bar::*Method3(int x))(int)
{
    void (Bar::*member)(int);
    if (x < 0)
    {
        // #TEST#: EM3 Extract Method on next line
        member = &Bar::Operation1;
    }
    else
    {
        member = &Bar::Operation2;
    }
    return member;
}

Extract Method for EM3 yields:

void (Bar::* MyMethod(void (Bar::* member)
{
    member = &Bar::Operation1;
    return member;
}

http://legalizeadulthood.wordpress.com
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19186 Posts

Posted - Jun 16 2014 :  2:46:31 PM  Show Profile  Reply with Quote
I am seeing the same effect here. Thank you for the clear description.

case=82956

I found the first problem when working through ExtractFunction.cpp. The second example is indeed the same problem, with a slightly different initial state.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000