Sign in to follow this  
hima

Example on compiling .as file to a pre-compiled bytecode?

Recommended Posts

I believe we can pre-compile .as file and let the VM read the compiled version of AngelScript, no? Like, how Lua has .lua and .luac which can be both read by the VM, just that the latter is already compiled and thus is safer from the hand of standard user. Is there any example on how to do this? I read the documentation but I don't quite understand how to do it. From what I understand, I have to write another application that has the same wrapper as the main application, but instead of executing the script, I save it to bytecode instead. And then in the main application, I'll read in the compiled script and execute it as usual. Is this correct? Also, I was wondering about the preprocesser like #include. Do I have to do anythin special to compile the included scripts? Thank you in advance :)

Share this post


Link to post
Share on other sites
You probably saw this: Pre-compiled bytecode.

If you want to keep the compiler separate from the application, then you need to write another application like you said. In it you need to register the same interface (types, methods, functions, etc) that you do in your real application. You can register the functions and methods with null pointers, as they won't actually be called. You may also want to set the engine property asEP_INIT_GLOBAL_VARS_AFTER_BUILD to false, so that the engine doesn't try to initialize the global variables after the build.

The saved byte code stores the entire script module, so if the module was compiled with multiple script sections, e.g. #includes, then all of them will be stored together so there is no need to do anything special about them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this