| 205 | } |
| 206 | |
| 207 | nullres nullcLoadModuleByBinary(const char* module, const char* binary) |
| 208 | { |
| 209 | using namespace NULLC; |
| 210 | NULLC_CHECK_INITIALIZED(false); |
| 211 | |
| 212 | if(strlen(module) > 512) |
| 213 | { |
| 214 | nullcLastError = "ERROR: module name is too long"; |
| 215 | return false; |
| 216 | } |
| 217 | |
| 218 | char path[1024]; |
| 219 | strcpy(path, module); |
| 220 | char *pos = path; |
| 221 | while(*pos) |
| 222 | if(*pos++ == '.') |
| 223 | pos[-1] = '/'; |
| 224 | strcat(path, ".nc"); |
| 225 | |
| 226 | if(BinaryCache::GetBytecode(path)) |
| 227 | { |
| 228 | nullcLastError = "ERROR: module already loaded"; |
| 229 | return false; |
| 230 | } |
| 231 | // Duplicate binary |
| 232 | char *copy = (char*)NULLC::alloc(((ByteCode*)binary)->size); |
| 233 | memcpy(copy, binary, ((ByteCode*)binary)->size); |
| 234 | binary = copy; |
| 235 | // Load it into cache |
| 236 | BinaryCache::PutBytecode(path, binary); |
| 237 | return 1; |
| 238 | } |
| 239 | |
| 240 | void nullcRemoveModule(const char* module) |
| 241 | { |
no outgoing calls