| 188 | |
| 189 | bool doSkipTemporary = true; |
| 190 | void PrintVariables(asIScriptContext *ctx, asUINT stackLevel) |
| 191 | { |
| 192 | asIScriptEngine *engine = ctx->GetEngine(); |
| 193 | |
| 194 | int typeId = ctx->GetThisTypeId(stackLevel); |
| 195 | void *varPointer = ctx->GetThisPointer(stackLevel); |
| 196 | if( typeId ) |
| 197 | { |
| 198 | print(" this = 0x%x\n", varPointer); |
| 199 | } |
| 200 | |
| 201 | int numVars = ctx->GetVarCount(stackLevel); |
| 202 | for( int n = 0; n < numVars; n++ ) |
| 203 | { |
| 204 | // Skip temporary variables |
| 205 | const char* name; |
| 206 | ctx->GetVar(n, stackLevel, &name, &typeId); |
| 207 | if ((name == 0 || strlen(name) == 0) && doSkipTemporary) |
| 208 | continue; |
| 209 | |
| 210 | bool inScope = false; |
| 211 | if (ctx->IsVarInScope(n, stackLevel)) |
| 212 | { |
| 213 | print(" (in scope)"); |
| 214 | inScope = true; |
| 215 | } |
| 216 | else |
| 217 | print(" (no scope)"); |
| 218 | |
| 219 | varPointer = ctx->GetAddressOfVar(n, stackLevel); |
| 220 | if( typeId == engine->GetTypeIdByDecl("int") ) |
| 221 | { |
| 222 | if (inScope) |
| 223 | print(" %s%s = %d\n", ctx->GetVarDeclaration(n, stackLevel), (name == 0 || strlen(name) == 0) ? "(temp)" : "", *(int*)varPointer); |
| 224 | else |
| 225 | print(" %s%s = {uninitialized}\n", ctx->GetVarDeclaration(n, stackLevel), (name == 0 || strlen(name) == 0) ? "(temp)" : ""); |
| 226 | } |
| 227 | else if (typeId == engine->GetTypeIdByDecl("uint")) |
| 228 | { |
| 229 | if (inScope) |
| 230 | print(" %s%s = %u\n", ctx->GetVarDeclaration(n, stackLevel), (name == 0 || strlen(name) == 0) ? "(temp)" : "", *(asUINT*)varPointer); |
| 231 | else |
| 232 | print(" %s%s = {uninitialized}\n", ctx->GetVarDeclaration(n, stackLevel), (name == 0 || strlen(name) == 0) ? "(temp)" : ""); |
| 233 | } |
| 234 | else if( typeId == engine->GetTypeIdByDecl("string") ) |
| 235 | { |
| 236 | CScriptString *str = (CScriptString*)varPointer; |
| 237 | if( str ) |
| 238 | print(" %s%s = '%s'\n", ctx->GetVarDeclaration(n, stackLevel), (name == 0 || strlen(name) == 0) ? "(temp)" : "", str->buffer.c_str()); |
| 239 | else |
| 240 | print(" %s%s = <null>\n", ctx->GetVarDeclaration(n, stackLevel), (name == 0 || strlen(name) == 0) ? "(temp)" : ""); |
| 241 | } |
| 242 | else if (typeId == engine->GetTypeIdByDecl("foo")) |
| 243 | { |
| 244 | if (varPointer) |
| 245 | print(" %s%s = %d\n", ctx->GetVarDeclaration(n, stackLevel), (name == 0 || strlen(name) == 0) ? "(temp)" : "", *(int*)varPointer); |
| 246 | else |
| 247 | print(" %s%s = <null>\n", ctx->GetVarDeclaration(n, stackLevel), (name == 0 || strlen(name) == 0) ? "(temp)" : ""); |
no test coverage detected