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
 Problems with extract method
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bjoern.jonsson
New Member

3 Posts

Posted - Oct 04 2006 :  08:48:09 AM  Show Profile  Reply with Quote
Hi all,
I've just installed the trial version of VA X because i'm planning to do a major refactoring on some quite old code. Much of this refactoring will deal extracting parts of (very, very, very) long functions into shorter ones.

But somehow i just don't manage to get VA X to use references where it would clearly be needed. It even fails on:

int CMeasureObject::DummyDoNothing()
{
	int a=1, b=2, c=3;
	float f=0.0,g=1.0,h=1.0;

	for(a=b;a<=c;a+=b)
	{
		f=a*c+b;
		g=f*h;
		h=f*g;
	}
	return (int)f*g*h/3;
}

select the lines inside the for loop -> extract function and what i get is:

int CMeasureObject::DummyDoNothing()
{
	int a=1, b=2, c=3;
	float f=0.0,g=1.0,h=1.0;

	for(a=b;a<=c;a+=b)
	{
		MyMethod(f, a, c, b, g, h);
	}
	return (int)f*g*h/3;
}

void CMeasureObject::MyMethod( float f, int a, int c, int b, float g, float h )
{
	f=a*c+b;
	g=f*h;
	h=f*g;
}

btw: i'm on build 1535

Thanx

BJ

bjoern.jonsson
New Member

3 Posts

Posted - Oct 04 2006 :  08:59:09 AM  Show Profile  Reply with Quote
Found it:

int CMeasureObject::DummyDoNothing()
{
	int a=1, b=2, c=3;
	float f=0.0,g=1.0,h=1.0;

	for(a=b;a<=c;a+=b)
	{
	      f=a*c+b;
	      g = f*h;
	      h = f*g;
	}
	return (int)f*g*h/3;
}

gets to:

int CMeasureObject::DummyDoNothing()
{
	int a=1, b=2, c=3;
	float f=0.0,g=1.0,h=1.0;

	for(a=b;a<=c;a+=b)
	{
		MyMethod(f, a, c, b, g, h);

	}
	return (int)f*g*h/3;
}

void CMeasureObject::MyMethod( float f, int a, int c, int b, float &g, float &h )
{
	f=a*c+b;
	g = f*h;
	h = f*g;
}


so it seems like assignements without space before or after the = are ignored.
Go to Top of Page

bjoern.jonsson
New Member

3 Posts

Posted - Oct 05 2006 :  03:53:58 AM  Show Profile  Reply with Quote
There is even more to it:

seems like ExtractMethod fails to notice assignements of type:

a=anything; //space before or after = will make VAX notice assignement
a<<=2;
a <<= 2;
a/=2; //funny, *= works...
a|=2; //&= works...

which is rather annoying.

can anyone reproduce this, or is it just me?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Oct 05 2006 :  11:08:54 AM  Show Profile  Reply with Quote
i am seeing the same problems here. for me the effect seems to be slightly more subtle. using the detailed example in your second post changing the line:

g = f*h;

to

g=f*h;

causes problems.

case=2866

thank you for your detective work on this.

zen is the art of being at one with the two'ness
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Dec 19 2006 :  9:15:48 PM  Show Profile  Reply with Quote
case=2866 is fixed in build 1543
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