ScummVM API documentation
script.h
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5  */
6 
7 #ifndef LINGODEC_SCRIPT_H
8 #define LINGODEC_SCRIPT_H
9 
10 #include "common/ptr.h"
11 #include "common/str.h"
12 #include "./enums.h"
13 
14 namespace Common {
15 class ReadStream;
16 }
17 
18 namespace LingoDec {
19 
20 class CodeWriterVisitor;
21 struct Datum;
22 struct Handler;
23 struct ScriptContext;
24 
25 /* LiteralStore */
26 
27 struct LiteralStore {
28  LiteralType type;
29  uint32 offset;
31 
32  void readRecord(Common::SeekableReadStream &stream, int version);
33  void readData(Common::SeekableReadStream &stream, uint32 startOffset);
34 };
35 
36 /* Script */
37 
38 struct Script {
39  /* 8 */ uint32 totalLength;
40  /* 12 */ uint32 totalLength2;
41  /* 16 */ uint16 headerLength;
42  /* 18 */ uint16 scriptNumber;
43  /* 20 */ int16 unk20;
44  /* 22 */ int16 parentNumber;
45 
46  /* 38 */ uint32 scriptFlags;
47  /* 42 */ int16 unk42;
48  /* 44 */ int32 castID;
49  /* 48 */ int16 factoryNameID;
50  /* 50 */ uint16 handlerVectorsCount;
51  /* 52 */ uint32 handlerVectorsOffset;
52  /* 56 */ uint32 handlerVectorsSize;
53  /* 60 */ uint16 propertiesCount;
54  /* 62 */ uint32 propertiesOffset;
55  /* 66 */ uint16 globalsCount;
56  /* 68 */ uint32 globalsOffset;
57  /* 72 */ uint16 handlersCount;
58  /* 74 */ uint32 handlersOffset;
59  /* 78 */ uint16 literalsCount;
60  /* 80 */ uint32 literalsOffset;
61  /* 84 */ uint32 literalsDataCount;
62  /* 88 */ uint32 literalsDataOffset;
63 
64  Common::Array<int16> propertyNameIDs;
65  Common::Array<int16> globalNameIDs;
66 
67  Common::String factoryName;
68  Common::Array<Common::String> propertyNames;
70  Common::Array<Handler> handlers;
72  Common::Array<Script *> factories;
73 
74  unsigned int version;
75  ScriptContext *context;
76 
77  Script(unsigned int version_);
78  ~Script();
79  void read(Common::SeekableReadStream &stream);
80  Common::Array<int16> readVarnamesTable(Common::SeekableReadStream &stream, uint16 count, uint32 offset);
81  bool validName(int id) const;
82  Common::String getName(int id) const;
83  void setContext(ScriptContext *ctx);
84  void parse();
85  void writeVarDeclarations(CodeWriterVisitor &code) const;
86  void writeScriptText(CodeWriterVisitor &code) const;
87  Common::String scriptText(const char *lineEnding, bool dotSyntax) const;
88  void writeBytecodeText(CodeWriterVisitor &code) const;
89  Common::String bytecodeText(const char *lineEnding, bool dotSyntax) const;
90 
91  bool isFactory() const;
92 };
93 
94 } // namespace LingoDec
95 
96 #endif // LINGODEC_SCRIPT_H
Definition: str.h:59
Definition: script.h:38
Definition: cast.h:33
Definition: stream.h:745
Definition: codewritervisitor.h:14
Definition: algorithm.h:29
Definition: context.h:26
Definition: ptr.h:159
Definition: script.h:27