diff --git a/bsp/simulation-keil-dev/MDK-ARM/mimiscript-demo.uvoptx b/bsp/simulation-keil-dev/MDK-ARM/mimiscript-demo.uvoptx
index 96788f924..613e21b0c 100644
--- a/bsp/simulation-keil-dev/MDK-ARM/mimiscript-demo.uvoptx
+++ b/bsp/simulation-keil-dev/MDK-ARM/mimiscript-demo.uvoptx
@@ -548,17 +548,41 @@
0
0
+
+ 5
+ 27
+ 1
+ 0
+ 0
+ 0
+ ..\pikascript\pikascript-lib\PikaStdData\PikaStdData_Dict.c
+ PikaStdData_Dict.c
+ 0
+ 0
+
+
+ 5
+ 28
+ 1
+ 0
+ 0
+ 0
+ ..\pikascript\pikascript-lib\PikaStdData\PikaStdData_List.c
+ PikaStdData_List.c
+ 0
+ 0
+
pikascript-api
- 0
+ 1
0
0
0
6
- 27
+ 29
1
0
0
@@ -570,7 +594,7 @@
6
- 28
+ 30
1
0
0
@@ -582,7 +606,7 @@
6
- 29
+ 31
1
0
0
@@ -594,7 +618,7 @@
6
- 30
+ 32
1
0
0
@@ -606,7 +630,7 @@
6
- 31
+ 33
1
0
0
@@ -618,7 +642,7 @@
6
- 32
+ 34
1
0
0
@@ -630,7 +654,7 @@
6
- 33
+ 35
1
0
0
@@ -642,7 +666,7 @@
6
- 34
+ 36
1
0
0
@@ -654,7 +678,7 @@
6
- 35
+ 37
1
0
0
@@ -664,6 +688,42 @@
0
0
+
+ 6
+ 38
+ 1
+ 0
+ 0
+ 0
+ ..\pikascript\pikascript-api\PikaStdData_Dict-api.c
+ PikaStdData_Dict-api.c
+ 0
+ 0
+
+
+ 6
+ 39
+ 1
+ 0
+ 0
+ 0
+ ..\pikascript\pikascript-api\PikaStdData_List-api.c
+ PikaStdData_List-api.c
+ 0
+ 0
+
+
+ 6
+ 40
+ 1
+ 0
+ 0
+ 0
+ ..\pikascript\pikascript-api\PikaStdData-api.c
+ PikaStdData-api.c
+ 0
+ 0
+
@@ -674,7 +734,7 @@
0
7
- 36
+ 41
1
0
0
@@ -686,7 +746,7 @@
7
- 37
+ 42
1
0
0
@@ -698,7 +758,7 @@
7
- 38
+ 43
1
0
0
@@ -710,7 +770,7 @@
7
- 39
+ 44
1
0
0
@@ -722,7 +782,7 @@
7
- 40
+ 45
1
0
0
@@ -734,7 +794,7 @@
7
- 41
+ 46
1
0
0
@@ -746,7 +806,7 @@
7
- 42
+ 47
1
0
0
@@ -758,7 +818,7 @@
7
- 43
+ 48
1
0
0
@@ -770,7 +830,7 @@
7
- 44
+ 49
1
0
0
@@ -782,7 +842,7 @@
7
- 45
+ 50
1
0
0
@@ -794,7 +854,7 @@
7
- 46
+ 51
1
0
0
@@ -806,7 +866,7 @@
7
- 47
+ 52
1
0
0
@@ -818,7 +878,7 @@
7
- 48
+ 53
1
0
0
@@ -830,7 +890,7 @@
7
- 49
+ 54
1
0
0
@@ -842,7 +902,7 @@
7
- 50
+ 55
1
0
0
@@ -854,7 +914,7 @@
7
- 51
+ 56
1
0
0
@@ -868,13 +928,13 @@
python
- 1
+ 0
0
0
0
8
- 52
+ 57
5
0
0
@@ -886,7 +946,7 @@
8
- 53
+ 58
5
0
0
@@ -898,7 +958,7 @@
8
- 54
+ 59
5
0
0
@@ -910,7 +970,7 @@
8
- 55
+ 60
5
0
0
diff --git a/bsp/simulation-keil-dev/MDK-ARM/mimiscript-demo.uvprojx b/bsp/simulation-keil-dev/MDK-ARM/mimiscript-demo.uvprojx
index 4b6a99316..520f70915 100644
--- a/bsp/simulation-keil-dev/MDK-ARM/mimiscript-demo.uvprojx
+++ b/bsp/simulation-keil-dev/MDK-ARM/mimiscript-demo.uvprojx
@@ -134,11 +134,11 @@
0
1
1
- 4101
+ 4096
1
BIN\UL2CM3.DLL
-
+ "" ()
@@ -337,7 +337,7 @@
0
- USE_HAL_DRIVER,STM32F103xE
+ USE_HAL_DRIVER,STM32F103xE,__VM_DEBUG__
../Core/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F1xx/Include;../Drivers/CMSIS/Include;..\pikascript\pikascript-api;..\..\..\src
@@ -533,6 +533,16 @@
1
..\pikascript\pikascript-lib\PikaStdLib\PikaStdLib_RangeObj.c
+
+ PikaStdData_Dict.c
+ 1
+ ..\pikascript\pikascript-lib\PikaStdData\PikaStdData_Dict.c
+
+
+ PikaStdData_List.c
+ 1
+ ..\pikascript\pikascript-lib\PikaStdData\PikaStdData_List.c
+
@@ -583,6 +593,21 @@
1
..\pikascript\pikascript-api\PikaStdLib_RangeObj-api.c
+
+ PikaStdData_Dict-api.c
+ 1
+ ..\pikascript\pikascript-api\PikaStdData_Dict-api.c
+
+
+ PikaStdData_List-api.c
+ 1
+ ..\pikascript\pikascript-api\PikaStdData_List-api.c
+
+
+ PikaStdData-api.c
+ 1
+ ..\pikascript\pikascript-api\PikaStdData-api.c
+
diff --git a/bsp/simulation-keil-dev/pikascript/PikaStdData.py b/bsp/simulation-keil-dev/pikascript/PikaStdData.py
new file mode 100644
index 000000000..a038e10b7
--- /dev/null
+++ b/bsp/simulation-keil-dev/pikascript/PikaStdData.py
@@ -0,0 +1,51 @@
+from PikaObj import *
+
+
+class List(TinyObj):
+ def __init__():
+ pass
+
+ # add an arg after the end of list
+ def append(arg: any):
+ pass
+
+ # get an arg by the index
+ def get(i: int) -> any:
+ pass
+
+ # set an arg by the index
+ def set(i: int, arg: any):
+ pass
+
+ # get the length of list
+ def len() -> int:
+ pass
+
+ def __iter__() -> any:
+ pass
+
+ def __next__() -> any:
+ pass
+
+
+class Dict(TinyObj):
+ def __init__():
+ pass
+
+ # get an arg by the key
+ def get(key: str) -> any:
+ pass
+
+ # set an arg by the key
+ def set(key: str, arg: any):
+ pass
+
+ # remove an arg by the key
+ def remove(key: str):
+ pass
+
+ def __iter__() -> any:
+ pass
+
+ def __next__() -> any:
+ pass
diff --git a/bsp/simulation-keil-dev/pikascript/main.py b/bsp/simulation-keil-dev/pikascript/main.py
index 3530e3420..364145035 100644
--- a/bsp/simulation-keil-dev/pikascript/main.py
+++ b/bsp/simulation-keil-dev/pikascript/main.py
@@ -1,14 +1,81 @@
from PikaObj import *
import Device
import PikaStdLib
+import PikaStdData
mem = PikaStdLib.MemChecker()
-
-for i in range(1, 100):
- print(i)
-
print('mem used max:')
mem.max()
-print('mem used now:')
-mem.now()
\ No newline at end of file
+
+def EXPECT_EQ(test_name, input, expected):
+ print('-----TEST-----')
+ print(test_name)
+ if input != expected:
+ print('[Error]')
+ print(test_name)
+ print('[info] Expected:')
+ print(expected)
+ print('[info] Input:')
+ print(input)
+ # error
+ while True:
+ is_error = 1
+ else:
+ print('[ OK ]')
+ print('')
+
+a = 0
+for i in range(0, 10):
+ if i == 5:
+ continue
+ a = a + i
+EXPECT_EQ('for_if_continue', a, 40)
+
+a = 0
+for i in range(0, 10):
+ if i == 5:
+ break
+ a = a + i
+EXPECT_EQ('for_if_break', a, 10)
+
+a = 0
+for i in range(0, 10):
+ for k in range(0, 3):
+ # print(k)
+ a = a + k
+EXPECT_EQ('for_for_in_range', a, 30)
+
+a = 0
+for i in range(0, 10):
+ # print(i)
+ a = a + i
+EXPECT_EQ('for_in_range', a, 45)
+
+list = PikaStdData.List()
+list.append(7)
+list.append('eee')
+len = list.len()
+for item in list:
+ # print(item)
+ a = item
+EXPECT_EQ('list_for_loop', a, 'eee')
+
+
+list = PikaStdData.List()
+list.append(7)
+list.append('eee')
+len = list.len()
+a1 = list.get(0)
+a2 = list.get(1)
+res = iter(list)
+EXPECT_EQ('iter', res, list)
+
+dict = PikaStdData.Dict()
+dict.set('a', 1)
+dict.set('b', 2)
+dict.remove('b')
+a = dict.get('a')
+b = dict.get('b')
+EXPECT_EQ('PikaStdData', a, 1)
+EXPECT_EQ('PikaStdData_2', b, 0)
\ No newline at end of file
diff --git a/bsp/simulation-keil-dev/pikascript/pikascript-api/PikaMain-api.c b/bsp/simulation-keil-dev/pikascript/pikascript-api/PikaMain-api.c
index 1feb838d5..6f54d10d7 100644
--- a/bsp/simulation-keil-dev/pikascript/pikascript-api/PikaMain-api.c
+++ b/bsp/simulation-keil-dev/pikascript/pikascript-api/PikaMain-api.c
@@ -4,6 +4,7 @@
#include "PikaMain.h"
#include "PikaStdLib_SysObj.h"
#include "Device.h"
+#include "PikaStdData.h"
#include "PikaStdLib.h"
#include
#include
@@ -12,6 +13,7 @@
PikaObj *New_PikaMain(Args *args){
PikaObj *self = New_PikaStdLib_SysObj(args);
obj_newObj(self, "Device", "Device", New_Device);
+ obj_newObj(self, "PikaStdData", "PikaStdData", New_PikaStdData);
obj_newObj(self, "PikaStdLib", "PikaStdLib", New_PikaStdLib);
return self;
}
diff --git a/bsp/simulation-keil-dev/pikascript/pikascript-api/compiler-info.txt b/bsp/simulation-keil-dev/pikascript/pikascript-api/compiler-info.txt
index 62eb068f3..f6e139e8b 100644
--- a/bsp/simulation-keil-dev/pikascript/pikascript-api/compiler-info.txt
+++ b/bsp/simulation-keil-dev/pikascript/pikascript-api/compiler-info.txt
@@ -1 +1 @@
-Compiler { dist_path: "pikascript-api/", source_path: "", class_list: {"Device": ClassInfo { this_class_name: "Device", super_class_name: "TinyObj", method_list: {"LED": MethodInfo { class_name: "Device", name: "LED", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "Uart": MethodInfo { class_name: "Device", name: "Uart", arg_list: None, return_type: Some(PyType { type_name: "any" }) }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: true }, "Device_LED": ClassInfo { this_class_name: "Device_LED", super_class_name: "TinyObj", method_list: {"off": MethodInfo { class_name: "Device_LED", name: "off", arg_list: None, return_type: None }, "on": MethodInfo { class_name: "Device_LED", name: "on", arg_list: None, return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "Device_Uart": ClassInfo { this_class_name: "Device_Uart", super_class_name: "TinyObj", method_list: {"printName": MethodInfo { class_name: "Device_Uart", name: "printName", arg_list: None, return_type: None }, "send": MethodInfo { class_name: "Device_Uart", name: "send", arg_list: Some(ArgList { py_arg_list: "data:str", list: {"data": PyArg { py_type: PyType { type_name: "str" }, name: "data" }} }), return_type: None }, "setName": MethodInfo { class_name: "Device_Uart", name: "setName", arg_list: Some(ArgList { py_arg_list: "name:str", list: {"name": PyArg { py_type: PyType { type_name: "str" }, name: "name" }} }), return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "PikaMain": ClassInfo { this_class_name: "PikaMain", super_class_name: "PikaStdLib_SysObj", method_list: {}, object_list: {"Device": ObjectInfo { class_name: "PikaMain", name: "Device", import_class_name: "Device" }, "PikaStdLib": ObjectInfo { class_name: "PikaMain", name: "PikaStdLib", import_class_name: "PikaStdLib" }}, import_list: {}, script_list: Script { content: " \"\\n\"\n \"mem = PikaStdLib.MemChecker()\\n\"\n \"\\n\"\n \"\\n\"\n \"for i in range(1, 100):\\n\"\n \" print(i)\\n\"\n \"\\n\"\n \"print('mem used max:')\\n\"\n \"mem.max()\\n\"\n \"print('mem used now:')\\n\"\n \"mem.now()\\n\"\n" }, is_package: false }, "PikaStdLib": ClassInfo { this_class_name: "PikaStdLib", super_class_name: "TinyObj", method_list: {"MemChecker": MethodInfo { class_name: "PikaStdLib", name: "MemChecker", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "RangeObj": MethodInfo { class_name: "PikaStdLib", name: "RangeObj", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "SysObj": MethodInfo { class_name: "PikaStdLib", name: "SysObj", arg_list: None, return_type: Some(PyType { type_name: "any" }) }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: true }, "PikaStdLib_MemChecker": ClassInfo { this_class_name: "PikaStdLib_MemChecker", super_class_name: "TinyObj", method_list: {"getMax": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "getMax", arg_list: None, return_type: Some(PyType { type_name: "float" }) }, "getNow": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "getNow", arg_list: None, return_type: Some(PyType { type_name: "float" }) }, "max": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "max", arg_list: None, return_type: None }, "now": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "now", arg_list: None, return_type: None }, "resetMax": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "resetMax", arg_list: None, return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "PikaStdLib_RangeObj": ClassInfo { this_class_name: "PikaStdLib_RangeObj", super_class_name: "TinyObj", method_list: {"__iter__": MethodInfo { class_name: "PikaStdLib_RangeObj", name: "__iter__", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "__next__": MethodInfo { class_name: "PikaStdLib_RangeObj", name: "__next__", arg_list: None, return_type: Some(PyType { type_name: "any" }) }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "PikaStdLib_SysObj": ClassInfo { this_class_name: "PikaStdLib_SysObj", super_class_name: "BaseObj", method_list: {"float": MethodInfo { class_name: "PikaStdLib_SysObj", name: "float", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: Some(PyType { type_name: "float" }) }, "int": MethodInfo { class_name: "PikaStdLib_SysObj", name: "int", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: Some(PyType { type_name: "int" }) }, "iter": MethodInfo { class_name: "PikaStdLib_SysObj", name: "iter", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: Some(PyType { type_name: "any" }) }, "next": MethodInfo { class_name: "PikaStdLib_SysObj", name: "next", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: Some(PyType { type_name: "any" }) }, "range": MethodInfo { class_name: "PikaStdLib_SysObj", name: "range", arg_list: Some(ArgList { py_arg_list: "a1:int,a2:int,a3:int", list: {"a1": PyArg { py_type: PyType { type_name: "int" }, name: "a1" }, "a2": PyArg { py_type: PyType { type_name: "int" }, name: "a2" }, "a3": PyArg { py_type: PyType { type_name: "int" }, name: "a3" }} }), return_type: Some(PyType { type_name: "any" }) }, "remove": MethodInfo { class_name: "PikaStdLib_SysObj", name: "remove", arg_list: Some(ArgList { py_arg_list: "argPath:str", list: {"argPath": PyArg { py_type: PyType { type_name: "str" }, name: "argPath" }} }), return_type: None }, "type": MethodInfo { class_name: "PikaStdLib_SysObj", name: "type", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }}, class_now_name: Some("PikaMain"), package_now_name: Some("PikaStdLib") }
\ No newline at end of file
+Compiler { dist_path: "pikascript-api/", source_path: "", class_list: {"Device": ClassInfo { this_class_name: "Device", super_class_name: "TinyObj", method_list: {"LED": MethodInfo { class_name: "Device", name: "LED", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "Uart": MethodInfo { class_name: "Device", name: "Uart", arg_list: None, return_type: Some(PyType { type_name: "any" }) }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: true }, "Device_LED": ClassInfo { this_class_name: "Device_LED", super_class_name: "TinyObj", method_list: {"off": MethodInfo { class_name: "Device_LED", name: "off", arg_list: None, return_type: None }, "on": MethodInfo { class_name: "Device_LED", name: "on", arg_list: None, return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "Device_Uart": ClassInfo { this_class_name: "Device_Uart", super_class_name: "TinyObj", method_list: {"printName": MethodInfo { class_name: "Device_Uart", name: "printName", arg_list: None, return_type: None }, "send": MethodInfo { class_name: "Device_Uart", name: "send", arg_list: Some(ArgList { py_arg_list: "data:str", list: {"data": PyArg { py_type: PyType { type_name: "str" }, name: "data" }} }), return_type: None }, "setName": MethodInfo { class_name: "Device_Uart", name: "setName", arg_list: Some(ArgList { py_arg_list: "name:str", list: {"name": PyArg { py_type: PyType { type_name: "str" }, name: "name" }} }), return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "PikaMain": ClassInfo { this_class_name: "PikaMain", super_class_name: "PikaStdLib_SysObj", method_list: {}, object_list: {"Device": ObjectInfo { class_name: "PikaMain", name: "Device", import_class_name: "Device" }, "PikaStdData": ObjectInfo { class_name: "PikaMain", name: "PikaStdData", import_class_name: "PikaStdData" }, "PikaStdLib": ObjectInfo { class_name: "PikaMain", name: "PikaStdLib", import_class_name: "PikaStdLib" }}, import_list: {}, script_list: Script { content: " \"\\n\"\n \"mem = PikaStdLib.MemChecker()\\n\"\n \"\\n\"\n \"print('mem used max:')\\n\"\n \"mem.max()\\n\"\n \"\\n\"\n \"def EXPECT_EQ(test_name, input, expected):\\n\"\n \" print('-----TEST-----')\\n\"\n \" print(test_name)\\n\"\n \" if input != expected:\\n\"\n \" print('[Error]')\\n\"\n \" print(test_name)\\n\"\n \" print('[info] Expected:')\\n\"\n \" print(expected)\\n\"\n \" print('[info] Input:')\\n\"\n \" print(input)\\n\"\n \" # error\\n\"\n \" while True:\\n\"\n \" is_error = 1\\n\"\n \" else:\\n\"\n \" print('[ OK ]')\\n\"\n \" print('')\\n\"\n \"\\n\"\n \"a = 0\\n\"\n \"for i in range(0, 10):\\n\"\n \" if i == 5:\\n\"\n \" continue\\n\"\n \" a = a + i\\n\"\n \"EXPECT_EQ('for_if_continue', a, 40)\\n\"\n \" \\n\"\n \"a = 0\\n\"\n \"for i in range(0, 10):\\n\"\n \" if i == 5:\\n\"\n \" break\\n\"\n \" a = a + i\\n\"\n \"EXPECT_EQ('for_if_break', a, 10)\\n\"\n \"\\n\"\n \"a = 0\\n\"\n \"for i in range(0, 10):\\n\"\n \" for k in range(0, 3):\\n\"\n \" # print(k)\\n\"\n \" a = a + k\\n\"\n \"EXPECT_EQ('for_for_in_range', a, 30)\\n\"\n \"\\n\"\n \"a = 0\\n\"\n \"for i in range(0, 10):\\n\"\n \" # print(i)\\n\"\n \" a = a + i\\n\"\n \"EXPECT_EQ('for_in_range', a, 45)\\n\"\n \"\\n\"\n \"list = PikaStdData.List()\\n\"\n \"list.append(7)\\n\"\n \"list.append('eee')\\n\"\n \"len = list.len()\\n\"\n \"for item in list:\\n\"\n \" # print(item)\\n\"\n \" a = item\\n\"\n \"EXPECT_EQ('list_for_loop', a, 'eee')\\n\"\n \"\\n\"\n \"\\n\"\n \"list = PikaStdData.List()\\n\"\n \"list.append(7)\\n\"\n \"list.append('eee')\\n\"\n \"len = list.len()\\n\"\n \"a1 = list.get(0)\\n\"\n \"a2 = list.get(1)\\n\"\n \"res = iter(list)\\n\"\n \"EXPECT_EQ('iter', res, list)\\n\"\n \"\\n\"\n \"dict = PikaStdData.Dict()\\n\"\n \"dict.set('a', 1)\\n\"\n \"dict.set('b', 2)\\n\"\n \"dict.remove('b')\\n\"\n \"a = dict.get('a')\\n\"\n \"b = dict.get('b')\\n\"\n \"EXPECT_EQ('PikaStdData', a, 1)\\n\"\n \"EXPECT_EQ('PikaStdData_2', b, 0)\\n\"\n" }, is_package: false }, "PikaStdData": ClassInfo { this_class_name: "PikaStdData", super_class_name: "TinyObj", method_list: {"Dict": MethodInfo { class_name: "PikaStdData", name: "Dict", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "List": MethodInfo { class_name: "PikaStdData", name: "List", arg_list: None, return_type: Some(PyType { type_name: "any" }) }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: true }, "PikaStdData_Dict": ClassInfo { this_class_name: "PikaStdData_Dict", super_class_name: "TinyObj", method_list: {"__init__": MethodInfo { class_name: "PikaStdData_Dict", name: "__init__", arg_list: None, return_type: None }, "__iter__": MethodInfo { class_name: "PikaStdData_Dict", name: "__iter__", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "__next__": MethodInfo { class_name: "PikaStdData_Dict", name: "__next__", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "get": MethodInfo { class_name: "PikaStdData_Dict", name: "get", arg_list: Some(ArgList { py_arg_list: "key:str", list: {"key": PyArg { py_type: PyType { type_name: "str" }, name: "key" }} }), return_type: Some(PyType { type_name: "any" }) }, "remove": MethodInfo { class_name: "PikaStdData_Dict", name: "remove", arg_list: Some(ArgList { py_arg_list: "key:str", list: {"key": PyArg { py_type: PyType { type_name: "str" }, name: "key" }} }), return_type: None }, "set": MethodInfo { class_name: "PikaStdData_Dict", name: "set", arg_list: Some(ArgList { py_arg_list: "key:str,arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }, "key": PyArg { py_type: PyType { type_name: "str" }, name: "key" }} }), return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "PikaStdData_List": ClassInfo { this_class_name: "PikaStdData_List", super_class_name: "TinyObj", method_list: {"__init__": MethodInfo { class_name: "PikaStdData_List", name: "__init__", arg_list: None, return_type: None }, "__iter__": MethodInfo { class_name: "PikaStdData_List", name: "__iter__", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "__next__": MethodInfo { class_name: "PikaStdData_List", name: "__next__", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "append": MethodInfo { class_name: "PikaStdData_List", name: "append", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: None }, "get": MethodInfo { class_name: "PikaStdData_List", name: "get", arg_list: Some(ArgList { py_arg_list: "i:int", list: {"i": PyArg { py_type: PyType { type_name: "int" }, name: "i" }} }), return_type: Some(PyType { type_name: "any" }) }, "len": MethodInfo { class_name: "PikaStdData_List", name: "len", arg_list: None, return_type: Some(PyType { type_name: "int" }) }, "set": MethodInfo { class_name: "PikaStdData_List", name: "set", arg_list: Some(ArgList { py_arg_list: "i:int,arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }, "i": PyArg { py_type: PyType { type_name: "int" }, name: "i" }} }), return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "PikaStdLib": ClassInfo { this_class_name: "PikaStdLib", super_class_name: "TinyObj", method_list: {"MemChecker": MethodInfo { class_name: "PikaStdLib", name: "MemChecker", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "RangeObj": MethodInfo { class_name: "PikaStdLib", name: "RangeObj", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "SysObj": MethodInfo { class_name: "PikaStdLib", name: "SysObj", arg_list: None, return_type: Some(PyType { type_name: "any" }) }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: true }, "PikaStdLib_MemChecker": ClassInfo { this_class_name: "PikaStdLib_MemChecker", super_class_name: "TinyObj", method_list: {"getMax": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "getMax", arg_list: None, return_type: Some(PyType { type_name: "float" }) }, "getNow": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "getNow", arg_list: None, return_type: Some(PyType { type_name: "float" }) }, "max": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "max", arg_list: None, return_type: None }, "now": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "now", arg_list: None, return_type: None }, "resetMax": MethodInfo { class_name: "PikaStdLib_MemChecker", name: "resetMax", arg_list: None, return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "PikaStdLib_RangeObj": ClassInfo { this_class_name: "PikaStdLib_RangeObj", super_class_name: "TinyObj", method_list: {"__iter__": MethodInfo { class_name: "PikaStdLib_RangeObj", name: "__iter__", arg_list: None, return_type: Some(PyType { type_name: "any" }) }, "__next__": MethodInfo { class_name: "PikaStdLib_RangeObj", name: "__next__", arg_list: None, return_type: Some(PyType { type_name: "any" }) }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }, "PikaStdLib_SysObj": ClassInfo { this_class_name: "PikaStdLib_SysObj", super_class_name: "BaseObj", method_list: {"float": MethodInfo { class_name: "PikaStdLib_SysObj", name: "float", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: Some(PyType { type_name: "float" }) }, "int": MethodInfo { class_name: "PikaStdLib_SysObj", name: "int", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: Some(PyType { type_name: "int" }) }, "iter": MethodInfo { class_name: "PikaStdLib_SysObj", name: "iter", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: Some(PyType { type_name: "any" }) }, "next": MethodInfo { class_name: "PikaStdLib_SysObj", name: "next", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: Some(PyType { type_name: "any" }) }, "range": MethodInfo { class_name: "PikaStdLib_SysObj", name: "range", arg_list: Some(ArgList { py_arg_list: "a1:int,a2:int,a3:int", list: {"a1": PyArg { py_type: PyType { type_name: "int" }, name: "a1" }, "a2": PyArg { py_type: PyType { type_name: "int" }, name: "a2" }, "a3": PyArg { py_type: PyType { type_name: "int" }, name: "a3" }} }), return_type: Some(PyType { type_name: "any" }) }, "remove": MethodInfo { class_name: "PikaStdLib_SysObj", name: "remove", arg_list: Some(ArgList { py_arg_list: "argPath:str", list: {"argPath": PyArg { py_type: PyType { type_name: "str" }, name: "argPath" }} }), return_type: None }, "type": MethodInfo { class_name: "PikaStdLib_SysObj", name: "type", arg_list: Some(ArgList { py_arg_list: "arg:any", list: {"arg": PyArg { py_type: PyType { type_name: "any" }, name: "arg" }} }), return_type: None }}, object_list: {}, import_list: {}, script_list: Script { content: "" }, is_package: false }}, class_now_name: Some("PikaMain"), package_now_name: Some("PikaStdData") }
\ No newline at end of file
diff --git a/bsp/simulation-keil-dev/pikascript/pikascript-api/pikaScript.c b/bsp/simulation-keil-dev/pikascript/pikascript-api/pikaScript.c
index 008eff4a3..3e52f77dd 100644
--- a/bsp/simulation-keil-dev/pikascript/pikascript-api/pikaScript.c
+++ b/bsp/simulation-keil-dev/pikascript/pikascript-api/pikaScript.c
@@ -11,14 +11,80 @@ PikaObj * pikaScriptInit(){
"\n"
"mem = PikaStdLib.MemChecker()\n"
"\n"
- "\n"
- "for i in range(1, 100):\n"
- " print(i)\n"
- "\n"
"print('mem used max:')\n"
"mem.max()\n"
- "print('mem used now:')\n"
- "mem.now()\n"
+ "\n"
+ "def EXPECT_EQ(test_name, input, expected):\n"
+ " print('-----TEST-----')\n"
+ " print(test_name)\n"
+ " if input != expected:\n"
+ " print('[Error]')\n"
+ " print(test_name)\n"
+ " print('[info] Expected:')\n"
+ " print(expected)\n"
+ " print('[info] Input:')\n"
+ " print(input)\n"
+ " # error\n"
+ " while True:\n"
+ " is_error = 1\n"
+ " else:\n"
+ " print('[ OK ]')\n"
+ " print('')\n"
+ "\n"
+ "a = 0\n"
+ "for i in range(0, 10):\n"
+ " if i == 5:\n"
+ " continue\n"
+ " a = a + i\n"
+ "EXPECT_EQ('for_if_continue', a, 40)\n"
+ " \n"
+ "a = 0\n"
+ "for i in range(0, 10):\n"
+ " if i == 5:\n"
+ " break\n"
+ " a = a + i\n"
+ "EXPECT_EQ('for_if_break', a, 10)\n"
+ "\n"
+ "a = 0\n"
+ "for i in range(0, 10):\n"
+ " for k in range(0, 3):\n"
+ " # print(k)\n"
+ " a = a + k\n"
+ "EXPECT_EQ('for_for_in_range', a, 30)\n"
+ "\n"
+ "a = 0\n"
+ "for i in range(0, 10):\n"
+ " # print(i)\n"
+ " a = a + i\n"
+ "EXPECT_EQ('for_in_range', a, 45)\n"
+ "\n"
+ "list = PikaStdData.List()\n"
+ "list.append(7)\n"
+ "list.append('eee')\n"
+ "len = list.len()\n"
+ "for item in list:\n"
+ " # print(item)\n"
+ " a = item\n"
+ "EXPECT_EQ('list_for_loop', a, 'eee')\n"
+ "\n"
+ "\n"
+ "list = PikaStdData.List()\n"
+ "list.append(7)\n"
+ "list.append('eee')\n"
+ "len = list.len()\n"
+ "a1 = list.get(0)\n"
+ "a2 = list.get(1)\n"
+ "res = iter(list)\n"
+ "EXPECT_EQ('iter', res, list)\n"
+ "\n"
+ "dict = PikaStdData.Dict()\n"
+ "dict.set('a', 1)\n"
+ "dict.set('b', 2)\n"
+ "dict.remove('b')\n"
+ "a = dict.get('a')\n"
+ "b = dict.get('b')\n"
+ "EXPECT_EQ('PikaStdData', a, 1)\n"
+ "EXPECT_EQ('PikaStdData_2', b, 0)\n"
"\n");
return pikaMain;
}
diff --git a/bsp/simulation-keil-dev/pikascript/pikascript-lib/PikaStdData/PikaStdData.py b/bsp/simulation-keil-dev/pikascript/pikascript-lib/PikaStdData/PikaStdData.py
new file mode 100644
index 000000000..a038e10b7
--- /dev/null
+++ b/bsp/simulation-keil-dev/pikascript/pikascript-lib/PikaStdData/PikaStdData.py
@@ -0,0 +1,51 @@
+from PikaObj import *
+
+
+class List(TinyObj):
+ def __init__():
+ pass
+
+ # add an arg after the end of list
+ def append(arg: any):
+ pass
+
+ # get an arg by the index
+ def get(i: int) -> any:
+ pass
+
+ # set an arg by the index
+ def set(i: int, arg: any):
+ pass
+
+ # get the length of list
+ def len() -> int:
+ pass
+
+ def __iter__() -> any:
+ pass
+
+ def __next__() -> any:
+ pass
+
+
+class Dict(TinyObj):
+ def __init__():
+ pass
+
+ # get an arg by the key
+ def get(key: str) -> any:
+ pass
+
+ # set an arg by the key
+ def set(key: str, arg: any):
+ pass
+
+ # remove an arg by the key
+ def remove(key: str):
+ pass
+
+ def __iter__() -> any:
+ pass
+
+ def __next__() -> any:
+ pass
diff --git a/bsp/simulation-keil-dev/pikascript/pikascript-lib/PikaStdData/PikaStdData_Dict.c b/bsp/simulation-keil-dev/pikascript/pikascript-lib/PikaStdData/PikaStdData_Dict.c
new file mode 100644
index 000000000..fd0f6f866
--- /dev/null
+++ b/bsp/simulation-keil-dev/pikascript/pikascript-lib/PikaStdData/PikaStdData_Dict.c
@@ -0,0 +1,24 @@
+#include "PikaObj.h"
+#include "PikaStdLib_SysObj.h"
+#include "PikaStdData_Dict.h"
+
+Arg* PikaStdData_Dict_get(PikaObj* self, char* key) {
+ return arg_copy(obj_getArg(self, key));
+}
+
+void PikaStdData_Dict___init__(PikaObj* self) {}
+
+void PikaStdData_Dict_set(PikaObj* self, Arg* arg, char* key) {
+ obj_setArg(self, key, arg);
+}
+
+void PikaStdData_Dict_remove(PikaObj* self, char* key) {
+ PikaStdLib_SysObj_remove(self, key);
+}
+
+Arg * PikaStdData_Dict___iter__(PikaObj *self){
+ return NULL;
+}
+Arg * PikaStdData_Dict___next__(PikaObj *self){
+ return NULL;
+}
\ No newline at end of file
diff --git a/bsp/simulation-keil-dev/pikascript/pikascript-lib/PikaStdData/PikaStdData_List.c b/bsp/simulation-keil-dev/pikascript/pikascript-lib/PikaStdData/PikaStdData_List.c
new file mode 100644
index 000000000..1dbf496ae
--- /dev/null
+++ b/bsp/simulation-keil-dev/pikascript/pikascript-lib/PikaStdData/PikaStdData_List.c
@@ -0,0 +1,55 @@
+#include "BaseObj.h"
+#include "PikaObj.h"
+
+void PikaStdData_List_append(PikaObj* self, Arg* arg) {
+ int top = obj_getInt(self, "top");
+ char buff[11];
+ char* topStr = fast_itoa(buff, top);
+ PikaObj* pyload = obj_getObj(self, "pyload", 0);
+ obj_setArg(pyload, topStr, arg);
+ /* top++ */
+ obj_setInt(self, "top", top + 1);
+}
+
+int PikaStdData_List_len(PikaObj* self) {
+ return obj_getInt(self, "top");
+}
+
+Arg* PikaStdData_List_get(PikaObj* self, int i) {
+ char buff[11];
+ char* index = fast_itoa(buff, i);
+ PikaObj* pyload = obj_getObj(self, "pyload", 0);
+ return arg_copy(obj_getArg(pyload, index));
+}
+void PikaStdData_List___init__(PikaObj* self) {
+ /* set top index for append */
+ obj_setInt(self, "top", 0);
+ obj_newObj(self, "pyload", "", New_TinyObj);
+}
+
+void PikaStdData_List_set(PikaObj* self, Arg* arg, int i) {
+ char buff[11];
+ char* i_str = fast_itoa(buff, i);
+ int top = obj_getInt(self, "top");
+ if (i > top) {
+ obj_setErrorCode(self, 1);
+ obj_setSysOut(self, "[error]: index exceeded lengh of list.");
+ }
+ PikaObj* pyload = obj_getObj(self, "pyload", 0);
+ obj_setArg(pyload, i_str, arg);
+}
+
+Arg* PikaStdData_List___iter__(PikaObj* self) {
+ obj_setInt(self, "__iter_i", 0);
+ return arg_setPtr(NULL, "", TYPE_POINTER, self);
+}
+
+Arg* PikaStdData_List___next__(PikaObj* self) {
+ int __iter_i = args_getInt(self->list, "__iter_i");
+ Arg* res = PikaStdData_List_get(self, __iter_i);
+ if(NULL == res){
+ return arg_setNull(NULL);
+ }
+ args_setInt(self->list, "__iter_i", __iter_i + 1);
+ return res;
+}
\ No newline at end of file
diff --git a/bsp/simulation-keil-dev/pikascript/requestment.txt b/bsp/simulation-keil-dev/pikascript/requestment.txt
index e83033d1e..2a6d5698e 100644
--- a/bsp/simulation-keil-dev/pikascript/requestment.txt
+++ b/bsp/simulation-keil-dev/pikascript/requestment.txt
@@ -1,2 +1,2 @@
-pikascript-core==v1.3.0
-PikaStdLib==v1.3.0
\ No newline at end of file
+PikaStdLib==latest
+PikaStdData==latest
\ No newline at end of file
diff --git a/bsp/stm32g030c8/pikascript/main.py b/bsp/stm32g030c8/pikascript/main.py
index 6b7f0e473..43785cb1a 100644
--- a/bsp/stm32g030c8/pikascript/main.py
+++ b/bsp/stm32g030c8/pikascript/main.py
@@ -1,137 +1,23 @@
-from PikaObj import *
-import PikaStdLib
-import PikaPiZero
import STM32G0
+import PikaPiZero
+import PikaStdLib
-# hardware init
-lcd = PikaPiZero.LCD()
-lcd.init()
-lcd.clear('white')
-key = PikaPiZero.KEY()
-key.init()
time = STM32G0.Time()
-x_max = 120
-y_max = 150
-
-# snake init
-s = PikaPiZero.Point()
-w = 9
-h = 9
-s.x = 50
-s.y = 10
-len = 0
-while len < 3:
- b = s
- i = 0
- while i < len:
- b = b.next
- i = i + 1
- b.next = PikaPiZero.Point()
- b.next.x = b.x - 10
- b.next.y = b.y
- b.next.prev = b
- len = len + 1
-# ring link
-b.next = s
-s.prev = b
-
-i = 0
-b = s
-while i < len:
- lcd.fill(b.x, b.y, w, h, 'blue')
- b = b.next
- i = i + 1
-
-print('snake lengh')
-print(len)
-
-# fruit init
-f = PikaPiZero.Point()
-f.x = 30
-f.y = 20
-lcd.fill(f.x, f.y, w, h, 'green')
-
-# memory check
+adc = STM32G0.ADC()
+pin = STM32G0.GPIO()
+pwm = STM32G0.PWM()
+uart = STM32G0.UART()
+rgb = PikaPiZero.RGB()
mem = PikaStdLib.MemChecker()
+
+rgb.init()
+rgb.enable()
+
+print('hello 2')
print('mem used max:')
mem.max()
-# main loop
-d = 0
-isUpdate = 1
-isEat = 0
while True:
- if isUpdate:
- # isUpdate = 0
- # check eat fruit
- if f.x == s.x and f.y == s.y:
- # have eat fruit
- isEat = 1
- f.x = f.x + 30
- if f.x > x_max:
- f.x = f.x - x_max
- f.y = f.y + 30
- if f.y > y_max:
- f.y = f.y - y_max
- lcd.fill(f.x, f.y, w, h, 'green')
- # move snake by the direction
- if d == 0:
- x_new = s.x + 10
- y_new = s.y
- if x_new > x_max:
- x_new = 0
- elif d == 1:
- x_new = s.x
- y_new = s.y - 10
- if y_new < 0:
- y_new = y_max
- elif d == 2:
- x_new = s.x
- y_new = s.y + 10
- if y_new > y_max:
- y_new = 0
- elif d == 3:
- x_new = s.x - 10
- y_new = s.y
- if x_new < 0:
- x_new = x_max
- if isEat:
- isEat = 0
- b_new = PikaPiZero.Point()
- b_new.x = x_new
- b_new.y = y_new
- b_new.prev = s.prev
- b_new.next = s
- s.prev.next = b_new
- s.prev = b_new
- s = b_new
- len = len + 1
- print('snake lengh')
- print(len)
- print('mem used max:')
- mem.max()
- # drow the snake and fruit
- # clear last body
- lcd.fill(s.prev.x, s.prev.y, w, h, 'white')
- # new body
- s.prev.x = x_new
- s.prev.y = y_new
- # head is last body
- s = s.prev
- lcd.fill(s.x, s.y, w, h, 'blue')
- b = s
- i = 0
- # scan key
- key_val = key.get()
- if key_val == 0:
- d = 0
- isUpdate = 1
- elif key_val == 1:
- d = 1
- isUpdate = 1
- elif key_val == 2:
- d = 2
- isUpdate = 1
- elif key_val == 3:
- d = 3
- isUpdate = 1
+ print('flowing')
+ rgb.flow()
+
diff --git a/port/linux/api-make-linux.sh b/port/linux/api-make-linux.sh
old mode 100755
new mode 100644
diff --git a/port/linux/api-make-win10.sh b/port/linux/api-make-win10.sh
old mode 100755
new mode 100644
diff --git a/port/linux/api-make.sh b/port/linux/api-make.sh
old mode 100755
new mode 100644
diff --git a/port/linux/gtest.sh b/port/linux/gtest.sh
old mode 100755
new mode 100644
diff --git a/port/linux/init.sh b/port/linux/init.sh
old mode 100755
new mode 100644
diff --git a/port/linux/make.sh b/port/linux/make.sh
old mode 100755
new mode 100644
diff --git a/port/linux/package/pikascript/rust-msc-latest-linux b/port/linux/package/pikascript/rust-msc-latest-linux
old mode 100755
new mode 100644
diff --git a/port/linux/pkg-push.sh b/port/linux/pkg-push.sh
old mode 100755
new mode 100644
diff --git a/port/linux/pull-core.sh b/port/linux/pull-core.sh
old mode 100755
new mode 100644
diff --git a/port/linux/push-core.sh b/port/linux/push-core.sh
old mode 100755
new mode 100644
diff --git a/port/linux/test-banchmark.sh b/port/linux/test-banchmark.sh
old mode 100755
new mode 100644
diff --git a/port/linux/update-compiler.sh b/port/linux/update-compiler.sh
old mode 100755
new mode 100644