Advertisement

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

Started by September 10, 2009 09:32 PM
1 comment, last by hima 15 years, 2 months ago
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 :)
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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
I see. That makes it a lot easier then :D Thank you very much.

This topic is closed to new replies.

Advertisement