depyo 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -102,28 +102,30 @@ function handleBuildSetUnpackA() {
102
102
  }
103
103
 
104
104
  function handleBuildMapUnpackA() {
105
- processBuildMapUnpack.call(this);
105
+ // Py 3.5-3.8: count of mappings to merge for {**a, **b} dict literal.
106
+ processBuildMapUnpack.call(this, /*withCall=*/false);
106
107
  }
107
108
 
108
109
  function handleBuildMapUnpackWithCallA() {
109
- processBuildMapUnpack.call(this);
110
+ // Py 3.5 only: oparg = count + (fn_loc << 8). Lower byte is the map count,
111
+ // upper byte locates the callable for error reporting.
112
+ // Py 3.6-3.8: oparg = plain count (this opcode is kept for unpack-with-call
113
+ // semantics but the fn_loc byte is dropped).
114
+ processBuildMapUnpack.call(this, /*withCall=*/true);
110
115
  }
111
116
 
112
- function processBuildMapUnpack() {
113
- let mapNode = new AST.ASTMap();
114
- for (let idx = 0; idx < this.code.Current.Argument; idx++) {
115
- let pair = this.dataStack.pop(); // Should be a dictionary
116
- if (pair instanceof AST.ASTMap) {
117
- for (const entry of pair.values) {
118
- mapNode.add(entry.key, entry.value);
119
- }
120
- } else {
121
- if (global.g_cliArgs?.debug) {
122
- console.error("Expected a map for BUILD_MAP_UNPACK");
123
- }
124
- }
117
+ function processBuildMapUnpack(withCall) {
118
+ let count = this.code.Current.Argument;
119
+ if (withCall && this.object.Reader.versionCompare(3, 6) < 0) {
120
+ count = count & 0xFF;
121
+ }
122
+ let items = [];
123
+ for (let idx = 0; idx < count; idx++) {
124
+ items.unshift(this.dataStack.pop());
125
125
  }
126
- this.dataStack.push(mapNode);
126
+ let node = new AST.ASTMapUnpack(items);
127
+ node.line = this.code.Current.LineNo;
128
+ this.dataStack.push(node);
127
129
  }
128
130
 
129
131
  module.exports = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "depyo",
3
- "version": "1.0.2",
4
- "description": "Python bytecode decompiler (Python 1.0–3.14) implemented in Node.js",
3
+ "version": "1.1.0",
4
+ "description": "Python bytecode decompiler (Python 1.0–3.15) implemented in Node.js",
5
5
  "bin": {
6
6
  "depyo": "./depyo.js"
7
7
  },