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

Commit830cc7e

Browse files
committed
revert macro
1 parent0a2aa1e commit830cc7e

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

‎vm/src/macros.rs‎

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ macro_rules! count_tts {
1414

1515
#[macro_export]
1616
macro_rules! type_check{
17-
18-
($vm:ident, $arg:expr, $arg_count: expr, $arg_name:ident, $arg_type:expr) =>{
17+
($vm:ident, $args:ident, $arg_count:ident, $arg_name:ident, $arg_type:expr) =>{
1918
// None indicates that we have no type requirement (i.e. we accept any type)
2019
ifletSome(expected_type) = $arg_type{
21-
if !$crate::obj::objtype::isinstance($arg,&expected_type){
22-
let arg_typ = $arg.typ();
20+
let arg =&$args.args[$arg_count];
21+
if !$crate::obj::objtype::isinstance(arg,&expected_type){
22+
let arg_typ = arg.typ();
2323
let expected_type_name = $vm.to_pystr(&expected_type)?;
2424
let actual_type = $vm.to_pystr(&arg_typ)?;
2525
returnErr($vm.new_type_error(format!(
@@ -71,7 +71,7 @@ macro_rules! arg_check {
7171
// check if the type matches. If not, return with error
7272
// assign the arg to a variable
7373
$(
74-
type_check!($vm,&$args.args[arg_count], arg_count, $arg_name, $arg_type);
74+
type_check!($vm, $args, arg_count, $arg_name, $arg_type);
7575
let $arg_name =&$args.args[arg_count];
7676
#[allow(unused_assignments)]
7777
{
@@ -83,21 +83,14 @@ macro_rules! arg_check {
8383
// check if the type matches. If not, return with error
8484
// assign the arg to a variable
8585
$(
86-
let len = $args.args.len();
87-
let klen = $args.kwargs.len();
88-
let $optional_arg_name =if arg_count >= len &&(arg_count - len) < $args.kwargs.len(){
89-
let idx = klen -(arg_count-len) -1;
90-
type_check!($vm,&$args.kwargs[idx].1, arg_count-len, $optional_arg_name, $optional_arg_type);
91-
let kwarg =&$args.kwargs[idx];
92-
if&kwarg.0 == stringify!($optional_arg_name){
93-
#[allow(unused_assignments)]
94-
{
95-
arg_count +=1;
96-
}
97-
Some(&kwarg.1)
98-
} else{
99-
None
86+
let $optional_arg_name =if arg_count < $args.args.len(){
87+
type_check!($vm, $args, arg_count, $optional_arg_name, $optional_arg_type);
88+
let ret =Some(&$args.args[arg_count]);
89+
#[allow(unused_assignments)]
90+
{
91+
arg_count +=1;
10092
}
93+
ret
10194
} else{
10295
None
10396
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp