jaclang 0.7.14__py3-none-any.whl → 0.7.16__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.

Potentially problematic release.


This version of jaclang might be problematic. Click here for more details.

Files changed (92) hide show
  1. jaclang/cli/cli.py +15 -10
  2. jaclang/cli/cmdreg.py +9 -12
  3. jaclang/compiler/__init__.py +19 -53
  4. jaclang/compiler/absyntree.py +86 -13
  5. jaclang/compiler/jac.lark +4 -3
  6. jaclang/compiler/parser.py +31 -23
  7. jaclang/compiler/passes/ir_pass.py +4 -13
  8. jaclang/compiler/passes/main/access_modifier_pass.py +1 -1
  9. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +4 -5
  10. jaclang/compiler/passes/main/import_pass.py +18 -23
  11. jaclang/compiler/passes/main/pyast_gen_pass.py +307 -559
  12. jaclang/compiler/passes/main/pyast_load_pass.py +32 -6
  13. jaclang/compiler/passes/main/registry_pass.py +37 -3
  14. jaclang/compiler/passes/main/sym_tab_build_pass.py +1 -1
  15. jaclang/compiler/passes/main/tests/__init__.py +1 -1
  16. jaclang/compiler/passes/main/type_check_pass.py +7 -0
  17. jaclang/compiler/passes/tool/jac_formatter_pass.py +124 -86
  18. jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +0 -1
  19. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/architype_test.jac +13 -0
  20. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/comment_alignment.jac +11 -0
  21. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/comments.jac +13 -0
  22. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/decorator_stack.jac +37 -0
  23. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/esc_keywords.jac +5 -0
  24. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/long_names.jac +19 -0
  25. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/triple_quoted_string.jac +6 -0
  26. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +11 -0
  27. jaclang/compiler/passes/tool/tests/test_unparse_validate.py +33 -39
  28. jaclang/compiler/passes/transform.py +4 -0
  29. jaclang/compiler/semtable.py +31 -7
  30. jaclang/compiler/tests/test_importer.py +12 -5
  31. jaclang/langserve/engine.py +65 -118
  32. jaclang/langserve/sem_manager.py +379 -0
  33. jaclang/langserve/server.py +8 -10
  34. jaclang/langserve/tests/fixtures/base_module_structure.jac +27 -6
  35. jaclang/langserve/tests/fixtures/circle.jac +3 -3
  36. jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
  37. jaclang/langserve/tests/fixtures/circle_pure.test.jac +3 -3
  38. jaclang/langserve/tests/fixtures/import_include_statements.jac +1 -1
  39. jaclang/langserve/tests/test_sem_tokens.py +277 -0
  40. jaclang/langserve/tests/test_server.py +72 -16
  41. jaclang/langserve/utils.py +163 -96
  42. jaclang/plugin/builtin.py +1 -1
  43. jaclang/plugin/default.py +212 -24
  44. jaclang/plugin/feature.py +59 -11
  45. jaclang/plugin/spec.py +58 -6
  46. jaclang/{core → runtimelib}/architype.py +1 -1
  47. jaclang/{core → runtimelib}/context.py +8 -1
  48. jaclang/runtimelib/importer.py +361 -0
  49. jaclang/runtimelib/machine.py +94 -0
  50. jaclang/{core → runtimelib}/utils.py +13 -5
  51. jaclang/settings.py +4 -1
  52. jaclang/tests/fixtures/abc.jac +3 -3
  53. jaclang/tests/fixtures/byllmissue.jac +1 -5
  54. jaclang/tests/fixtures/chandra_bugs2.jac +11 -10
  55. jaclang/tests/fixtures/cls_method.jac +41 -0
  56. jaclang/tests/fixtures/dblhello.jac +6 -0
  57. jaclang/tests/fixtures/deep/one_lev.jac +3 -3
  58. jaclang/tests/fixtures/deep/one_lev_dup.jac +2 -3
  59. jaclang/tests/fixtures/deep_import_mods.jac +13 -0
  60. jaclang/tests/fixtures/err.impl.jac +3 -0
  61. jaclang/tests/fixtures/err.jac +4 -2
  62. jaclang/tests/fixtures/err.test.jac +3 -0
  63. jaclang/tests/fixtures/err_runtime.jac +15 -0
  64. jaclang/tests/fixtures/game1.jac +1 -1
  65. jaclang/tests/fixtures/hello.jac +4 -0
  66. jaclang/tests/fixtures/impl_grab.impl.jac +2 -1
  67. jaclang/tests/fixtures/impl_grab.jac +4 -1
  68. jaclang/tests/fixtures/jp_importer_auto.jac +14 -0
  69. jaclang/tests/fixtures/maxfail_run_test.jac +4 -4
  70. jaclang/tests/fixtures/needs_import.jac +2 -2
  71. jaclang/tests/fixtures/pyfunc_2.py +3 -0
  72. jaclang/tests/fixtures/registry.jac +9 -0
  73. jaclang/tests/fixtures/run_test.jac +4 -4
  74. jaclang/tests/fixtures/semstr.jac +1 -4
  75. jaclang/tests/fixtures/simple_archs.jac +1 -1
  76. jaclang/tests/test_cli.py +65 -2
  77. jaclang/tests/test_language.py +74 -7
  78. jaclang/tests/test_reference.py +6 -0
  79. jaclang/utils/helpers.py +45 -21
  80. jaclang/utils/test.py +9 -0
  81. jaclang/utils/treeprinter.py +0 -4
  82. {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/METADATA +3 -2
  83. {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/RECORD +89 -74
  84. jaclang/core/importer.py +0 -344
  85. jaclang/tests/fixtures/aott_raise.jac +0 -25
  86. jaclang/tests/fixtures/package_import.jac +0 -6
  87. /jaclang/{core → runtimelib}/__init__.py +0 -0
  88. /jaclang/{core → runtimelib}/constructs.py +0 -0
  89. /jaclang/{core → runtimelib}/memory.py +0 -0
  90. /jaclang/{core → runtimelib}/test.py +0 -0
  91. {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/WHEEL +0 -0
  92. {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,379 @@
1
+ """Semantic Token Manager module."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import List, Optional, Tuple
6
+
7
+ import jaclang.compiler.absyntree as ast
8
+ from jaclang.langserve.utils import (
9
+ find_surrounding_tokens,
10
+ get_line_of_code,
11
+ get_token_start,
12
+ )
13
+
14
+ import lsprotocol.types as lspt
15
+
16
+
17
+ class SemTokManager:
18
+ """Semantic Token Manager class."""
19
+
20
+ def __init__(self, ir: ast.Module) -> None:
21
+ """Initialize semantic token manager."""
22
+ self.sem_tokens: List[int] = self.gen_sem_tokens(ir)
23
+ self.static_sem_tokens: List[
24
+ Tuple[lspt.Position, int, int, ast.AstSymbolNode]
25
+ ] = self.gen_sem_tok_node(ir)
26
+
27
+ def gen_sem_tokens(self, ir: ast.Module) -> list[int]:
28
+ """Return semantic tokens."""
29
+ tokens = []
30
+ prev_line, prev_col = 0, 0
31
+ for node in ir._in_mod_nodes:
32
+ if isinstance(node, ast.NameAtom) and node.sem_token:
33
+ line, col_start, col_end = (
34
+ node.loc.first_line - 1,
35
+ node.loc.col_start - 1,
36
+ node.loc.col_end - 1,
37
+ )
38
+ length = col_end - col_start
39
+ tokens += [
40
+ line - prev_line,
41
+ col_start if line != prev_line else col_start - prev_col,
42
+ length,
43
+ *node.sem_token,
44
+ ]
45
+ prev_line, prev_col = line, col_start
46
+ return tokens
47
+
48
+ def gen_sem_tok_node(
49
+ self, ir: ast.Module
50
+ ) -> List[Tuple[lspt.Position, int, int, ast.AstSymbolNode]]:
51
+ """Return semantic tokens."""
52
+ tokens: List[Tuple[lspt.Position, int, int, ast.AstSymbolNode]] = []
53
+ for node in ir._in_mod_nodes:
54
+ if isinstance(node, ast.NameAtom) and node.sem_token:
55
+ line, col_start, col_end = (
56
+ node.loc.first_line - 1,
57
+ node.loc.col_start - 1,
58
+ node.loc.col_end - 1,
59
+ )
60
+ length = col_end - col_start
61
+ pos = lspt.Position(line, col_start)
62
+ tokens += [(pos, col_end, length, node)]
63
+ return tokens
64
+
65
+ def update_sem_tokens(
66
+ self,
67
+ content_changes: lspt.DidChangeTextDocumentParams,
68
+ sem_tokens: list[int],
69
+ document_lines: List[str],
70
+ ) -> list[int]:
71
+ """Update semantic tokens on change."""
72
+ for change in [
73
+ x
74
+ for x in content_changes.content_changes
75
+ if isinstance(x, lspt.TextDocumentContentChangeEvent_Type1)
76
+ ]:
77
+ change_start_line = change.range.start.line
78
+ change_start_char = change.range.start.character
79
+ change_end_line = change.range.end.line
80
+ change_end_char = change.range.end.character
81
+
82
+ is_delete = change.text == ""
83
+ prev_token_index, next_token_index, insert_inside_token = (
84
+ find_surrounding_tokens(
85
+ change_start_line,
86
+ change_start_char,
87
+ change_end_line,
88
+ change_end_char,
89
+ sem_tokens,
90
+ )
91
+ )
92
+ prev_tok_pos = get_token_start(prev_token_index, sem_tokens)
93
+ nxt_tok_pos = get_token_start(next_token_index, sem_tokens)
94
+ changing_line_text = get_line_of_code(change_start_line, document_lines)
95
+ if not changing_line_text:
96
+ return sem_tokens
97
+ is_edit_between_tokens = bool(
98
+ (
99
+ change_start_line > prev_tok_pos[0]
100
+ or (
101
+ change_start_line == prev_tok_pos[0]
102
+ and change_start_char
103
+ > prev_tok_pos[1] + sem_tokens[prev_token_index + 2]
104
+ if prev_token_index and prev_token_index + 2 < len(sem_tokens)
105
+ else 0
106
+ )
107
+ )
108
+ and (
109
+ change_end_line < nxt_tok_pos[0]
110
+ or (
111
+ change_end_line == nxt_tok_pos[0]
112
+ and change_end_char < nxt_tok_pos[1]
113
+ )
114
+ )
115
+ )
116
+ text = r"%s" % change.text
117
+ line_delta = len(text.split("\n")) - 1
118
+
119
+ is_multiline_insertion = line_delta > 0
120
+ is_next_token_same_line = change_end_line == nxt_tok_pos[0]
121
+
122
+ if is_delete:
123
+ next_token_index = (
124
+ prev_token_index + 5
125
+ if insert_inside_token
126
+ and prev_token_index is not None
127
+ or (
128
+ next_token_index
129
+ and prev_token_index is not None
130
+ and next_token_index >= 10
131
+ and next_token_index - prev_token_index == 10
132
+ )
133
+ else next_token_index
134
+ )
135
+ if next_token_index is None:
136
+ return sem_tokens
137
+ nxt_tok_pos = get_token_start(next_token_index, sem_tokens)
138
+ is_single_line_change = change_end_line == change_start_line
139
+ is_next_token_same_line = change_end_line == nxt_tok_pos[0]
140
+ if (
141
+ is_single_line_change
142
+ and insert_inside_token
143
+ and prev_token_index is not None
144
+ ):
145
+ sem_tokens = SemTokManager.handle_single_line_delete(
146
+ sem_tokens,
147
+ next_token_index,
148
+ prev_token_index,
149
+ is_next_token_same_line,
150
+ change,
151
+ )
152
+ elif is_single_line_change and is_edit_between_tokens:
153
+ sem_tokens = SemTokManager.handle_single_line_delete_between_tokens(
154
+ sem_tokens,
155
+ next_token_index,
156
+ is_next_token_same_line,
157
+ change,
158
+ change_start_line,
159
+ change_end_line,
160
+ )
161
+ else:
162
+ sem_tokens = SemTokManager.handle_multi_line_delete(
163
+ sem_tokens,
164
+ next_token_index,
165
+ nxt_tok_pos,
166
+ change_start_line,
167
+ change_end_line,
168
+ change_start_char,
169
+ change_end_char,
170
+ prev_tok_pos,
171
+ is_next_token_same_line,
172
+ )
173
+ return sem_tokens
174
+
175
+ is_token_boundary_edit = False
176
+ if insert_inside_token and prev_token_index is not None:
177
+ sem_tokens, is_token_boundary_edit, nxt_tok_pos, next_token_index = (
178
+ SemTokManager.handle_insert_inside_token(
179
+ change,
180
+ sem_tokens,
181
+ prev_token_index,
182
+ changing_line_text,
183
+ line_delta,
184
+ prev_tok_pos,
185
+ change_start_char,
186
+ change_end_char,
187
+ is_token_boundary_edit,
188
+ nxt_tok_pos,
189
+ )
190
+ )
191
+ tokens_on_same_line = prev_tok_pos[0] == nxt_tok_pos[0]
192
+ if (
193
+ is_edit_between_tokens
194
+ or is_token_boundary_edit
195
+ or is_multiline_insertion
196
+ ) and next_token_index is not None:
197
+ if is_multiline_insertion:
198
+ sem_tokens = SemTokManager.handle_multi_line_insertion(
199
+ sem_tokens,
200
+ next_token_index,
201
+ nxt_tok_pos,
202
+ change_start_line,
203
+ change_end_line,
204
+ change_end_char,
205
+ prev_tok_pos,
206
+ tokens_on_same_line,
207
+ changing_line_text,
208
+ line_delta,
209
+ )
210
+ else:
211
+ sem_tokens = SemTokManager.handle_single_line_insertion(
212
+ sem_tokens,
213
+ next_token_index,
214
+ is_next_token_same_line,
215
+ change,
216
+ tokens_on_same_line,
217
+ nxt_tok_pos,
218
+ change_start_line,
219
+ line_delta,
220
+ )
221
+ return sem_tokens
222
+
223
+ @staticmethod
224
+ def handle_multi_line_delete(
225
+ sem_tokens: list[int],
226
+ next_token_index: int,
227
+ nxt_tok_pos: tuple[int, int, int],
228
+ change_start_line: int,
229
+ change_end_line: int,
230
+ change_start_char: int,
231
+ change_end_char: int,
232
+ prev_tok_pos: tuple[int, int, int],
233
+ is_next_token_same_line: bool,
234
+ ) -> list[int]:
235
+ """Handle multi line deletion."""
236
+ if is_next_token_same_line:
237
+ char_del = nxt_tok_pos[1] - change_end_char
238
+ total_char_del = change_start_char + char_del
239
+ sem_tokens[next_token_index + 1] = (
240
+ (total_char_del - prev_tok_pos[1])
241
+ if prev_tok_pos[0] == change_start_line
242
+ else total_char_del
243
+ )
244
+ sem_tokens[next_token_index] -= change_end_line - change_start_line
245
+ return sem_tokens
246
+
247
+ @staticmethod
248
+ def handle_single_line_delete_between_tokens(
249
+ sem_tokens: list[int],
250
+ next_token_index: int,
251
+ is_next_token_same_line: bool,
252
+ change: lspt.TextDocumentContentChangeEvent_Type1,
253
+ change_start_line: int,
254
+ change_end_line: int,
255
+ ) -> list[int]:
256
+ """Handle single line deletion between tokens."""
257
+ if is_next_token_same_line:
258
+ sem_tokens[next_token_index + 1] -= change.range_length
259
+
260
+ else:
261
+ sem_tokens[next_token_index] -= change_end_line - change_start_line
262
+ return sem_tokens
263
+
264
+ @staticmethod
265
+ def handle_single_line_delete(
266
+ sem_tokens: list[int],
267
+ next_token_index: int,
268
+ prev_token_index: int,
269
+ is_next_token_same_line: bool,
270
+ change: lspt.TextDocumentContentChangeEvent_Type1,
271
+ ) -> list[int]:
272
+ """Handle single line deletion."""
273
+ sem_tokens[prev_token_index + 2] -= change.range_length
274
+ if is_next_token_same_line:
275
+ sem_tokens[next_token_index + 1] -= change.range_length
276
+ return sem_tokens
277
+
278
+ @staticmethod
279
+ def handle_single_line_insertion(
280
+ sem_tokens: list[int],
281
+ next_token_index: int,
282
+ is_next_token_same_line: bool,
283
+ change: lspt.TextDocumentContentChangeEvent_Type1,
284
+ tokens_on_same_line: bool,
285
+ nxt_tok_pos: tuple[int, int, int],
286
+ change_start_line: int,
287
+ line_delta: int,
288
+ ) -> list[int]:
289
+ """Handle single line insertion."""
290
+ if tokens_on_same_line:
291
+ sem_tokens[next_token_index + 1] += len(change.text)
292
+ sem_tokens[next_token_index] += line_delta
293
+ else:
294
+ is_next_token_same_line = change_start_line == nxt_tok_pos[0]
295
+ if is_next_token_same_line:
296
+ sem_tokens[next_token_index] += line_delta
297
+ sem_tokens[next_token_index + 1] += len(change.text)
298
+ else:
299
+ sem_tokens[next_token_index] += line_delta
300
+ return sem_tokens
301
+
302
+ @staticmethod
303
+ def handle_multi_line_insertion(
304
+ sem_tokens: list[int],
305
+ next_token_index: int,
306
+ nxt_tok_pos: tuple[int, int, int],
307
+ change_start_line: int,
308
+ change_end_line: int,
309
+ change_end_char: int,
310
+ prev_tok_pos: tuple[int, int, int],
311
+ tokens_on_same_line: bool,
312
+ changing_line_text: tuple[str, int],
313
+ line_delta: int,
314
+ ) -> list[int]:
315
+ """Handle multi line insertion."""
316
+ if tokens_on_same_line:
317
+ char_del = nxt_tok_pos[1] - change_end_char
318
+ total_char_del = changing_line_text[1] + char_del
319
+
320
+ else:
321
+ is_prev_token_same_line = change_end_line == prev_tok_pos[0]
322
+ is_next_token_same_line = change_start_line == nxt_tok_pos[0]
323
+ if is_prev_token_same_line:
324
+ total_char_del = nxt_tok_pos[1]
325
+ elif is_next_token_same_line:
326
+ char_del = nxt_tok_pos[1] - change_end_char
327
+ total_char_del = changing_line_text[1] + char_del
328
+ else:
329
+ total_char_del = sem_tokens[next_token_index + 1]
330
+ line_delta -= change_end_line - change_start_line
331
+ sem_tokens[next_token_index + 1] = total_char_del
332
+ sem_tokens[next_token_index] += line_delta
333
+ return sem_tokens
334
+
335
+ @staticmethod
336
+ def handle_insert_inside_token(
337
+ change: lspt.TextDocumentContentChangeEvent_Type1,
338
+ sem_tokens: list[int],
339
+ prev_token_index: int,
340
+ changing_line_text: tuple[str, int],
341
+ line_delta: int,
342
+ prev_tok_pos: tuple[int, int, int],
343
+ change_start_char: int,
344
+ change_end_char: int,
345
+ is_token_boundary_edit: bool,
346
+ nxt_tok_pos: tuple[int, int, int],
347
+ ) -> tuple[list[int], bool, tuple[int, int, int], Optional[int]]:
348
+ """Handle insert inside token."""
349
+ next_token_index = None
350
+ for i in ["\n", " ", "\t"]:
351
+ if i in change.text:
352
+ if prev_tok_pos[1] == change_start_char:
353
+ if i == "\n":
354
+ sem_tokens[prev_token_index] += line_delta
355
+ sem_tokens[prev_token_index + 1] = changing_line_text[1]
356
+ else:
357
+ sem_tokens[prev_token_index + 1] += len(change.text)
358
+ return (
359
+ sem_tokens,
360
+ is_token_boundary_edit,
361
+ nxt_tok_pos,
362
+ next_token_index,
363
+ )
364
+ else:
365
+ is_token_boundary_edit = True
366
+ next_token_index = prev_token_index + 5
367
+ nxt_tok_pos = get_token_start(next_token_index, sem_tokens)
368
+ break
369
+ if not is_token_boundary_edit:
370
+ selected_region = change_end_char - change_start_char
371
+ index_offset = 2
372
+ sem_tokens[prev_token_index + index_offset] += (
373
+ len(change.text) - selected_region
374
+ )
375
+ if prev_tok_pos[0] == get_token_start(prev_token_index + 5, sem_tokens)[0]:
376
+ sem_tokens[prev_token_index + index_offset + 4] += (
377
+ len(change.text) - selected_region
378
+ )
379
+ return sem_tokens, is_token_boundary_edit, nxt_tok_pos, next_token_index
@@ -9,6 +9,7 @@ from jaclang.compiler.constant import (
9
9
  JacSemTokenType as SemTokType,
10
10
  )
11
11
  from jaclang.langserve.engine import JacLangServer
12
+ from jaclang.settings import settings
12
13
 
13
14
  import lsprotocol.types as lspt
14
15
 
@@ -30,7 +31,11 @@ async def did_change(
30
31
  """Check syntax on change."""
31
32
  await ls.launch_quick_check(file_path := params.text_document.uri)
32
33
  if file_path in ls.modules:
33
- ls.modules[file_path].update_sem_tokens(params)
34
+ document = ls.workspace.get_text_document(file_path)
35
+ lines = document.source.splitlines()
36
+ ls.modules[file_path].sem_manager.update_sem_tokens(
37
+ params, ls.modules[file_path].sem_manager.sem_tokens, lines
38
+ )
34
39
  ls.lsp.send_request(lspt.WORKSPACE_SEMANTIC_TOKENS_REFRESH)
35
40
 
36
41
 
@@ -110,7 +115,7 @@ def document_symbol(
110
115
  ls: JacLangServer, params: lspt.DocumentSymbolParams
111
116
  ) -> list[lspt.DocumentSymbol]:
112
117
  """Provide document symbols."""
113
- return ls.get_document_symbols(params.text_document.uri)
118
+ return ls.get_outline(params.text_document.uri)
114
119
 
115
120
 
116
121
  @server.feature(lspt.TEXT_DOCUMENT_DEFINITION)
@@ -138,19 +143,12 @@ def semantic_tokens_full(
138
143
  ls: JacLangServer, params: lspt.SemanticTokensParams
139
144
  ) -> lspt.SemanticTokens:
140
145
  """Provide semantic tokens."""
141
- # import logging
142
-
143
- # logging.info("\nGetting semantic tokens\n")
144
- # # logging.info(ls.get_semantic_tokens(params.text_document.uri))
145
- # i = 0
146
- # while i < len(ls.get_semantic_tokens(params.text_document.uri).data):
147
- # logging.info(ls.get_semantic_tokens(params.text_document.uri).data[i : i + 5])
148
- # i += 5
149
146
  return ls.get_semantic_tokens(params.text_document.uri)
150
147
 
151
148
 
152
149
  def run_lang_server() -> None:
153
150
  """Run the language server."""
151
+ settings.pass_timer = True
154
152
  server.start_io()
155
153
 
156
154
 
@@ -35,20 +35,41 @@ obj Colour1 {
35
35
  }
36
36
 
37
37
  :obj:Colour1:can:get_color1 -> Colorenum {
38
- return self.color;
38
+
39
+ return self.color1;
39
40
  }
40
41
 
41
42
  obj red :Colour1: {
42
- has base_colorred: Colorenum = Color.RED,
43
+ has base_colorred: Colorenum = Colorenum.RED,
43
44
  pointred: int = 10;
44
- obj color2 {
45
- has color22: Color = Colorenum.BLUE,
45
+
46
+ obj inner_red {
47
+ has color22: enum_red = enum_red.BLUE22,
48
+ doublepoint22:doubleinner.double = 2,
46
49
  point22: int = 20;
50
+
51
+ can apply_inner_red -> enum_red {
52
+ return self.color22;
53
+ }
54
+ enum enum_red {
55
+ RED22,
56
+ GREEN22,
57
+ BLUE22
58
+ }
47
59
  }
60
+ class doubleinner {
61
+ has double: int = 2;
62
+ }
63
+
64
+ can apply_red -> int {
65
+ x =
66
+ self.inner_red.color22.GREEN22;
67
+ return self.point1 + self.pointred;
68
+ }
48
69
  }
49
70
 
50
71
  with entry:__main__ {
51
- r = red(color1=Color.GREEN, point1=20);
72
+ r = red(color1=Colorenum.GREEN, point1=20);
52
73
  print(r.get_color1());
53
- print(r.color2.color22);
74
+ print(r.inner_red);
54
75
  }
@@ -63,15 +63,15 @@ with entry:__main__ {
63
63
  glob expected_area = 78.53981633974483;
64
64
 
65
65
  test calc_area {
66
- check assertAlmostEqual(calculate_area(RAD), expected_area);
66
+ check almostEqual(calculate_area(RAD), expected_area);
67
67
  }
68
68
 
69
69
  test circle_area {
70
70
  c = Circle(RAD);
71
- check assertAlmostEqual(c.area(), expected_area);
71
+ check almostEqual(c.area(), expected_area);
72
72
  }
73
73
 
74
74
  test circle_type {
75
75
  c = Circle(RAD);
76
- check assertEqual(c.shape_type, ShapeType.CIRCLE);
76
+ check c.shape_type == ShapeType.CIRCLE;
77
77
  }
@@ -59,15 +59,15 @@ print(f"Area of a {c.shape_type.value} with radius {RAD} using class: {c.area()}
59
59
  glob expected_area = 78.53981633974483;
60
60
 
61
61
  test calc_area {
62
- check assertAlmostEqual(calculate_area(RAD), expected_area);
62
+ check almostEqual(calculate_area(RAD), expected_area);
63
63
  }
64
64
 
65
65
  test circle_area {
66
66
  c = Circle(RAD);
67
- check assertAlmostEqual(c.area(), expected_area);
67
+ check almostEqual(c.area(), expected_area);
68
68
  }
69
69
 
70
70
  test circle_type {
71
71
  c = Circle(RAD);
72
- check assertEqual(c.shape_type, ShapeType.CIRCLE);
72
+ check c.shape_type == ShapeType.CIRCLE;
73
73
  }
@@ -1,15 +1,15 @@
1
1
  glob expected_area = 78.53981633974483;
2
2
 
3
3
  test a1 {
4
- check assertAlmostEqual(calculate_area(RAD), expected_area);
4
+ check almostEqual(calculate_area(RAD), expected_area);
5
5
  }
6
6
 
7
7
  test a2 {
8
8
  c = Circle(RAD);
9
- check assertAlmostEqual(c.area(), expected_area);
9
+ check almostEqual(c.area(), expected_area);
10
10
  }
11
11
 
12
12
  test a3 {
13
13
  c = Circle(RAD);
14
- check assertEqual(c.shape_type, ShapeType.CIRCLE);
14
+ check c.shape_type == ShapeType.CIRCLE;
15
15
  }
@@ -1,6 +1,6 @@
1
1
  import:py os;
2
2
  import:py from math, sqrt as square_root;
3
3
  import:py datetime as dt;
4
- import:jac from base_module_structure, add_numbers as adsd, subtract,x,Colorenum as clr;
4
+ import:jac from base_module_structure, add as add_numbers , subtract,x,Colorenum as clr;
5
5
  import:jac base_module_structure as base_module_structure;
6
6
  import:py from py_import,add1 as ss, sub1 as subtract1,apple,Orange1;