소스 검색

Update python.js

Lutz Roeder 1 개월 전
부모
커밋
68dda0b91d
1개의 변경된 파일17개의 추가작업 그리고 4개의 파일을 삭제
  1. 17 4
      source/python.js

+ 17 - 4
source/python.js

@@ -3838,6 +3838,9 @@ python.Execution = class {
                         }
                         case 103: { // GET 'g'
                             const index = parseInt(reader.line(), 10);
+                            if (index in memo === false) {
+                                throw new python.Error(`Memo value not found at index '${index}'.`);
+                            }
                             stack.push(memo[index]);
                             break;
                         }
@@ -3883,9 +3886,14 @@ python.Execution = class {
                             stack.push(obj);
                             break;
                         }
-                        case 104: // BINGET 'h'
-                            stack.push(memo[reader.byte()]);
+                        case 104: { // BINGET 'h'
+                            const index = reader.byte();
+                            if (index in memo === false) {
+                                throw new python.Error(`Memo value not found at index '${index}'.`);
+                            }
+                            stack.push(memo[index]);
                             break;
+                        }
                         case 105: { // INST 'i'
                             const module = reader.line();
                             const name = reader.line();
@@ -3897,9 +3905,14 @@ python.Execution = class {
                             stack.push(obj);
                             break;
                         }
-                        case 106: // LONG_BINGET 'j'
-                            stack.push(memo[reader.uint32()]);
+                        case 106: { // LONG_BINGET 'j'
+                            const index = reader.uint32();
+                            if (index in memo === false) {
+                                throw new python.Error(`Memo value not found at index '${index}'.`);
+                            }
+                            stack.push(memo[index]);
                             break;
+                        }
                         case 113: // BINPUT 'q'
                             if (stack.length === 0) {
                                 throw new python.Error(`Empty stack during 'BINPUT' operation.`);