Ronan Lamy committed d3207d8

Resolve names at decoding time

Comments (0)

Files changed (2)


         if opnum in opcode.hasjrel:
             oparg += next_instr
+        elif opnum in opcode.hasname:
+            oparg = self.names[oparg]
             op = Opcode.num2op[opnum].decode(oparg, pos, self)
         except KeyError:


     def getlocalvarname(self, index):
         return self.pycode.co_varnames[index]
-    def getname_u(self, index):
-        return self.pycode.names[index]
-    def getname_w(self, index):
-        return Constant(self.pycode.names[index])
     def BAD_OPCODE(self, _):
         raise FlowingError(self, "This operation is not RPython")
         operror = space.exc_from_raise(w_type, w_value)
         raise operror
-    def IMPORT_NAME(self, nameindex):
+    def IMPORT_NAME(self, modulename):
         space =
-        modulename = self.getname_u(nameindex)
         glob = space.unwrap(self.w_globals)
         fromlist = space.unwrap(self.popvalue())
         level = self.popvalue().value
         w_obj = space.import_name(modulename, glob, None, fromlist, level)
-    def IMPORT_FROM(self, nameindex):
-        w_name = self.getname_w(nameindex)
+    def IMPORT_FROM(self, name):
+        w_name = Constant(name)
         w_module = self.peekvalue()
         self.pushvalue(, w_name))
         w_const =
-    def LOAD_GLOBAL(self, nameindex):
-        w_result =, self.getname_u(nameindex))
+    def LOAD_GLOBAL(self, name):
+        w_result =, name)
-    def LOAD_ATTR(self, nameindex):
+    def LOAD_ATTR(self, name):
         w_obj = self.popvalue()
-        w_attributename = self.getname_w(nameindex)
+        w_attributename = Constant(name)
         w_value =, w_attributename)
         assert w_newvalue is not None
         self.locals_stack_w[varindex] = w_newvalue
-    def STORE_GLOBAL(self, nameindex):
-        varname = self.getname_u(nameindex)
+    def STORE_GLOBAL(self, varname):
         raise FlowingError(self,
                 "Attempting to modify global variable  %r." % (varname))
         fn =, self.w_globals, defaults)
-    def STORE_ATTR(self, nameindex):
+    def STORE_ATTR(self, name):
         "obj.attributename = newvalue"
-        w_attributename = self.getname_w(nameindex)
+        w_attributename = Constant(name)
         w_obj = self.popvalue()
         w_newvalue = self.popvalue(), w_attributename, w_newvalue)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.