l0n0lc 0.7.6__tar.gz → 0.8.1__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.1/PKG-INFO ADDED
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: l0n0lc
3
+ Version: 0.8.1
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
+ ## 2. 运行hello_world.py
18
+ ```
19
+ uv run tests/hello_world.py
20
+ # 输入: b'1\n2\n100\n101\n'
21
+ ```
22
+ ```bash
23
+ 输出map:
24
+ c 3
25
+ a 1
26
+ b 2
27
+ 输出list:
28
+ 0 134
29
+ 1 3
30
+ 2 2
31
+ Hello World 13 3
32
+ test_other_fn 10
33
+ test编译的函数 39
34
+ 请输入>>>输入的 1 小于等于100
35
+ 请输入>>>输入的 2 小于等于100
36
+ 请输入>>>输入的 100 小于等于100
37
+ 请输入>>>结果: 241
38
+
39
+ ```
40
+
41
+ ## 3. 查看输出文件
42
+ ```bash
43
+ ls -al ./l0n0lcoutput
44
+ total 96
45
+ drwxr-xr-x 2 root root 4096 Sep 12 01:42 .
46
+ drwxrwxrwx 11 1000 1000 4096 Sep 12 01:14 ..
47
+ -rw-r--r-- 1 root root 1233 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.cpp
48
+ -rw-r--r-- 1 root root 246 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.h
49
+ -rwxr-xr-x 1 root root 29904 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.so
50
+ -rw-r--r-- 1 root root 121 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.cpp
51
+ -rw-r--r-- 1 root root 93 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.h
52
+ -rwxr-xr-x 1 root root 15616 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.so
53
+ -rw-r--r-- 1 root root 185 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.cpp
54
+ -rw-r--r-- 1 root root 151 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.h
55
+ -rwxr-xr-x 1 root root 15656 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.so
56
+
57
+ ```
58
+ ## 4. hello_world.py
59
+ ```python
60
+ import l0n0lc as lc
61
+ import math
62
+
63
+
64
+ @lc.映射函数(math.ceil, ['<cmath>'])
65
+ def cpp_ceil(v):
66
+ return f'std::ceil({lc.toCString(v)});'
67
+
68
+
69
+ @lc.映射函数(print, ['<iostream>'])
70
+ def cpp_cout(*args):
71
+ code = f'std::cout'
72
+ for arg in args:
73
+ code += f'<< {lc.toCString(arg)} << " "'
74
+ code += '<< std::endl;'
75
+ return code
76
+
77
+
78
+ def py_cin(v):
79
+ pass
80
+
81
+
82
+ @lc.映射函数(py_cin, ['<iostream>'])
83
+ def cpp_cin(v):
84
+ return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
85
+
86
+
87
+ @lc.直接调用函数
88
+ def test_直接调用():
89
+ return 123
90
+
91
+
92
+ def test_other_fn(a: int, b: int) -> int:
93
+ return a - b
94
+
95
+
96
+ @lc.jit()
97
+ def test编译的函数(a: int, b: int) -> int:
98
+ return a * b
99
+
100
+
101
+ @lc.jit(每次运行都重新编译=True)
102
+ def test_add(a: int, b: int) -> int:
103
+ if a > 1:
104
+ return a + b
105
+ for i in range(1, 10, 2):
106
+ a += i
107
+ for i in [1, 2, 3]:
108
+ a += i
109
+ a = math.ceil(12.5)
110
+ cc = {'a': 1, 'b': 2}
111
+ cc['c'] = 3
112
+ print('输出map:')
113
+ for ii in cc:
114
+ print(ii.first, ii.second) # type: ignore
115
+ aa = [1, 3, 2]
116
+ aa[0] = 134
117
+ print('输出list:')
118
+ for i in range(3):
119
+ print(i, aa[i])
120
+ print('Hello World', a, b)
121
+ print('test_other_fn', test_other_fn(a, b))
122
+ print('test编译的函数', test编译的函数(a, b))
123
+ v = 0
124
+ while (1):
125
+ py_cin(v)
126
+ if v > 100:
127
+ break
128
+ else:
129
+ print('输入的', v, '小于等于100')
130
+ return a + b + 1 + test_直接调用() + v
131
+
132
+
133
+ print('结果:', test_add(1, 3))
134
+
135
+ ```
136
+ ## 5. test_add_@3ecbfe0013e83ebc.cpp
137
+ ```c++
138
+ #include "test_add_@3ecbfe0013e83ebc.h"
139
+ extern "C" int64_t test_add (int64_t a, int64_t b)
140
+ {
141
+ if ((a > 1))
142
+ {
143
+ return a + b;
144
+ }
145
+
146
+ for (int64_t i = 1; i < 10; i += 2)
147
+ {
148
+ a = a + i;
149
+ }
150
+
151
+ for (auto i : {1,2,3})
152
+ {
153
+ a = a + i;
154
+ }
155
+
156
+ a = std::ceil(12.5);;
157
+ std::unordered_map<std::string, int64_t> cc = {{ u8"a", 1 },{ u8"b", 2 }};
158
+ cc[u8"c"] = 3;
159
+ std::cout<< u8"输出map:" << " "<< std::endl;
160
+ for (auto ii : cc)
161
+ {
162
+ std::cout<< ii.first << " "<< ii.second << " "<< std::endl;
163
+ }
164
+
165
+ int64_t aa[] = {1,3,2};
166
+ aa[0] = 134;
167
+ std::cout<< u8"输出list:" << " "<< std::endl;
168
+ for (int64_t i = 0; i < 3; ++i)
169
+ {
170
+ std::cout<< i << " "<< aa[i] << " "<< std::endl;
171
+ }
172
+
173
+ std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
174
+ std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
175
+ std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
176
+ auto v = 0;
177
+ while (1)
178
+ {
179
+ std::cout << u8"请输入>>>"; std::cin >> v;
180
+ if ((v > 100))
181
+ {
182
+ break;
183
+ }
184
+
185
+ {
186
+ std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
187
+ }
188
+
189
+ }
190
+
191
+ return a + b + 1 + 123 + v;
192
+ }
193
+
194
+ ```
195
+ ## 6. test_add_@3ecbfe0013e83ebc.h
196
+ ```c++
197
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
198
+ #include "test编译的函数_@3bf4501e0408a243.h"
199
+ #include <cmath>
200
+ #include <cstdint>
201
+ #include <iostream>
202
+ #include <string>
203
+ #include <unordered_map>
204
+ extern "C" int64_t test_add (int64_t a, int64_t b);
205
+ ```
206
+ ## 7. test_other_fn_@75fdd928ab58a8e3.cpp
207
+ ```c++
208
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
209
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b)
210
+ {
211
+ return a - b;
212
+ }
213
+
214
+ ```
215
+ ## 8. test_other_fn_@75fdd928ab58a8e3.h
216
+ ```c++
217
+ #include <cstdint>
218
+ #include <string>
219
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b);
220
+ ```
221
+ ## 9. test编译的函数_@3bf4501e0408a243.cpp
222
+ ```c++
223
+ #include "test编译的函数_@3bf4501e0408a243.h"
224
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
225
+ {
226
+ return a * b;
227
+ }
228
+
229
+ ```
230
+ ## 10. test编译的函数_@3bf4501e0408a243.h
231
+ ```c++
232
+ #include <cstdint>
233
+ #include <string>
234
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
235
+ ```
l0n0lc-0.8.1/README.md ADDED
@@ -0,0 +1,225 @@
1
+
2
+ # 将python函数翻译为c++函数并运行
3
+ ## 1. 安装
4
+ ```
5
+ pip install l0n0lc
6
+ ```
7
+ ## 2. 运行hello_world.py
8
+ ```
9
+ uv run tests/hello_world.py
10
+ # 输入: b'1\n2\n100\n101\n'
11
+ ```
12
+ ```bash
13
+ 输出map:
14
+ c 3
15
+ a 1
16
+ b 2
17
+ 输出list:
18
+ 0 134
19
+ 1 3
20
+ 2 2
21
+ Hello World 13 3
22
+ test_other_fn 10
23
+ test编译的函数 39
24
+ 请输入>>>输入的 1 小于等于100
25
+ 请输入>>>输入的 2 小于等于100
26
+ 请输入>>>输入的 100 小于等于100
27
+ 请输入>>>结果: 241
28
+
29
+ ```
30
+
31
+ ## 3. 查看输出文件
32
+ ```bash
33
+ ls -al ./l0n0lcoutput
34
+ total 96
35
+ drwxr-xr-x 2 root root 4096 Sep 12 01:42 .
36
+ drwxrwxrwx 11 1000 1000 4096 Sep 12 01:14 ..
37
+ -rw-r--r-- 1 root root 1233 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.cpp
38
+ -rw-r--r-- 1 root root 246 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.h
39
+ -rwxr-xr-x 1 root root 29904 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.so
40
+ -rw-r--r-- 1 root root 121 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.cpp
41
+ -rw-r--r-- 1 root root 93 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.h
42
+ -rwxr-xr-x 1 root root 15616 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.so
43
+ -rw-r--r-- 1 root root 185 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.cpp
44
+ -rw-r--r-- 1 root root 151 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.h
45
+ -rwxr-xr-x 1 root root 15656 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.so
46
+
47
+ ```
48
+ ## 4. hello_world.py
49
+ ```python
50
+ import l0n0lc as lc
51
+ import math
52
+
53
+
54
+ @lc.映射函数(math.ceil, ['<cmath>'])
55
+ def cpp_ceil(v):
56
+ return f'std::ceil({lc.toCString(v)});'
57
+
58
+
59
+ @lc.映射函数(print, ['<iostream>'])
60
+ def cpp_cout(*args):
61
+ code = f'std::cout'
62
+ for arg in args:
63
+ code += f'<< {lc.toCString(arg)} << " "'
64
+ code += '<< std::endl;'
65
+ return code
66
+
67
+
68
+ def py_cin(v):
69
+ pass
70
+
71
+
72
+ @lc.映射函数(py_cin, ['<iostream>'])
73
+ def cpp_cin(v):
74
+ return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
75
+
76
+
77
+ @lc.直接调用函数
78
+ def test_直接调用():
79
+ return 123
80
+
81
+
82
+ def test_other_fn(a: int, b: int) -> int:
83
+ return a - b
84
+
85
+
86
+ @lc.jit()
87
+ def test编译的函数(a: int, b: int) -> int:
88
+ return a * b
89
+
90
+
91
+ @lc.jit(每次运行都重新编译=True)
92
+ def test_add(a: int, b: int) -> int:
93
+ if a > 1:
94
+ return a + b
95
+ for i in range(1, 10, 2):
96
+ a += i
97
+ for i in [1, 2, 3]:
98
+ a += i
99
+ a = math.ceil(12.5)
100
+ cc = {'a': 1, 'b': 2}
101
+ cc['c'] = 3
102
+ print('输出map:')
103
+ for ii in cc:
104
+ print(ii.first, ii.second) # type: ignore
105
+ aa = [1, 3, 2]
106
+ aa[0] = 134
107
+ print('输出list:')
108
+ for i in range(3):
109
+ print(i, aa[i])
110
+ print('Hello World', a, b)
111
+ print('test_other_fn', test_other_fn(a, b))
112
+ print('test编译的函数', test编译的函数(a, b))
113
+ v = 0
114
+ while (1):
115
+ py_cin(v)
116
+ if v > 100:
117
+ break
118
+ else:
119
+ print('输入的', v, '小于等于100')
120
+ return a + b + 1 + test_直接调用() + v
121
+
122
+
123
+ print('结果:', test_add(1, 3))
124
+
125
+ ```
126
+ ## 5. test_add_@3ecbfe0013e83ebc.cpp
127
+ ```c++
128
+ #include "test_add_@3ecbfe0013e83ebc.h"
129
+ extern "C" int64_t test_add (int64_t a, int64_t b)
130
+ {
131
+ if ((a > 1))
132
+ {
133
+ return a + b;
134
+ }
135
+
136
+ for (int64_t i = 1; i < 10; i += 2)
137
+ {
138
+ a = a + i;
139
+ }
140
+
141
+ for (auto i : {1,2,3})
142
+ {
143
+ a = a + i;
144
+ }
145
+
146
+ a = std::ceil(12.5);;
147
+ std::unordered_map<std::string, int64_t> cc = {{ u8"a", 1 },{ u8"b", 2 }};
148
+ cc[u8"c"] = 3;
149
+ std::cout<< u8"输出map:" << " "<< std::endl;
150
+ for (auto ii : cc)
151
+ {
152
+ std::cout<< ii.first << " "<< ii.second << " "<< std::endl;
153
+ }
154
+
155
+ int64_t aa[] = {1,3,2};
156
+ aa[0] = 134;
157
+ std::cout<< u8"输出list:" << " "<< std::endl;
158
+ for (int64_t i = 0; i < 3; ++i)
159
+ {
160
+ std::cout<< i << " "<< aa[i] << " "<< std::endl;
161
+ }
162
+
163
+ std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
164
+ std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
165
+ std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
166
+ auto v = 0;
167
+ while (1)
168
+ {
169
+ std::cout << u8"请输入>>>"; std::cin >> v;
170
+ if ((v > 100))
171
+ {
172
+ break;
173
+ }
174
+
175
+ {
176
+ std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
177
+ }
178
+
179
+ }
180
+
181
+ return a + b + 1 + 123 + v;
182
+ }
183
+
184
+ ```
185
+ ## 6. test_add_@3ecbfe0013e83ebc.h
186
+ ```c++
187
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
188
+ #include "test编译的函数_@3bf4501e0408a243.h"
189
+ #include <cmath>
190
+ #include <cstdint>
191
+ #include <iostream>
192
+ #include <string>
193
+ #include <unordered_map>
194
+ extern "C" int64_t test_add (int64_t a, int64_t b);
195
+ ```
196
+ ## 7. test_other_fn_@75fdd928ab58a8e3.cpp
197
+ ```c++
198
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
199
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b)
200
+ {
201
+ return a - b;
202
+ }
203
+
204
+ ```
205
+ ## 8. test_other_fn_@75fdd928ab58a8e3.h
206
+ ```c++
207
+ #include <cstdint>
208
+ #include <string>
209
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b);
210
+ ```
211
+ ## 9. test编译的函数_@3bf4501e0408a243.cpp
212
+ ```c++
213
+ #include "test编译的函数_@3bf4501e0408a243.h"
214
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
215
+ {
216
+ return a * b;
217
+ }
218
+
219
+ ```
220
+ ## 10. test编译的函数_@3bf4501e0408a243.h
221
+ ```c++
222
+ #include <cstdint>
223
+ #include <string>
224
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
225
+ ```
@@ -62,9 +62,19 @@ class c获取属性:
62
62
  return f'{self.变量}.{self.属性}'
