l0n0lc 0.6.0__py3-none-any.whl → 0.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- l0n0lc/jit.py +13 -1
- {l0n0lc-0.6.0.dist-info → l0n0lc-0.7.1.dist-info}/METADATA +22 -7
- {l0n0lc-0.6.0.dist-info → l0n0lc-0.7.1.dist-info}/RECORD +6 -6
- {l0n0lc-0.6.0.dist-info → l0n0lc-0.7.1.dist-info}/WHEEL +0 -0
- {l0n0lc-0.6.0.dist-info → l0n0lc-0.7.1.dist-info}/licenses/LICENSE +0 -0
- {l0n0lc-0.6.0.dist-info → l0n0lc-0.7.1.dist-info}/top_level.txt +0 -0
l0n0lc/jit.py
CHANGED
@@ -50,6 +50,18 @@ class c获取索引项目:
|
|
50
50
|
return f'{self.变量}[{toCString(self.索引)}]'
|
51
51
|
|
52
52
|
|
53
|
+
class c获取属性:
|
54
|
+
def __init__(self, 变量, 属性) -> None:
|
55
|
+
self.变量 = 变量
|
56
|
+
self.属性 = 属性
|
57
|
+
|
58
|
+
def __str__(self) -> str:
|
59
|
+
if isinstance(self.变量, c变量):
|
60
|
+
if self.变量.类型.endswith('*'):
|
61
|
+
return f'{self.变量}->{self.属性}'
|
62
|
+
return f'{self.变量}.{self.属性}'
|
63
|
+
|
64
|
+
|
53
65
|
class py2cpp编译器(ast.NodeVisitor):
|
54
66
|
def __init__(self, 被编译的函数: Callable) -> None:
|
55
67
|
self.被编译的函数 = 被编译的函数
|
@@ -144,7 +156,7 @@ class py2cpp编译器(ast.NodeVisitor):
|
|
144
156
|
if isinstance(value, ast.Attribute):
|
145
157
|
对象 = self.获取值(value.value)
|
146
158
|
if isinstance(对象, c变量):
|
147
|
-
return
|
159
|
+
return c获取属性(对象, value.attr)
|
148
160
|
if 对象 is None:
|
149
161
|
self.抛出代码异常(f'没找到{value.value}', value)
|
150
162
|
return getattr(对象, value.attr)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: l0n0lc
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.1
|
4
4
|
Summary: 用python写c
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
6
6
|
Requires-Python: >=3.10
|
@@ -40,25 +40,34 @@ def test_add(a: int, b: int) -> int:
|
|
40
40
|
a += i
|
41
41
|
a = math.ceil(12.5)
|
42
42
|
cc = {'a': 1, 'b': 2}
|
43
|
-
cc['
|
43
|
+
cc['c'] = 3
|
44
|
+
print('输出map:')
|
45
|
+
for ii in cc:
|
46
|
+
print(ii.first, ii.second) # type: ignore
|
44
47
|
aa = [1, 3, 2]
|
45
48
|
aa[0] = 134
|
49
|
+
print('输出list:')
|
46
50
|
for i in range(3):
|
47
51
|
print(i, aa[i])
|
48
52
|
print('Hello World', a, b)
|
49
53
|
return a + b + 1
|
50
54
|
|
51
55
|
|
52
|
-
print(test_add(1, 3))
|
56
|
+
print('结果:', test_add(1, 3))
|
53
57
|
```
|
54
58
|
## 执行hello_world.py
|
55
59
|
```bash
|
56
60
|
$ python hello_world.py
|
61
|
+
输出map:
|
62
|
+
c 3
|
63
|
+
a 1
|
64
|
+
b 2
|
65
|
+
输出list:
|
57
66
|
0 134
|
58
67
|
1 3
|
59
68
|
2 2
|
60
69
|
Hello World 13 3
|
61
|
-
17
|
70
|
+
结果: 17
|
62
71
|
```
|
63
72
|
## 查看生成的c++代码文件
|
64
73
|
```bash
|
@@ -84,7 +93,7 @@ extern "C" int64_t test_add (int64_t a, int64_t b);
|
|
84
93
|
|
85
94
|
## test_add_@402bbf73254216d8.cpp
|
86
95
|
```c++
|
87
|
-
#include "test_add_@
|
96
|
+
#include "test_add_@141921ba1aaa0352.h"
|
88
97
|
extern "C" int64_t test_add (int64_t a, int64_t b)
|
89
98
|
{
|
90
99
|
if ((a > 1))
|
@@ -104,9 +113,16 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
|
|
104
113
|
|
105
114
|
a = std::ceil(12.5);;
|
106
115
|
std::unordered_map<std::string, int64_t> cc = {{ u8"a", 1 },{ u8"b", 2 }};
|
107
|
-
cc[u8"
|
116
|
+
cc[u8"c"] = 3;
|
117
|
+
std::cout<< u8"输出map:" << " "<< std::endl;
|
118
|
+
for (auto ii : cc)
|
119
|
+
{
|
120
|
+
std::cout<< ii.first << " "<< ii.second << " "<< std::endl;
|
121
|
+
}
|
122
|
+
|
108
123
|
int64_t aa[] = {1,3,2};
|
109
124
|
aa[0] = 134;
|
125
|
+
std::cout<< u8"输出list:" << " "<< std::endl;
|
110
126
|
for (int64_t i = 0; i < 3; ++i)
|
111
127
|
{
|
112
128
|
std::cout<< i << " "<< aa[i] << " "<< std::endl;
|
@@ -115,5 +131,4 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
|
|
115
131
|
std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
|
116
132
|
return a + b + 1;
|
117
133
|
}
|
118
|
-
|
119
134
|
```
|
@@ -2,11 +2,11 @@ l0n0lc/StdList.py,sha256=fA6sWAfW2JgDUhQDK2Hlx_PPuSdLwTcCTk5aha4zA-Q,863
|
|
2
2
|
l0n0lc/StdMap.py,sha256=TIVKqhT078cjLIM0Zlq-TwGFSy-KwOyJe00BLFPVxr8,735
|
3
3
|
l0n0lc/__init__.py,sha256=fUC6TMeN_fEL7HDazrBEdoWOQkXi5uSGZb7LZj6juog,137
|
4
4
|
l0n0lc/c基础处理.py,sha256=FMauoVx4-33JXl4OLpUl1D6NCkLjk6yBH7do9WnT0Wg,5671
|
5
|
-
l0n0lc/jit.py,sha256=
|
5
|
+
l0n0lc/jit.py,sha256=8BjvTeRzRK8CPkRCRvEjTNnFGJslLwC2R5JRE4Plo5o,22998
|
6
6
|
l0n0lc/编译.py,sha256=f1ugdTpnKcDOprcGu2Q5zMm_sYdxWMphBeo4ZL-cW3o,2016
|
7
7
|
l0n0lc/通用.py,sha256=O_Y4bbW1WzHCJkibxAy9WGACv-aEZJLG-fEeVBcAbBQ,3649
|
8
|
-
l0n0lc-0.
|
9
|
-
l0n0lc-0.
|
10
|
-
l0n0lc-0.
|
11
|
-
l0n0lc-0.
|
12
|
-
l0n0lc-0.
|
8
|
+
l0n0lc-0.7.1.dist-info/licenses/LICENSE,sha256=1L-MAjulZ3kpbYwsJtlXpDVITRxykna2Ecg_521YfkA,1093
|
9
|
+
l0n0lc-0.7.1.dist-info/METADATA,sha256=f4mekJITeqhyeuP7dZV_FhX58VvgA6-99miKbZJW0KA,2760
|
10
|
+
l0n0lc-0.7.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
+
l0n0lc-0.7.1.dist-info/top_level.txt,sha256=Q21D_eEY_-xgRUPwATGp9YDKSBO4w_7MI2MYxQI1aT4,7
|
12
|
+
l0n0lc-0.7.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|