interface
| 258 | |
| 259 | // interface |
| 260 | int asCModule::Build() |
| 261 | { |
| 262 | #ifdef AS_NO_COMPILER |
| 263 | return asNOT_SUPPORTED; |
| 264 | #else |
| 265 | TimeIt("asCModule::Build"); |
| 266 | |
| 267 | // Don't allow the module to be rebuilt if there are still |
| 268 | // external references that will need the previous code |
| 269 | // TODO: interface: The asIScriptModule must have a method for querying if the module is used |
| 270 | if( HasExternalReferences(false) ) |
| 271 | { |
| 272 | m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, TXT_MODULE_IS_IN_USE); |
| 273 | return asMODULE_IS_IN_USE; |
| 274 | } |
| 275 | |
| 276 | // Only one thread may build at one time |
| 277 | // TODO: It should be possible to have multiple threads perform compilations |
| 278 | int r = m_engine->RequestBuild(); |
| 279 | if( r < 0 ) |
| 280 | return r; |
| 281 | |
| 282 | m_engine->PrepareEngine(); |
| 283 | if( m_engine->configFailed ) |
| 284 | { |
| 285 | m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, TXT_INVALID_CONFIGURATION); |
| 286 | m_engine->BuildCompleted(); |
| 287 | return asINVALID_CONFIGURATION; |
| 288 | } |
| 289 | |
| 290 | InternalReset(); |
| 291 | |
| 292 | if( !m_builder ) |
| 293 | { |
| 294 | m_engine->BuildCompleted(); |
| 295 | return asSUCCESS; |
| 296 | } |
| 297 | |
| 298 | // Compile the script |
| 299 | r = m_builder->Build(); |
| 300 | asDELETE(m_builder,asCBuilder); |
| 301 | m_builder = 0; |
| 302 | |
| 303 | if( r < 0 ) |
| 304 | { |
| 305 | // Reset module again |
| 306 | InternalReset(); |
| 307 | |
| 308 | m_engine->BuildCompleted(); |
| 309 | return r; |
| 310 | } |
| 311 | |
| 312 | JITCompile(); |
| 313 | |
| 314 | m_engine->PrepareEngine(); |
| 315 | |
| 316 | #ifdef AS_DEBUG |
| 317 | // Verify that there are no unwanted gaps in the scriptFunctions array. |