| 1146 | } |
| 1147 | |
| 1148 | asCScriptFunction *asCReader::ReadFunction(bool &isNew, bool addToModule, bool addToEngine, bool addToGC, bool *isExternal) |
| 1149 | { |
| 1150 | isNew = false; |
| 1151 | if (isExternal) *isExternal = false; |
| 1152 | if( error ) return 0; |
| 1153 | |
| 1154 | char c; |
| 1155 | ReadData(&c, 1); |
| 1156 | |
| 1157 | if( c == '\0' ) |
| 1158 | { |
| 1159 | // There is no function, so return a null pointer |
| 1160 | return 0; |
| 1161 | } |
| 1162 | |
| 1163 | if( c == 'r' ) |
| 1164 | { |
| 1165 | // This is a reference to a previously saved function |
| 1166 | asUINT index = ReadEncodedUInt(); |
| 1167 | if( index < savedFunctions.GetLength() ) |
| 1168 | return savedFunctions[index]; |
| 1169 | else |
| 1170 | { |
| 1171 | Error(TXT_INVALID_BYTECODE_d); |
| 1172 | return 0; |
| 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | // Load the new function |
| 1177 | isNew = true; |
| 1178 | asCScriptFunction *func = asNEW(asCScriptFunction)(engine,0,asFUNC_DUMMY); |
| 1179 | if( func == 0 ) |
| 1180 | { |
| 1181 | // Out of memory |
| 1182 | error = true; |
| 1183 | return 0; |
| 1184 | } |
| 1185 | savedFunctions.PushLast(func); |
| 1186 | |
| 1187 | int i, count; |
| 1188 | asCDataType dt; |
| 1189 | int num; |
| 1190 | |
| 1191 | asCObjectType *parentClass = 0; |
| 1192 | ReadFunctionSignature(func, &parentClass); |
| 1193 | if( error ) |
| 1194 | { |
| 1195 | func->DestroyHalfCreated(); |
| 1196 | return 0; |
| 1197 | } |
| 1198 | |
| 1199 | if( func->funcType == asFUNC_SCRIPT ) |
| 1200 | { |
| 1201 | // Skip this for external shared entities |
| 1202 | if (module->m_externalTypes.IndexOf(func->objectType) >= 0) |
| 1203 | { |
| 1204 | // Replace with the real function from the existing entity |
| 1205 | isNew = false; |
nothing calls this directly
no test coverage detected