| 149 | } |
| 150 | |
| 151 | int dlua_chunk::load(CLua &interp) |
| 152 | { |
| 153 | if (!compiled.empty()) |
| 154 | { |
| 155 | return check_op(interp, |
| 156 | interp.loadbuffer(compiled.c_str(), compiled.length(), |
| 157 | context.c_str())); |
| 158 | } |
| 159 | |
| 160 | if (empty()) |
| 161 | { |
| 162 | chunk.clear(); |
| 163 | return E_CHUNK_LOAD_FAILURE; |
| 164 | } |
| 165 | |
| 166 | int err = check_op(interp, |
| 167 | interp.loadstring(chunk.c_str(), context.c_str())); |
| 168 | if (err) |
| 169 | return err; |
| 170 | ostringstream out; |
| 171 | err = lua_dump(interp, dlua_compiled_chunk_writer, &out, 0); |
| 172 | if (err) |
| 173 | { |
| 174 | const char *e = lua_tostring(interp, -1); |
| 175 | error = e? e : "Unknown error compiling chunk"; |
| 176 | lua_pop(interp, 2); |
| 177 | } |
| 178 | compiled = out.str(); |
| 179 | return err; |
| 180 | } |
| 181 | |
| 182 | int dlua_chunk::run(CLua &interp) |
| 183 | { |
no test coverage detected