l0n0lc 0.8.0__tar.gz → 0.8.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.8.0 → l0n0lc-0.8.2}/PKG-INFO +86 -50
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/README.md +86 -50
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc.egg-info/PKG-INFO +86 -50
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/pyproject.toml +1 -1
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/LICENSE +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc/StdList.py +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc/StdMap.py +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc/__init__.py +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc/c/345/237/272/347/241/200/345/244/204/347/220/206.py" +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc/jit.py +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc//347/274/226/350/257/221.py" +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc//351/200/232/347/224/250.py" +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc.egg-info/SOURCES.txt +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc.egg-info/dependency_links.txt +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/l0n0lc.egg-info/top_level.txt +0 -0
- {l0n0lc-0.8.0 → l0n0lc-0.8.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: l0n0lc
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.2
|
4
4
|
Summary: 一个将python函数翻译为c++函数并运行的jit编译器
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
6
6
|
Requires-Python: >=3.10
|
@@ -8,13 +8,13 @@ Description-Content-Type: text/markdown
|
|
8
8
|
License-File: LICENSE
|
9
9
|
Dynamic: license-file
|
10
10
|
|
11
|
+
|
11
12
|
# 将python函数翻译为c++函数并运行
|
12
|
-
## 安装
|
13
|
+
## 1. 安装
|
13
14
|
```
|
14
15
|
pip install l0n0lc
|
15
16
|
```
|
16
|
-
|
17
|
-
## hello_world.py
|
17
|
+
## 2. hello_world.py
|
18
18
|
```python
|
19
19
|
import l0n0lc as lc
|
20
20
|
import math
|
@@ -34,6 +34,15 @@ def cpp_cout(*args):
|
|
34
34
|
return code
|
35
35
|
|
36
36
|
|
37
|
+
def py_cin(v):
|
38
|
+
pass
|
39
|
+
|
40
|
+
|
41
|
+
@lc.映射函数(py_cin, ['<iostream>'])
|
42
|
+
def cpp_cin(v):
|
43
|
+
return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
|
44
|
+
|
45
|
+
|
37
46
|
@lc.直接调用函数
|
38
47
|
def test_直接调用():
|
39
48
|
return 123
|
@@ -43,7 +52,7 @@ def test_other_fn(a: int, b: int) -> int:
|
|
43
52
|
return a - b
|
44
53
|
|
45
54
|
|
46
|
-
@lc.jit(
|
55
|
+
@lc.jit()
|
47
56
|
def test编译的函数(a: int, b: int) -> int:
|
48
57
|
return a * b
|
49
58
|
|
@@ -70,14 +79,26 @@ def test_add(a: int, b: int) -> int:
|
|
70
79
|
print('Hello World', a, b)
|
71
80
|
print('test_other_fn', test_other_fn(a, b))
|
72
81
|
print('test编译的函数', test编译的函数(a, b))
|
73
|
-
|
82
|
+
v = 0
|
83
|
+
while (1):
|
84
|
+
py_cin(v)
|
85
|
+
if v > 100:
|
86
|
+
break
|
87
|
+
else:
|
88
|
+
print('输入的', v, '小于等于100')
|
89
|
+
return a + b + 1 + test_直接调用() + v
|
74
90
|
|
75
91
|
|
76
92
|
print('结果:', test_add(1, 3))
|
93
|
+
|
94
|
+
```
|
95
|
+
|
96
|
+
## 3. 运行hello_world.py
|
97
|
+
```
|
98
|
+
uv run tests/hello_world.py
|
99
|
+
# 输入: b'1\n2\n100\n101\n'
|
77
100
|
```
|
78
|
-
## 执行hello_world.py
|
79
101
|
```bash
|
80
|
-
$ python hello_world.py
|
81
102
|
输出map:
|
82
103
|
c 3
|
83
104
|
a 1
|
@@ -89,41 +110,33 @@ b 2
|
|
89
110
|
Hello World 13 3
|
90
111
|
test_other_fn 10
|
91
112
|
test编译的函数 39
|
92
|
-
|
113
|
+
请输入>>>输入的 1 小于等于100
|
114
|
+
请输入>>>输入的 2 小于等于100
|
115
|
+
请输入>>>输入的 100 小于等于100
|
116
|
+
请输入>>>结果: 241
|
117
|
+
|
93
118
|
```
|
94
|
-
|
119
|
+
|
120
|
+
## 4. 查看输出文件
|
95
121
|
```bash
|
96
|
-
|
122
|
+
ls -al ./l0n0lcoutput
|
97
123
|
total 96
|
98
|
-
drwxr-xr-x 2 root root 4096 Sep 12
|
99
|
-
drwxrwxrwx 11 1000 1000 4096 Sep
|
100
|
-
-rw-r--r-- 1 root root
|
101
|
-
-rw-r--r-- 1 root root 246 Sep 12
|
102
|
-
-rwxr-xr-x 1 root root
|
103
|
-
-rw-r--r-- 1 root root 121 Sep 12
|
104
|
-
-rw-r--r-- 1 root root 93 Sep 12
|
105
|
-
-rwxr-xr-x 1 root root 15616 Sep 12
|
106
|
-
-rw-r--r-- 1 root root 185 Sep 12
|
107
|
-
-rw-r--r-- 1 root root 151 Sep 12
|
108
|
-
-rwxr-xr-x 1 root root 15656 Sep 12
|
109
|
-
```
|
110
|
-
|
111
|
-
## test_add_@6ddf6c9d797f5d1b.h
|
124
|
+
drwxr-xr-x 2 root root 4096 Sep 12 01:46 .
|
125
|
+
drwxrwxrwx 11 1000 1000 4096 Sep 12 01:46 ..
|
126
|
+
-rw-r--r-- 1 root root 1233 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.cpp
|
127
|
+
-rw-r--r-- 1 root root 246 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.h
|
128
|
+
-rwxr-xr-x 1 root root 29904 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.so
|
129
|
+
-rw-r--r-- 1 root root 121 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.cpp
|
130
|
+
-rw-r--r-- 1 root root 93 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.h
|
131
|
+
-rwxr-xr-x 1 root root 15616 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.so
|
132
|
+
-rw-r--r-- 1 root root 185 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.cpp
|
133
|
+
-rw-r--r-- 1 root root 151 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.h
|
134
|
+
-rwxr-xr-x 1 root root 15656 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.so
|
112
135
|
|
113
|
-
```c++
|
114
|
-
#include "test_other_fn_@75fdd928ab58a8e3.h"
|
115
|
-
#include "test编译的函数_@5f8bb0506cab8a49.h"
|
116
|
-
#include <cmath>
|
117
|
-
#include <cstdint>
|
118
|
-
#include <iostream>
|
119
|
-
#include <string>
|
120
|
-
#include <unordered_map>
|
121
|
-
extern "C" int64_t test_add (int64_t a, int64_t b);
|
122
136
|
```
|
123
|
-
|
124
|
-
## test_add_@6ddf6c9d797f5d1b.cpp
|
137
|
+
## 5. test_add_@3ecbfe0013e83ebc.cpp
|
125
138
|
```c++
|
126
|
-
#include "test_add_@
|
139
|
+
#include "test_add_@3ecbfe0013e83ebc.h"
|
127
140
|
extern "C" int64_t test_add (int64_t a, int64_t b)
|
128
141
|
{
|
129
142
|
if ((a > 1))
|
@@ -161,40 +174,63 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
|
|
161
174
|
std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
|
162
175
|
std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
|
163
176
|
std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
|
164
|
-
|
177
|
+
auto v = 0;
|
178
|
+
while (1)
|
179
|
+
{
|
180
|
+
std::cout << u8"请输入>>>"; std::cin >> v;
|
181
|
+
if ((v > 100))
|
182
|
+
{
|
183
|
+
break;
|
184
|
+
}
|
185
|
+
|
186
|
+
{
|
187
|
+
std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
|
188
|
+
}
|
189
|
+
|
190
|
+
}
|
191
|
+
|
192
|
+
return a + b + 1 + 123 + v;
|
165
193
|
}
|
166
194
|
|
167
195
|
```
|
168
|
-
|
169
|
-
## test_other_fn_@75fdd928ab58a8e3.h
|
196
|
+
## 6. test_add_@3ecbfe0013e83ebc.h
|
170
197
|
```c++
|
198
|
+
#include "test_other_fn_@75fdd928ab58a8e3.h"
|
199
|
+
#include "test编译的函数_@3bf4501e0408a243.h"
|
200
|
+
#include <cmath>
|
171
201
|
#include <cstdint>
|
202
|
+
#include <iostream>
|
172
203
|
#include <string>
|
173
|
-
|
204
|
+
#include <unordered_map>
|
205
|
+
extern "C" int64_t test_add (int64_t a, int64_t b);
|
174
206
|
```
|
175
|
-
|
176
|
-
## test_other_fn_@75fdd928ab58a8e3.cpp
|
207
|
+
## 7. test_other_fn_@75fdd928ab58a8e3.cpp
|
177
208
|
```c++
|
178
209
|
#include "test_other_fn_@75fdd928ab58a8e3.h"
|
179
210
|
extern "C" int64_t test_other_fn (int64_t a, int64_t b)
|
180
211
|
{
|
181
212
|
return a - b;
|
182
213
|
}
|
183
|
-
```
|
184
|
-
|
185
214
|
|
186
|
-
|
215
|
+
```
|
216
|
+
## 8. test_other_fn_@75fdd928ab58a8e3.h
|
187
217
|
```c++
|
188
218
|
#include <cstdint>
|
189
219
|
#include <string>
|
190
|
-
extern "C" int64_t
|
220
|
+
extern "C" int64_t test_other_fn (int64_t a, int64_t b);
|
191
221
|
```
|
192
|
-
|
193
|
-
## test编译的函数_@5f8bb0506cab8a49.cpp
|
222
|
+
## 9. test编译的函数_@3bf4501e0408a243.cpp
|
194
223
|
```c++
|
195
|
-
#include "test编译的函数_@
|
224
|
+
#include "test编译的函数_@3bf4501e0408a243.h"
|
196
225
|
extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
|
197
226
|
{
|
198
227
|
return a * b;
|
199
228
|
}
|
229
|
+
|
230
|
+
```
|
231
|
+
## 10. test编译的函数_@3bf4501e0408a243.h
|
232
|
+
```c++
|
233
|
+
#include <cstdint>
|
234
|
+
#include <string>
|
235
|
+
extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
|
200
236
|
```
|
@@ -1,10 +1,10 @@
|
|
1
|
+
|
1
2
|
# 将python函数翻译为c++函数并运行
|
2
|
-
## 安装
|
3
|
+
## 1. 安装
|
3
4
|
```
|
4
5
|
pip install l0n0lc
|
5
6
|
```
|
6
|
-
|
7
|
-
## hello_world.py
|
7
|
+
## 2. hello_world.py
|
8
8
|
```python
|
9
9
|
import l0n0lc as lc
|
10
10
|
import math
|
@@ -24,6 +24,15 @@ def cpp_cout(*args):
|
|
24
24
|
return code
|
25
25
|
|
26
26
|
|
27
|
+
def py_cin(v):
|
28
|
+
pass
|
29
|
+
|
30
|
+
|
31
|
+
@lc.映射函数(py_cin, ['<iostream>'])
|
32
|
+
def cpp_cin(v):
|
33
|
+
return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
|
34
|
+
|
35
|
+
|
27
36
|
@lc.直接调用函数
|
28
37
|
def test_直接调用():
|
29
38
|
return 123
|
@@ -33,7 +42,7 @@ def test_other_fn(a: int, b: int) -> int:
|
|
33
42
|
return a - b
|
34
43
|
|
35
44
|
|
36
|
-
@lc.jit(
|
45
|
+
@lc.jit()
|
37
46
|
def test编译的函数(a: int, b: int) -> int:
|
38
47
|
return a * b
|
39
48
|
|
@@ -60,14 +69,26 @@ def test_add(a: int, b: int) -> int:
|
|
60
69
|
print('Hello World', a, b)
|
61
70
|
print('test_other_fn', test_other_fn(a, b))
|
62
71
|
print('test编译的函数', test编译的函数(a, b))
|
63
|
-
|
72
|
+
v = 0
|
73
|
+
while (1):
|
74
|
+
py_cin(v)
|
75
|
+
if v > 100:
|
76
|
+
break
|
77
|
+
else:
|
78
|
+
print('输入的', v, '小于等于100')
|
79
|
+
return a + b + 1 + test_直接调用() + v
|
64
80
|
|
65
81
|
|
66
82
|
print('结果:', test_add(1, 3))
|
83
|
+
|
84
|
+
```
|
85
|
+
|
86
|
+
## 3. 运行hello_world.py
|
87
|
+
```
|
88
|
+
uv run tests/hello_world.py
|
89
|
+
# 输入: b'1\n2\n100\n101\n'
|
67
90
|
```
|
68
|
-
## 执行hello_world.py
|
69
91
|
```bash
|
70
|
-
$ python hello_world.py
|
71
92
|
输出map:
|
72
93
|
c 3
|
73
94
|
a 1
|
@@ -79,41 +100,33 @@ b 2
|
|
79
100
|
Hello World 13 3
|
80
101
|
test_other_fn 10
|
81
102
|
test编译的函数 39
|
82
|
-
|
103
|
+
请输入>>>输入的 1 小于等于100
|
104
|
+
请输入>>>输入的 2 小于等于100
|
105
|
+
请输入>>>输入的 100 小于等于100
|
106
|
+
请输入>>>结果: 241
|
107
|
+
|
83
108
|
```
|
84
|
-
|
109
|
+
|
110
|
+
## 4. 查看输出文件
|
85
111
|
```bash
|
86
|
-
|
112
|
+
ls -al ./l0n0lcoutput
|
87
113
|
total 96
|
88
|
-
drwxr-xr-x 2 root root 4096 Sep 12
|
89
|
-
drwxrwxrwx 11 1000 1000 4096 Sep
|
90
|
-
-rw-r--r-- 1 root root
|
91
|
-
-rw-r--r-- 1 root root 246 Sep 12
|
92
|
-
-rwxr-xr-x 1 root root
|
93
|
-
-rw-r--r-- 1 root root 121 Sep 12
|
94
|
-
-rw-r--r-- 1 root root 93 Sep 12
|
95
|
-
-rwxr-xr-x 1 root root 15616 Sep 12
|
96
|
-
-rw-r--r-- 1 root root 185 Sep 12
|
97
|
-
-rw-r--r-- 1 root root 151 Sep 12
|
98
|
-
-rwxr-xr-x 1 root root 15656 Sep 12
|
99
|
-
```
|
100
|
-
|
101
|
-
## test_add_@6ddf6c9d797f5d1b.h
|
114
|
+
drwxr-xr-x 2 root root 4096 Sep 12 01:46 .
|
115
|
+
drwxrwxrwx 11 1000 1000 4096 Sep 12 01:46 ..
|
116
|
+
-rw-r--r-- 1 root root 1233 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.cpp
|
117
|
+
-rw-r--r-- 1 root root 246 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.h
|
118
|
+
-rwxr-xr-x 1 root root 29904 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.so
|
119
|
+
-rw-r--r-- 1 root root 121 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.cpp
|
120
|
+
-rw-r--r-- 1 root root 93 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.h
|
121
|
+
-rwxr-xr-x 1 root root 15616 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.so
|
122
|
+
-rw-r--r-- 1 root root 185 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.cpp
|
123
|
+
-rw-r--r-- 1 root root 151 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.h
|
124
|
+
-rwxr-xr-x 1 root root 15656 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.so
|
102
125
|
|
103
|
-
```c++
|
104
|
-
#include "test_other_fn_@75fdd928ab58a8e3.h"
|
105
|
-
#include "test编译的函数_@5f8bb0506cab8a49.h"
|
106
|
-
#include <cmath>
|
107
|
-
#include <cstdint>
|
108
|
-
#include <iostream>
|
109
|
-
#include <string>
|
110
|
-
#include <unordered_map>
|
111
|
-
extern "C" int64_t test_add (int64_t a, int64_t b);
|
112
126
|
```
|
113
|
-
|
114
|
-
## test_add_@6ddf6c9d797f5d1b.cpp
|
127
|
+
## 5. test_add_@3ecbfe0013e83ebc.cpp
|
115
128
|
```c++
|
116
|
-
#include "test_add_@
|
129
|
+
#include "test_add_@3ecbfe0013e83ebc.h"
|
117
130
|
extern "C" int64_t test_add (int64_t a, int64_t b)
|
118
131
|
{
|
119
132
|
if ((a > 1))
|
@@ -151,40 +164,63 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
|
|
151
164
|
std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
|
152
165
|
std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
|
153
166
|
std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
|
154
|
-
|
167
|
+
auto v = 0;
|
168
|
+
while (1)
|
169
|
+
{
|
170
|
+
std::cout << u8"请输入>>>"; std::cin >> v;
|
171
|
+
if ((v > 100))
|
172
|
+
{
|
173
|
+
break;
|
174
|
+
}
|
175
|
+
|
176
|
+
{
|
177
|
+
std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
|
178
|
+
}
|
179
|
+
|
180
|
+
}
|
181
|
+
|
182
|
+
return a + b + 1 + 123 + v;
|
155
183
|
}
|
156
184
|
|
157
185
|
```
|
158
|
-
|
159
|
-
## test_other_fn_@75fdd928ab58a8e3.h
|
186
|
+
## 6. test_add_@3ecbfe0013e83ebc.h
|
160
187
|
```c++
|
188
|
+
#include "test_other_fn_@75fdd928ab58a8e3.h"
|
189
|
+
#include "test编译的函数_@3bf4501e0408a243.h"
|
190
|
+
#include <cmath>
|
161
191
|
#include <cstdint>
|
192
|
+
#include <iostream>
|
162
193
|
#include <string>
|
163
|
-
|
194
|
+
#include <unordered_map>
|
195
|
+
extern "C" int64_t test_add (int64_t a, int64_t b);
|
164
196
|
```
|
165
|
-
|
166
|
-
## test_other_fn_@75fdd928ab58a8e3.cpp
|
197
|
+
## 7. test_other_fn_@75fdd928ab58a8e3.cpp
|
167
198
|
```c++
|
168
199
|
#include "test_other_fn_@75fdd928ab58a8e3.h"
|
169
200
|
extern "C" int64_t test_other_fn (int64_t a, int64_t b)
|
170
201
|
{
|
171
202
|
return a - b;
|
172
203
|
}
|
173
|
-
```
|
174
204
|
|
175
|
-
|
176
|
-
##
|
205
|
+
```
|
206
|
+
## 8. test_other_fn_@75fdd928ab58a8e3.h
|
177
207
|
```c++
|
178
208
|
#include <cstdint>
|
179
209
|
#include <string>
|
180
|
-
extern "C" int64_t
|
210
|
+
extern "C" int64_t test_other_fn (int64_t a, int64_t b);
|
181
211
|
```
|
182
|
-
|
183
|
-
## test编译的函数_@5f8bb0506cab8a49.cpp
|
212
|
+
## 9. test编译的函数_@3bf4501e0408a243.cpp
|
184
213
|
```c++
|
185
|
-
#include "test编译的函数_@
|
214
|
+
#include "test编译的函数_@3bf4501e0408a243.h"
|
186
215
|
extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
|
187
216
|
{
|
188
217
|
return a * b;
|
189
218
|
}
|
190
|
-
|
219
|
+
|
220
|
+
```
|
221
|
+
## 10. test编译的函数_@3bf4501e0408a243.h
|
222
|
+
```c++
|
223
|
+
#include <cstdint>
|
224
|
+
#include <string>
|
225
|
+
extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
|
226
|
+
```
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: l0n0lc
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.2
|
4
4
|
Summary: 一个将python函数翻译为c++函数并运行的jit编译器
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
6
6
|
Requires-Python: >=3.10
|
@@ -8,13 +8,13 @@ Description-Content-Type: text/markdown
|
|
8
8
|
License-File: LICENSE
|
9
9
|
Dynamic: license-file
|
10
10
|
|
11
|
+
|
11
12
|
# 将python函数翻译为c++函数并运行
|
12
|
-
## 安装
|
13
|
+
## 1. 安装
|
13
14
|
```
|
14
15
|
pip install l0n0lc
|
15
16
|
```
|
16
|
-
|
17
|
-
## hello_world.py
|
17
|
+
## 2. hello_world.py
|
18
18
|
```python
|
19
19
|
import l0n0lc as lc
|
20
20
|
import math
|
@@ -34,6 +34,15 @@ def cpp_cout(*args):
|
|
34
34
|
return code
|
35
35
|
|
36
36
|
|
37
|
+
def py_cin(v):
|
38
|
+
pass
|
39
|
+
|
40
|
+
|
41
|
+
@lc.映射函数(py_cin, ['<iostream>'])
|
42
|
+
def cpp_cin(v):
|
43
|
+
return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
|
44
|
+
|
45
|
+
|
37
46
|
@lc.直接调用函数
|
38
47
|
def test_直接调用():
|
39
48
|
return 123
|
@@ -43,7 +52,7 @@ def test_other_fn(a: int, b: int) -> int:
|
|
43
52
|
return a - b
|
44
53
|
|
45
54
|
|
46
|
-
@lc.jit(
|
55
|
+
@lc.jit()
|
47
56
|
def test编译的函数(a: int, b: int) -> int:
|
48
57
|
return a * b
|
49
58
|
|
@@ -70,14 +79,26 @@ def test_add(a: int, b: int) -> int:
|
|
70
79
|
print('Hello World', a, b)
|
71
80
|
print('test_other_fn', test_other_fn(a, b))
|
72
81
|
print('test编译的函数', test编译的函数(a, b))
|
73
|
-
|
82
|
+
v = 0
|
83
|
+
while (1):
|
84
|
+
py_cin(v)
|
85
|
+
if v > 100:
|
86
|
+
break
|
87
|
+
else:
|
88
|
+
print('输入的', v, '小于等于100')
|
89
|
+
return a + b + 1 + test_直接调用() + v
|
74
90
|
|
75
91
|
|
76
92
|
print('结果:', test_add(1, 3))
|
93
|
+
|
94
|
+
```
|
95
|
+
|
96
|
+
## 3. 运行hello_world.py
|
97
|
+
```
|
98
|
+
uv run tests/hello_world.py
|
99
|
+
# 输入: b'1\n2\n100\n101\n'
|
77
100
|
```
|
78
|
-
## 执行hello_world.py
|
79
101
|
```bash
|
80
|
-
$ python hello_world.py
|
81
102
|
输出map:
|
82
103
|
c 3
|
83
104
|
a 1
|
@@ -89,41 +110,33 @@ b 2
|
|
89
110
|
Hello World 13 3
|
90
111
|
test_other_fn 10
|
91
112
|
test编译的函数 39
|
92
|
-
|
113
|
+
请输入>>>输入的 1 小于等于100
|
114
|
+
请输入>>>输入的 2 小于等于100
|
115
|
+
请输入>>>输入的 100 小于等于100
|
116
|
+
请输入>>>结果: 241
|
117
|
+
|
93
118
|
```
|
94
|
-
|
119
|
+
|
120
|
+
## 4. 查看输出文件
|
95
121
|
```bash
|
96
|
-
|
122
|
+
ls -al ./l0n0lcoutput
|
97
123
|
total 96
|
98
|
-
drwxr-xr-x 2 root root 4096 Sep 12
|
99
|
-
drwxrwxrwx 11 1000 1000 4096 Sep
|
100
|
-
-rw-r--r-- 1 root root
|
101
|
-
-rw-r--r-- 1 root root 246 Sep 12
|
102
|
-
-rwxr-xr-x 1 root root
|
103
|
-
-rw-r--r-- 1 root root 121 Sep 12
|
104
|
-
-rw-r--r-- 1 root root 93 Sep 12
|
105
|
-
-rwxr-xr-x 1 root root 15616 Sep 12
|
106
|
-
-rw-r--r-- 1 root root 185 Sep 12
|
107
|
-
-rw-r--r-- 1 root root 151 Sep 12
|
108
|
-
-rwxr-xr-x 1 root root 15656 Sep 12
|
109
|
-
```
|
110
|
-
|
111
|
-
## test_add_@6ddf6c9d797f5d1b.h
|
124
|
+
drwxr-xr-x 2 root root 4096 Sep 12 01:46 .
|
125
|
+
drwxrwxrwx 11 1000 1000 4096 Sep 12 01:46 ..
|
126
|
+
-rw-r--r-- 1 root root 1233 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.cpp
|
127
|
+
-rw-r--r-- 1 root root 246 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.h
|
128
|
+
-rwxr-xr-x 1 root root 29904 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.so
|
129
|
+
-rw-r--r-- 1 root root 121 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.cpp
|
130
|
+
-rw-r--r-- 1 root root 93 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.h
|
131
|
+
-rwxr-xr-x 1 root root 15616 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.so
|
132
|
+
-rw-r--r-- 1 root root 185 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.cpp
|
133
|
+
-rw-r--r-- 1 root root 151 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.h
|
134
|
+
-rwxr-xr-x 1 root root 15656 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.so
|
112
135
|
|
113
|
-
```c++
|
114
|
-
#include "test_other_fn_@75fdd928ab58a8e3.h"
|
115
|
-
#include "test编译的函数_@5f8bb0506cab8a49.h"
|
116
|
-
#include <cmath>
|
117
|
-
#include <cstdint>
|
118
|
-
#include <iostream>
|
119
|
-
#include <string>
|
120
|
-
#include <unordered_map>
|
121
|
-
extern "C" int64_t test_add (int64_t a, int64_t b);
|
122
136
|
```
|
123
|
-
|
124
|
-
## test_add_@6ddf6c9d797f5d1b.cpp
|
137
|
+
## 5. test_add_@3ecbfe0013e83ebc.cpp
|
125
138
|
```c++
|
126
|
-
#include "test_add_@
|
139
|
+
#include "test_add_@3ecbfe0013e83ebc.h"
|
127
140
|
extern "C" int64_t test_add (int64_t a, int64_t b)
|
128
141
|
{
|
129
142
|
if ((a > 1))
|
@@ -161,40 +174,63 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
|
|
161
174
|
std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
|
162
175
|
std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
|
163
176
|
std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
|
164
|
-
|
177
|
+
auto v = 0;
|
178
|
+
while (1)
|
179
|
+
{
|
180
|
+
std::cout << u8"请输入>>>"; std::cin >> v;
|
181
|
+
if ((v > 100))
|
182
|
+
{
|
183
|
+
break;
|
184
|
+
}
|
185
|
+
|
186
|
+
{
|
187
|
+
std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
|
188
|
+
}
|
189
|
+
|
190
|
+
}
|
191
|
+
|
192
|
+
return a + b + 1 + 123 + v;
|
165
193
|
}
|
166
194
|
|
167
195
|
```
|
168
|
-
|
169
|
-
## test_other_fn_@75fdd928ab58a8e3.h
|
196
|
+
## 6. test_add_@3ecbfe0013e83ebc.h
|
170
197
|
```c++
|
198
|
+
#include "test_other_fn_@75fdd928ab58a8e3.h"
|
199
|
+
#include "test编译的函数_@3bf4501e0408a243.h"
|
200
|
+
#include <cmath>
|
171
201
|
#include <cstdint>
|
202
|
+
#include <iostream>
|
172
203
|
#include <string>
|
173
|
-
|
204
|
+
#include <unordered_map>
|
205
|
+
extern "C" int64_t test_add (int64_t a, int64_t b);
|
174
206
|
```
|
175
|
-
|
176
|
-
## test_other_fn_@75fdd928ab58a8e3.cpp
|
207
|
+
## 7. test_other_fn_@75fdd928ab58a8e3.cpp
|
177
208
|
```c++
|
178
209
|
#include "test_other_fn_@75fdd928ab58a8e3.h"
|
179
210
|
extern "C" int64_t test_other_fn (int64_t a, int64_t b)
|
180
211
|
{
|
181
212
|
return a - b;
|
182
213
|
}
|
183
|
-
```
|
184
|
-
|
185
214
|
|
186
|
-
|
215
|
+
```
|
216
|
+
## 8. test_other_fn_@75fdd928ab58a8e3.h
|
187
217
|
```c++
|
188
218
|
#include <cstdint>
|
189
219
|
#include <string>
|
190
|
-
extern "C" int64_t
|
220
|
+
extern "C" int64_t test_other_fn (int64_t a, int64_t b);
|
191
221
|
```
|
192
|
-
|
193
|
-
## test编译的函数_@5f8bb0506cab8a49.cpp
|
222
|
+
## 9. test编译的函数_@3bf4501e0408a243.cpp
|
194
223
|
```c++
|
195
|
-
#include "test编译的函数_@
|
224
|
+
#include "test编译的函数_@3bf4501e0408a243.h"
|
196
225
|
extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
|
197
226
|
{
|
198
227
|
return a * b;
|
199
228
|
}
|
229
|
+
|
230
|
+
```
|
231
|
+
## 10. test编译的函数_@3bf4501e0408a243.h
|
232
|
+
```c++
|
233
|
+
#include <cstdint>
|
234
|
+
#include <string>
|
235
|
+
extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
|
200
236
|
```
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|