Author: Colin Valliant <alcarithe...@gmail.com> Branch: pep526 Changeset: r93923:52cd5d8635c2 Date: 2018-02-14 22:13 -0800 http://bitbucket.org/pypy/pypy/changeset/52cd5d8635c2/
Log: Implement the variable annotation bytecodes. diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -292,6 +292,10 @@ self.DELETE_DEREF(oparg, next_instr) elif opcode == opcodedesc.DELETE_FAST.index: self.DELETE_FAST(oparg, next_instr) + elif opcode == opcodedesc.SETUP_ANNOTATIONS.index: + self.SETUP_ANNOTATIONS(oparg, next_instr) + elif opcode == opcodedesc.STORE_ANNOTATION.index: + self.STORE_ANNOTATION(oparg, next_instr) elif opcode == opcodedesc.DELETE_GLOBAL.index: self.DELETE_GLOBAL(oparg, next_instr) elif opcode == opcodedesc.DELETE_NAME.index: @@ -947,6 +951,18 @@ varname) self.locals_cells_stack_w[varindex] = None + def SETUP_ANNOTATIONS(self, oparg, next_instr): + w_locals = self.getorcreatedebug().w_locals + if not self.space.finditem_str(w_locals, '__annotations__'): + w_annotations = self.space.newdict() + self.space.setitem_str(w_locals, '__annotations__', w_annotations) + + def STORE_ANNOTATION(self, varindex, next_instr): + varname = self.getname_u(varindex) + w_newvalue = self.popvalue() + self.space.setitem_str(self.getorcreatedebug().w_locals.getitem_str('__annotations__'), varname, + w_newvalue) + def BUILD_TUPLE(self, itemcount, next_instr): items = self.popvalues(itemcount) w_tuple = self.space.newtuple(items) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit