diff options
author | Filippos Karapetis | 2009-05-30 22:15:00 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-05-30 22:15:00 +0000 |
commit | 76406c35ec9cfcc247dc326c44a8d7fc00327fbc (patch) | |
tree | 4559e37a6cda50861a7df22ce00be01a7881e5da /engines/sci/console.cpp | |
parent | 6059f84f6a9a0173674f32b176963fee7832ec12 (diff) | |
download | scummvm-rg350-76406c35ec9cfcc247dc326c44a8d7fc00327fbc.tar.gz scummvm-rg350-76406c35ec9cfcc247dc326c44a8d7fc00327fbc.tar.bz2 scummvm-rg350-76406c35ec9cfcc247dc326c44a8d7fc00327fbc.zip |
Started objectifying the vocabulary functions (WIP)
svn-id: r41051
Diffstat (limited to 'engines/sci/console.cpp')
-rw-r--r-- | engines/sci/console.cpp | 89 |
1 files changed, 22 insertions, 67 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 95075c0eb7..c1105e5f5f 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -134,16 +134,9 @@ bool Console::cmdGetVersion(int argc, const char **argv) { } bool Console::cmdOpcodes(int argc, const char **argv) { - Common::Array<opcode> opcodes; - - if (!vocab_get_opcodes(_vm->getResMgr(), opcodes)) { - DebugPrintf("No opcode name table found!\n"); - return true; - } - DebugPrintf("Opcode names in numeric order [index: type name]:\n"); - for (uint seeker = 0; seeker < opcodes.size(); seeker++) { - opcode &op = opcodes[seeker]; + for (uint seeker = 0; seeker < g_EngineState->_vocabulary->_opcodes.size(); seeker++) { + opcode &op = g_EngineState->_vocabulary->_opcodes[seeker]; DebugPrintf("%03x: %03x %20s | ", seeker, op.type, op.name.c_str()); if ((seeker % 3) == 2) DebugPrintf("\n"); @@ -155,16 +148,9 @@ bool Console::cmdOpcodes(int argc, const char **argv) { } bool Console::cmdSelectors(int argc, const char **argv) { - Common::StringList selectorNames; - - if (!vocab_get_snames(_vm->getResMgr(), (_vm->getFlags() & GF_SCI0_OLD), selectorNames)) { - DebugPrintf("No selector name table found!\n"); - return true; - } - DebugPrintf("Selector names in numeric order:\n"); - for (uint seeker = 0; seeker < selectorNames.size(); seeker++) { - DebugPrintf("%03x: %20s | ", seeker, selectorNames[seeker].c_str()); + for (uint seeker = 0; seeker < g_EngineState->_vocabulary->_selectorNames.size(); seeker++) { + DebugPrintf("%03x: %20s | ", seeker, g_EngineState->_vocabulary->_selectorNames[seeker].c_str()); if ((seeker % 3) == 2) DebugPrintf("\n"); } @@ -175,18 +161,9 @@ bool Console::cmdSelectors(int argc, const char **argv) { } bool Console::cmdKernelNames(int argc, const char **argv) { - Common::StringList kernelNames; - - vocab_get_knames(_vm->getResMgr(), kernelNames); - - if (kernelNames.empty()) { - DebugPrintf("No kernel name table found!\n"); - return true; - } - DebugPrintf("Selector names in numeric order:\n"); - for (uint seeker = 0; seeker < kernelNames.size(); seeker++) { - DebugPrintf("%03x: %20s | ", seeker, kernelNames[seeker].c_str()); + for (uint seeker = 0; seeker < g_EngineState->_vocabulary->_kernelNames.size(); seeker++) { + DebugPrintf("%03x: %20s | ", seeker, g_EngineState->_vocabulary->_kernelNames[seeker].c_str()); if ((seeker % 3) == 2) DebugPrintf("\n"); } @@ -197,16 +174,10 @@ bool Console::cmdKernelNames(int argc, const char **argv) { } bool Console::cmdSuffixes(int argc, const char **argv) { - SuffixList suffixes; char word_buf[256], alt_buf[256]; - if (!vocab_get_suffixes(_vm->getResMgr(), suffixes)) { - DebugPrintf("No suffix vocabulary.\n"); - return true; - } - int i = 0; - for (SuffixList::const_iterator suf = suffixes.begin(); suf != suffixes.end(); ++suf) { + for (SuffixList::const_iterator suf = g_EngineState->_vocabulary->_parserSuffixes.begin(); suf != g_EngineState->_vocabulary->_parserSuffixes.end(); ++suf) { strncpy(word_buf, suf->word_suffix, suf->word_suffix_length); word_buf[suf->word_suffix_length] = 0; strncpy(alt_buf, suf->alt_suffix, suf->alt_suffix_length); @@ -216,23 +187,12 @@ bool Console::cmdSuffixes(int argc, const char **argv) { ++i; } - vocab_free_suffixes(_vm->getResMgr(), suffixes); - return true; } bool Console::cmdKernelWords(int argc, const char **argv) { - WordMap words; - - vocab_get_words(_vm->getResMgr(), words); - - if (words.empty()) { - DebugPrintf("No vocabulary.\n"); - return true; - } - int j = 0; - for (WordMap::iterator i = words.begin(); i != words.end(); ++i) { + for (WordMap::iterator i = g_EngineState->_vocabulary->_parserWords.begin(); i != g_EngineState->_vocabulary->_parserWords.end(); ++i) { DebugPrintf("%4d: %03x [%03x] %20s |", j, i->_value._class, i->_value._group, i->_key.c_str()); if (j % 3 == 0) DebugPrintf("\n"); @@ -283,12 +243,7 @@ bool Console::cmdDissectScript(int argc, const char **argv) { return true; } - if (!vocab_get_snames(_vm->getResMgr(), (_vm->getFlags() & GF_SCI0_OLD), selectorNames)) { - DebugPrintf("No selector name table found!\n"); - return true; - } - - script_dissect(_vm->getResMgr(), atoi(argv[1]), selectorNames); + script_dissect(_vm->getResMgr(), atoi(argv[1]), g_EngineState->_vocabulary->_parserWords, g_EngineState->_vocabulary->_selectorNames); return true; } @@ -563,32 +518,32 @@ bool Console::cmdClassTable(int argc, const char **argv) { bool Console::cmdSentenceFragments(int argc, const char **argv) { DebugPrintf("Sentence fragments (used to build Parse trees\n"); - for (uint i = 0; i < g_EngineState->_parserBranches.size(); i++) { + for (uint i = 0; i < g_EngineState->_vocabulary->_parserBranches.size(); i++) { int j = 0; - DebugPrintf("R%02d: [%x] ->", i, g_EngineState->_parserBranches[i].id); - while ((j < 10) && g_EngineState->_parserBranches[i].data[j]) { - int dat = g_EngineState->_parserBranches[i].data[j++]; + DebugPrintf("R%02d: [%x] ->", i, g_EngineState->_vocabulary->_parserBranches[i].id); + while ((j < 10) && g_EngineState->_vocabulary->_parserBranches[i].data[j]) { + int dat = g_EngineState->_vocabulary->_parserBranches[i].data[j++]; switch (dat) { case VOCAB_TREE_NODE_COMPARE_TYPE: - dat = g_EngineState->_parserBranches[i].data[j++]; + dat = g_EngineState->_vocabulary->_parserBranches[i].data[j++]; DebugPrintf(" C(%x)", dat); break; case VOCAB_TREE_NODE_COMPARE_GROUP: - dat = g_EngineState->_parserBranches[i].data[j++]; + dat = g_EngineState->_vocabulary->_parserBranches[i].data[j++]; DebugPrintf(" WG(%x)", dat); break; case VOCAB_TREE_NODE_FORCE_STORAGE: - dat = g_EngineState->_parserBranches[i].data[j++]; + dat = g_EngineState->_vocabulary->_parserBranches[i].data[j++]; DebugPrintf(" FORCE(%x)", dat); break; default: if (dat > VOCAB_TREE_NODE_LAST_WORD_STORAGE) { - int dat2 = g_EngineState->_parserBranches[i].data[j++]; + int dat2 = g_EngineState->_vocabulary->_parserBranches[i].data[j++]; DebugPrintf(" %x[%x]", dat, dat2); } else DebugPrintf(" ?%x?", dat); @@ -597,7 +552,7 @@ bool Console::cmdSentenceFragments(int argc, const char **argv) { DebugPrintf("\n"); } - DebugPrintf("%d rules.\n", g_EngineState->_parserBranches.size()); + DebugPrintf("%d rules.\n", g_EngineState->_vocabulary->_parserBranches.size()); return true; } @@ -625,15 +580,15 @@ bool Console::cmdParserNodes(int argc, const char **argv) { } bool Console::cmdParserWords(int argc, const char **argv) { - if (g_EngineState->_parserWords.empty()) { + if (g_EngineState->_vocabulary->_parserWords.empty()) { DebugPrintf("No words.\n"); return true; } - for (WordMap::iterator i = g_EngineState->_parserWords.begin(); i != g_EngineState->_parserWords.end(); ++i) + for (WordMap::iterator i = g_EngineState->_vocabulary->_parserWords.begin(); i != g_EngineState->_vocabulary->_parserWords.end(); ++i) DebugPrintf("%s: C %03x G %03x\n", i->_key.c_str(), i->_value._class, i->_value._group); - DebugPrintf("%d words\n", g_EngineState->_parserWords.size()); + DebugPrintf("%d words\n", g_EngineState->_vocabulary->_parserWords.size()); return true; } @@ -741,7 +696,7 @@ bool Console::cmdPrintPort(int argc, const char **argv) { bool Console::cmdParseGrammar(int argc, const char **argv) { DebugPrintf("Parse grammar, in strict GNF:\n"); - parse_rule_list_t *tlist = vocab_build_gnf(g_EngineState->_parserBranches, 1); + parse_rule_list_t *tlist = vocab_build_gnf(g_EngineState->_vocabulary->_parserBranches, 1); DebugPrintf("%d allocd rules\n", getAllocatedRulesCount()); vocab_free_rule_list(tlist); |