[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10496: Corner cases in comparison o
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10496: Corner cases in comparison opcode, fixes relational-#.swf tests of swfdec, from version 5 to 7 (all). |
Date: |
Wed, 31 Dec 2008 03:19:30 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10496
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Wed 2008-12-31 03:19:30 +0100
message:
Corner cases in comparison opcode, fixes relational-#.swf tests of swfdec,
from version 5 to 7 (all).
modified:
libcore/vm/ASHandlers.cpp
testsuite/actionscript.all/ops.as
testsuite/swfdec/PASSING
=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2008-12-27 19:56:32 +0000
+++ b/libcore/vm/ASHandlers.cpp 2008-12-31 02:19:30 +0000
@@ -3081,29 +3081,48 @@
as_environment& env = thread.env;
- as_value& op1_in = env.top(1);
- as_value& op2_in = env.top(0);
-
- as_value operand1;
- as_value operand2;
-
- try { operand1 = op1_in.to_primitive(); }
- catch (ActionTypeError& e)
- {
- log_debug(_("%s.to_primitive() threw an error during "
- "ActionNewLessThen"), op1_in);
- }
-
- try { operand2 = op2_in.to_primitive(); }
- catch (ActionTypeError& e)
- {
- log_debug(_("%s.to_primitive() threw an error during "
- "ActionNewLessThen"), op2_in);
+ as_value operand1 = env.top(1);
+ as_value operand2 = env.top(0);
+
+ try { operand1 = operand1.to_primitive(); }
+ catch (ActionTypeError& e)
+ {
+ log_debug(_("%s.to_primitive() threw an error during "
+ "ActionNewLessThan"), operand1);
+ }
+ if ( operand1.is_object() && !operand1.is_sprite() )
+ {
+ // comparison involving an object (NOT sprite!) is always false
+ env.top(1).set_bool(false);
+ env.drop(1);
+ return;
+ }
+
+ try { operand2 = operand2.to_primitive(); }
+ catch (ActionTypeError& e)
+ {
+ log_debug(_("%s.to_primitive() threw an error during "
+ "ActionNewLessThan"), operand2);
+ }
+ if ( operand2.is_object() && !operand2.is_sprite() )
+ {
+ // comparison involving an object (NOT sprite!) is always false
+ env.top(1).set_bool(false);
+ env.drop(1);
+ return;
}
if ( operand1.is_string() && operand2.is_string() )
{
- env.top(1).set_bool(operand1.to_string() < operand2.to_string());
+ const std::string& s1 = operand1.to_string();
+ const std::string& s2 = operand2.to_string();
+ // Don't ask me why, but an empty string is not less than a non-empty
one
+ if ( s1.empty() ) {
+ env.top(1).set_bool(false);
+ } else if ( s2.empty() ) {
+ env.top(1).set_bool(true);
+ }
+ else env.top(1).set_bool(s1 < s2);
}
else
{
@@ -3687,32 +3706,12 @@
void
SWFHandlers::ActionGreater(ActionExec& thread)
{
- //GNASH_REPORT_FUNCTION;
-
+ // Just swap the operator and invoke ActionNewLessThan
as_environment& env = thread.env;
-
- as_value& operand1 = env.top(1);
- as_value& operand2 = env.top(0);
-
- if ( operand1.is_string() && operand2.is_string() )
- {
- env.top(1).set_bool(operand1.to_string() > operand2.to_string());
- }
- else
- {
- const double op1 = operand1.to_number();
- const double op2 = operand2.to_number();
-
- if ( isNaN(op1) || isNaN(op2) )
- {
- env.top(1).set_undefined();
- }
- else
- {
- env.top(1).set_bool(op1 > op2);
- }
- }
- env.drop(1);
+ as_value tmp = env.top(1);
+ env.top(1) = env.top(0);
+ env.top(0) = tmp;
+ ActionNewLessThan(thread);
}
void
=== modified file 'testsuite/actionscript.all/ops.as'
--- a/testsuite/actionscript.all/ops.as 2008-07-15 20:05:07 +0000
+++ b/testsuite/actionscript.all/ops.as 2008-12-31 02:19:30 +0000
@@ -170,6 +170,12 @@
y=1.0;
check(x<y);
+x='';
+y='0';
+r=(x<y);
+check_equals(typeof(r), 'boolean');
+check(!r);
+
check(! (NaN < NaN) );
check(! (undefined < undefined) );
@@ -196,6 +202,25 @@
check(r != false);
#endif
+r = _level0 < _level0;
+check_equals(typeof(r), 'undefined');
+
+o1 = {};
+o2 = {};
+r = o1 < o2;
+check_equals(typeof(r), 'boolean');
+check(!r);
+r = o2 < o1;
+check_equals(typeof(r), 'boolean');
+check(!r);
+
+r = o2 < _level0;
+check_equals(typeof(r), 'boolean');
+check(!r);
+r = _level0 < o2;
+check_equals(typeof(r), 'boolean');
+check(!r);
+
//------------------------------------------------
// Logical AND operator (ACTION_LOGICALAND : 0x10)
//------------------------------------------------
@@ -801,14 +826,14 @@
#if OUTPUT_VERSION < 7
# ifndef MING_LOGICAL_ANDOR_BROKEN
- totals(239);
+ totals(250);
# else
- totals(216);
+ totals(227);
# endif
#else
# ifndef MING_LOGICAL_ANDOR_BROKEN
- totals(241);
+ totals(252);
# else
- totals(218);
+ totals(229);
# endif
#endif
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2008-12-08 14:05:33 +0000
+++ b/testsuite/swfdec/PASSING 2008-12-31 02:19:30 +0000
@@ -831,6 +831,9 @@
registerclass-previous.swf:7ea3d590fa576190bda56996ff0fa768
registerclass-properties.swf:9deba9b328c2e4af1c1eb98a62d4e355
register-count.swf:861abb623a228e4152df92896ee807f0
+relational-5.swf:d49852fe40588c69ce4fd7c55610a8f1
+relational-6.swf:a46a49ee09230fff1023ee471b58a716
+relational-7.swf:eb429c9ca96a6fc0236eee6da7bae8fd
remove-child-onUnload-5.swf:895da940f20c08bdccfcc3c826acbe34
remove-child-onUnload-6.swf:ff63ff1af8eb36815c85f8dfdcbe2814
remove-child-onUnload-7.swf:45ddcce6e9b19e512183557c552c8a08
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10496: Corner cases in comparison opcode, fixes relational-#.swf tests of swfdec, from version 5 to 7 (all).,
Sandro Santilli <=