Compiled code size
Hi, I'm trying out AngelScript and I have a couple quick questions about compiling AngelScript to byte-code.
First off, it appears that a script cannot be compiled unless all of its native functions have been registered. Is there any way to forward declare native functions so a general byte compiler can be made? Otherwise, is it impossible to compile to byte-code without knowing and declaring every native function? (This may not be a bad thing, as it allows many compile time checks, but I'm just asking.)
Secondly, I expected compiled byte-code to be small, but instead it's several times bigger than the script size. Is this normal, or am I doing something wrong? I'm just using the SaveByteCode and LoadByteCode methods. The scripts run fine from byte-code.
I'm still using version 2.16.0.
Thanks very much.
Hi Wirthy,
You cannot compile scripts that are going to call native functions without first registering them. However, you can register the functions with null pointers, so you don't actually have to have the implementation of them. Taking this a step further you could allow the scripts to declare the functions themselves and then run a preprocessor on the script to register the functions before compiling the rest of the script.
You know, I never actually checked the size of the bytecode that is saved, and there are likely things that can be done to make it smaller. However, it is quite reasonable that the saved bytecode is larger in some cases. Especially if the original script is small. The saved bytecode has some overhead to store the used registered functions to be able to relink them upon loading.
I'll see what I can do to reduce the size of the saved bytecode in the future. Thanks for bringing it up to attention.
Regards,
Andreas
You cannot compile scripts that are going to call native functions without first registering them. However, you can register the functions with null pointers, so you don't actually have to have the implementation of them. Taking this a step further you could allow the scripts to declare the functions themselves and then run a preprocessor on the script to register the functions before compiling the rest of the script.
You know, I never actually checked the size of the bytecode that is saved, and there are likely things that can be done to make it smaller. However, it is quite reasonable that the saved bytecode is larger in some cases. Especially if the original script is small. The saved bytecode has some overhead to store the used registered functions to be able to relink them upon loading.
I'll see what I can do to reduce the size of the saved bytecode in the future. Thanks for bringing it up to attention.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement