| 1075 | } |
| 1076 | |
| 1077 | void Object::DebugWriteProperty(IDebugProperties *aDebugger, int aPage, int aPageSize, int aDepth) |
| 1078 | { |
| 1079 | auto enum_method = IsClassPrototype() ? nullptr : GetMethod(_T("__Enum")); |
| 1080 | int num_children = (int)mFields.Length() + (mBase != nullptr) + (enum_method != nullptr); |
| 1081 | |
| 1082 | DebugCookie cookie; |
| 1083 | aDebugger->BeginProperty(NULL, "object", num_children, cookie); |
| 1084 | |
| 1085 | if (aDepth) |
| 1086 | { |
| 1087 | int page_start = aPageSize * aPage, page_end = aPageSize * (aPage + 1); |
| 1088 | |
| 1089 | if (mBase) |
| 1090 | { |
| 1091 | // Since this object has a "base", let it count as the first field. |
| 1092 | if (page_start == 0) // i.e. this is the first page. |
| 1093 | { |
| 1094 | aDebugger->WriteBaseProperty(mBase); |
| 1095 | // Now fall through and retrieve field[0] (unless aPageSize == 1). |
| 1096 | } |
| 1097 | // So 20..39 becomes 19..38 when there's a base object: |
| 1098 | else --page_start; |
| 1099 | --page_end; |
| 1100 | } |
| 1101 | int field_count = (int)mFields.Length(); |
| 1102 | int i = page_start, page_end_field = min(page_end, field_count); |
| 1103 | // For each field in the requested page... |
| 1104 | for ( ; i < page_end_field; ++i) |
| 1105 | { |
| 1106 | Object::FieldType &field = mFields[i]; |
| 1107 | ExprTokenType value; |
| 1108 | if (field.symbol == SYM_DYNAMIC) |
| 1109 | { |
| 1110 | if (field.prop->MinParams > 0) |
| 1111 | continue; |
| 1112 | aDebugger->WriteDynamicProperty(field.name); |
| 1113 | } |
| 1114 | else |
| 1115 | { |
| 1116 | field.ToToken(value); |
| 1117 | aDebugger->WriteProperty(field.name, value); |
| 1118 | } |
| 1119 | } |
| 1120 | if (enum_method && i < page_end) |
| 1121 | { |
| 1122 | if (dynamic_cast<BuiltInMethod *>(enum_method)) |
| 1123 | { |
| 1124 | // Built-in enumerators are always safe to call automatically. |
| 1125 | aDebugger->WriteEnumItems(this, i - field_count, page_end - field_count); |
| 1126 | } |
| 1127 | else |
| 1128 | { |
| 1129 | DebugCookie cookie; |
| 1130 | // Write an empty property; enumerate only on property_get. |
| 1131 | aDebugger->BeginProperty("<enum>", "object", 1, cookie); |
| 1132 | aDebugger->EndProperty(cookie); |
| 1133 | } |
| 1134 | } |
no test coverage detected