support in op for **kw

This commit is contained in:
Lyon 2023-09-10 10:22:58 +08:00
parent 2d599664a3
commit 13bfc829aa
6 changed files with 32 additions and 22 deletions

12
examples/builtins/kw.py Normal file
View File

@ -0,0 +1,12 @@
def test_kw(**kw):
if 'a' in kw:
return kw['a']
if 'b' in kw:
return kw['b']
a = test_kw(a=1)
b = test_kw(b=2)
assert a == 1
assert b == 2
print('PASS')

View File

@ -189,16 +189,9 @@ int PikaStdData_dict_keys___len__(PikaObj* self) {
}
int dict_contains(PikaDict* dict, Arg* key) {
int i = 0;
while (PIKA_TRUE) {
Arg* item = args_getArgByIndex(_OBJ2KEYS(dict), i);
if (NULL == item) {
break;
}
if (arg_isEqual(item, key)) {
return PIKA_TRUE;
}
i++;
Hash hash = hash_time33(arg_getStr(key));
if (args_isArgExist_hash(_OBJ2DICT(dict), hash)) {
return pika_true;
}
return pika_false;
}

View File

@ -12,7 +12,7 @@
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
"args": [
// "--gtest_filter=vm.keyword_2"
"--gtest_filter=builtin.repl_mode"
// "--gtest_filter=builtin.kw"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",

View File

@ -189,16 +189,9 @@ int PikaStdData_dict_keys___len__(PikaObj* self) {
}
int dict_contains(PikaDict* dict, Arg* key) {
int i = 0;
while (PIKA_TRUE) {
Arg* item = args_getArgByIndex(_OBJ2KEYS(dict), i);
if (NULL == item) {
break;
}
if (arg_isEqual(item, key)) {
return PIKA_TRUE;
}
i++;
Hash hash = hash_time33(arg_getStr(key));
if (args_isArgExist_hash(_OBJ2DICT(dict), hash)) {
return pika_true;
}
return pika_false;
}

View File

@ -0,0 +1,12 @@
def test_kw(**kw):
if 'a' in kw:
return kw['a']
if 'b' in kw:
return kw['b']
a = test_kw(a=1)
b = test_kw(b=2)
assert a == 1
assert b == 2
print('PASS')

View File

@ -2,4 +2,4 @@
#define PIKA_VERSION_MINOR 12
#define PIKA_VERSION_MICRO 5
#define PIKA_EDIT_TIME "2023/09/07 14:46:48"
#define PIKA_EDIT_TIME "2023/09/10 10:22:49"