| 172 | } |
| 173 | |
| 174 | nullres nullcLoadModuleBySource(const char* module, const char* code) |
| 175 | { |
| 176 | using namespace NULLC; |
| 177 | NULLC_CHECK_INITIALIZED(false); |
| 178 | |
| 179 | if(!nullcCompile(code)) |
| 180 | return false; |
| 181 | if(strlen(module) > 512) |
| 182 | { |
| 183 | nullcLastError = "ERROR: module name is too long"; |
| 184 | return false; |
| 185 | } |
| 186 | |
| 187 | char path[1024]; |
| 188 | strcpy(path, module); |
| 189 | char *pos = path; |
| 190 | while(*pos) |
| 191 | if(*pos++ == '.') |
| 192 | pos[-1] = '/'; |
| 193 | strcat(path, ".nc"); |
| 194 | |
| 195 | if(BinaryCache::GetBytecode(path)) |
| 196 | { |
| 197 | nullcLastError = "ERROR: module already loaded"; |
| 198 | return false; |
| 199 | } |
| 200 | |
| 201 | char *bytecode = NULL; |
| 202 | nullcGetBytecode(&bytecode); |
| 203 | BinaryCache::PutBytecode(path, bytecode); |
| 204 | return 1; |
| 205 | } |
| 206 | |
| 207 | nullres nullcLoadModuleByBinary(const char* module, const char* binary) |
| 208 | { |