Jump to content
  • Advertisement
Sign in to follow this  
Takayuki

Questions about how to add a ByteCode

This topic is 2335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

AddSectionFromFile will add the text.
LoadByteCode will load the ByteCode.
Please tell me if there is a way to add a ByteCode as AddSectionFromFile.

Share this post


Link to post
Share on other sites
Advertisement
Hi, LoadBytecode() will load the entire script module as it was built with the Build() function. There is currently no way of saving or loading a partial script module.

Can you elaborate on what you're trying to accomplish? Perhaps there is something I might consider for future releases.

Share this post


Link to post
Share on other sites
previous versions were able to add angelscript_2.22.1 ByteCode by overriding the CScriptBuilder. from angelscript_2.22.2 was that this will not be able to.

int CScriptBuilderEx::Build()
{
// int r = module->Build();
int r = ModuleBuild(); // Change
if( r < 0 )
return r;
int CScriptBuilderEx::ModuleBuild()
{
// Only one thread may build at one time
// TODO: It should be possible to have multiple threads perform compilations
int r = ((asCScriptEngine*)engine)->RequestBuild();
if( r < 0 )
return r;
((asCScriptEngine*)engine)->PrepareEngine();
if( ((asCScriptEngine*)engine)->configFailed )
{
engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, TXT_INVALID_CONFIGURATION);
((asCScriptEngine*)engine)->BuildCompleted();
return asINVALID_CONFIGURATION;
}
// ((asCModule*)module)->InternalReset();
if( !((asCModule*)module)->builder )
{
((asCScriptEngine*)engine)->BuildCompleted();
return asSUCCESS;
}
// Compile the script
r = ((asCModule*)module)->builder->Build();
asDELETE(((asCModule*)module)->builder,asCBuilder);
((asCModule*)module)->builder = 0;

if( r < 0 )
{
// Reset module again
((asCModule*)module)->InternalReset();
((asCScriptEngine*)engine)->BuildCompleted();
return r;
}
((asCModule*)module)->JITCompile();
((asCScriptEngine*)engine)->PrepareEngine();
((asCScriptEngine*)engine)->BuildCompleted();
// Initialize global variables
if( r >= 0 && ((asCScriptEngine*)engine)->ep.initGlobalVarsAfterBuild )
r = ((asCModule*)module)->ResetGlobalVars(0);
return r;
}

Share this post


Link to post
Share on other sites
The internals of the script engine were never intended to be accessed directly by the application. Of course, you're free to do so in your project as you like, but you cannot make any assumptions that it will continue to work with new releases.

You didn't tell me what you're trying to accomplish.

If you just want to dynamically add functions and global variables, you can use the asIScriptModule::CompileFunction and CompileGlobalVar to do that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!