interface
| 1636 | |
| 1637 | // interface |
| 1638 | int asCModule::LoadByteCode(asIBinaryStream *in, bool *wasDebugInfoStripped) |
| 1639 | { |
| 1640 | if( in == 0 ) return asINVALID_ARG; |
| 1641 | |
| 1642 | // Don't allow the module to be rebuilt if there are still |
| 1643 | // external references that will need the previous code |
| 1644 | if( HasExternalReferences(false) ) |
| 1645 | { |
| 1646 | m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, TXT_MODULE_IS_IN_USE); |
| 1647 | return asMODULE_IS_IN_USE; |
| 1648 | } |
| 1649 | |
| 1650 | // Only permit loading bytecode if no other thread is currently compiling |
| 1651 | // TODO: It should be possible to have multiple threads perform compilations |
| 1652 | int r = m_engine->RequestBuild(); |
| 1653 | if( r < 0 ) |
| 1654 | return r; |
| 1655 | |
| 1656 | asCReader read(this, in, m_engine); |
| 1657 | r = read.Read(wasDebugInfoStripped); |
| 1658 | if (r < 0) |
| 1659 | { |
| 1660 | m_engine->BuildCompleted(); |
| 1661 | return r; |
| 1662 | } |
| 1663 | |
| 1664 | JITCompile(); |
| 1665 | |
| 1666 | #ifdef AS_DEBUG |
| 1667 | // Verify that there are no unwanted gaps in the scriptFunctions array. |
| 1668 | for( asUINT n = 1; n < m_engine->scriptFunctions.GetLength(); n++ ) |
| 1669 | { |
| 1670 | int id = n; |
| 1671 | if( m_engine->scriptFunctions[n] == 0 && !m_engine->freeScriptFunctionIds.Exists(id) ) |
| 1672 | asASSERT( false ); |
| 1673 | } |
| 1674 | #endif |
| 1675 | |
| 1676 | m_engine->BuildCompleted(); |
| 1677 | |
| 1678 | return r; |
| 1679 | } |
| 1680 | |
| 1681 | // interface |
| 1682 | int asCModule::CompileGlobalVar(const char *sectionName, const char *code, int lineOffset) |