[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/ActionExec.cpp server/Fu...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/ActionExec.cpp server/Fu... |
Date: |
Mon, 26 Jun 2006 10:12:10 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/06/26 10:12:10
Modified files:
. : ChangeLog
server : ActionExec.cpp Function.cpp Function.h
server/swf : ASHandlers.cpp
Log message:
* server/Function.h, server/Function.cpp: added assertion
checking
in set_length() and constructor by action_buffer.
* server/swf/ASHandlers.cpp: fixed ActionDefineFunction impl.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.432&r2=1.433
http://cvs.savannah.gnu.org/viewcvs/gnash/server/ActionExec.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Function.cpp?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Function.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/ASHandlers.cpp?cvsroot=gnash&r1=1.13&r2=1.14
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.432
retrieving revision 1.433
diff -u -b -r1.432 -r1.433
--- ChangeLog 26 Jun 2006 10:04:00 -0000 1.432
+++ ChangeLog 26 Jun 2006 10:12:10 -0000 1.433
@@ -1,5 +1,8 @@
2006-06-26 Sandro Santilli <address@hidden>
+ * server/Function.h, server/Function.cpp: added assertion checking
+ in set_length() and constructor by action_buffer.
+ * server/swf/ASHandlers.cpp: fixed ActionDefineFunction impl.
* server/ActionExec.cpp: fixed handling of ACTION_RETURN.
2006-06-25 Sandro Santilli <address@hidden>
Index: server/ActionExec.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/ActionExec.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/ActionExec.cpp 26 Jun 2006 10:04:00 -0000 1.2
+++ server/ActionExec.cpp 26 Jun 2006 10:12:10 -0000 1.3
@@ -167,7 +167,8 @@
}
if ( action_id == SWF::ACTION_END ) {
- log_msg("At ACTION_END pc=%d, stop_pc=%d", pc, stop_pc);
+ // this would turn into an assertion (next_pc==stop_pc)
+ log_msg("At ACTION_END next_pc=%d, stop_pc=%d", next_pc,
stop_pc);
break;
}
Index: server/Function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/Function.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/Function.cpp 25 Jun 2006 16:53:04 -0000 1.19
+++ server/Function.cpp 26 Jun 2006 10:12:10 -0000 1.20
@@ -198,6 +198,8 @@
m_function2_flags(0)
{
assert(m_action_buffer);
+ assert( m_start_pc < m_action_buffer->size() );
+
init();
// Define the 'prototype' member as a new object with
Index: server/Function.h
===================================================================
RCS file: /sources/gnash/gnash/server/Function.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/Function.h 25 Jun 2006 16:53:04 -0000 1.11
+++ server/Function.h 26 Jun 2006 10:12:10 -0000 1.12
@@ -154,7 +154,13 @@
m_args.back().m_name = name;
}
- void set_length(int len) { assert(len >= 0); m_length = len; }
+ void set_length(int len)
+ {
+ assert(m_action_buffer);
+ assert(len >= 0);
+ assert(m_start_pc+len <= m_action_buffer->size());
+ m_length = len;
+ }
/// Dispatch.
void operator()(const fn_call& fn);
Index: server/swf/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/ASHandlers.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/swf/ASHandlers.cpp 25 Jun 2006 16:53:04 -0000 1.13
+++ server/swf/ASHandlers.cpp 26 Jun 2006 10:12:10 -0000 1.14
@@ -1341,20 +1341,28 @@
void
SWFHandlers::ActionCallFunction(ActionExec& thread)
{
-// GNASH_REPORT_FUNCTION;
+ //GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
+
+ //cerr << "At ActionCallFunction enter:"<<endl;
+ //env.dump_stack();
+
as_value function;
- if (env.top(0).get_type() == as_value::STRING) {
+ if (env.top(0).get_type() == as_value::STRING)
+ {
// Function is a string; lookup the function.
const tu_string &function_name = env.top(0).to_tu_string();
function = env.get_variable(function_name);
if (function.get_type() != as_value::AS_FUNCTION &&
- function.get_type() != as_value::C_FUNCTION) {
+ function.get_type() != as_value::C_FUNCTION)
+ {
log_error("error in call_function: '%s' is not a function\n",
function_name.c_str());
}
- } else {
+ }
+ else
+ {
// Hopefully the actual
// function object is here.
// QUESTION: would this be
@@ -1364,20 +1372,30 @@
}
int nargs = (int)env.top(1).to_number();
+ //log_msg("Function's nargs: %d", nargs);
+
as_value result = call_method(function, &env, env.get_target(),
nargs, env.get_top_index() - 2);
+ //log_msg("Function's result: %s", result.to_string());
+
env.drop(nargs + 1);
env.top(0) = result;
+
+ //cerr << "After ActionCallFunction:"<<endl;
+ //env.dump_stack();
}
void
SWFHandlers::ActionReturn(ActionExec& thread)
{
-// GNASH_REPORT_FUNCTION;
+ //GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
as_value* retval = thread.retval;
+ //log_msg("Before top/drop (retval=%p)", (void*)retval);
+ //env.dump_stack();
+
// Put top of stack in the provided return slot, if
// it's not NULL.
if (retval) {
@@ -1385,10 +1403,12 @@
}
env.drop(1);
+ //log_msg("After top/drop");
+ //env.dump_stack();
+
// Skip the rest of this buffer (return from this action_buffer).
thread.next_pc = thread.stop_pc;
- //dbglogfile << __PRETTY_FUNCTION__ << ": FIXME: Set the PC pointer
here!!" << endl;
}
void
@@ -2009,22 +2029,29 @@
as_environment& env = thread.env;
const action_buffer& code = thread.code;
+ // Code starts at thread.next_pc as the DefineFunction tag
+ // contains name and args, while next tag is first tag
+ // of the function body.
function_as_object* func = new function_as_object(
&code, &env, thread.next_pc, thread.with_stack);
+
func->set_is_function2();
- size_t i = thread.pc;
- i += 3;
+ size_t i = thread.pc + 3; // skip tag id and length
// Extract name.
// @@ security: watch out for possible missing terminator here!
- tu_string name = (const char*) code.read_string(i);
+ tu_string name = code.read_string(i);
i += name.length() + 1;
+ //cerr << " name:" << name << endl;
+
// Get number of arguments.
int nargs = code.read_int16(i);
i += 2;
+ //cerr << " nargs:" << nargs << endl;
+
// Get the count of local registers used by this function.
uint8 register_count = code[i];
i += 1;
@@ -2047,14 +2074,13 @@
}
// Get the length of the actual function code.
- int16_t length = code.read_int16(thread.pc);
- assert( length >= 0 );
+ int16_t code_size = code.read_int16(thread.pc);
+ assert( code_size >= 0 );
i += 2;
- func->set_length(length);
+ func->set_length(code_size);
// Skip the function body (don't interpret it now).
- assert (thread.next_pc == thread.pc + length);
- //thread.next_pc += length; // this shoudn't be needed
+ thread.next_pc += code_size;
// If we have a name, then save the function in this
// environment under that name.
@@ -2090,10 +2116,15 @@
as_environment& env = thread.env;
const action_buffer& code = thread.code;
- //int16_t tag_length = code.read_int16(thread.pc);
- //assert( tag_length >= 0 );
+ int16_t length = code.read_int16(thread.pc+1);
+ assert( length >= 0 );
+
+ //cerr << " length:" << length << endl;
// Create a new function_as_object
+ // Code starts at thread.next_pc as the DefineFunction tag
+ // contains name and args, while next tag is first tag
+ // of the function body.
function_as_object* func = new function_as_object(
&code, &env, thread.next_pc, thread.with_stack);
@@ -2104,35 +2135,54 @@
tu_string name = code.read_string(i);
i += name.length() + 1;
+ //cerr << " name:" << name << endl;
+
// Get number of arguments.
int nargs = code.read_int16(i);
i += 2;
+ //cerr << " nargs:" << nargs << endl;
+
// Get the names of the arguments.
- for (int n = 0; n < nargs; n++) {
+ for (int n = 0; n < nargs; n++)
+ {
+ const char* arg = code.read_string(i);
+ //cerr << " arg" << n << " : " << arg << endl;
+
// @@ security: watch out for possible missing terminator here!
- func->add_arg(0, code.read_string(i));
+ func->add_arg(0, arg);
+ // wouldn't it be simpler to use strlen(arg)+1 ?
i += func->m_args.back().m_name.length() + 1;
}
// Get the length of the actual function code.
- int length = code.read_int16(i);
- i += 2;
- func->set_length(length);
+ int16_t code_size = code.read_int16(i);
+
+ //cerr << " code size:" << code_size << endl;
+
+ func->set_length(code_size);
+
// Skip the function body (don't interpret it now).
- thread.next_pc += length;
+ // next_pc is assumed to point to first action of
+ // the function body (one-past the current tag, whic
+ // is DefineFunction). We add code_size to it.
+ thread.next_pc += code_size;
// If we have a name, then save the function in this
// environment under that name.
as_value function_value(func);
- if (name.length() > 0) {
+ if (name.length() > 0)
+ {
// @@ NOTE: should this be m_target->set_variable()???
env.set_member(name, function_value);
}
// Also leave it on the stack.
env.push_val(function_value);
+
+ //cerr << "After ActionDefineFunction:"<<endl;
+ //env.dump_stack();
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/ActionExec.cpp server/Fu...,
Sandro Santilli <=