63
63
 
64
64
 
65
+ class c函数调用:
66
+ def __init__(self, 函数名, 参数字符串) -> None:
67
+ self.函数名 = 函数名
68
+ self.参数字符串 = 参数字符串
69
+
70
+ def __str__(self) -> str:
71
+ return f'{self.函数名}({self.参数字符串})'
72
+
73
+
65
74
  class py2cpp编译器(ast.NodeVisitor):
66
- def __init__(self, 被编译的函数: Callable) -> None:
75
+ def __init__(self, 被编译的函数: Callable, c编译器) -> None:
67
76
  self.被编译的函数 = 被编译的函数
77
+ self.c编译器: cpp编译器 = c编译器
68
78
  self.源代码 = inspect.getsource(被编译的函数)
69
79
  self.代码哈希值 = hashlib.blake2s(
70
80
  self.源代码.encode(), digest_size=8).hexdigest()
@@ -77,7 +87,7 @@ class py2cpp编译器(ast.NodeVisitor):
77
87
  self.参数不同c类型前置处理函数 = {}
78
88
  self.ascendc变量对应表: List[Dict[str, Any]] = [{}]
79
89
  self.当前上下文层级 = 0
80
- self.依赖函数 = []
90
+ self.依赖函数: List[py2cpp编译器] = []
81
91
  self.函数映射表 = {}
