mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 20:59:00 +00:00
Renaming "Parse" to "Expression"
svn-id: r41772
This commit is contained in:
parent
7ba9c46cb0
commit
487a9bd14b
@ -34,42 +34,42 @@
|
||||
|
||||
namespace Gob {
|
||||
|
||||
Parse::Stack::Stack(size_t size) {
|
||||
Expression::Stack::Stack(size_t size) {
|
||||
opers = new byte[size];
|
||||
values = new int32[size];
|
||||
memset(opers , 0, size * sizeof(byte ));
|
||||
memset(values, 0, size * sizeof(int32));
|
||||
}
|
||||
|
||||
Parse::Stack::~Stack() {
|
||||
Expression::Stack::~Stack() {
|
||||
delete[] opers;
|
||||
delete[] values;
|
||||
}
|
||||
|
||||
Parse::StackFrame::StackFrame(const Stack &stack) {
|
||||
Expression::StackFrame::StackFrame(const Stack &stack) {
|
||||
opers = stack.opers - 1;
|
||||
values = stack.values - 1;
|
||||
pos = -1;
|
||||
}
|
||||
|
||||
void Parse::StackFrame::push(int count) {
|
||||
void Expression::StackFrame::push(int count) {
|
||||
opers += count;
|
||||
values += count;
|
||||
pos += count;
|
||||
}
|
||||
|
||||
void Parse::StackFrame::pop(int count) {
|
||||
void Expression::StackFrame::pop(int count) {
|
||||
opers -= count;
|
||||
values -= count;
|
||||
pos -= count;
|
||||
}
|
||||
|
||||
Parse::Parse(GobEngine *vm) : _vm(vm) {
|
||||
Expression::Expression(GobEngine *vm) : _vm(vm) {
|
||||
_resultStr[0] = 0;
|
||||
_resultInt = 0;
|
||||
}
|
||||
|
||||
int32 Parse::encodePtr(byte *ptr, int type) {
|
||||
int32 Expression::encodePtr(byte *ptr, int type) {
|
||||
int32 offset = 0;
|
||||
|
||||
switch (type) {
|
||||
@ -83,13 +83,13 @@ int32 Parse::encodePtr(byte *ptr, int type) {
|
||||
offset = ptr - ((byte *) _resultStr);
|
||||
break;
|
||||
default:
|
||||
error("Parse::encodePtr(): Unknown pointer type");
|
||||
error("Expression::encodePtr(): Unknown pointer type");
|
||||
}
|
||||
assert((offset & 0xF0000000) == 0);
|
||||
return (type << 28) | offset;
|
||||
}
|
||||
|
||||
byte *Parse::decodePtr(int32 n) {
|
||||
byte *Expression::decodePtr(int32 n) {
|
||||
byte *ptr;
|
||||
|
||||
switch (n >> 28) {
|
||||
@ -103,12 +103,12 @@ byte *Parse::decodePtr(int32 n) {
|
||||
ptr = (byte *) _resultStr;
|
||||
break;
|
||||
default:
|
||||
error("Parse::decodePtr(): Unknown pointer type");
|
||||
error("Expression::decodePtr(): Unknown pointer type");
|
||||
}
|
||||
return ptr + (n & 0x0FFFFFFF);
|
||||
}
|
||||
|
||||
void Parse::skipExpr(char stopToken) {
|
||||
void Expression::skipExpr(char stopToken) {
|
||||
int16 dimCount;
|
||||
byte operation;
|
||||
int16 num;
|
||||
@ -203,7 +203,7 @@ void Parse::skipExpr(char stopToken) {
|
||||
}
|
||||
}
|
||||
|
||||
void Parse::printExpr(char stopToken) {
|
||||
void Expression::printExpr(char stopToken) {
|
||||
// Expression printing disabled by default
|
||||
return;
|
||||
|
||||
@ -214,7 +214,7 @@ void Parse::printExpr(char stopToken) {
|
||||
_vm->_game->_script->seek(savedPos);
|
||||
}
|
||||
|
||||
void Parse::printExpr_internal(char stopToken) {
|
||||
void Expression::printExpr_internal(char stopToken) {
|
||||
int16 dimCount;
|
||||
byte operation;
|
||||
int16 num;
|
||||
@ -406,7 +406,7 @@ void Parse::printExpr_internal(char stopToken) {
|
||||
|
||||
default:
|
||||
debugN(5, "<%d>", (int16) operation);
|
||||
error("Parse::printExpr(): invalid operator in expression");
|
||||
error("Expression::printExpr(): invalid operator in expression");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ void Parse::printExpr_internal(char stopToken) {
|
||||
}
|
||||
|
||||
|
||||
void Parse::printVarIndex() {
|
||||
void Expression::printVarIndex() {
|
||||
byte *arrDesc;
|
||||
int16 dim;
|
||||
int16 dimCount;
|
||||
@ -486,7 +486,7 @@ void Parse::printVarIndex() {
|
||||
return;
|
||||
}
|
||||
|
||||
int Parse::cmpHelper(const StackFrame &stackFrame) {
|
||||
int Expression::cmpHelper(const StackFrame &stackFrame) {
|
||||
byte type = stackFrame.opers[-3];
|
||||
int cmpTemp = 0;
|
||||
|
||||
@ -503,7 +503,7 @@ int Parse::cmpHelper(const StackFrame &stackFrame) {
|
||||
return cmpTemp;
|
||||
}
|
||||
|
||||
bool Parse::getVarBase(uint32 &varBase, bool mindStop,
|
||||
bool Expression::getVarBase(uint32 &varBase, bool mindStop,
|
||||
uint16 *size, uint16 *type) {
|
||||
|
||||
varBase = 0;
|
||||
@ -573,7 +573,7 @@ bool Parse::getVarBase(uint32 &varBase, bool mindStop,
|
||||
return false;
|
||||
}
|
||||
|
||||
int16 Parse::parseVarIndex(uint16 *size, uint16 *type) {
|
||||
int16 Expression::parseVarIndex(uint16 *size, uint16 *type) {
|
||||
int16 temp2;
|
||||
byte *arrDesc;
|
||||
int16 dim;
|
||||
@ -647,14 +647,14 @@ int16 Parse::parseVarIndex(uint16 *size, uint16 *type) {
|
||||
}
|
||||
}
|
||||
|
||||
int16 Parse::parseValExpr(byte stopToken) {
|
||||
int16 Expression::parseValExpr(byte stopToken) {
|
||||
parseExpr(stopToken, 0);
|
||||
|
||||
return _resultInt;
|
||||
}
|
||||
|
||||
// Load a value according to the operation
|
||||
void Parse::loadValue(byte operation, uint32 varBase, const StackFrame &stackFrame) {
|
||||
void Expression::loadValue(byte operation, uint32 varBase, const StackFrame &stackFrame) {
|
||||
int16 dimCount;
|
||||
int16 temp;
|
||||
int16 temp2;
|
||||
@ -793,7 +793,7 @@ void Parse::loadValue(byte operation, uint32 varBase, const StackFrame &stackFra
|
||||
}
|
||||
}
|
||||
|
||||
void Parse::simpleArithmetic1(StackFrame &stackFrame) {
|
||||
void Expression::simpleArithmetic1(StackFrame &stackFrame) {
|
||||
switch (stackFrame.opers[-1]) {
|
||||
case OP_ADD:
|
||||
if (stackFrame.opers[-2] == OP_LOAD_IMM_STR) {
|
||||
@ -828,7 +828,7 @@ void Parse::simpleArithmetic1(StackFrame &stackFrame) {
|
||||
}
|
||||
}
|
||||
|
||||
void Parse::simpleArithmetic2(StackFrame &stackFrame) {
|
||||
void Expression::simpleArithmetic2(StackFrame &stackFrame) {
|
||||
if (stackFrame.pos > 1) {
|
||||
if (stackFrame.opers[-2] == OP_NEG) {
|
||||
stackFrame.opers[-2] = OP_LOAD_IMM_INT16;
|
||||
@ -867,7 +867,7 @@ void Parse::simpleArithmetic2(StackFrame &stackFrame) {
|
||||
}
|
||||
|
||||
// Complex arithmetics with brackets
|
||||
bool Parse::complexArithmetic(Stack &stack, StackFrame &stackFrame, int16 brackStart) {
|
||||
bool Expression::complexArithmetic(Stack &stack, StackFrame &stackFrame, int16 brackStart) {
|
||||
switch (stackFrame.opers[-2]) {
|
||||
case OP_ADD:
|
||||
if (stack.opers[brackStart] == OP_LOAD_IMM_INT16) {
|
||||
@ -967,7 +967,7 @@ bool Parse::complexArithmetic(Stack &stack, StackFrame &stackFrame, int16 brackS
|
||||
}
|
||||
|
||||
// Assign the result to the appropriate _result variable
|
||||
void Parse::getResult(byte operation, int32 value, byte *type) {
|
||||
void Expression::getResult(byte operation, int32 value, byte *type) {
|
||||
if (type != 0)
|
||||
*type = operation;
|
||||
|
||||
@ -998,7 +998,7 @@ void Parse::getResult(byte operation, int32 value, byte *type) {
|
||||
}
|
||||
}
|
||||
|
||||
int16 Parse::parseExpr(byte stopToken, byte *type) {
|
||||
int16 Expression::parseExpr(byte stopToken, byte *type) {
|
||||
Stack stack;
|
||||
StackFrame stackFrame(stack);
|
||||
byte operation;
|
||||
@ -1134,11 +1134,11 @@ int16 Parse::parseExpr(byte stopToken, byte *type) {
|
||||
}
|
||||
}
|
||||
|
||||
int32 Parse::getResultInt() {
|
||||
int32 Expression::getResultInt() {
|
||||
return _resultInt;
|
||||
}
|
||||
|
||||
char *Parse::getResultStr() {
|
||||
char *Expression::getResultStr() {
|
||||
return _resultStr;
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GOB_PARSE_H
|
||||
#define GOB_PARSE_H
|
||||
#ifndef GOB_EXPRESSION_H
|
||||
#define GOB_EXPRESSION_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
|
||||
@ -109,10 +109,10 @@ enum {
|
||||
GOB_FALSE = 23
|
||||
};
|
||||
|
||||
class Parse {
|
||||
class Expression {
|
||||
public:
|
||||
Parse(GobEngine *vm);
|
||||
virtual ~Parse() {}
|
||||
Expression(GobEngine *vm);
|
||||
virtual ~Expression() {}
|
||||
|
||||
void skipExpr(char stopToken);
|
||||
void printExpr(char stopToken);
|
||||
@ -175,4 +175,4 @@ private:
|
||||
|
||||
} // End of namespace Gob
|
||||
|
||||
#endif // GOB_PARSE_H
|
||||
#endif // GOB_EXPRESSION_H
|
||||
|
@ -35,7 +35,7 @@
|
||||
namespace Gob {
|
||||
|
||||
Script::Script(GobEngine *vm) : _vm(vm) {
|
||||
_parser = new Parse(vm);
|
||||
_expression = new Expression(vm);
|
||||
|
||||
_finished = true;
|
||||
|
||||
@ -49,7 +49,7 @@ Script::Script(GobEngine *vm) : _vm(vm) {
|
||||
Script::~Script() {
|
||||
unload();
|
||||
|
||||
delete _parser;
|
||||
delete _expression;
|
||||
}
|
||||
|
||||
uint32 Script::read(byte *data, int32 size) {
|
||||
@ -236,33 +236,33 @@ char *Script::peekString(int32 offset) {
|
||||
}
|
||||
|
||||
int16 Script::readVarIndex(uint16 *size, uint16 *type) {
|
||||
return _parser->parseVarIndex(size, type);
|
||||
return _expression->parseVarIndex(size, type);
|
||||
}
|
||||
|
||||
int16 Script::readValExpr(byte stopToken) {
|
||||
return _parser->parseValExpr(stopToken);
|
||||
return _expression->parseValExpr(stopToken);
|
||||
}
|
||||
|
||||
int16 Script::readExpr(byte stopToken, byte *type) {
|
||||
return _parser->parseExpr(stopToken, type);
|
||||
return _expression->parseExpr(stopToken, type);
|
||||
}
|
||||
|
||||
void Script::skipExpr(char stopToken) {
|
||||
_parser->skipExpr(stopToken);
|
||||
_expression->skipExpr(stopToken);
|
||||
}
|
||||
|
||||
char Script::evalExpr(int16 *pRes) {
|
||||
byte type;
|
||||
|
||||
_parser->printExpr(99);
|
||||
_expression->printExpr(99);
|
||||
|
||||
_parser->parseExpr(99, &type);
|
||||
_expression->parseExpr(99, &type);
|
||||
if (!pRes)
|
||||
return type;
|
||||
|
||||
switch (type) {
|
||||
case TYPE_IMM_INT16:
|
||||
*pRes = _parser->getResultInt();
|
||||
*pRes = _expression->getResultInt();
|
||||
break;
|
||||
|
||||
case TYPE_IMM_STR:
|
||||
@ -281,22 +281,22 @@ char Script::evalExpr(int16 *pRes) {
|
||||
bool Script::evalBoolResult() {
|
||||
byte type;
|
||||
|
||||
_parser->printExpr(99);
|
||||
_expression->printExpr(99);
|
||||
|
||||
_parser->parseExpr(99, &type);
|
||||
_expression->parseExpr(99, &type);
|
||||
if ( (type == GOB_TRUE) ||
|
||||
((type == TYPE_IMM_INT16) && _parser->getResultInt()))
|
||||
((type == TYPE_IMM_INT16) && _expression->getResultInt()))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 Script::getResultInt() {
|
||||
return _parser->getResultInt();
|
||||
return _expression->getResultInt();
|
||||
}
|
||||
|
||||
char *Script::getResultStr() {
|
||||
return _parser->getResultStr();
|
||||
return _expression->getResultStr();
|
||||
}
|
||||
|
||||
bool Script::load(const char *fileName) {
|
||||
|
@ -32,7 +32,7 @@
|
||||
namespace Gob {
|
||||
|
||||
class GobEngine;
|
||||
class Parse;
|
||||
class Expression;
|
||||
|
||||
class Script {
|
||||
public:
|
||||
@ -120,7 +120,7 @@ private:
|
||||
};
|
||||
|
||||
GobEngine *_vm;
|
||||
Parse *_parser;
|
||||
Expression *_expression;
|
||||
|
||||
bool _finished;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user