stackeffect(int opcode, int oparg) { switch (opcode) { case POP_TOP: return -1; case ROT_TWO: case ROT_THREE: case ROT_FOUR: return 0; case DUP_TOP: return 1; case UNARY_POSITIVE: case UNARY_NEGATIVE: case UNARY_NOT: case UNARY_CONVERT: case UNARY_INVERT: return 0; case BINARY_POWER: case BINARY_MULTIPLY: case BINARY_DIVIDE: case BINARY_MODULO: case BINARY_ADD: case BINARY_SUBTRACT: case BINARY_SUBSCR: case BINARY_FLOOR_DIVIDE: case BINARY_TRUE_DIVIDE: case BINARY_LSHIFT: case BINARY_RSHIFT: case BINARY_AND: case BINARY_XOR: case BINARY_OR: return -1; case SLICE+0: return 0; case SLICE+1: return -1; case SLICE+2: return -1; case SLICE+3: return -2; case STORE_SLICE+0: return -2; case STORE_SLICE+1: return -3; case STORE_SLICE+2: return -3; case STORE_SLICE+3: return -4; case DELETE_SLICE+0: return -1; case DELETE_SLICE+1: return -2; case DELETE_SLICE+2: return -2; case DELETE_SLICE+3: return -3; case INPLACE_ADD: case INPLACE_SUBTRACT: case INPLACE_MULTIPLY: case INPLACE_DIVIDE: case INPLACE_MODULO: return -2; case STORE_SUBSCR: return -3; case DELETE_SUBSCR: return -2; case PRINT_EXPR: return -1; case PRINT_ITEM_TO: return -2; case PRINT_ITEM: return -1; case RETURN_VALUE: return -1; case YIELD_VALUE: return -1; case EXEC_STMT: return -3; case BUILD_CLASS: return -2; case STORE_NAME: return -1; case STORE_ATTR: return -2; case DELETE_ATTR: return -1; case STORE_GLOBAL: return -1; case BUILD_MAP: return 1; case COMPARE_OP: return -1; case STORE_FAST: return -1; case IMPORT_STAR: return -1; case IMPORT_NAME: return 0; case IMPORT_FROM: return 1; case LOAD_ATTR: return 0; case SETUP_EXCEPT: return 3; case SETUP_FINALLY: return 3; case FOR_ITER: return 1; case LOAD_LOCALS: case LOAD_CONST: case LOAD_NAME: case LOAD_ATTR: case LOAD_GLOBAL: case LOAD_FAST: case LOAD_CLOSURE: case LOAD_DEREF: return 1; case MAKE_CLOSURE: /* XXX depends on number of freevars */ return -oparg; case MAKE_FUNCTION: return -oparg; } }