Skip to content

Commit e694ced

Browse files
Update keywords
1 parent 8e3a4be commit e694ced

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

multilingualprogramming/codegen/ui_lowering.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
IRBinaryOp,
2222
IRBooleanOp,
2323
IRBreakStatement,
24+
IRPassStatement,
2425
IRCallExpr,
2526
IRCanvasBlock,
2627
IRClassDecl,
@@ -381,6 +382,17 @@ class ReactiveEngine {
381382
return Boolean(value);
382383
}
383384
385+
function __ml_iterate(obj) {
386+
if (obj == null) return [];
387+
if (Array.isArray(obj) || obj instanceof Set || obj instanceof Map || typeof obj === 'string') {
388+
return obj;
389+
}
390+
if (typeof obj === 'object') {
391+
return Object.keys(obj);
392+
}
393+
return obj;
394+
}
395+
384396
function __ml_add(container, item) {
385397
if (container instanceof Set) {
386398
container.add(item);
@@ -629,6 +641,8 @@ def _stmt_to_js(self, stmt: IRNode, indent: int) -> str:
629641
return f"{pad}break;"
630642
if isinstance(stmt, IRContinueStatement):
631643
return f"{pad}continue;"
644+
if isinstance(stmt, IRPassStatement):
645+
return ""
632646
if isinstance(stmt, IRImportStatement):
633647
return ""
634648
if isinstance(stmt, IRDelStatement):
@@ -751,7 +765,7 @@ def _for_to_js(self, node: IRForLoop, indent: int) -> str:
751765
lines.append(f"{pad}}}")
752766
return "\n".join(lines)
753767
iterable_js = self._expr_to_js(iterable)
754-
lines = [f"{pad}for (const {target} of {iterable_js}) {{"]
768+
lines = [f"{pad}for (const {target} of __ml_iterate({iterable_js})) {{"]
755769
lines.extend(self._stmt_to_js(stmt, indent + 1) for stmt in (node.body or []))
756770
lines.append(f"{pad}}}")
757771
return "\n".join(lines)
@@ -884,7 +898,7 @@ def _for_render_to_js(self, node: IRForLoop, parent_var: str, indent: int) -> st
884898
)
885899
else:
886900
iterable_js = self._expr_to_js(iterable)
887-
lines.append(f"{pad}for (const {target} of {iterable_js}) {{")
901+
lines.append(f"{pad}for (const {target} of __ml_iterate({iterable_js})) {{")
888902
for stmt in (node.body or []):
889903
lines.extend(self._render_child(stmt, parent_var, indent + 1))
890904
lines.append(f"{pad}}}")

multilingualprogramming/resources/usm/keywords.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
},
250250
"PASS": {
251251
"en": "pass",
252-
"fr": "passer",
252+
"fr": ["passer", "passe"],
253253
"es": "pasar",
254254
"de": "pass",
255255
"hi": "छोड़ो",

0 commit comments

Comments
 (0)