l0n0lc 0.10.3__py3-none-any.whl → 0.10.4__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.
@@ -177,6 +177,10 @@ def py类型转c类型(类型, 类型实例=None):
177
177
  raise Exception("不支持的类型", 类型, 类型实例)
178
178
 
179
179
 
180
+ class 列表内类型不一异常(Exception):
181
+ pass
182
+
183
+
180
184
  class list初始化列表:
181
185
  def __init__(
182
186
  self,
@@ -206,7 +210,7 @@ def 从list构建初始化列表(value: List):
206
210
  if all(类型[0] == 数据类型列表[0][0] for 类型 in 数据类型列表):
207
211
  数据类型列表 = 数据类型列表[0]
208
212
  else:
209
- raise Exception(f"列表内数据类型必须相同{value}")
213
+ raise key类型不一异常
210
214
 
211
215
  return list初始化列表(初始化列表, 数据类型列表, len(value))
212
216
 
@@ -227,6 +231,14 @@ class dict初始化列表:
227
231
  return self.代码
228
232
 
229
233
 
234
+ class key类型不一异常(Exception):
235
+ pass
236
+
237
+
238
+ class value类型不一异常(Exception):
239
+ pass
240
+
241
+
230
242
  def 从dict构建初始化列表(value: dict):
231
243
  code = []
232
244
  key类型列表 = []
@@ -242,12 +254,12 @@ def 从dict构建初始化列表(value: dict):
242
254
  if all(类型 == key类型列表[0] for 类型 in key类型列表):
243
255
  key类型列表 = (key类型列表[0], k)
244
256
  else:
245
- raise Exception(f"key数据类型必须相同{value.keys()}")
257
+ raise key类型不一异常
246
258
 
247
259
  if all(类型 == value类型列表[0] for 类型 in value类型列表):
248
260
  value类型列表 = (value类型列表[0], v)
249
261
  else:
250
- raise Exception(f"value数据类型必须相同{value.values()}")
262
+ raise value类型不一异常
251
263
 
252
264
  # 构建初始化列表
253
265
  初始化列表 = '{' + ','.join(code) + '}'
l0n0lc/jit.py CHANGED
@@ -15,8 +15,14 @@ class 代码异常抛出器:
15
15
  self.代码行 = 代码.split('\n')
16
16
 
17
17
  def __call__(self, 错误信息: str, node: ast.stmt | ast.expr | ast.arg) -> Any:
18
- raise Exception(
19
- f'{错误信息} {self.代码行[node.lineno][node.col_offset:node.end_col_offset]}')
18
+ print(f'\033[31m[错误]:{错误信息}\033[0m')
19
+ print(f'错误代码:')
20
+ print('```python')
21
+ print(self.代码行[node.lineno - 1][:node.col_offset], end='')
22
+ print(
23
+ f'\033[31m{self.代码行[node.lineno - 1][node.col_offset: node.end_col_offset]}\033[0m', end='')
24
+ print(self.代码行[node.lineno - 1][node.end_col_offset:])
25
+ print('```')
20
26
 
21
27
 
22
28
  class py2cpp编译器(ast.NodeVisitor):
@@ -174,16 +180,28 @@ class py2cpp编译器(ast.NodeVisitor):
174
180
 
175
181
  if isinstance(value, ast.List):
176
182
  l = [self.获取值(e) for e in value.elts]
177
- return 从list构建初始化列表(l)
183
+ try:
184
+ return 从list构建初始化列表(l)
185
+ except:
186
+ self.抛出代码异常(str(l) + ' 类型不相同!', value)
178
187
  if isinstance(value, ast.Tuple):
179
188
  l = [self.获取值(e) for e in value.elts]
180
189
  if not self.正在构建参数:
181
- return 从list构建初始化列表(l)
190
+ try:
191
+ return 从list构建初始化列表(l)
192
+ except:
193
+ self.抛出代码异常(str(l) + ' 类型不相同!', value)
182
194
  return tuple(l)
183
195
  if isinstance(value, ast.Dict):
184
196
  d = {self.获取值(k): self.获取值(v)
185
197
  for k, v in zip(value.keys, value.values)}
186
- return 从dict构建初始化列表(d)
198
+ try:
199
+ return 从dict构建初始化列表(d)
200
+ except key类型不一异常:
201
+ self.抛出代码异常(str(d.keys()) + ' 类型不相同!', value)
202
+ except value类型不一异常:
203
+ self.抛出代码异常(str(d.values()) + ' 类型不相同!', value)
204
+ return
187
205
 
188
206
  if isinstance(value, ast.Call):
189
207
  return self.调用Call(value)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: l0n0lc
3
- Version: 0.10.3
3
+ Version: 0.10.4
4
4
  Summary: 一个将python函数翻译为c++函数并运行的jit编译器
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Requires-Python: >=3.10
@@ -292,23 +292,23 @@ vv: 1
292
292
  ```bash
293
293
  ls -al ./l0n0lcoutput
294
294
  total 176
295
- drwxr-xr-x 2 root root 4096 Oct 22 02:25 .
296
- drwxrwxrwx 11 1000 1000 4096 Oct 22 02:25 ..
297
- -rw-r--r-- 1 root root 298 Oct 22 02:25 6cbfb68e317eace4_测试可执行.py_可执行_@d82ed7910ac3268c.cpp
298
- -rw-r--r-- 1 root root 128 Oct 22 02:25 6cbfb68e317eace4_测试可执行.py_可执行_@d82ed7910ac3268c.h
299
- -rw-r--r-- 1 root root 1944 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_jit_all_ops_@c636865fefd2fd71.cpp
300
- -rw-r--r-- 1 root root 167 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_jit_all_ops_@c636865fefd2fd71.h
301
- -rwxr-xr-x 1 root root 29000 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_jit_all_ops_@c636865fefd2fd71.so
302
- -rw-r--r-- 1 root root 1531 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_test_add_@469de6acaaabc570.cpp
303
- -rw-r--r-- 1 root root 398 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_test_add_@469de6acaaabc570.h
304
- -rwxr-xr-x 1 root root 41728 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_test_add_@469de6acaaabc570.so
305
- -rw-r--r-- 1 root root 155 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_test_other_fn_@75fdd928ab58a8e3.cpp
306
- -rw-r--r-- 1 root root 106 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_test_other_fn_@75fdd928ab58a8e3.h
307
- -rwxr-xr-x 1 root root 15648 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_test_other_fn_@75fdd928ab58a8e3.so
308
- -rw-r--r-- 1 root root 219 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_test编译的函数_@3bf4501e0408a243.cpp
309
- -rw-r--r-- 1 root root 164 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_test编译的函数_@3bf4501e0408a243.h
310
- -rwxr-xr-x 1 root root 15688 Oct 22 02:25 c31f68e99ed4ce3c_hello_world.py_test编译的函数_@3bf4501e0408a243.so
311
- -rwxr-xr-x 1 root root 17248 Oct 22 02:25 测试可执行文件
295
+ drwxr-xr-x 2 root root 4096 Oct 22 02:51 .
296
+ drwxrwxrwx 11 1000 1000 4096 Oct 22 02:51 ..
297
+ -rw-r--r-- 1 root root 298 Oct 22 02:51 6cbfb68e317eace4_测试可执行.py_可执行_@d82ed7910ac3268c.cpp
298
+ -rw-r--r-- 1 root root 128 Oct 22 02:51 6cbfb68e317eace4_测试可执行.py_可执行_@d82ed7910ac3268c.h
299
+ -rw-r--r-- 1 root root 1944 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_jit_all_ops_@c636865fefd2fd71.cpp
300
+ -rw-r--r-- 1 root root 167 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_jit_all_ops_@c636865fefd2fd71.h
301
+ -rwxr-xr-x 1 root root 29000 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_jit_all_ops_@c636865fefd2fd71.so
302
+ -rw-r--r-- 1 root root 1531 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_test_add_@469de6acaaabc570.cpp
303
+ -rw-r--r-- 1 root root 398 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_test_add_@469de6acaaabc570.h
304
+ -rwxr-xr-x 1 root root 41728 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_test_add_@469de6acaaabc570.so
305
+ -rw-r--r-- 1 root root 155 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_test_other_fn_@75fdd928ab58a8e3.cpp
306
+ -rw-r--r-- 1 root root 106 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_test_other_fn_@75fdd928ab58a8e3.h
307
+ -rwxr-xr-x 1 root root 15648 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_test_other_fn_@75fdd928ab58a8e3.so
308
+ -rw-r--r-- 1 root root 219 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_test编译的函数_@3bf4501e0408a243.cpp
309
+ -rw-r--r-- 1 root root 164 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_test编译的函数_@3bf4501e0408a243.h
310
+ -rwxr-xr-x 1 root root 15688 Oct 22 02:51 c31f68e99ed4ce3c_hello_world.py_test编译的函数_@3bf4501e0408a243.so
311
+ -rwxr-xr-x 1 root root 17248 Oct 22 02:51 测试可执行文件
312
312
 
313
313
  ```
314
314
  ## 6. 6cbfb68e317eace4_测试可执行.py_可执行_@d82ed7910ac3268c.cpp
@@ -0,0 +1,12 @@
1
+ l0n0lc/StdList.py,sha256=0NTIpaRrNHaCiLrRbEVob21pZHa8S8rfaBRALPT-tD0,889
2
+ l0n0lc/StdMap.py,sha256=997LCvP0ewNciabbmGHVL2eUgMakHBsR3c5HQmOwC_E,666
3
+ l0n0lc/__init__.py,sha256=fUC6TMeN_fEL7HDazrBEdoWOQkXi5uSGZb7LZj6juog,137
4
+ l0n0lc/c基础处理.py,sha256=i2zLdymhqX3Ao9W1J-6b-EpU06jVUMTAbRy-a6xVSq0,7542
5
+ l0n0lc/jit.py,sha256=ofhwtGoNv9RkKUoPMaAYW96ChoOn99XIJ3JRw6ztCm8,26624
6
+ l0n0lc/编译.py,sha256=A9FUV95cVD7Fz7vlKhbqE9CsjpixpdqWQxq1h8e4DBw,2262
7
+ l0n0lc/通用.py,sha256=ckCW4Sz3IVsIIctoUGA55j_IZrcZQdtH7VXWS3Uh1Dk,4789
8
+ l0n0lc-0.10.4.dist-info/licenses/LICENSE,sha256=1L-MAjulZ3kpbYwsJtlXpDVITRxykna2Ecg_521YfkA,1093
9
+ l0n0lc-0.10.4.dist-info/METADATA,sha256=lNqCkCoGpmOxxrowb-8ybFAfZ6CtVjkv1syc3mWsv4k,13191
10
+ l0n0lc-0.10.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ l0n0lc-0.10.4.dist-info/top_level.txt,sha256=Q21D_eEY_-xgRUPwATGp9YDKSBO4w_7MI2MYxQI1aT4,7
12
+ l0n0lc-0.10.4.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- l0n0lc/StdList.py,sha256=0NTIpaRrNHaCiLrRbEVob21pZHa8S8rfaBRALPT-tD0,889
2
- l0n0lc/StdMap.py,sha256=997LCvP0ewNciabbmGHVL2eUgMakHBsR3c5HQmOwC_E,666
3
- l0n0lc/__init__.py,sha256=fUC6TMeN_fEL7HDazrBEdoWOQkXi5uSGZb7LZj6juog,137
4
- l0n0lc/c基础处理.py,sha256=LIKEU8oW7Ean_LLfKq_9yVP0eNxfPWw9sMw5QLdv9Us,7484
5
- l0n0lc/jit.py,sha256=f77_RwGWc_c5nU_yPyYXnNjDOKNcG5EIvVV-_Y7RYIA,25798
6
- l0n0lc/编译.py,sha256=A9FUV95cVD7Fz7vlKhbqE9CsjpixpdqWQxq1h8e4DBw,2262
7
- l0n0lc/通用.py,sha256=ckCW4Sz3IVsIIctoUGA55j_IZrcZQdtH7VXWS3Uh1Dk,4789
8
- l0n0lc-0.10.3.dist-info/licenses/LICENSE,sha256=1L-MAjulZ3kpbYwsJtlXpDVITRxykna2Ecg_521YfkA,1093
9
- l0n0lc-0.10.3.dist-info/METADATA,sha256=9LdtM0gEkx1lZwA9WiICguuhDOm1muo6RtP8dck8Gas,13191
10
- l0n0lc-0.10.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- l0n0lc-0.10.3.dist-info/top_level.txt,sha256=Q21D_eEY_-xgRUPwATGp9YDKSBO4w_7MI2MYxQI1aT4,7
12
- l0n0lc-0.10.3.dist-info/RECORD,,