Skip to content

Commit

Permalink
Allow units to be bound to a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
smartycope authored and Lonami committed Aug 16, 2024
1 parent 03e9453 commit 01b797a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pyndustric/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,16 +742,17 @@ def emit_unit_syscall(self, node: ast.Call):
if len(node.args) != 1:
raise CompilerError(ERR_BAD_SYSCALL_ARGS, node)

if not isinstance(node.args[0], ast.Constant):
raise CompilerError(ERR_BAD_SYSCALL_ARGS, node)

unit = node.args[0].value
if isinstance(node.args[0], ast.Constant):
unit = node.args[0].value

if not isinstance(unit, str):
if not isinstance(unit, str):
raise CompilerError(ERR_BAD_SYSCALL_ARGS, node)
self.ins_append(f"ubind @{unit}")
elif isinstance(node.args[0], ast.Name):
self.ins_append(f"ubind {node.args[0].id}")
else:
raise CompilerError(ERR_BAD_SYSCALL_ARGS, node)

self.ins_append(f"ubind @{unit}")

elif method == "idle":
if len(node.args) != 0:
raise CompilerError(ERR_BAD_SYSCALL_ARGS, node)
Expand Down

0 comments on commit 01b797a

Please sign in to comment.