
CNest™ program
by Stanislaw Raczynski ©
Consult also: http://www.raczynski.com/pn/bluesss.htm (Bluesss Simulation System)
http://www.raczynski.com/pn/simcourse.htm (Program and material for a complete simulation course)
|
|
This is a simple program which will help you to make your
C code more readable and clear. The main function of CNest is to insert
proper nesting to your code. It works only on the code (*.c or *.cpp units)
and does not change header files, if any exist. The operation modes of CNest
are as follows:
CNest has been developed to process the code generated by the Bluesss Simulation System. However, it can process any C or C++ code. Examples: Simple nesting: The original code: String ucho; int MyFunction // my function
(int a, float b
){
a=sqr(a); b=a+52*b; for(int k=0;k<10;k++)b+=a+b; return b;}
void OtherFunction(int a, float variablex[]){variablex[a]=7;if
(a==2){variablex[a]=a*a; Sleep(200); variablex[a+1]=0;}}
The result of processning in "Simple nesting" mode: String ucho;
// my function
int MyFunction
(int a, float b)
{
a=sqr(a);
b=a+52*b;
for(int k=0;k<10;k++)b+=a+b;
return b;
}
// End of function MyFunction
void OtherFunction(int a, float variablex[])
{
variablex[a]=7;
if(a==2)
{
variablex[a]=a*a;
Sleep(200);
variablex[a+1]=0;
}
}
// End of function OtherFunction
Processing in "Compact" mode will result in the following: String ucho;
// my function
int MyFunction
(int a, float b)
{a=sqr(a);
b=a+52*b;
for(int k=0;k<10;k++)b+=a+b;
return b;}
// End of function MyFunction
void OtherFunction(int a, float variablex[])
{variablex[a]=7;
if(a==2)
{variablex[a]=a*a;
Sleep(200);
variablex[a+1]=0;}}
// End of function OtherFunction
The same code after processing in "Compact" and "Merge short instructions" mode: String ucho;
// my function
int MyFunction (int a, float b) {a=sqr(a); b=a+52*b;
for(int k=0;k<10;k++)b+=a+b; return b;}
// End of function MyFunction
void OtherFunction(int a, float variablex[])
{variablex[a]=7;
if (a==2)
{variablex[a]=a*a; Sleep(200); variablex[a+1]=0;}}
// End of function OtherFunction
|
![]() |
Consult also http://www.raczynski.com/pn/pn.htm and http://www.raczynski.com (resume of Stanislaw Raczynski) |
You are visitor number since Feb 25, 2007 (last counter reset)