Creates the register type list for a function. Native functions only need this to assert their parameters in debug mode, script functions use this to load their registers from the VMValues.
| 78 | // Creates the register type list for a function. |
| 79 | // Native functions only need this to assert their parameters in debug mode, script functions use this to load their registers from the VMValues. |
| 80 | void VMFunction::CreateRegUse() |
| 81 | { |
| 82 | #ifdef NDEBUG |
| 83 | if (VarFlags & VARF_Native) return; // we do not need this for native functions in release builds. |
| 84 | #endif |
| 85 | int count = 0; |
| 86 | if (!Proto) |
| 87 | { |
| 88 | //if (RegTypes) return; |
| 89 | //Printf(TEXTCOLOR_ORANGE "Function without prototype needs register info manually set: %s\n", PrintableName); |
| 90 | return; |
| 91 | } |
| 92 | assert(Proto->isPrototype()); |
| 93 | |
| 94 | for (auto arg : Proto->ArgumentTypes) |
| 95 | { |
| 96 | count += arg? arg->GetRegCount() : 1; |
| 97 | } |
| 98 | uint8_t *regp; |
| 99 | RegTypes = regp = (uint8_t*)ClassDataAllocator.Alloc(count); |
| 100 | count = 0; |
| 101 | for (unsigned i = 0; i < Proto->ArgumentTypes.Size(); i++) |
| 102 | { |
| 103 | auto arg = Proto->ArgumentTypes[i]; |
| 104 | auto flg = ArgFlags.Size() > i ? ArgFlags[i] : 0; |
| 105 | if (arg == nullptr) |
| 106 | { |
| 107 | // Marker for start of varargs. |
| 108 | *regp++ = REGT_NIL; |
| 109 | } |
| 110 | else if ((flg & VARF_Out) && !arg->isPointer()) |
| 111 | { |
| 112 | *regp++ = REGT_POINTER; |
| 113 | } |
| 114 | else for (int j = 0; j < arg->GetRegCount(); j++) |
| 115 | { |
| 116 | *regp++ = arg->GetRegType(); |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | VMScriptFunction::VMScriptFunction(FName name) |
| 122 | { |
no test coverage detected