l0n0lc 0.8.9__tar.gz → 0.11.2__tar.gz
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-0.11.2/PKG-INFO +593 -0
- l0n0lc-0.11.2/README.md +583 -0
- l0n0lc-0.11.2/l0n0lc/Py/350/275/254Cpp/350/275/254/350/257/221/345/231/250.py +939 -0
- l0n0lc-0.11.2/l0n0lc/__init__.py +8 -0
- l0n0lc-0.11.2/l0n0lc/cpp/347/261/273/345/236/213.py +360 -0
- l0n0lc-0.11.2/l0n0lc/cpp/347/274/226/350/257/221/345/231/250.py +117 -0
- l0n0lc-0.11.2/l0n0lc/std_map.py +22 -0
- l0n0lc-0.11.2/l0n0lc/std_vector.py +24 -0
- l0n0lc-0.11.2/l0n0lc//345/215/263/346/227/266/347/274/226/350/257/221.py +45 -0
- l0n0lc-0.11.2/l0n0lc//345/267/245/345/205/267.py +164 -0
- l0n0lc-0.11.2/l0n0lc//345/274/202/345/270/270.py +17 -0
- l0n0lc-0.11.2/l0n0lc.egg-info/PKG-INFO +593 -0
- l0n0lc-0.11.2/l0n0lc.egg-info/SOURCES.txt +18 -0
- {l0n0lc-0.8.9 → l0n0lc-0.11.2}/pyproject.toml +1 -1
- l0n0lc-0.11.2/tests/test_class_jit.py +28 -0
- l0n0lc-0.11.2/tests/test_jit.py +37 -0
- l0n0lc-0.8.9/PKG-INFO +0 -455
- l0n0lc-0.8.9/README.md +0 -445
- l0n0lc-0.8.9/l0n0lc/StdList.py +0 -24
- l0n0lc-0.8.9/l0n0lc/StdMap.py +0 -21
- l0n0lc-0.8.9/l0n0lc/__init__.py +0 -6
- l0n0lc-0.8.9/l0n0lc/c/345/237/272/347/241/200/345/244/204/347/220/206.py +0 -208
- l0n0lc-0.8.9/l0n0lc/jit.py +0 -637
- l0n0lc-0.8.9/l0n0lc//347/274/226/350/257/221.py +0 -58
- l0n0lc-0.8.9/l0n0lc//351/200/232/347/224/250.py +0 -163
- l0n0lc-0.8.9/l0n0lc.egg-info/PKG-INFO +0 -455
- l0n0lc-0.8.9/l0n0lc.egg-info/SOURCES.txt +0 -14
- {l0n0lc-0.8.9 → l0n0lc-0.11.2}/LICENSE +0 -0
- {l0n0lc-0.8.9 → l0n0lc-0.11.2}/l0n0lc.egg-info/dependency_links.txt +0 -0
- {l0n0lc-0.8.9 → l0n0lc-0.11.2}/l0n0lc.egg-info/top_level.txt +0 -0
- {l0n0lc-0.8.9 → l0n0lc-0.11.2}/setup.cfg +0 -0
l0n0lc-0.11.2/PKG-INFO
ADDED
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: l0n0lc
|
|
3
|
+
Version: 0.11.2
|
|
4
|
+
Summary: 一个将python函数翻译为c++函数并运行的jit编译器
|
|
5
|
+
Classifier: Programming Language :: Python :: 3
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# 将python函数翻译为c++函数并运行
|
|
13
|
+
## 1. 安装
|
|
14
|
+
```
|
|
15
|
+
pip install l0n0lc
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 2. 测试可执行.py
|
|
19
|
+
```python
|
|
20
|
+
import sys
|
|
21
|
+
import pathlib
|
|
22
|
+
sys.path.append(str(pathlib.Path(__file__).parent.parent))
|
|
23
|
+
import l0n0lc as lc
|
|
24
|
+
import subprocess
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@lc.映射函数(print, ['<iostream>'])
|
|
28
|
+
def cpp_cout(*args):
|
|
29
|
+
code = f'std::cout'
|
|
30
|
+
for arg in args:
|
|
31
|
+
code += f'<< {lc.转C字符串(arg)} << " "'
|
|
32
|
+
code += '<< std::endl;'
|
|
33
|
+
return code
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@lc.映射类型('int')
|
|
37
|
+
class int32_t:
|
|
38
|
+
def __init__(self, v) -> None:
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@lc.映射类型('char**')
|
|
43
|
+
class charpp:
|
|
44
|
+
def __getitem__(self, key):
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
编译为可执行文件文件名 = '测试可执行文件'
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@lc.即时编译(总是重编=True, 可执行文件名=编译为可执行文件文件名)
|
|
52
|
+
def 可执行(argc: int32_t, argv: charpp) -> int32_t:
|
|
53
|
+
for i in range(argc): # type: ignore
|
|
54
|
+
print(argv[i])
|
|
55
|
+
print('Hello World')
|
|
56
|
+
return int32_t(0)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
subprocess.run([f'l0n0lcoutput/{编译为可执行文件文件名}', '参数1', '参数2'])
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
## 3. test_class_jit.py
|
|
63
|
+
```python
|
|
64
|
+
import sys
|
|
65
|
+
import pathlib
|
|
66
|
+
sys.path.append(str(pathlib.Path(__file__).parent.parent))
|
|
67
|
+
|
|
68
|
+
import unittest
|
|
69
|
+
from l0n0lc import jit
|
|
70
|
+
class Point:
|
|
71
|
+
x: int
|
|
72
|
+
y: int
|
|
73
|
+
|
|
74
|
+
def __init__(self, x: int, y: int):
|
|
75
|
+
self.x = x
|
|
76
|
+
self.y = y
|
|
77
|
+
|
|
78
|
+
def area(self) -> int:
|
|
79
|
+
return self.x * self.y
|
|
80
|
+
|
|
81
|
+
@jit()
|
|
82
|
+
def test_point_area(x: int, y: int) -> int:
|
|
83
|
+
p = Point(x, y)
|
|
84
|
+
return p.area()
|
|
85
|
+
|
|
86
|
+
class TestClassJit(unittest.TestCase):
|
|
87
|
+
def test_basic_class(self):
|
|
88
|
+
self.assertEqual(test_point_area(10, 20), 200)
|
|
89
|
+
|
|
90
|
+
if __name__ == '__main__':
|
|
91
|
+
unittest.main()
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## 4. hello_world.py
|
|
96
|
+
```python
|
|
97
|
+
import sys
|
|
98
|
+
import pathlib
|
|
99
|
+
sys.path.append(str(pathlib.Path(__file__).parent.parent))
|
|
100
|
+
import l0n0lc as lc
|
|
101
|
+
import math
|
|
102
|
+
import 测试可执行
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@lc.映射函数(math.ceil, ['<cmath>'])
|
|
106
|
+
def cpp_ceil(v):
|
|
107
|
+
return f'std::ceil({lc.转C字符串(v)});'
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@lc.映射函数(print, ['<iostream>'])
|
|
111
|
+
def cpp_cout(*args):
|
|
112
|
+
code = f'std::cout'
|
|
113
|
+
for arg in args:
|
|
114
|
+
code += f'<< {lc.转C字符串(arg)} << " "'
|
|
115
|
+
code += '<< std::endl;'
|
|
116
|
+
return code
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def py_cin(v):
|
|
120
|
+
pass
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@lc.映射函数(py_cin, ['<iostream>'])
|
|
124
|
+
def cpp_cin(v):
|
|
125
|
+
return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@lc.可直接调用
|
|
129
|
+
def test_direct_call():
|
|
130
|
+
return 123
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def test_other_fn(a: int, b: int) -> int:
|
|
134
|
+
return a - b
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@lc.即时编译()
|
|
138
|
+
def test编译的函数(a: int, b: int) -> int:
|
|
139
|
+
return a * b
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
@lc.映射类型('std::vector<int>', ['<vector>'])
|
|
143
|
+
class CppVectorInt:
|
|
144
|
+
def push_back(self, v):
|
|
145
|
+
pass
|
|
146
|
+
|
|
147
|
+
def size(self):
|
|
148
|
+
return 0
|
|
149
|
+
|
|
150
|
+
def __getitem__(self, key):
|
|
151
|
+
return 0
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@lc.映射类型('short')
|
|
155
|
+
class ShortInt:
|
|
156
|
+
def __init__(self, v) -> None:
|
|
157
|
+
pass
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
@lc.即时编译(总是重编=True)
|
|
161
|
+
def jit_all_ops(a: int, b: int) -> int:
|
|
162
|
+
# 常量与基础赋值
|
|
163
|
+
x = 42
|
|
164
|
+
y: int = a + b
|
|
165
|
+
z = 3.14
|
|
166
|
+
flag = True
|
|
167
|
+
nums = [1, 2, 3]
|
|
168
|
+
numsshorts = [ShortInt(1), ShortInt(2), ShortInt(3)]
|
|
169
|
+
tup = (4, 5)
|
|
170
|
+
mp = {1: 10, 2: 20}
|
|
171
|
+
mp2 = {ShortInt(1): 10, ShortInt(2): 20}
|
|
172
|
+
|
|
173
|
+
# 一元运算
|
|
174
|
+
pos = +(a + 1)
|
|
175
|
+
neg = -b
|
|
176
|
+
inv = ~a
|
|
177
|
+
not_flag = not flag
|
|
178
|
+
|
|
179
|
+
# 二元运算
|
|
180
|
+
add = a + b
|
|
181
|
+
sub = a - b
|
|
182
|
+
mul = a * b
|
|
183
|
+
div = a / (b if b != 0 else 1)
|
|
184
|
+
mod = a % (b if b != 0 else 1)
|
|
185
|
+
band = a & b
|
|
186
|
+
bor = a | b
|
|
187
|
+
bxor = a ^ b
|
|
188
|
+
lshift = a << 1
|
|
189
|
+
rshift = a >> 1
|
|
190
|
+
|
|
191
|
+
# 比较运算
|
|
192
|
+
cmp1 = a == b
|
|
193
|
+
cmp2 = a != b
|
|
194
|
+
cmp3 = a < b
|
|
195
|
+
cmp4 = a <= b
|
|
196
|
+
cmp5 = a > b
|
|
197
|
+
cmp6 = a >= b
|
|
198
|
+
|
|
199
|
+
# 逻辑运算与三元表达式
|
|
200
|
+
logic_and = cmp1 and cmp2
|
|
201
|
+
logic_or = cmp3 or cmp4
|
|
202
|
+
ternary = a if a > b else b
|
|
203
|
+
|
|
204
|
+
# if / else
|
|
205
|
+
if a > b:
|
|
206
|
+
y += 1
|
|
207
|
+
else:
|
|
208
|
+
y -= 1
|
|
209
|
+
|
|
210
|
+
# for 循环 range
|
|
211
|
+
for i in range(3):
|
|
212
|
+
y += i
|
|
213
|
+
|
|
214
|
+
# for 循环 列表
|
|
215
|
+
for v in nums:
|
|
216
|
+
y += v
|
|
217
|
+
if v == 2:
|
|
218
|
+
continue
|
|
219
|
+
if v == 3:
|
|
220
|
+
break
|
|
221
|
+
|
|
222
|
+
# while 循环
|
|
223
|
+
count = 0
|
|
224
|
+
while count < 2:
|
|
225
|
+
y += count
|
|
226
|
+
count += 1
|
|
227
|
+
|
|
228
|
+
# 增强赋值
|
|
229
|
+
y += 5
|
|
230
|
+
y -= 1
|
|
231
|
+
y *= 2
|
|
232
|
+
y //= 2
|
|
233
|
+
y %= 10
|
|
234
|
+
y &= 7
|
|
235
|
+
y |= 3
|
|
236
|
+
y ^= 1
|
|
237
|
+
y <<= 1
|
|
238
|
+
y >>= 1
|
|
239
|
+
|
|
240
|
+
# 下标访问
|
|
241
|
+
first_num = nums[0]
|
|
242
|
+
mp_val = mp[1]
|
|
243
|
+
y += first_num + mp_val
|
|
244
|
+
|
|
245
|
+
vector = CppVectorInt()
|
|
246
|
+
vector.push_back(count)
|
|
247
|
+
vector.push_back(y)
|
|
248
|
+
for i in range(vector.size()):
|
|
249
|
+
print('vector->', i, '=', vector[i])
|
|
250
|
+
return y
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
@lc.即时编译(总是重编=True)
|
|
254
|
+
def test_add(a: int, b: int) -> int:
|
|
255
|
+
if a > 1:
|
|
256
|
+
return (a + b) * 123123
|
|
257
|
+
for i in range(1, 10, 2):
|
|
258
|
+
a += i
|
|
259
|
+
for i in [1, 2, 3]:
|
|
260
|
+
a += i
|
|
261
|
+
a = math.ceil(12.5)
|
|
262
|
+
cc = {'a': 1, 'b': 2}
|
|
263
|
+
cc['c'] = 3
|
|
264
|
+
print('输出map:')
|
|
265
|
+
for ii in cc:
|
|
266
|
+
print(ii.first, ii.second) # type: ignore
|
|
267
|
+
aa = [1, 3, 2]
|
|
268
|
+
aa[0] = 134
|
|
269
|
+
print('输出list:')
|
|
270
|
+
for i in range(3):
|
|
271
|
+
print(i, aa[i])
|
|
272
|
+
print('Hello World', a, b)
|
|
273
|
+
print('test_other_fn', test_other_fn(a, b))
|
|
274
|
+
print('test编译的函数', test编译的函数(a, b))
|
|
275
|
+
|
|
276
|
+
print('测试所有操作:')
|
|
277
|
+
jit_all_ops(a, b)
|
|
278
|
+
|
|
279
|
+
v = 0
|
|
280
|
+
vv = True and (False or 1)
|
|
281
|
+
print('vv:', vv)
|
|
282
|
+
print('测试while:')
|
|
283
|
+
while vv:
|
|
284
|
+
py_cin(v)
|
|
285
|
+
if v > 100:
|
|
286
|
+
break
|
|
287
|
+
else:
|
|
288
|
+
print('输入的', v, '小于等于100')
|
|
289
|
+
return a + b + 1 + test_direct_call() + v
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
print('结果:', test_add(1, 3))
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## 5. 运行hello_world.py
|
|
297
|
+
```
|
|
298
|
+
uv run tests/hello_world.py
|
|
299
|
+
# 输入: b'1\n2\n100\n101\n'
|
|
300
|
+
```
|
|
301
|
+
```bash
|
|
302
|
+
l0n0lcoutput/测试可执行文件
|
|
303
|
+
参数1
|
|
304
|
+
参数2
|
|
305
|
+
Hello World
|
|
306
|
+
输出map:
|
|
307
|
+
c 3
|
|
308
|
+
b 2
|
|
309
|
+
a 1
|
|
310
|
+
输出list:
|
|
311
|
+
0 134
|
|
312
|
+
1 3
|
|
313
|
+
2 2
|
|
314
|
+
Hello World 13 3
|
|
315
|
+
test_other_fn 10
|
|
316
|
+
test编译的函数 39
|
|
317
|
+
测试所有操作:
|
|
318
|
+
vector-> 0 = 2
|
|
319
|
+
vector-> 1 = 13
|
|
320
|
+
vv: 1
|
|
321
|
+
测试while:
|
|
322
|
+
请输入>>>输入的 1 小于等于100
|
|
323
|
+
请输入>>>输入的 2 小于等于100
|
|
324
|
+
请输入>>>输入的 100 小于等于100
|
|
325
|
+
请输入>>>结果: 241
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## 6. 查看输出文件
|
|
330
|
+
```bash
|
|
331
|
+
ls -al ./l0n0lcoutput
|
|
332
|
+
总计 176
|
|
333
|
+
drwxrwxr-x 2 aaa aaa 4096 12月 6 11:04 .
|
|
334
|
+
drwxrwxrwx 11 aaa aaa 4096 12月 6 11:04 ..
|
|
335
|
+
-rw-rw-r-- 1 aaa aaa 284 12月 6 11:04 6c22a76f2f7be7ad_测试可执行.py_可执行_@99fdc30bb9450a9a.cpp
|
|
336
|
+
-rw-rw-r-- 1 aaa aaa 117 12月 6 11:04 6c22a76f2f7be7ad_测试可执行.py_可执行_@99fdc30bb9450a9a.h
|
|
337
|
+
-rwxrwxr-x 1 aaa aaa 16904 12月 6 11:04 测试可执行文件
|
|
338
|
+
-rw-rw-r-- 1 aaa aaa 1977 12月 6 11:04 a7f2bebe05e41294_hello_world.py_jit_all_ops_@0bebf1e25ec036ba.cpp
|
|
339
|
+
-rw-rw-r-- 1 aaa aaa 170 12月 6 11:04 a7f2bebe05e41294_hello_world.py_jit_all_ops_@0bebf1e25ec036ba.h
|
|
340
|
+
-rwxrwxr-x 1 aaa aaa 29528 12月 6 11:04 a7f2bebe05e41294_hello_world.py_jit_all_ops_@0bebf1e25ec036ba.so
|
|
341
|
+
-rw-rw-r-- 1 aaa aaa 195 12月 6 11:04 a7f2bebe05e41294_hello_world.py_test编译的函数_@bc18204b4a05c8a8.cpp
|
|
342
|
+
-rw-rw-r-- 1 aaa aaa 143 12月 6 11:04 a7f2bebe05e41294_hello_world.py_test编译的函数_@bc18204b4a05c8a8.h
|
|
343
|
+
-rwxrwxr-x 1 aaa aaa 15240 12月 6 11:04 a7f2bebe05e41294_hello_world.py_test编译的函数_@bc18204b4a05c8a8.so
|
|
344
|
+
-rw-rw-r-- 1 aaa aaa 1542 12月 6 11:04 a7f2bebe05e41294_hello_world.py_test_add_@ee9520a2002003b9.cpp
|
|
345
|
+
-rw-rw-r-- 1 aaa aaa 401 12月 6 11:04 a7f2bebe05e41294_hello_world.py_test_add_@ee9520a2002003b9.h
|
|
346
|
+
-rwxrwxr-x 1 aaa aaa 42280 12月 6 11:04 a7f2bebe05e41294_hello_world.py_test_add_@ee9520a2002003b9.so
|
|
347
|
+
-rw-rw-r-- 1 aaa aaa 155 12月 6 11:04 a7f2bebe05e41294_hello_world.py_test_other_fn_@75fdd928ab58a8e3.cpp
|
|
348
|
+
-rw-rw-r-- 1 aaa aaa 109 12月 6 11:04 a7f2bebe05e41294_hello_world.py_test_other_fn_@75fdd928ab58a8e3.h
|
|
349
|
+
-rwxrwxr-x 1 aaa aaa 15200 12月 6 11:04 a7f2bebe05e41294_hello_world.py_test_other_fn_@75fdd928ab58a8e3.so
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
## 6. 6c22a76f2f7be7ad_测试可执行.py_可执行_@99fdc30bb9450a9a.cpp
|
|
353
|
+
```c++
|
|
354
|
+
#include "6c22a76f2f7be7ad_测试可执行.py_可执行_@99fdc30bb9450a9a.h"
|
|
355
|
+
extern "C" int main (int argc, char** argv)
|
|
356
|
+
{
|
|
357
|
+
for (int64_t i = 0; i < argc; ++i)
|
|
358
|
+
{
|
|
359
|
+
std::cout<< argv[i] << " "<< std::endl;;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
std::cout<< u8"Hello World" << " "<< std::endl;;
|
|
363
|
+
return int(0);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
## 7. 6c22a76f2f7be7ad_测试可执行.py_可执行_@99fdc30bb9450a9a.h
|
|
368
|
+
```c++
|
|
369
|
+
#pragma once
|
|
370
|
+
#include <iostream>
|
|
371
|
+
#include <stdint.h>
|
|
372
|
+
#include <string.h>
|
|
373
|
+
extern "C" int main (int argc, char** argv);
|
|
374
|
+
```
|
|
375
|
+
## 8. a7f2bebe05e41294_hello_world.py_jit_all_ops_@0bebf1e25ec036ba.cpp
|
|
376
|
+
```c++
|
|
377
|
+
#include "a7f2bebe05e41294_hello_world.py_jit_all_ops_@0bebf1e25ec036ba.h"
|
|
378
|
+
extern "C" int64_t jit_all_ops (int64_t a, int64_t b)
|
|
379
|
+
{
|
|
380
|
+
auto x = 42;
|
|
381
|
+
auto y = ((int64_t)((a + b)));
|
|
382
|
+
auto z = 3.14;
|
|
383
|
+
auto flag = true;
|
|
384
|
+
std::vector<int64_t> nums = {1,2,3};
|
|
385
|
+
std::vector<short> numsshorts = {short(1),short(2),short(3)};
|
|
386
|
+
std::vector<int64_t> tup = {4,5};
|
|
387
|
+
std::unordered_map<int64_t, int64_t> mp = {{ 1, 10 },{ 2, 20 }};
|
|
388
|
+
std::unordered_map<short, int64_t> mp2 = {{ short(1), 10 },{ short(2), 20 }};
|
|
389
|
+
auto pos = (+(a + 1));
|
|
390
|
+
auto neg = (-b);
|
|
391
|
+
auto inv = (~a);
|
|
392
|
+
auto not_flag = (!flag);
|
|
393
|
+
auto add = (a + b);
|
|
394
|
+
auto sub = (a - b);
|
|
395
|
+
auto mul = (a * b);
|
|
396
|
+
auto div = (a / (((b != 0)) ? (b) : (1)));
|
|
397
|
+
auto mod = (a % (((b != 0)) ? (b) : (1)));
|
|
398
|
+
auto band = (a & b);
|
|
399
|
+
auto bor = (a | b);
|
|
400
|
+
auto bxor = (a ^ b);
|
|
401
|
+
auto lshift = (a << 1);
|
|
402
|
+
auto rshift = (a >> 1);
|
|
403
|
+
auto cmp1 = (a == b);
|
|
404
|
+
auto cmp2 = (a != b);
|
|
405
|
+
auto cmp3 = (a < b);
|
|
406
|
+
auto cmp4 = (a <= b);
|
|
407
|
+
auto cmp5 = (a > b);
|
|
408
|
+
auto cmp6 = (a >= b);
|
|
409
|
+
auto logic_and = (cmp1)&&(cmp2);
|
|
410
|
+
auto logic_or = (cmp3)||(cmp4);
|
|
411
|
+
auto ternary = (((a > b)) ? (a) : (b));
|
|
412
|
+
if ((a > b))
|
|
413
|
+
{
|
|
414
|
+
y = (y + 1);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
else
|
|
418
|
+
{
|
|
419
|
+
y = (y - 1);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
for (int64_t i = 0; i < 3; ++i)
|
|
423
|
+
{
|
|
424
|
+
y = (y + i);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
for (auto v : nums)
|
|
428
|
+
{
|
|
429
|
+
y = (y + v);
|
|
430
|
+
if ((v == 2))
|
|
431
|
+
{
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
if ((v == 3))
|
|
436
|
+
{
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
auto count = 0;
|
|
443
|
+
while ((count < 2))
|
|
444
|
+
{
|
|
445
|
+
y = (y + count);
|
|
446
|
+
count = (count + 1);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
y = (y + 5);
|
|
450
|
+
y = (y - 1);
|
|
451
|
+
y = (y * 2);
|
|
452
|
+
y = (y / 2);
|
|
453
|
+
y = (y % 10);
|
|
454
|
+
y = (y & 7);
|
|
455
|
+
y = (y | 3);
|
|
456
|
+
y = (y ^ 1);
|
|
457
|
+
y = (y << 1);
|
|
458
|
+
y = (y >> 1);
|
|
459
|
+
auto first_num = nums[0];
|
|
460
|
+
auto mp_val = mp[1];
|
|
461
|
+
y = (y + (first_num + mp_val));
|
|
462
|
+
auto vector = std::vector<int>();
|
|
463
|
+
vector.push_back(count);
|
|
464
|
+
vector.push_back(y);
|
|
465
|
+
for (int64_t i = 0; i < vector.size(); ++i)
|
|
466
|
+
{
|
|
467
|
+
std::cout<< u8"vector->" << " "<< i << " "<< u8"=" << " "<< vector[i] << " "<< std::endl;;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return y;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
```
|
|
474
|
+
## 9. a7f2bebe05e41294_hello_world.py_jit_all_ops_@0bebf1e25ec036ba.h
|
|
475
|
+
```c++
|
|
476
|
+
#pragma once
|
|
477
|
+
#include <iostream>
|
|
478
|
+
#include <stdint.h>
|
|
479
|
+
#include <string.h>
|
|
480
|
+
#include <unordered_map>
|
|
481
|
+
#include <vector>
|
|
482
|
+
extern "C" int64_t jit_all_ops (int64_t a, int64_t b);
|
|
483
|
+
```
|
|
484
|
+
## 10. a7f2bebe05e41294_hello_world.py_test_add_@ee9520a2002003b9.cpp
|
|
485
|
+
```c++
|
|
486
|
+
#include "a7f2bebe05e41294_hello_world.py_test_add_@ee9520a2002003b9.h"
|
|
487
|
+
extern "C" int64_t test_add (int64_t a, int64_t b)
|
|
488
|
+
{
|
|
489
|
+
if ((a > 1))
|
|
490
|
+
{
|
|
491
|
+
return ((a + b) * 123123);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
for (int64_t i = 1; i < 10; i += 2)
|
|
495
|
+
{
|
|
496
|
+
a = (a + i);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
for (auto i : {1,2,3})
|
|
500
|
+
{
|
|
501
|
+
a = (a + i);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
a = std::ceil(12.5);;
|
|
505
|
+
std::unordered_map<std::string, int64_t> cc = {{ u8"a", 1 },{ u8"b", 2 }};
|
|
506
|
+
cc[u8"c"] = 3;
|
|
507
|
+
std::cout<< u8"输出map:" << " "<< std::endl;;
|
|
508
|
+
for (auto ii : cc)
|
|
509
|
+
{
|
|
510
|
+
std::cout<< ii.first << " "<< ii.second << " "<< std::endl;;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
std::vector<int64_t> aa = {1,3,2};
|
|
514
|
+
aa[0] = 134;
|
|
515
|
+
std::cout<< u8"输出list:" << " "<< std::endl;;
|
|
516
|
+
for (int64_t i = 0; i < 3; ++i)
|
|
517
|
+
{
|
|
518
|
+
std::cout<< i << " "<< aa[i] << " "<< std::endl;;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;;
|
|
522
|
+
std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;;
|
|
523
|
+
std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;;
|
|
524
|
+
std::cout<< u8"测试所有操作:" << " "<< std::endl;;
|
|
525
|
+
jit_all_ops(a,b);
|
|
526
|
+
auto v = 0;
|
|
527
|
+
auto vv = (true)&&((false)||(1));
|
|
528
|
+
std::cout<< u8"vv:" << " "<< vv << " "<< std::endl;;
|
|
529
|
+
std::cout<< u8"测试while:" << " "<< std::endl;;
|
|
530
|
+
while (vv)
|
|
531
|
+
{
|
|
532
|
+
std::cout << u8"请输入>>>"; std::cin >> v;;
|
|
533
|
+
if ((v > 100))
|
|
534
|
+
{
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
else
|
|
539
|
+
{
|
|
540
|
+
std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return ((((a + b) + 1) + 123) + v);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
```
|
|
549
|
+
## 11. a7f2bebe05e41294_hello_world.py_test_add_@ee9520a2002003b9.h
|
|
550
|
+
```c++
|
|
551
|
+
#pragma once
|
|
552
|
+
#include "a7f2bebe05e41294_hello_world.py_jit_all_ops_@0bebf1e25ec036ba.h"
|
|
553
|
+
#include "a7f2bebe05e41294_hello_world.py_test_other_fn_@75fdd928ab58a8e3.h"
|
|
554
|
+
#include "a7f2bebe05e41294_hello_world.py_test编译的函数_@bc18204b4a05c8a8.h"
|
|
555
|
+
#include <cmath>
|
|
556
|
+
#include <iostream>
|
|
557
|
+
#include <stdint.h>
|
|
558
|
+
#include <string.h>
|
|
559
|
+
#include <unordered_map>
|
|
560
|
+
extern "C" int64_t test_add (int64_t a, int64_t b);
|
|
561
|
+
```
|
|
562
|
+
## 12. a7f2bebe05e41294_hello_world.py_test_other_fn_@75fdd928ab58a8e3.cpp
|
|
563
|
+
```c++
|
|
564
|
+
#include "a7f2bebe05e41294_hello_world.py_test_other_fn_@75fdd928ab58a8e3.h"
|
|
565
|
+
extern "C" int64_t test_other_fn (int64_t a, int64_t b)
|
|
566
|
+
{
|
|
567
|
+
return (a - b);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
```
|
|
571
|
+
## 13. a7f2bebe05e41294_hello_world.py_test_other_fn_@75fdd928ab58a8e3.h
|
|
572
|
+
```c++
|
|
573
|
+
#pragma once
|
|
574
|
+
#include <stdint.h>
|
|
575
|
+
#include <string.h>
|
|
576
|
+
extern "C" int64_t test_other_fn (int64_t a, int64_t b);
|
|
577
|
+
```
|
|
578
|
+
## 14. a7f2bebe05e41294_hello_world.py_test编译的函数_@bc18204b4a05c8a8.cpp
|
|
579
|
+
```c++
|
|
580
|
+
#include "a7f2bebe05e41294_hello_world.py_test编译的函数_@bc18204b4a05c8a8.h"
|
|
581
|
+
extern "C" int64_t function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
|
|
582
|
+
{
|
|
583
|
+
return (a * b);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
```
|
|
587
|
+
## 15. a7f2bebe05e41294_hello_world.py_test编译的函数_@bc18204b4a05c8a8.h
|
|
588
|
+
```c++
|
|
589
|
+
#pragma once
|
|
590
|
+
#include <stdint.h>
|
|
591
|
+
#include <string.h>
|
|
592
|
+
extern "C" int64_t function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
|
|
593
|
+
```
|