[Scummvm-cvs-logs] SF.net SVN: scummvm:[40694] scummvm/trunk/engines/sci/engine

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon May 18 20:15:45 CEST 2009


Revision: 40694
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40694&view=rev
Author:   fingolfin
Date:     2009-05-18 18:15:45 +0000 (Mon, 18 May 2009)

Log Message:
-----------
SCI: Got rid of EngineState::execution_stack_pos; overally, the resulting code should be even stricter in detecting invalid VM stack access (and some bugs when loading saves might be fixed now...)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/gc.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kfile.cpp
    scummvm/trunk/engines/sci/engine/kscripts.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/sciconsole.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/engine/state.h
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/engine/vm.h

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -430,7 +430,6 @@
 
 	s->_executionStack.clear();    // Start without any execution stack
 	s->execution_stack_base = -1; // No vm is running yet
-	s->execution_stack_pos = -1;   // Start at execution stack position 0
 
 	vocabulary_get_knames(s->resmgr, s->_kernelNames);
 	script_map_kernel(s);

Modified: scummvm/trunk/engines/sci/engine/gc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/gc.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/gc.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -86,7 +86,7 @@
 	// Init: Value Stack
 	// We do this one by hand since the stack doesn't know the current execution stack
 	{
-		ExecStack &xs = s->_executionStack[s->execution_stack_pos];
+		ExecStack &xs = s->_executionStack.back();
 		reg_t *pos;
 
 		for (pos = s->stack_base; pos < xs.sp; pos++)
@@ -97,7 +97,7 @@
 #endif
 
 	// Init: Execution Stack
-	for (i = 0; (int)i <= s->execution_stack_pos; i++) {
+	for (i = 0; i < s->_executionStack.size(); i++) {
 		ExecStack &es = s->_executionStack[i];
 
 		if (es.type != EXEC_STACK_TYPE_KERNEL) {

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -263,7 +263,7 @@
 	old_save_dir = strdup(deref_save_dir);
 	s->restarting_flags |= SCI_GAME_IS_RESTARTING_NOW;
 	s->restarting_flags &= ~SCI_GAME_WAS_RESTARTED_AT_LEAST_ONCE; // This appears to help
-	s->execution_stack_pos = s->execution_stack_base;
+	s->_executionStack.resize(s->execution_stack_base + 1);
 	script_abort_flag = 1; // Force vm to abort ASAP
 	return NULL_REG;
 }

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -652,7 +652,7 @@
 			if (newstate) {
 				s->successor = newstate;
 				script_abort_flag = SCRIPT_ABORT_WITH_REPLAY; // Abort current game
-				s->execution_stack_pos = s->execution_stack_base;
+				s->_executionStack.resize(s->execution_stack_base + 1);
 			} else {
 				s->r_acc = make_reg(0, 1);
 				sciprintf("Restoring failed (game_id = '%s').\n", game_id);

Modified: scummvm/trunk/engines/sci/engine/kscripts.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kscripts.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/kscripts.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -92,7 +92,7 @@
 
 	// Write "kernel" call to the stack, for debugging:
 	xstack = add_exec_stack_entry(s, NULL_REG, NULL, NULL_REG, k_argc, k_argp - 1, 0, NULL_REG,
-	                              s->execution_stack_pos, SCI_XS_CALLEE_LOCALS);
+	                              s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS);
 	xstack->selector = -42 - kfunct; // Evil debugging hack to identify kernel function
 	xstack->type = EXEC_STACK_TYPE_KERNEL;
 
@@ -104,7 +104,7 @@
 
 	run_vm(s, 0); // Start a new vm
 
-	--(s->execution_stack_pos); // Get rid of the extra stack entry
+	s->_executionStack.pop_back(); // Get rid of the extra stack entry
 
 	return 0;
 }
@@ -269,7 +269,7 @@
 	int id = s->seg_manager->segGet(script);
 	Script *scr = s->seg_manager->getScriptIfLoaded(id);
 	if (scr) {
-		if (s->_executionStack[s->execution_stack_pos].addr.pc.segment != id)
+		if (s->_executionStack.back().addr.pc.segment != id)
 			scr->setLockers(1);
 	}
 

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -794,7 +794,7 @@
 
 	// Set exec stack base to zero
 	retval->execution_stack_base = 0;
-	retval->execution_stack_pos = 0;
+	retval->_executionStack.clear();
 
 	// Now copy all current state information
 	// Graphics and input state:

Modified: scummvm/trunk/engines/sci/engine/sciconsole.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/sciconsole.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/sciconsole.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -221,10 +221,10 @@
 		rel_offsetting = 1;
 
 		if (!scumm_strnicmp(str + 1, "PC", 2)) {
-			*dest = s->_executionStack[s->execution_stack_pos].addr.pc;
+			*dest = s->_executionStack.back().addr.pc;
 			offsetting = str + 3;
 		} else if (!scumm_strnicmp(str + 1, "P", 1)) {
-			*dest = s->_executionStack[s->execution_stack_pos].addr.pc;
+			*dest = s->_executionStack.back().addr.pc;
 			offsetting = str + 2;
 		} else if (!scumm_strnicmp(str + 1, "PREV", 4)) {
 			*dest = s->r_prev;
@@ -236,10 +236,10 @@
 			*dest = s->r_acc;
 			offsetting = str + 2;
 		} else if (!scumm_strnicmp(str + 1, "OBJ", 3)) {
-			*dest = s->_executionStack[s->execution_stack_pos].objp;
+			*dest = s->_executionStack.back().objp;
 			offsetting = str + 4;
 		} else if (!scumm_strnicmp(str + 1, "O", 1)) {
-			*dest = s->_executionStack[s->execution_stack_pos].objp;
+			*dest = s->_executionStack.back().objp;
 			offsetting = str + 2;
 		} else
 			return 1; // No matching register

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -692,7 +692,7 @@
 
 	sciprintf("acc="PREG" prev="PREG" &rest=%x\n", PRINT_REG(s->r_acc), PRINT_REG(s->r_prev), *p_restadjust);
 
-	if (!s->_executionStack.empty() && s->execution_stack_pos >= 0) {
+	if (!s->_executionStack.empty()) {
 		sciprintf("pc="PREG" obj="PREG" fp="PSTK" sp="PSTK"\n", PRINT_REG(*p_pc), PRINT_REG(*p_objp), PRINT_STK(*p_pp), PRINT_STK(*p_sp));
 	} else
 		sciprintf("<no execution stack: pc,obj,fp omitted>\n");
@@ -728,7 +728,7 @@
 	if (opnumber == 0x22 /* callb */ || opnumber == 0x23 /* calle */ ||
 	        opnumber == 0x25 /* send */ || opnumber == 0x2a /* self */ || opnumber == 0x2b /* super */) {
 		_debug_seeking = _DEBUG_SEEK_SO;
-		_debug_seek_level = s->execution_stack_pos;
+		_debug_seek_level = s->_executionStack.size()-1;
 		// Store in _debug_seek_special the offset of the next command after send
 		switch (opcode) {
 		case 0x46: // calle W
@@ -1103,7 +1103,7 @@
 
 		script_abort_flag = SCRIPT_ABORT_WITH_REPLAY; // Abort current game
 		_debugstate_valid = 0;
-		s->execution_stack_pos = s->execution_stack_base;
+		s->_executionStack.resize(s->execution_stack_base + 1);
 		return 0;
 	} else {
 		sciprintf("Restoring gamestate '%s' failed.\n", cmdParams[0].str);
@@ -1151,12 +1151,12 @@
 		return 1;
 	}
 
-	if (s->execution_stack_pos < 0) {
+	if (s->_executionStack.empty()) {
 		sciprintf("No exec stack!");
 		return 1;
 	}
 
-	ExecStack &xs = s->_executionStack[s->execution_stack_pos];
+	ExecStack &xs = s->_executionStack.back();
 
 	for (int i = cmdParams[0].val ; i > 0; i--) {
 		if ((xs.sp - xs.fp - i) == 0)
@@ -1526,15 +1526,13 @@
 }
 
 static int c_backtrace(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	int i;
-
 	if (!_debugstate_valid) {
 		sciprintf("Not in debug state\n");
 		return 1;
 	}
 
 	sciprintf("Call stack (current base: 0x%x):\n", s->execution_stack_base);
-	for (i = 0; i <= s->execution_stack_pos; i++) {
+	for (uint i = 0; i < s->_executionStack.size(); i++) {
 		ExecStack &call = s->_executionStack[i];
 		const char *objname = obj_get_name(s, call.sendp);
 		int paramc, totalparamc;
@@ -2121,7 +2119,7 @@
 
 static int c_sret(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
 	_debug_seeking = _DEBUG_SEEK_LEVEL_RET;
-	_debug_seek_level = s->execution_stack_pos;
+	_debug_seek_level = s->_executionStack.size()-1;
 	_debugstate_valid = 0;
 	return 0;
 }
@@ -2176,7 +2174,7 @@
 		stackframe[i] = cmdParams[i].reg;
 
 	xstack = add_exec_stack_entry(s, fptr, s->_executionStack[0].sp + cmdParams.size(), object, cmdParams.size() - 2,
-									s->_executionStack[0].sp - 1, 0, object, s->execution_stack_pos, SCI_XS_CALLEE_LOCALS);
+									s->_executionStack[0].sp - 1, 0, object, s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS);
 	xstack->selector = selector_id;
 	xstack->type = selector_type == kSelectorVariable ? EXEC_STACK_TYPE_VARSELECTOR : EXEC_STACK_TYPE_CALL;
 
@@ -2904,13 +2902,13 @@
 			}
 
 			case _DEBUG_SEEK_LEVEL_RET: {
-				if ((op != op_ret) || (_debug_seek_level < s->execution_stack_pos))
+				if ((op != op_ret) || (_debug_seek_level < (int)s->_executionStack.size()-1))
 					return;
 				break;
 			}
 
 			case _DEBUG_SEEK_SO:
-				if (!REG_EQ(*pc, _debug_seek_reg) || s->execution_stack_pos != _debug_seek_level)
+				if (!REG_EQ(*pc, _debug_seek_reg) || (int)s->_executionStack.size()-1 != _debug_seek_level)
 					return;
 				break;
 
@@ -2920,7 +2918,7 @@
 					return;
 				if ((op & 0x3) > 1)
 					return; // param or temp
-				if ((op & 0x3) && s->_executionStack[s->execution_stack_pos].local_segment > 0)
+				if ((op & 0x3) && s->_executionStack.back().local_segment > 0)
 					return; // locals and not running in script.000
 				if (paramf1 != _debug_seek_special)
 					return; // CORRECT global?

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -104,7 +104,6 @@
 
 	kernel_opt_flags = 0;
 
-	execution_stack_pos = 0;
 	execution_stack_base = 0;
 	_executionStackPosChanged = false;
 

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/state.h	2009-05-18 18:15:45 UTC (rev 40694)
@@ -208,7 +208,6 @@
 	/* VM Information */
 
 	Common::Array<ExecStack> _executionStack; /**< The execution stack */
-	int execution_stack_pos;       /**< Position on the execution stack */
 	/**
 	 * When called from kernel functions, the vm is re-started recursively on
 	 * the same stack. This variable contains the stack base for the current vm.

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2009-05-18 18:15:45 UTC (rev 40694)
@@ -279,49 +279,43 @@
 		}
 	}
 
-	return add_exec_stack_entry(s, make_reg(seg, temp), sp, calling_obj, argc, argp, -1, calling_obj, s->execution_stack_pos, seg);
+	return add_exec_stack_entry(s, make_reg(seg, temp), sp, calling_obj, argc, argp, -1, calling_obj, s->_executionStack.size()-1, seg);
 }
 
 
 static void _exec_varselectors(EngineState *s) {
 	// Executes all varselector read/write ops on the TOS
 	// Now check the TOS to execute all varselector entries
-	if (s->execution_stack_pos >= 0)
-		while (s->_executionStack[s->execution_stack_pos].type == EXEC_STACK_TYPE_VARSELECTOR) {
+	if (!s->_executionStack.empty())
+		while (s->_executionStack.back().type == EXEC_STACK_TYPE_VARSELECTOR) {
 			// varselector access?
-			if (s->_executionStack[s->execution_stack_pos].argc) { // write?
-				reg_t temp = s->_executionStack[s->execution_stack_pos].variables_argp[1];
-				*(s->_executionStack[s->execution_stack_pos].addr.varp) = temp;
+			if (s->_executionStack.back().argc) { // write?
+				reg_t temp = s->_executionStack.back().variables_argp[1];
+				*(s->_executionStack.back().addr.varp) = temp;
 
 			} else // No, read
-				s->r_acc = *(s->_executionStack[s->execution_stack_pos].addr.varp);
+				s->r_acc = *(s->_executionStack.back().addr.varp);
 
-			--(s->execution_stack_pos);
+			s->_executionStack.pop_back();
 		}
 }
 
 ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPtr sp, int framesize, StackPtr argp) {
 // send_obj and work_obj are equal for anything but 'super'
 // Returns a pointer to the TOS exec_stack element
-#ifdef VM_DEBUG_SEND
-	int i;
-#endif
+	assert(s);
+
 	reg_t *varp;
 	reg_t funcp;
 	int selector;
 	int argc;
-	int origin = s->execution_stack_pos; // Origin: Used for debugging
+	int origin = s->_executionStack.size()-1; // Origin: Used for debugging
 	int print_send_action = 0;
 	// We return a pointer to the new active ExecStack
 
 	// The selector calls we catch are stored below:
 	Common::Stack<CallsStruct> sendCalls;
 
-	if (NULL == s) {
-		sciprintf("vm.c: ExecStack(): NULL passed for \"s\"\n");
-		return NULL;
-	}
-
 	while (framesize > 0) {
 		selector = validate_arithmetic(*argp++);
 		argc = validate_arithmetic(*argp);
@@ -423,7 +417,7 @@
 
 #ifdef VM_DEBUG_SEND
 			sciprintf("Funcselector(");
-			for (i = 0; i < argc; i++) {
+			for (int i = 0; i < argc; i++) {
 				sciprintf(PREG, PRINT_REG(argp[i+1]));
 				if (i + 1 < argc)
 					sciprintf(", ");
@@ -467,7 +461,9 @@
 
 	_exec_varselectors(s);
 
-	return &(s->_executionStack[s->execution_stack_pos]);
+	if (s->_executionStack.empty())
+		return NULL;
+	return &(s->_executionStack.back());
 }
 
 ExecStack *add_exec_stack_varselector(EngineState *s, reg_t objp, int argc, StackPtr argp, Selector selector, reg_t *address, int origin) {
@@ -485,36 +481,34 @@
 	// Returns new TOS element for the execution stack
 	// locals_segment may be -1 if derived from the called object
 
-	++s->execution_stack_pos;
-	if (s->execution_stack_pos >= (int)s->_executionStack.size()) // Out of stack space?
-		s->_executionStack.resize(s->execution_stack_pos+1);
-
 	//sciprintf("Exec stack: [%d/%d], origin %d, at %p\n", s->execution_stack_pos, s->_executionStack.size(), origin, s->execution_stack);
 
-	ExecStack *xstack = &(s->_executionStack[s->execution_stack_pos]);
+	ExecStack xstack;
 
-	xstack->objp = objp;
+	xstack.objp = objp;
 	if (locals_segment != SCI_XS_CALLEE_LOCALS)
-		xstack->local_segment = locals_segment;
+		xstack.local_segment = locals_segment;
 	else
-		xstack->local_segment = pc.segment;
+		xstack.local_segment = pc.segment;
 
-	xstack->sendp = sendp;
-	xstack->addr.pc = pc;
-	xstack->fp = xstack->sp = sp;
-	xstack->argc = argc;
+	xstack.sendp = sendp;
+	xstack.addr.pc = pc;
+	xstack.fp = xstack.sp = sp;
+	xstack.argc = argc;
 
-	xstack->variables_argp = argp; // Parameters
+	xstack.variables_argp = argp; // Parameters
 
 	*argp = make_reg(0, argc);  // SCI code relies on the zeroeth argument to equal argc
 
 	// Additional debug information
-	xstack->selector = selector;
-	xstack->origin = origin;
+	xstack.selector = selector;
+	xstack.origin = origin;
 
-	xstack->type = EXEC_STACK_TYPE_CALL; // Normal call
+	xstack.type = EXEC_STACK_TYPE_CALL; // Normal call
 
-	return xstack;
+	s->_executionStack.push_back(xstack);
+
+	return &(s->_executionStack.back());
 }
 
 #ifdef DISABLE_VALIDATONS
@@ -585,7 +579,7 @@
 	int restadjust = s->r_amp_rest;
 	// &rest adjusts the parameter count by this value
 	// Current execution data:
-	ExecStack *xs = &(s->_executionStack[s->execution_stack_pos]);
+	ExecStack *xs = &(s->_executionStack.back());
 	ExecStack *xs_new = NULL;
 	Object *obj = obj_get(s, xs->objp);
 	Script *local_script = script_locate_by_segment(s, xs->local_segment);
@@ -604,7 +598,7 @@
 	}
 
 	if (!restoring)
-		s->execution_stack_base = s->execution_stack_pos;
+		s->execution_stack_base = s->_executionStack.size()-1;
 
 #ifndef DISABLE_VALIDATIONS
 	// Initialize maximum variable count
@@ -640,7 +634,7 @@
 
 		if (s->_executionStackPosChanged) {
 			Script *scr;
-			xs = &(s->_executionStack[s->execution_stack_pos]);
+			xs = &(s->_executionStack.back());
 			s->_executionStackPosChanged = false;
 
 			scr = script_locate_by_segment(s, xs->addr.pc.segment);
@@ -988,7 +982,7 @@
 			xs->sp[1].offset += restadjust;
 			xs_new = add_exec_stack_entry(s, make_reg(xs->addr.pc.segment, xs->addr.pc.offset + opparams[0]),
 			                              xs->sp, xs->objp, (validate_arithmetic(*call_base)) + restadjust,
-			                              call_base, NULL_SELECTOR, xs->objp, s->execution_stack_pos, xs->local_segment);
+			                              call_base, NULL_SELECTOR, xs->objp, s->_executionStack.size()-1, xs->local_segment);
 			restadjust = 0; // Used up the &rest adjustment
 			xs->sp = call_base;
 
@@ -1026,7 +1020,7 @@
 				// Calculate xs again: The kernel function might
 				// have spawned a new VM
 
-				xs_new = &(s->_executionStack[s->execution_stack_pos]);
+				xs_new = &(s->_executionStack.back());
 				s->_executionStackPosChanged = true;
 
 				if (!(s->flags & GF_SCI0_OLD))
@@ -1064,12 +1058,12 @@
 			do {
 				StackPtr old_sp2 = xs->sp;
 				StackPtr old_fp = xs->fp;
-				ExecStack *old_xs = &(s->_executionStack[s->execution_stack_pos]);
+				ExecStack *old_xs = &(s->_executionStack.back());
 
-				if (s->execution_stack_pos == s->execution_stack_base) { // Have we reached the base?
+				if ((int)s->_executionStack.size()-1 == s->execution_stack_base) { // Have we reached the base?
 					s->execution_stack_base = old_execution_stack_base; // Restore stack base
 
-					--(s->execution_stack_pos);
+					s->_executionStack.pop_back();
 
 					s->_executionStackPosChanged = true;
 					s->r_amp_rest = restadjust; // Update &rest
@@ -1085,10 +1079,10 @@
 				}
 
 				// Not reached the base, so let's do a soft return
-				--(s->execution_stack_pos);
+				s->_executionStack.pop_back();
 				xs = old_xs - 1;
 				s->_executionStackPosChanged = true;
-				xs = &(s->_executionStack[s->execution_stack_pos]);
+				xs = &(s->_executionStack.back());
 
 				if (xs->sp == CALL_SP_CARRY // Used in sends to 'carry' the stack pointer
 				        || xs->type != EXEC_STACK_TYPE_CALL) {
@@ -1452,8 +1446,8 @@
 			xs = xs_new;
 
 #ifndef DISABLE_VALIDATIONS
-		if (xs != &(s->_executionStack[s->execution_stack_pos])) {
-			sciprintf("Error: xs is stale (%d vs %d); last command was %02x\n", (int)(xs - &s->_executionStack[0]), s->execution_stack_pos, opnumber);
+		if (xs != &(s->_executionStack.back())) {
+			sciprintf("Error: xs is stale (%d vs %d); last command was %02x\n", (int)(xs - &s->_executionStack[0]), s->_executionStack.size()-1, opnumber);
 		}
 #endif
 		if (script_error_flag) {
@@ -1991,7 +1985,6 @@
 		if (s->restarting_flags & SCI_GAME_IS_RESTARTING_NOW) { // Restart was requested?
 			successor = NULL;
 			s->_executionStack.clear();
-			s->execution_stack_pos = -1;
 			s->_executionStackPosChanged = false;
 
 			game_exit(s);
@@ -2017,7 +2010,7 @@
 
 				if (script_abort_flag == SCRIPT_ABORT_WITH_REPLAY) {
 					sciprintf("Restarting with replay()\n");
-					s->execution_stack_pos = -1; // Restart with replay
+					s->_executionStack.clear(); // Restart with replay
 
 					_init_stack_base_with_selector(s, s->selector_map.replay);
 

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2009-05-18 16:00:15 UTC (rev 40693)
+++ scummvm/trunk/engines/sci/engine/vm.h	2009-05-18 18:15:45 UTC (rev 40694)
@@ -808,73 +808,77 @@
 extern kernel_function* kfuncs[];
 extern int max_instance;
 
-/*inline*/
+/**
+ * Executes function pubfunct of the specified script.
+ * Parameters: (EngineState *) s: The state which is to be executed with
+ *             (uint16) script: The script which is called
+ *             (uint16) pubfunct: The exported script function which is to be called
+ *             (StackPtr) sp: Stack pointer position
+ *             (reg_t) calling_obj: The heap address of the object which executed the call
+ *             (uint16) argc: Number of arguments supplied
+ *             (StackPtr) argp: Pointer to the first supplied argument
+ * Returns   : (ExecStack *): A pointer to the new exec stack TOS entry
+ */
 ExecStack *execute_method(EngineState *s, uint16 script, uint16 pubfunct, StackPtr sp, reg_t calling_obj,
 	uint16 argc, StackPtr argp);
-/* Executes function pubfunct of the specified script.
-** Parameters: (EngineState *) s: The state which is to be executed with
-**             (uint16) script: The script which is called
-**             (uint16) pubfunct: The exported script function which is to be called
-**             (StackPtr) sp: Stack pointer position
-**             (reg_t) calling_obj: The heap address of the object which executed the call
-**             (uint16) argc: Number of arguments supplied
-**             (StackPtr) argp: Pointer to the first supplied argument
-** Returns   : (ExecStack *): A pointer to the new exec stack TOS entry
-*/
 
 
+/**
+ * Executes a "send" or related operation to a selector.
+ * Parameters: (EngineState *) s: The EngineState to operate on
+ *             (reg_t) send_obj: Heap address of the object to send to
+ *             (reg_t) work_obj: Heap address of the object initiating the send
+ *             (StackPtr) sp: Stack pointer position
+ *             (int) framesize: Size of the send as determined by the "send" operation
+ *             (StackPtr) argp: Pointer to the beginning of the heap block containing the
+ *                              data to be sent. This area is a succession of one or more
+ *                              sequences of [selector_number][argument_counter] and then
+ *                              "argument_counter" word entries with the parameter values.
+ * Returns   : (ExecStack *): A pointer to the new execution stack TOS entry
+ */
 ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj,
 	StackPtr sp, int framesize, StackPtr argp);
-/* Executes a "send" or related operation to a selector
-** Parameters: (EngineState *) s: The EngineState to operate on
-**             (reg_t) send_obj: Heap address of the object to send to
-**             (reg_t) work_obj: Heap address of the object initiating the send
-**             (StackPtr) sp: Stack pointer position
-**             (int) framesize: Size of the send as determined by the "send" operation
-**             (StackPtr) argp: Pointer to the beginning of the heap block containing the
-**                              data to be send. This area is a succession of one or more
-**                              sequences of [selector_number][argument_counter] and then
-**                              "argument_counter" word entries with the parameter values.
-** Returns   : (ExecStack *): A pointer to the new execution stack TOS entry
-*/
 
 
 #define SCI_XS_CALLEE_LOCALS -1
 
+/**
+ * Adds an entry to the top of the execution stack.
+ *
+ * @param s				The state with which to execute
+ * @param pc			The initial program counter
+ * @param sp			The initial stack pointer
+ * @param objp			Pointer to the beginning of the current object
+ * @param argc			Number of parameters to call with
+ * @param argp			Heap pointer to the first parameter
+ * @param selector		The selector by which it was called or
+ *						NULL_SELECTOR if n.a. For debugging.
+ * @param sendp			Pointer to the object which the message was sent to.
+ *						Equal to objp for anything but super.
+ * @param origin		Number of the execution stack element this entry was created by
+ *						(usually the current TOS number, except for multiple sends).
+ * @param local_segment	The segment to use for local variables,
+ *						or SCI_XS_CALLEE_LOCALS to use obj's segment.
+ * @return a pointer to the new exec stack TOS entry
+ */
 ExecStack *add_exec_stack_entry(EngineState *s, reg_t pc, StackPtr sp, reg_t objp, int argc,
 	StackPtr argp, Selector selector, reg_t sendp, int origin, SegmentId local_segment);
-/* Adds an entry to the top of the execution stack
-** Parameters: (EngineState *) s: The state with which to execute
-**             (reg_t) pc: The initial program counter
-**             (StackPtr) sp: The initial stack pointer
-**             (reg_t) objp: Pointer to the beginning of the current object
-**             (int) argc: Number of parameters to call with
-**             (StackPtr) argp: Heap pointer to the first parameter
-**             (Selector) selector: The selector by which it was called or
-**			  NULL_SELECTOR if n.a. For debugging.
-**             (reg_t) sendp: Pointer to the object which the message was sent to.
-**                       Equal to objp for anything but super.
-**             (int) origin: Number of the execution stack element this entry was created by
-**                       (usually the current TOS number, except for multiple sends).
-**             (SegmentId) local_segment: The segment to use for local variables,
-**                        or SCI_XS_CALLEE_LOCALS to use obj's segment.
-** Returns   : (ExecStack *): A pointer to the new exec stack TOS entry
-*/
 
 
+/**
+ * Adds one varselector access to the execution stack.
+ * Parameters: (EngineState *) s: The EngineState to use
+ *             (reg_t) objp: Pointer to the object owning the selector
+ *             (int) argc: 1 for writing, 0 for reading
+ *             (StackPtr) argp: Pointer to the address of the data to write -2
+ *             (int) selector: Selector name
+ *             (reg_t *) address: Heap address of the selector
+ *             (int) origin: Stack frame which the access originated from
+ * Returns   : (ExecStack *): Pointer to the new exec-TOS element
+ * This function is called from send_selector only.
+ */
 ExecStack *add_exec_stack_varselector(EngineState *s, reg_t objp, int argc, StackPtr argp,
 	Selector selector, reg_t *address, int origin);
-/* Adds one varselector access to the execution stack
-** Parameters: (EngineState *) s: The EngineState to use
-**             (reg_t) objp: Pointer to the object owning the selector
-**             (int) argc: 1 for writing, 0 for reading
-**             (StackPtr) argp: Pointer to the address of the data to write -2
-**             (int) selector: Selector name
-**             (reg_t *) address: Heap address of the selector
-**             (int) origin: Stack frame which the access originated from
-** Returns   : (ExecStack *): Pointer to the new exec-TOS element
-** This function is called from send_selector only.
-*/
 
 
 void run_vm(EngineState *s, int restoring);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list