Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5cfd018

Browse files
committed
implargc method
1 parent5573159 commit5cfd018

File tree

1 file changed

+42
-16
lines changed

1 file changed

+42
-16
lines changed

‎crates/compiler-core/src/bytecode.rs‎

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use itertools::Itertools;
1010
use malachite_bigint::BigInt;
1111
use num_complex::Complex64;
1212
use rustpython_wtf8::{Wtf8,Wtf8Buf};
13-
use std::{collections::BTreeSet, fmt, hash, marker::PhantomData, mem, ops::Deref};
13+
use std::{collections::BTreeSet, fmt, hash, marker::PhantomData, mem,num::NonZeroU8,ops::Deref};
1414

1515
#[derive(Copy,Clone,Debug,Hash,PartialEq,Eq)]
1616
#[repr(i8)]
@@ -1150,21 +1150,47 @@ op_arg_enum!(
11501150
}
11511151
);
11521152

1153-
op_arg_enum!(
1154-
/// Specifies if a slice is built with either 2 or 3 arguments.
1155-
#[repr(u8)]
1156-
#[derive(Clone,Copy,Debug,Eq,PartialEq)]
1157-
pubenumBuildSliceArgCount{
1158-
/// ```py
1159-
/// x[5:10]
1160-
/// ```
1161-
Two =2,
1162-
/// ```py
1163-
/// x[5:10:2]
1164-
/// ```
1165-
Three =3,
1153+
/// Specifies if a slice is built with either 2 or 3 arguments.
1154+
#[derive(Clone,Copy,Debug,Eq,PartialEq)]
1155+
pubenumBuildSliceArgCount{
1156+
/// ```py
1157+
/// x[5:10]
1158+
/// ```
1159+
Two,
1160+
/// ```py
1161+
/// x[5:10:2]
1162+
/// ```
1163+
Three,
1164+
}
1165+
1166+
implOpArgTypeforBuildSliceArgCount{
1167+
#[inline(always)]
1168+
fnfrom_op_arg(x:u32) ->Option<Self>{
1169+
Some(match x{
1170+
2 =>Self::Two,
1171+
3 =>Self::Three,
1172+
_ =>returnNone,
1173+
})
11661174
}
1167-
);
1175+
1176+
#[inline(always)]
1177+
fnto_op_arg(self) ->u32{
1178+
u32::from(self.argc().get())
1179+
}
1180+
}
1181+
1182+
implBuildSliceArgCount{
1183+
/// Get the numeric value of `Self`.
1184+
#[must_use]
1185+
pubconstfnargc(self) ->NonZeroU8{
1186+
let inner =matchself{
1187+
Self::Two =>2,
1188+
Self::Three =>3,
1189+
};
1190+
// Safety: `inner` can be either 2 or 3.
1191+
unsafe{NonZeroU8::new_unchecked(inner)}
1192+
}
1193+
}
11681194

11691195
#[derive(Copy,Clone)]
11701196
pubstructUnpackExArgs{
@@ -1565,7 +1591,7 @@ impl Instruction {
15651591
BuildSlice{ argc} =>{
15661592
// push 1
15671593
// pops either 2/3
1568-
1 -(argc.get(arg)asi32)
1594+
1 -(argc.get(arg).argc().get()asi32)
15691595
}
15701596
ListAppend{ ..} |SetAdd{ ..} => -1,
15711597
MapAdd{ ..} => -2,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp