[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.6/kdelibs/kjs/bytecode
From:       Maks Orlovich <maksim () kde ! org>
Date:       2011-01-18 23:47:30
Message-ID: 20110118234730.C0354AC8B7 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1215529 by orlovich:

Merged revision:r1215528 | orlovich | 2011-01-18 18:46:40 -0500 (Tue, 18 Jan 2011) | 11 lines

Fix problems with negative indeces in bracket ops in cases we can statically
determine arguments to be of int32 type. Fixes reply problem on 
userbase.kde.org. I think I'll probably just have to bite the bullet and add in 
a uint32 type to FrostByte's type system, but getting conversion rules right
for that will be tricky... and it'll be extra-annoying that all the bitops 
like to produce int32.

BUG:262398
BUG:204143

 M  +23 -4     codes.def  


--- branches/KDE/4.6/kdelibs/kjs/bytecode/codes.def #1215528:1215529
@@ -729,7 +729,14 @@
     ]]
 
     impl value (value [noimm] base, int32 [exact] prop) [[
-        $$ = base->getByIndex(exec, prop);
+        if (prop >= 0) {
+            $$ = base->getByIndex(exec, static_cast<uint32_t>(prop));
+        } else {
+            // Have to go as a string, as above.
+            JSObject* o = base->toObject(exec);
+            JSValue* val = o->get(exec, Identifier(UString::from(prop)));
+            $$ = val;
+        }
     ]]
 }
 
@@ -757,7 +764,12 @@
         // toObject may fail and return an exception object, but get from it is harmless
         localStore[objDest].val.valueVal = baseObj;
 
-        $$ = baseObj->get(exec, (uint32_t)prop);
+        if (prop >= 0) {
+            $$ = baseObj->get(exec, static_cast<uint32_t>(prop));
+        } else {
+            JSValue* val = baseObj->get(exec, Identifier(UString::from(prop)));
+            $$ = val;
+        }
     ]]
 }
 
@@ -776,7 +788,11 @@
 
     impl void (value [noimm] base, int32 [exact] prop, value val) [[
         ASSERT(base->isObject());
-        static_cast<JSObject*>(base)->put(exec, (uint32_t)prop, val);
+        if (prop >= 0) {
+            static_cast<JSObject*>(base)->put(exec, static_cast<uint32_t>(prop), val);
+        } else {
+            static_cast<JSObject*>(base)->put(exec, Identifier(UString::from(prop)), val);
+        }
     ]]
 }
 
@@ -826,7 +842,10 @@
         if (pc != localPC)
             continue;
 
-        $$ = o->deleteProperty(exec, (uint32_t)i);
+        if (i >= 0)
+            $$ = o->deleteProperty(exec, static_cast<uint32_t>(i));
+        else
+            $$ = o->deleteProperty(exec, Identifier(UString::from(i)));
     ]]
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic