PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Feature for ecompile - small Preprocessor

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
OWHorus



Joined: 04 Feb 2006
Posts: 7
Location: Vienna, Austria

PostPosted: Tue Jul 04, 2006 6:48 pm    Post subject: Feature for ecompile - small Preprocessor Reply with quote

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

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 355
Location: San Diego, California

PostPosted: Tue Jul 04, 2006 10:11 pm    Post subject: Reply with quote

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.

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Tue Jul 04, 2006 10:31 pm    Post subject: Reply with quote

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!

Author Message
OWHorus



Joined: 04 Feb 2006
Posts: 7
Location: Vienna, Austria

PostPosted: Wed Jul 05, 2006 4:07 pm    Post subject: Reply with quote

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

Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty