PenUltima Online

It is currently Tue Oct 07, 2008 7:13 pm

All times are UTC - 8 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Feature for ecompile - small Preprocessor
PostPosted: Tue Jul 04, 2006 2:48 pm 
Offline

Joined: Sat Feb 04, 2006 1:24 pm
Posts: 8
Location: Vienna, Austria
Hello,

it would be a fine thing to have at least a few preprocessor commands available in ecompile. (GNU CPP could be adapted, but it would be rather complex and much too large).

Only very few commands would help a lot:

#define VARIABLE [value] ... define a Variable in the Preprocessors namespace and optionally give it a value other than 1 (String or interger number would suffice).

#ifdef VARIABLE
... // Compile this lines only if #ifdef VARIABLE evalues to true.
...
...
#else
... // else compile this lines
...
...
#endif

With this simple commands we could for example have different includes, or could modify an entire code base with the new *.em files, and have it valid for an older version (096) too.

If the preprocessor variables could be replaced at any place in the code, a lot of practical things would be possible.

#ifdef POL_096_1
#define BUFFER 12
#else
#define BUFFER 14
#endif

const BUF_SIZE := BUFFER;
function xyz(x)
...
endfunction

I like eScript, and use it now for years, the only thing missing for me is a preprocessor. It could be written externally, but ecompile has a make function integrated and I think it would be ideally a part of ecompile.

OWHorus


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 6:11 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 419
Location: San Diego, California
It already has this ability, and has for a while..
When you compile something, it only compiles code into the ecl it will actually use.

This means if you have a function in your code that is never called, it doesn't get put into the ECL.

This also means if you have a constant and check its value, it will only compile it if can go into it - thats the preprocessor setup.

Example:
Find a large script, write down its file size.
Edit the script to have at the top

CONST COMPILE := 0;

in the program group put
program SomeProgram(some arguments)
if ( !COMPILE )
//... all the code here
endif
endprogram

compile and look at the ecl file size.. itll be lots smaller.

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 6:31 pm 
Ahhh.... I had actually suspected just that...

I've been using a nearly globally included "TESTING" const for some time now, to generate different compiles for testing or production, and sometimes it did seem to me that the file size really was different based solely on that single constant. I had mostly been assuming I was going nuts, though. hehe.

I did know, however, that eCompile never includes functions that are not used. I know that because I know that assuming the function block itself is properly defined, you could have an error in an include function's code that goes for a while without being realized, until you compile a script that actually USES the function.

I usually try to remove any 'testing' code, but use the const just as a second level of assurance... but knowing this now, that makes things interesting!


Top
  
 
 Post subject:
PostPosted: Wed Jul 05, 2006 12:07 pm 
Offline

Joined: Sat Feb 04, 2006 1:24 pm
Posts: 8
Location: Vienna, Austria
Austin wrote:
It already has this ability, and has for a while..
When you compile something, it only compiles code into the ecl it will actually use.

This means if you have a function in your code that is never called, it doesn't get put into the ECL.


This I knew already.

Austin wrote:
This also means if you have a constant and check its value, it will only compile it if can go into it - thats the preprocessor setup.

Example:
Find a large script, write down its file size.
Edit the script to have at the top

CONST COMPILE := 0;

in the program group put
program SomeProgram(some arguments)
if ( !COMPILE )
//... all the code here
endif
endprogram

compile and look at the ecl file size.. itll be lots smaller.


This is new to me, thank you. This will help.

Horus


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl