1 /* 2 * Copyright 2012, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "CliVariablesCommand.h" 8 9 #include <stdio.h> 10 11 #include <AutoLocker.h> 12 13 #include "CliContext.h" 14 #include "Team.h" 15 #include "ValueNode.h" 16 #include "ValueNodeContainer.h" 17 #include "ValueNodeManager.h" 18 19 20 CliVariablesCommand::CliVariablesCommand() 21 : 22 CliCommand("show current frame variables", 23 "%s\n" 24 "Prints the parameters and variables of the current frame, if " 25 " available.") 26 { 27 } 28 29 30 void 31 CliVariablesCommand::Execute(int argc, const char* const* argv, 32 CliContext& context) 33 { 34 if (argc > 1) { 35 PrintUsage(argv[0]); 36 return; 37 } 38 39 ValueNodeManager* manager = context.GetValueNodeManager(); 40 41 ValueNodeContainer* container = manager->GetContainer(); 42 AutoLocker<ValueNodeContainer> containerLocker(container); 43 if (container == NULL || container->CountChildren() == 0) { 44 printf("No variables available.\n"); 45 return; 46 } 47 48 printf("Variables:\n"); 49 for (int32 i = 0; ValueNodeChild* child = container->ChildAt(i); i++) { 50 printf(" %s\n", child->Name().String()); 51 } 52 } 53