Skip to content

Commit

Permalink
Fix typo in compile_asts (binpash#740)
Browse files Browse the repository at this point in the history
* Fix typo

Signed-off-by: Bolun Thompson <[email protected]>

* Add check that compile_ast result is an IR

Signed-off-by: Bolun Thompson <[email protected]>

* Add return type hint to compile_node

Signed-off-by: Bolun Thompson <[email protected]>

---------

Signed-off-by: Bolun Thompson <[email protected]>
  • Loading branch information
BolunThompson authored and kwakubiney committed Jan 28, 2025
1 parent 0d0a563 commit 023e0cc
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions compiler/ast_to_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,19 @@ def compile_asts(ast_objects: "list[AstNode]", fileIdGen, config):
if isinstance(compiled_ast, IR):
acc_ir.background_union(compiled_ast)
else:
## TODO: Make this union the compiled_ast with the
## accumulated IR, since the user wanted to run these
## commands in parallel (Is that correct?)
# acc_ir.background_union(IR([compiled_ast]))
compiled_asts.append(acc_ir)
acc_it = None
compiled_asts.append(compiled_ast)
## shouldn't happen since compile_node should have already
## raised this error
raise UnparallelizableError(f"Node: {compiled_ast} is not pure")

## If the current compiled ast not in background (and so
## the union isn't in background too), stop accumulating
if not acc_ir is None and not acc_ir.is_in_background():
if not acc_ir.is_in_background():
compiled_asts.append(acc_ir)
acc_ir = None
else:
## If the compiled ast is in background, start
## accumulating it
if isinstance(compiled_ast, IR) and compiled_ast.is_in_background():
if compiled_ast.is_in_background():
acc_ir = compiled_ast
else:
compiled_asts.append(compiled_ast)
Expand All @@ -128,7 +124,7 @@ def compile_asts(ast_objects: "list[AstNode]", fileIdGen, config):
return compiled_asts


def compile_node(ast_object, fileIdGen, config):
def compile_node(ast_object, fileIdGen, config) -> IR:
global compile_cases
return ast_match(ast_object, compile_cases, fileIdGen, config)

Expand Down

0 comments on commit 023e0cc

Please sign in to comment.