Changeset 1390 for code/branches/console/src/core/CommandEvaluation.cc
- Timestamp:
- May 23, 2008, 2:10:52 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/CommandEvaluation.cc
r1351 r1390 52 52 this->bEvaluatedParams_ = false; 53 53 54 this->listOfPossible FunctionClasses_.clear();54 this->listOfPossibleIdentifiers_.clear(); 55 55 this->listOfPossibleFunctions_.clear(); 56 56 … … 64 64 bool CommandEvaluation::isValid() const 65 65 { 66 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 67 { 68 return this->function_; 69 } 70 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 71 { 72 return (this->functionclass_ && this->function_); 73 } 74 else 75 { 76 return false; 77 } 66 return (this->function_); 78 67 } 79 68 … … 94 83 unsigned int startindex = this->getStartindex(); 95 84 if (this->originalCommandTokens_.size() > startindex) 96 return evaluation.shortcut_->parse(removeSlashes(this->originalCommandTokens_.subSet(startindex).join() + evaluation.getAdditionalParameter()));85 return this->function_->parse(removeSlashes(this->originalCommandTokens_.subSet(startindex).join() + this->getAdditionalParameter())); 97 86 else 98 return evaluation.shortcut_->parse(removeSlashes(evaluation.additionalParameter_));87 return this->function_->parse(removeSlashes(this->additionalParameter_)); 99 88 } 100 89 … … 103 92 switch (this->state_) 104 93 { 94 case CS_Uninitialized: 105 95 case CS_Empty: 106 std::list<std::pair<const std::string*, const std::string*> > temp; 107 if (evaluation.state_ == CS_Empty) 108 { 109 temp.insert(temp.end(), this->listOfPossibleFunctions_.begin(), this->listOfPossibleFunctions_.end()); 110 temp.insert(temp.end(), this->listOfPossibleFunctionClasses_.begin(), this->listOfPossibleFunctionClasses_.end()); 111 } 112 return (CommandEvaluation::getCommonBegin(temp)); 96 case CS_ShortcutOrIdentifier: 97 { 98 std::list<std::pair<const std::string*, const std::string*> > temp; 99 if (this->state_ == CS_Empty) 100 { 101 temp.insert(temp.end(), this->listOfPossibleFunctions_.begin(), this->listOfPossibleFunctions_.end()); 102 temp.insert(temp.end(), this->listOfPossibleIdentifiers_.begin(), this->listOfPossibleIdentifiers_.end()); 103 } 104 return (CommandEvaluation::getCommonBegin(temp)); 105 } 113 106 break; 114 107 case CS_Shortcut_Params: 115 108 if (this->function_) 116 return (this->function_->getName() + " "); 109 { 110 if (this->commandTokens_.size() > 1) 111 return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 112 else 113 return (this->function_->getName() + " "); 114 } 117 115 break; 118 116 case CS_Shortcut_Finished: 119 117 if (this->function_) 120 118 { 121 if (this->function_->getParamCount() == 0) 119 if (this->commandTokens_.size() > 1) 120 return (this->function_->getName() + " " + this->originalCommandTokens_.subSet(1, this->originalCommandTokens_.size() - 1).join()); 121 else 122 122 return (this->function_->getName()); 123 else if (this->originalCommandTokens_.size() > 1)124 return (this->function_->getName() + " " + this->originalCommandTokens_.subSet(1).join());125 123 } 126 124 break; … … 131 129 case CS_Function_Params: 132 130 if (this->functionclass_ && this->function_) 133 return (this->functionclass_->getName() + " " + this->function_->getName() + " "); 131 { 132 if (this->commandTokens_.size() > 2) 133 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 134 else 135 return (this->functionclass_->getName() + " " + this->function_->getName() + " "); 136 } 134 137 break; 135 138 case CS_Function_Finished: 136 139 if (this->functionclass_ && this->function_) 137 140 { 138 if (this->function_->getParamCount() == 0) 139 return (this->functionclass_->getName() + " " + this->unction_->getName()); 140 else if (this->originalCommandTokens_.size() > 2) 141 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->originalCommandTokens_.subSet(2).join()); 142 } 141 if (this->commandTokens_.size() > 2) 142 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->originalCommandTokens_.subSet(2, this->originalCommandTokens_.size() - 1).join()); 143 else 144 return (this->functionclass_->getName() + " " + this->function_->getName()); 145 } 146 break; 147 case CS_Error: 143 148 break; 144 149 } … … 151 156 switch (this->state_) 152 157 { 158 case CS_Uninitialized: 159 break; 153 160 case CS_Empty: 154 return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandExecutor::dump(this->listOfPossibleFunctionClasses_)); 161 case CS_ShortcutOrIdentifier: 162 return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_)); 155 163 break; 156 164 case CS_Function: … … 158 166 break; 159 167 case CS_Shortcut_Params: 168 case CS_Function_Params: 169 return CommandEvaluation::dump(this->listOfPossibleArguments_); 160 170 case CS_Shortcut_Finished: 161 case CS_Function_Params:162 171 case CS_Function_Finished: 163 172 if (this->function_) … … 175 184 { 176 185 this->bEvaluatedParams_ = false; 177 this->evaluatedExecutor_ = 0;178 186 179 187 for (unsigned int i = 0; i < MAX_FUNCTOR_ARGUMENTS; i++) … … 188 196 { 189 197 if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " ")) 190 {191 198 this->bEvaluatedParams_ = true; 192 this->evaluatedExecutor_ = this->function_;193 }194 199 } 195 200 else if (this->originalCommandTokens_.size() > startindex) 196 201 { 197 202 if (this->function_->evaluate(this->originalCommandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " ")) 198 {199 203 this->bEvaluatedParams_ = true; 200 this->evaluatedExecutor_ = this->function_;201 }202 204 } 203 205 } … … 238 240 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 239 241 return 1; 240 else if (this->state_ == CS_Function _Params || this->state_ == CS_Function_Finished)242 else if (this->state_ == CS_Function || this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 241 243 return 2; 242 244 else
Note: See TracChangeset
for help on using the changeset viewer.