ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

command.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef STARK_TOOLS_COMMAND_H
00024 #define STARK_TOOLS_COMMAND_H
00025 
00026 #include "common/array.h"
00027 #include "common/hashmap.h"
00028 #include "common/hash-ptr.h"
00029 
00030 #include "engines/stark/resources/command.h"
00031 
00032 namespace Stark {
00033 namespace Tools {
00034 
00035 class Block;
00036 class DefinitionRegistry;
00037 
00045 class Command {
00046 public:
00047     enum ControlFlowType {
00048         kFlowNormal,
00049         kFlowBranch,
00050         kFlowEnd
00051     };
00052     typedef Common::Array<Resources::Command::Argument> ArgumentArray;
00053 
00054     Command(Command *command);
00055     Command(Resources::Command *resource);
00056 
00060     void printCall() const;
00061 
00063     uint16 getIndex() const;
00064     Resources::Command::SubType getSubType() const;
00065     bool hasSubtypeDescription() const;
00066 
00068     ArgumentArray getEffectiveArguments() const;
00069 
00070 protected:
00071     struct SubTypeDesc {
00072         Resources::Command::SubType subType;
00073         const char *name;
00074         ControlFlowType controlFlowType;
00075     };
00076 
00078     static const SubTypeDesc *searchSubTypeDesc(Resources::Command::SubType subType);
00079 
00081     Common::String describeArguments(DefinitionRegistry *definitions) const;
00082 
00083     uint16 _index;
00084     Resources::Command::SubType _subType;
00085     const SubTypeDesc *_subTypeDesc;
00086     ArgumentArray _arguments;
00087 };
00088 
00095 class CFGCommand : public Command {
00096 public:
00097     CFGCommand(Resources::Command *resource);
00098 
00100     bool isEntryPoint() const;
00101 
00103     bool isBranch() const;
00104 
00106     bool isBranchTarget() const;
00107 
00115     CFGCommand *getFollower() const;
00116     CFGCommand *getTrueBranch() const;
00117     CFGCommand *getFalseBranch() const;
00118 
00122     Block *getBlock() const;
00123     void setBlock(Block *block);
00124 
00130     void linkBranches(const Common::Array<CFGCommand *> &commands);
00131 
00132 protected:
00134     void initBranches();
00135 
00137     static CFGCommand *findCommandWithIndex(const Common::Array<CFGCommand *> &commands, int32 index);
00138 
00139     int32 _followerIndex;
00140     int32 _trueBranchIndex;
00141     int32 _falseBranchIndex;
00142 
00143     CFGCommand *_follower;
00144     CFGCommand *_trueBranch;
00145     CFGCommand *_falseBranch;
00146     Common::Array<CFGCommand *> _predecessors;
00147 
00148     Block *_block;
00149 };
00150 
00154 class DefinitionRegistry {
00155 public:
00161     void registerReference(const ResourceReference &reference);
00162 
00164     Common::String getFromReference(const ResourceReference &reference) const;
00165 
00167     void printAll() const;
00168 
00169 private:
00170     typedef Common::HashMap<Resources::Object *, Common::String> DefinitionMap;
00171 
00172     Common::String stringToCamelCase(const Common::String &input);
00173 
00174     DefinitionMap _definitions;
00175 };
00176 
00177 } // End of namespace Tools
00178 } // End of namespace Stark
00179 
00180 #endif // STARK_TOOLS_COMMAND_H


Generated on Sat Jul 13 2019 05:01:12 for ResidualVM by doxygen 1.7.1
curved edge   curved edge