82
92
  self.代码序列 = []
83
93
  self.花括号 = 花括号(self)
@@ -98,6 +108,18 @@ class py2cpp编译器(ast.NodeVisitor):
98
108
  def 编译(self):
99
109
  语法树 = ast.parse(self.源代码)
100
110
  self.visit(语法树)
111
+ # 读取依赖函数
112
+ cpps = [f'{通用信息.工作文件夹地址}/{self.获取cpp文件名()}']
113
+ for b in self.依赖函数:
114
+ self.include目录.add(f'"{b.获取h文件名()}"')
115
+ cpps.append(f'{通用信息.工作文件夹地址}/{b.获取cpp文件名()}')
116
+
117
+ self.将代码保存到文件()
118
+ self.c编译器.include目录列表 = list(self.include目录)
119
+ self.c编译器.库目录列表 = list(self.库目录)
120
+ self.c编译器.链接库 = list(self.链接库列表)
121
+ 输出路径 = f'{通用信息.工作文件夹地址}/{self.获取库文件名()}'
122
+ self.c编译器.编译为动态库(cpps, 输出路径=输出路径)
101
123
 
102
124
  def 添加c代码(self, 代码: str):
103
125
  self.代码序列.append(c代码(代码, self.当前上下文层级))
@@ -288,19 +310,20 @@ class py2cpp编译器(ast.NodeVisitor):
288
310
  if not isinstance(fn, Callable):
