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

Method call_intrinsic_1

crates/vm/src/frame.rs:9376–9488  ·  view source on GitHub ↗
(
        &mut self,
        func: bytecode::IntrinsicFunction1,
        arg: PyObjectRef,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

9374 }
9375
9376 fn call_intrinsic_1(
9377 &mut self,
9378 func: bytecode::IntrinsicFunction1,
9379 arg: PyObjectRef,
9380 vm: &VirtualMachine,
9381 ) -> PyResult {
9382 match func {
9383 bytecode::IntrinsicFunction1::Print => {
9384 let displayhook = vm
9385 .sys_module
9386 .get_attr("displayhook", vm)
9387 .map_err(|_| vm.new_runtime_error("lost sys.displayhook"))?;
9388 displayhook.call((arg,), vm)
9389 }
9390 bytecode::IntrinsicFunction1::ImportStar => {
9391 // arg is the module object
9392 self.push_value(arg); // Push module back on stack for import_star
9393 self.import_star(vm)?;
9394 Ok(vm.ctx.none())
9395 }
9396 bytecode::IntrinsicFunction1::UnaryPositive => vm._pos(&arg),
9397 bytecode::IntrinsicFunction1::SubscriptGeneric => {
9398 // Used for PEP 695: Generic[*type_params]
9399 crate::builtins::genericalias::subscript_generic(arg, vm)
9400 }
9401 bytecode::IntrinsicFunction1::TypeVar => {
9402 let type_var: PyObjectRef =
9403 _typing::TypeVar::new(vm, arg.clone(), vm.ctx.none(), vm.ctx.none())
9404 .into_ref(&vm.ctx)
9405 .into();
9406 Ok(type_var)
9407 }
9408 bytecode::IntrinsicFunction1::ParamSpec => {
9409 let param_spec: PyObjectRef = _typing::ParamSpec::new(arg.clone(), vm)
9410 .into_ref(&vm.ctx)
9411 .into();
9412 Ok(param_spec)
9413 }
9414 bytecode::IntrinsicFunction1::TypeVarTuple => {
9415 let type_var_tuple: PyObjectRef = _typing::TypeVarTuple::new(arg.clone(), vm)
9416 .into_ref(&vm.ctx)
9417 .into();
9418 Ok(type_var_tuple)
9419 }
9420 bytecode::IntrinsicFunction1::TypeAlias => {
9421 // TypeAlias receives a tuple of (name, type_params, value)
9422 let tuple: PyTupleRef = arg
9423 .downcast()
9424 .map_err(|_| vm.new_type_error("TypeAlias expects a tuple argument"))?;
9425
9426 if tuple.len() != 3 {
9427 return Err(vm.new_type_error(format!(
9428 "TypeAlias expects exactly 3 arguments, got {}",
9429 tuple.len()
9430 )));
9431 }
9432
9433 let name = tuple.as_slice()[0].clone();

Callers 1

execute_instructionMethod · 0.80

Calls 15

subscript_genericFunction · 0.85
newFunction · 0.85
push_valueMethod · 0.80
import_starMethod · 0.80
noneMethod · 0.80
_posMethod · 0.80
downcastMethod · 0.80
to_vecMethod · 0.80
borrow_vecMethod · 0.80
fast_isinstanceMethod · 0.80
set___cause__Method · 0.80

Tested by

no test coverage detected