Sign in to follow this  
TheAtom

Debug information invalidates the bytecode

Recommended Posts

TheAtom    330

Edit: false alarm, see below

 

Tested on rev1602. Empty lines (or otherwise syntactically insignificant lines, such as comments) can make the saved bytecode unloadable due to some problems with source line debug information. The following fails to load from bytecode unless debug information has been stripped:

 















funcdef void FUNC();
class T
{
    FUNC@ f;
}

void tmain()
{
    T t;
    @t.f = test;
    t.f();
}

void test()
{
}

LoadByteCode() returns asERROR. Removing any of the empty lines before the actual code begins seems to solve the issue.

Edited by TheAtom

Share this post


Link to post
Share on other sites
WitchLord    4678

I couldn't reproduce the problem with the following test:

 

 
{
  engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
  engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL);
 
  mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
  mod->AddScriptSection("Test",
    "\n"
    " \n"
    " \n"
    " \n"
    " \n"
    " \n"
    " \n"
    " \n"
    " \n"
    " \n"
    " \n"
    " \n"
    " \n"
    " \n"
    "funcdef void FUNC();\n"
    "class T\n"
    "{\n"
    "    FUNC@ f;\n"
    "}\n"
    "\n"
    "void tmain()\n"
    "{\n"
    "    T t;\n"
    "    @t.f = test;\n"
    "    t.f();\n"
    "}\n"
    "\n"
    "void test()\n"
    "{\n"
    "}\n");
  r = mod->Build();
  if( r < 0 )
    TEST_FAILED;
 
  CBytecodeStream stream(__FILE__"white");
  mod->SaveByteCode(&stream);
  engine->Release();
 
  engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
  engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL);
  mod = engine->GetModule("2", asGM_ALWAYS_CREATE);
  r = mod->LoadByteCode(&stream);
  if( r < 0 )
    TEST_FAILED;
 
  engine->Release();
}

 

Any idea what's missing to reproduce the problem?

Share this post


Link to post
Share on other sites
TheAtom    330

The thing turned out to be a false alarm: it was Windows' CR/LF conversion mess up while loading the bytecode in our new test tool. Sorry to have bothered about this.

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