289
311
  self.抛出代码异常(f'{ast.dump(node.func)} 没找到', node)
290
312
 
291
- 依赖函数编译器 = self.__class__(fn)
292
- 依赖函数编译器.编译()
293
-
294
- # 添加依赖
295
- self.依赖函数.append(依赖函数编译器)
296
-
297
- # 构建调用代码
298
313
  if len(node.keywords) > 0:
299
314
  self.代码异常抛出器('暂不支持 keywords 函数调用', node)
300
315
 
301
316
  参数列表 = [str(self.获取值(arg)) for arg in node.args]
302
317
  参数字符串 = ','.join(参数列表)
303
- return f'{fn.__name__}({参数字符串});'
318
+
319
+ if isinstance(fn, py2cpp编译器):
320
+ self.依赖函数.append(fn)
321
+ return c函数调用(fn.c函数名, 参数字符串)
322
+ else:
323
+ 依赖函数编译器 = self.__class__(fn, self.c编译器)
324
+ 依赖函数编译器.编译()
325
+ self.依赖函数.append(依赖函数编译器)
326
+ return c函数调用(fn.__name__, 参数字符串)
304
327
 
305
328
  def 获取Subscript(self, node: ast.Subscript):
306
329
  对象 = self.获取值(node.value)
@@ -454,7 +477,7 @@ class py2cpp编译器(ast.NodeVisitor):
454
477
 
455
478
  def visit_Call(self, node: ast.Call) -> Any:
456
479
  代码 = self.调用Call(node)
457
- self.添加c代码(代码)
480
+ self.添加c代码(str(代码))
458
481
 
459
482
  def _赋值(self, target, 值, node):
460
483
  目标 = self.获取值(target)
@@ -545,7 +568,8 @@ class py2cpp编译器(ast.NodeVisitor):
545
568
  fp.write(cpp代码)
546
569
 
547
570
  def 加载库(self):
548
- self.目标库 = ctypes.CDLL(f'{通用信息.工作文件夹地址}/{self.获取库文件名()}')
571
+ 库地址 = f'{通用信息.工作文件夹地址}/{self.获取库文件名()}'
572
+ self.目标库 = ctypes.CDLL(库地址)
549
573
  self.cpp函数 = self.目标库[self.c函数名]
550
574
  self.cpp函数.argtypes = self.ctypes类型
551
575
  self.cpp函数.restype = self.ctypes返回类型
@@ -554,24 +578,15 @@ class py2cpp编译器(ast.NodeVisitor):
554
578
  return self.cpp函数(*args)
555
579
 
556
580
 
557
- def jit(jit编译器=None, c编译器=None, 每次运行都重新编译: bool = False):
581
+ def jit(jit编译器类=None, cpp编译器类=None, 每次运行都重新编译: bool = False):
558
582
  def 编译函数(fn: Callable):
559
583
  # print(ast.dump(语法树, indent=' '))
560
- c语言函数编译器 = jit编译器(fn) if jit编译器 else py2cpp编译器(fn)
584
+ _c编译器类 = cpp编译器类 or cpp编译器
585
+ _jit编译器类 = jit编译器类 or py2cpp编译器
586
+ c语言函数编译器 = _jit编译器类(fn, _c编译器类())
561
587
  库文件名 = c语言函数编译器.获取库文件名()
562
- # 检测是否已存在
563
588
  if 每次运行都重新编译 or not os.path.exists(f'{通用信息.工作文件夹地址}/{库文件名}'):
564
589
  c语言函数编译器.编译()
565
- c语言函数编译器.将代码保存到文件()
566
- 编译器 = c编译器 or cpp编译器()
567
- 编译器.include目录列表 = list(c语言函数编译器.include目录)
568
- 编译器.库目录列表 = list(c语言函数编译器.库目录)
569
- 编译器.链接库 = list(c语言函数编译器.链接库列表)
570
- 编译器.编译为动态库(f'{通用信息.工作文件夹地址}/{c语言函数编译器.获取cpp文件名()}',
571
- f'{通用信息.工作文件夹地址}/{c语言函数编译器.获取库文件名()}')
572
590
  c语言函数编译器.加载库()
573
-
574
- def call(*args):
575
- return c语言函数编译器(*args)
576
- return call
591
+ return c语言函数编译器
577
592
  return 编译函数
@@ -37,18 +37,21 @@ class cpp编译器:
37
37
  return
38
38
  self.编译选项 += 选项
39
39
 
