Commits

Ronan Lamy committed d3207d8

Resolve names at decoding time

Comments (0)

Files changed (2)

rpython/flowspace/bytecode.py

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

rpython/flowspace/flowcontext.py

     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 = self.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)
         self.pushvalue(w_obj)
 
-    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(self.space.import_from(w_module, w_name))
 
         w_const = self.space.wrap(const)
         self.pushvalue(w_const)
 
-    def LOAD_GLOBAL(self, nameindex):
-        w_result = self.space.find_global(self.w_globals, self.getname_u(nameindex))
+    def LOAD_GLOBAL(self, name):
+        w_result = self.space.find_global(self.w_globals, name)
         self.pushvalue(w_result)
     LOAD_NAME = LOAD_GLOBAL
 
-    def LOAD_ATTR(self, nameindex):
+    def LOAD_ATTR(self, name):
         "obj.attributename"
         w_obj = self.popvalue()
-        w_attributename = self.getname_w(nameindex)
+        w_attributename = Constant(name)
         w_value = self.space.getattr(w_obj, w_attributename)
         self.pushvalue(w_value)
     LOOKUP_METHOD = LOAD_ATTR
         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.space.newfunction(w_codeobj, self.w_globals, defaults)
         self.pushvalue(fn)
 
-    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()
         self.space.setattr(w_obj, 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 ProjectModifiedEvent.java.
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.