/// called when bytecode index "index" has been identified as the target of a branch, so needs its own basic block
 ///  if queueTarget is true, target index added to the _todoQueue to make sure it is translated
 ///  genBBStart to create the basic block structure
 ///  saveStack to make sure the state of the operand stack is accessible at the beginning of the basic block associated with target
 ///  returns the TR::TreeTop to which new treetops in the target block should be appended
 TR::TreeTop * genTarget(int32_t index, bool queueTarget = true)
    {
    if (queueTarget)
       _todoQueue.append(new (this->comp()->trStackMemory()) TodoIndex(index));
    genBBStart(index);
    saveStack(index);
    return blocks(index)->getEntry();
    }
Example #2
0
bool saveStackRef(StackHandler *vs, Common::WriteStream *stream) {
	stackLibrary *s = stackLib;
	int a = 0;
	while (s) {
		if (s->stack == vs) {
			stream->writeByte(1);
			stream->writeUint16BE(stackLibTotal - a);
			return true;
		}
		s = s->next;
		a++;
	}
	stream->writeByte(0);
	saveStack(vs->first, stream);
	s = new stackLibrary;
	stackLibTotal++;
	if (!checkNew(s))
		return false;
	s->next = stackLib;
	s->stack = vs;
	stackLib = s;
	return true;
}
Example #3
0
//----------------------------------------------------------------------
// For saving and loading functions
//----------------------------------------------------------------------
void saveFunction(LoadedFunction *fun, Common::WriteStream *stream) {
	int a;
	stream->writeUint16BE(fun->originalNumber);
	if (fun->calledBy) {
		stream->writeByte(1);
		saveFunction(fun->calledBy, stream);
	} else {
		stream->writeByte(0);
	}
	stream->writeUint32LE(fun->timeLeft);
	stream->writeUint16BE(fun->runThisLine);
	stream->writeByte(fun->cancelMe);
	stream->writeByte(fun->returnSomething);
	stream->writeByte(fun->isSpeech);
	saveVariable(&(fun->reg), stream);

	if (fun->freezerLevel) {
		fatal(ERROR_GAME_SAVE_FROZEN);
	}
	saveStack(fun->stack, stream);
	for (a = 0; a < fun->numLocals; a++) {
		saveVariable(&(fun->localVars[a]), stream);
	}
}