40
- def 编译文件(self, 文件路径: str, 输出路径: str):
40
+ def 编译文件(self, 文件路径: Union[List[str], str], 输出路径: str):
41
41
  编译指令 = [self.编译器]
42
42
  include指令 = [f'-I{目录}' for 目录 in self.include目录列表]
43
43
  库目录指令 = [f'-L{目录}' for 目录 in self.库目录列表]
44
44
  库链接指令 = [f'-l{库名}' for 库名 in self.链接库]
45
45
  编译指令 += include指令 + 库目录指令 + 库链接指令 + self.编译选项
46
- 编译指令.append(文件路径)
46
+ if isinstance(文件路径, list):
47
+ 编译指令 += 文件路径
48
+ else:
49
+ 编译指令.append(文件路径)
47
50
  编译指令.append('-o')
48
51
  编译指令.append(输出路径)
49
52
  subprocess.run(编译指令)
50
53
 
51
- def 编译为动态库(self, 文件路径: str, 输出路径: str):
54
+ def 编译为动态库(self, 文件路径: Union[List[str], str], 输出路径: str):
52
55
  self.添加编译选项('-fPIC')
53
56
  self.添加编译选项('--shared')
54
57
  self.添加编译选项('-O2')
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: l0n0lc
3
+ Version: 0.8.1
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
+ ## 2. 运行hello_world.py
18
+ ```
19
+ uv run tests/hello_world.py
20
+ # 输入: b'1\n2\n100\n101\n'
21
+ ```
22
+ ```bash
23
+ 输出map:
24
+ c 3
25
+ a 1
26
+ b 2
27
+ 输出list:
28
+ 0 134
29
+ 1 3
30
+ 2 2
31
+ Hello World 13 3
32
+ test_other_fn 10
33
+ test编译的函数 39
34
+ 请输入>>>输入的 1 小于等于100
35
+ 请输入>>>输入的 2 小于等于100
36
+ 请输入>>>输入的 100 小于等于100
37
+ 请输入>>>结果: 241
38
+
39
+ ```
40
+
41
+ ## 3. 查看输出文件
42
+ ```bash
43
+ ls -al ./l0n0lcoutput
44
+ total 96
45
+ drwxr-xr-x 2 root root 4096 Sep 12 01:42 .
46
+ drwxrwxrwx 11 1000 1000 4096 Sep 12 01:14 ..
47
+ -rw-r--r-- 1 root root 1233 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.cpp
48
+ -rw-r--r-- 1 root root 246 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.h
49
+ -rwxr-xr-x 1 root root 29904 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.so
50
+ -rw-r--r-- 1 root root 121 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.cpp
51
+ -rw-r--r-- 1 root root 93 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.h
52
+ -rwxr-xr-x 1 root root 15616 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.so
53
+ -rw-r--r-- 1 root root 185 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.cpp
54
+ -rw-r--r-- 1 root root 151 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.h
55
+ -rwxr-xr-x 1 root root 15656 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.so
56
+
57
+ ```
58
+ ## 4. hello_world.py
59
+ ```python
60
+ import l0n0lc as lc
61
+ import math
62
+
63
+
64
+ @lc.映射函数(math.ceil, ['<cmath>'])
65
+ def cpp_ceil(v):
66
+ return f'std::ceil({lc.toCString(v)});'
67
+
68
+
69
+ @lc.映射函数(print, ['<iostream>'])
70
+ def cpp_cout(*args):
71
+ code = f'std::cout'
72
+ for arg in args:
73
+ code += f'<< {lc.toCString(arg)} << " "'
74
+ code += '<< std::endl;'
75
+ return code
76
+
77
+
78
+ def py_cin(v):
79
+ pass
80
+
81
+
82
+ @lc.映射函数(py_cin, ['<iostream>'])
83
+ def cpp_cin(v):
84
+ return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
85
+
86
+
87
+ @lc.直接调用函数
88
+ def test_直接调用():
89
+ return 123
90
+
91
+
92
+ def test_other_fn(a: int, b: int) -> int:
93
+ return a - b
94
+
95
+
96
+ @lc.jit()
97
+ def test编译的函数(a: int, b: int) -> int:
98
+ return a * b
99
+
100
+
101
+ @lc.jit(每次运行都重新编译=True)
102
+ def test_add(a: int, b: int) -> int:
103
+ if a > 1:
104
+ return a + b
105
+ for i in range(1, 10, 2):
106
+ a += i
107
+ for i in [1, 2, 3]:
108
+ a += i
109
+ a = math.ceil(12.5)
110
+ cc = {'a': 1, 'b': 2}
111
+ cc['c'] = 3
112
+ print('输出map:')
113
+ for ii in cc:
114
+ print(ii.first, ii.second) # type: ignore
115
+ aa = [1, 3, 2]
116
+ aa[0] = 134
117
+ print('输出list:')
118
+ for i in range(3):
119
+ print(i, aa[i])
120
+ print('Hello World', a, b)
121
+ print('test_other_fn', test_other_fn(a, b))
122
+ print('test编译的函数', test编译的函数(a, b))
123
+ v = 0
124
+ while (1):
125
+ py_cin(v)
126
+ if v > 100:
127
+ break
128
+ else:
129
+ print('输入的', v, '小于等于100')
130
+ return a + b + 1 + test_直接调用() + v
131
+
132
+
133
+ print('结果:', test_add(1, 3))
134
+
135
+ ```
136
+ ## 5. test_add_@3ecbfe0013e83ebc.cpp
137
+ ```c++
138
+ #include "test_add_@3ecbfe0013e83ebc.h"
139
+ extern "C" int64_t test_add (int64_t a, int64_t b)
140
+ {
141
+ if ((a > 1))
142
+ {
143
+ return a + b;
144
+ }
145
+
146
+ for (int64_t i = 1; i < 10; i += 2)
147
+ {
148
+ a = a + i;
149
+ }
150
+
151
+ for (auto i : {1,2,3})
152
+ {
153
+ a = a + i;
154
+ }
155
+
156
+ a = std::ceil(12.5);;
157
+ std::unordered_map<std::string, int64_t> cc = {{ u8"a", 1 },{ u8"b", 2 }};
158
+ cc[u8"c"] = 3;
159
+ std::cout<< u8"输出map:" << " "<< std::endl;
160
+ for (auto ii : cc)
161
+ {
162
+ std::cout<< ii.first << " "<< ii.second << " "<< std::endl;
163
+ }
164
+
165
+ int64_t aa[] = {1,3,2};
166
+ aa[0] = 134;
167
+ std::cout<< u8"输出list:" << " "<< std::endl;
168
+ for (int64_t i = 0; i < 3; ++i)
169
+ {
170
+ std::cout<< i << " "<< aa[i] << " "<< std::endl;
171
+ }
172
+
173
+ std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
174
+ std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
175
+ std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
176
+ auto v = 0;
177
+ while (1)
178
+ {
179
+ std::cout << u8"请输入>>>"; std::cin >> v;
180
+ if ((v > 100))
181
+ {
182
+ break;
183
+ }
184
+
185
+ {
186
+ std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
187
+ }
188
+
189
+ }
190
+
191
+ return a + b + 1 + 123 + v;
192
+ }
193
+
194
+ ```
195
+ ## 6. test_add_@3ecbfe0013e83ebc.h
196
+ ```c++
197
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
198
+ #include "test编译的函数_@3bf4501e0408a243.h"
199
+ #include <cmath>
200
+ #include <cstdint>
201
+ #include <iostream>
202
+ #include <string>
203
+ #include <unordered_map>
204
+ extern "C" int64_t test_add (int64_t a, int64_t b);
205
+ ```
206
+ ## 7. test_other_fn_@75fdd928ab58a8e3.cpp
207
+ ```c++
208
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
209
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b)
210
+ {
211
+ return a - b;
212
+ }
213
+
214
+ ```
215
+ ## 8. test_other_fn_@75fdd928ab58a8e3.h
216
+ ```c++
217
+ #include <cstdint>
218
+ #include <string>
219
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b);
220
+ ```
221
+ ## 9. test编译的函数_@3bf4501e0408a243.cpp
222
+ ```c++
223
+ #include "test编译的函数_@3bf4501e0408a243.h"
224
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
225
+ {
226
+ return a * b;
227
+ }
228
+
229
+ ```
230
+ ## 10. test编译的函数_@3bf4501e0408a243.h
231
+ ```c++
232
+ #include <cstdint>
233
+ #include <string>
234
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
235
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "l0n0lc"
3
- version = "0.7.6"
3
+ version = "0.8.1"
4
4
  description = "一个将python函数翻译为c++函数并运行的jit编译器"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
l0n0lc-0.7.6/PKG-INFO DELETED
@@ -1,141 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: l0n0lc
3
- Version: 0.7.6
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
- # 将python函数翻译为c++函数并运行
12
- ## 安装
13
- ```
14
- pip install l0n0lc
15
- ```
16
-
17
- ## hello_world.py
18
- ```python
19
- import l0n0lc as lc
20
- import math
21
-
22
-
23
- @lc.映射函数(math.ceil, ['<cmath>'])
24
- def cpp_ceil(v):
25
- return f'std::ceil({lc.toCString(v)});'
26
-
27
-
28
- @lc.映射函数(print, ['<iostream>'])
29
- def cpp_cout(*args):
30
- code = f'std::cout'
31
- for arg in args:
32
- code += f'<< {lc.toCString(arg)} << " "'
33
- code += '<< std::endl;'
34
- return code
35
-
36
- @lc.直接调用函数
37
- def test_直接调用():
38
- return 123
39
-
40
- @lc.jit(每次运行都重新编译=True)
41
- def test_add(a: int, b: int) -> int:
42
- if a > 1:
43
- return a + b
44
- for i in range(1, 10, 2):
45
- a += i
46
- for i in [1, 2, 3]:
47
- a += i
48
- a = math.ceil(12.5)
49
- cc = {'a': 1, 'b': 2}
50
- cc['c'] = 3
51
- print('输出map:')
52
- for ii in cc:
53
- print(ii.first, ii.second) # type: ignore
54
- aa = [1, 3, 2]
55
- aa[0] = 134
56
- print('输出list:')
57
- for i in range(3):
58
- print(i, aa[i])
59
- print('Hello World', a, b)
60
- return a + b + 1 + test_直接调用()
61
-
62
- print('结果:', test_add(1, 3))
63
-
64
- ```
65
- ## 执行hello_world.py
66
- ```bash
67
- $ python hello_world.py
68
- 输出map:
69
- c 3
70
- a 1
71
- b 2
72
- 输出list:
73
- 0 134
74
- 1 3
75
- 2 2
76
- Hello World 13 3
77
- 结果: 140
78
- ```
79
- ## 查看生成的c++代码文件
80
- ```bash
81
- $ ls -al l0n0lcoutput/
82
- total 48
83
- drwxr-xr-x 2 root root 4096 Sep 11 02:32 .
84
- drwxrwxrwx 11 1000 1000 4096 Sep 11 02:32 ..
85
- -rw-r--r-- 1 root root 794 Sep 11 02:32 test_add_@0bfbc28de3631ddd.cpp
86
- -rw-r--r-- 1 root root 150 Sep 11 02:32 test_add_@0bfbc28de3631ddd.h
87
- -rwxr-xr-x 1 root root 29496 Sep 11 02:32 test_add_@0bfbc28de3631ddd.so
88
- ```
89
-
90
- ## test_add_@0bfbc28de3631ddd.h
91
-
92
- ```c++
93
- #include <cmath>
94
- #include <cstdint>
95
- #include <iostream>
96
- #include <string>
97
- #include <unordered_map>
98
- extern "C" int64_t test_add (int64_t a, int64_t b);
99
- ```
100
-
101
- ## test_add_@0bfbc28de3631ddd.cpp
102
- ```c++
103
- #include "test_add_@141921ba1aaa0352.h"
104
- extern "C" int64_t test_add (int64_t a, int64_t b)
105
- {
106
- if ((a > 1))
107
- {
108
- return a + b;
109
- }
110
-
111
- for (int64_t i = 1; i < 10; i += 2)
112
- {
113
- a = a + i;
114
- }
115
-
116
- for (auto i : {1,2,3})
117
- {
118
- a = a + i;
119
- }
120
-
121
- a = std::ceil(12.5);;
122
- std::unordered_map<std::string, int64_t> cc = {{ u8"a", 1 },{ u8"b", 2 }};
123
- cc[u8"c"] = 3;
124
- std::cout<< u8"输出map:" << " "<< std::endl;
125
- for (auto ii : cc)
126
- {
127
- std::cout<< ii.first << " "<< ii.second << " "<< std::endl;
128
- }
129
-
130
- int64_t aa[] = {1,3,2};
131
- aa[0] = 134;
132
- std::cout<< u8"输出list:" << " "<< std::endl;
133
- for (int64_t i = 0; i < 3; ++i)
134
- {
135
- std::cout<< i << " "<< aa[i] << " "<< std::endl;
136
- }
137
-
138
- std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
139
- return a + b + 1;
140
- }
141
- ```
l0n0lc-0.7.6/README.md DELETED
@@ -1,131 +0,0 @@
1
- # 将python函数翻译为c++函数并运行
2
- ## 安装
3
- ```
4
- pip install l0n0lc
5
- ```
6
-
7
- ## hello_world.py
8
- ```python
9
- import l0n0lc as lc
10
- import math
11
-
12
-
13
- @lc.映射函数(math.ceil, ['<cmath>'])
14
- def cpp_ceil(v):
15
- return f'std::ceil({lc.toCString(v)});'
16
-
17
-
18
- @lc.映射函数(print, ['<iostream>'])
19
- def cpp_cout(*args):
20
- code = f'std::cout'
21
- for arg in args:
22
- code += f'<< {lc.toCString(arg)} << " "'
23
- code += '<< std::endl;'
24
- return code
25
-
26
- @lc.直接调用函数
27
- def test_直接调用():
28
- return 123
29
-
30
- @lc.jit(每次运行都重新编译=True)
31
- def test_add(a: int, b: int) -> int:
32
- if a > 1:
33
- return a + b
34
- for i in range(1, 10, 2):
35
- a += i
36
- for i in [1, 2, 3]:
37
- a += i
38
- a = math.ceil(12.5)
39
- cc = {'a': 1, 'b': 2}
40
- cc['c'] = 3
41
- print('输出map:')
42
- for ii in cc:
43
- print(ii.first, ii.second) # type: ignore
44
- aa = [1, 3, 2]
45
- aa[0] = 134
46
- print('输出list:')
47
- for i in range(3):
48
- print(i, aa[i])
49
- print('Hello World', a, b)
50
- return a + b + 1 + test_直接调用()
51
-
52
- print('结果:', test_add(1, 3))
53
-
54
- ```
55
- ## 执行hello_world.py
56
- ```bash
57
- $ python hello_world.py
58
- 输出map:
59
- c 3
60
- a 1
61
- b 2
62
- 输出list:
63
- 0 134
64
- 1 3
65
- 2 2
66
- Hello World 13 3
67
- 结果: 140
68
- ```
69
- ## 查看生成的c++代码文件
70
- ```bash
71
- $ ls -al l0n0lcoutput/
72
- total 48
73
- drwxr-xr-x 2 root root 4096 Sep 11 02:32 .
74
- drwxrwxrwx 11 1000 1000 4096 Sep 11 02:32 ..
75
- -rw-r--r-- 1 root root 794 Sep 11 02:32 test_add_@0bfbc28de3631ddd.cpp
76
- -rw-r--r-- 1 root root 150 Sep 11 02:32 test_add_@0bfbc28de3631ddd.h
77
- -rwxr-xr-x 1 root root 29496 Sep 11 02:32 test_add_@0bfbc28de3631ddd.so
78
- ```
79
-
80
- ## test_add_@0bfbc28de3631ddd.h
81
-
82
- ```c++
83
- #include <cmath>
84
- #include <cstdint>
85
- #include <iostream>
86
- #include <string>
87
- #include <unordered_map>
88
- extern "C" int64_t test_add (int64_t a, int64_t b);
89
- ```
90
-
91
- ## test_add_@0bfbc28de3631ddd.cpp
92
- ```c++
93
- #include "test_add_@141921ba1aaa0352.h"
94
- extern "C" int64_t test_add (int64_t a, int64_t b)
95
- {
96
- if ((a > 1))
97
- {
98
- return a + b;
99
- }
100
-
101
- for (int64_t i = 1; i < 10; i += 2)
102
- {
103
- a = a + i;
104
- }
105
-
106
- for (auto i : {1,2,3})
107
- {
108
- a = a + i;
109
- }
110
-
111
- a = std::ceil(12.5);;
112
- std::unordered_map<std::string, int64_t> cc = {{ u8"a", 1 },{ u8"b", 2 }};
113
- cc[u8"c"] = 3;
114
- std::cout<< u8"输出map:" << " "<< std::endl;
115
- for (auto ii : cc)
116
- {
117
- std::cout<< ii.first << " "<< ii.second << " "<< std::endl;
118
- }
119
-
120
- int64_t aa[] = {1,3,2};
121
- aa[0] = 134;
122
- std::cout<< u8"输出list:" << " "<< std::endl;
123
- for (int64_t i = 0; i < 3; ++i)
124
- {
125
- std::cout<< i << " "<< aa[i] << " "<< std::endl;
126
- }
127
-
128
- std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
129
- return a + b + 1;
130
- }
131
- ```
@@ -1,141 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: l0n0lc
3
- Version: 0.7.6
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
- # 将python函数翻译为c++函数并运行
12
- ## 安装
13
- ```
14
- pip install l0n0lc
15
- ```
16
-
17
- ## hello_world.py
18
- ```python
19
- import l0n0lc as lc
20
- import math
21
-
22
-
23
- @lc.映射函数(math.ceil, ['<cmath>'])
24
- def cpp_ceil(v):
25
- return f'std::ceil({lc.toCString(v)});'
26
-
27
-
28
- @lc.映射函数(print, ['<iostream>'])
29
- def cpp_cout(*args):
30
- code = f'std::cout'
31
- for arg in args:
32
- code += f'<< {lc.toCString(arg)} << " "'
33
- code += '<< std::endl;'
34
- return code
35
-
36
- @lc.直接调用函数
37
- def test_直接调用():
38
- return 123
39
-
40
- @lc.jit(每次运行都重新编译=True)
41
- def test_add(a: int, b: int) -> int:
42
- if a > 1:
43
- return a + b
44
- for i in range(1, 10, 2):
45
- a += i
46
- for i in [1, 2, 3]:
47
- a += i
48
- a = math.ceil(12.5)
49
- cc = {'a': 1, 'b': 2}
50
- cc['c'] = 3
51
- print('输出map:')
52
- for ii in cc:
53
- print(ii.first, ii.second) # type: ignore
54
- aa = [1, 3, 2]
55
- aa[0] = 134
56
- print('输出list:')
57
- for i in range(3):
58
- print(i, aa[i])
59
- print('Hello World', a, b)
60
- return a + b + 1 + test_直接调用()
61
-
62
- print('结果:', test_add(1, 3))
63
-
64
- ```
65
- ## 执行hello_world.py
66
- ```bash
67
- $ python hello_world.py
68
- 输出map:
69
- c 3
70
- a 1
71
- b 2
72
- 输出list:
73
- 0 134
74
- 1 3
75
- 2 2
76
- Hello World 13 3
77
- 结果: 140
78
- ```
79
- ## 查看生成的c++代码文件
80
- ```bash
81
- $ ls -al l0n0lcoutput/
82
- total 48
83
- drwxr-xr-x 2 root root 4096 Sep 11 02:32 .
84
- drwxrwxrwx 11 1000 1000 4096 Sep 11 02:32 ..
85
- -rw-r--r-- 1 root root 794 Sep 11 02:32 test_add_@0bfbc28de3631ddd.cpp
86
- -rw-r--r-- 1 root root 150 Sep 11 02:32 test_add_@0bfbc28de3631ddd.h
87
- -rwxr-xr-x 1 root root 29496 Sep 11 02:32 test_add_@0bfbc28de3631ddd.so
88
- ```
89
-
90
- ## test_add_@0bfbc28de3631ddd.h
91
-
92
- ```c++
93
- #include <cmath>
94
- #include <cstdint>
95
- #include <iostream>
96
- #include <string>
97
- #include <unordered_map>
98
- extern "C" int64_t test_add (int64_t a, int64_t b);
99
- ```
100
-
101
- ## test_add_@0bfbc28de3631ddd.cpp
102
- ```c++
103
- #include "test_add_@141921ba1aaa0352.h"
104
- extern "C" int64_t test_add (int64_t a, int64_t b)
105
- {
106
- if ((a > 1))
107
- {
108
- return a + b;
109
- }
110
-
111
- for (int64_t i = 1; i < 10; i += 2)
112
- {
113
- a = a + i;
114
- }
115
-
116
- for (auto i : {1,2,3})
117
- {
118
- a = a + i;
119
- }
120
-
121
- a = std::ceil(12.5);;
122
- std::unordered_map<std::string, int64_t> cc = {{ u8"a", 1 },{ u8"b", 2 }};
123
- cc[u8"c"] = 3;
124
- std::cout<< u8"输出map:" << " "<< std::endl;
125
- for (auto ii : cc)
126
- {
127
- std::cout<< ii.first << " "<< ii.second << " "<< std::endl;
128
- }
129
-
130
- int64_t aa[] = {1,3,2};
131
- aa[0] = 134;
132
- std::cout<< u8"输出list:" << " "<< std::endl;
133
- for (int64_t i = 0; i < 3; ++i)
134
- {
135
- std::cout<< i << " "<< aa[i] << " "<< std::endl;
136
- }
137
-
138
- std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
139
- return a + b + 1;
140
- }
141
- ```
File without changes
File without changes
File without changes
File without changes
File without changes