MCPcopy Index your code
hub / github.com/RustPython/RustPython / stack_effect_info

Method stack_effect_info

crates/compiler-core/src/bytecode/instruction.rs:855–1096  ·  view source on GitHub ↗
(&self, oparg: u32)

Source from the content-addressed store, hash-verified

853 }
854
855 fn stack_effect_info(&self, oparg: u32) -> StackEffect {
856 // Reason for converting oparg to i32 is because of expressions like `1 + (oparg -1)`
857 // that causes underflow errors.
858 let oparg = i32::try_from(oparg).expect("oparg does not fit in an `i32`");
859
860 // NOTE: Please don't "simplify" expressions here (i.e. `1 + (oparg - 1)`)
861 // as it will be harder to see diff with what CPython auto-generates
862 let (pushed, popped) = match self {
863 Self::BinaryOp { .. } => (1, 2),
864 Self::BinaryOpAddFloat => (1, 2),
865 Self::BinaryOpAddInt => (1, 2),
866 Self::BinaryOpAddUnicode => (1, 2),
867 Self::BinaryOpExtend => (1, 2),
868 Self::BinaryOpInplaceAddUnicode => (0, 2),
869 Self::BinaryOpMultiplyFloat => (1, 2),
870 Self::BinaryOpMultiplyInt => (1, 2),
871 Self::BinaryOpSubscrDict => (1, 2),
872 Self::BinaryOpSubscrGetitem => (0, 2),
873 Self::BinaryOpSubscrListInt => (1, 2),
874 Self::BinaryOpSubscrListSlice => (1, 2),
875 Self::BinaryOpSubscrStrInt => (1, 2),
876 Self::BinaryOpSubscrTupleInt => (1, 2),
877 Self::BinaryOpSubtractFloat => (1, 2),
878 Self::BinaryOpSubtractInt => (1, 2),
879 Self::BinarySlice { .. } => (1, 3),
880 Self::BuildInterpolation { .. } => (1, 2 + (oparg & 1)),
881 Self::BuildList { .. } => (1, oparg),
882 Self::BuildMap { .. } => (1, oparg * 2),
883 Self::BuildSet { .. } => (1, oparg),
884 Self::BuildSlice { .. } => (1, oparg),
885 Self::BuildString { .. } => (1, oparg),
886 Self::BuildTemplate { .. } => (1, 2),
887 Self::BuildTuple { .. } => (1, oparg),
888 Self::Cache => (0, 0),
889 Self::Call { .. } => (1, 2 + oparg),
890 Self::CallAllocAndEnterInit => (0, 2 + oparg),
891 Self::CallBoundMethodExactArgs => (0, 2 + oparg),
892 Self::CallBoundMethodGeneral => (0, 2 + oparg),
893 Self::CallBuiltinClass => (1, 2 + oparg),
894 Self::CallBuiltinFast => (1, 2 + oparg),
895 Self::CallBuiltinFastWithKeywords => (1, 2 + oparg),
896 Self::CallBuiltinO => (1, 2 + oparg),
897 Self::CallFunctionEx => (1, 4),
898 Self::CallIntrinsic1 { .. } => (1, 1),
899 Self::CallIntrinsic2 { .. } => (1, 2),
900 Self::CallIsinstance => (1, 2 + oparg),
901 Self::CallKw { .. } => (1, 3 + oparg),
902 Self::CallKwBoundMethod => (0, 3 + oparg),
903 Self::CallKwNonPy => (1, 3 + oparg),
904 Self::CallKwPy => (0, 3 + oparg),
905 Self::CallLen => (1, 3),
906 Self::CallListAppend => (0, 3),
907 Self::CallMethodDescriptorFast => (1, 2 + oparg),
908 Self::CallMethodDescriptorFastWithKeywords => (1, 2 + oparg),
909 Self::CallMethodDescriptorNoargs => (1, 2 + oparg),
910 Self::CallMethodDescriptorO => (1, 2 + oparg),
911 Self::CallNonPyGeneral => (1, 2 + oparg),
912 Self::CallPyExactArgs => (0, 2 + oparg),

Callers 3

mark_stacksFunction · 0.80
stack_effectMethod · 0.80

Calls 1

newFunction · 0.85

Tested by

no test coverage detected