Ejemplo n.º 1
0
 def visit_Assign(self, node: Assign) -> gtir.ParAssignStmt:
     assert isinstance(node.target, FieldRef) or isinstance(
         node.target, VarRef)
     return gtir.ParAssignStmt(
         left=self.visit(node.target),
         right=self.visit(node.value),
         loc=location_to_source_location(node.loc),
     )
Ejemplo n.º 2
0
def test_visit_Assign_VariableKOffset():
    testee = gtir.ParAssignStmt(
        left=FieldAccessFactory(), right=FieldAccessFactory(offset=VariableKOffsetFactory())
    )
    ctx = GTIRToOIR.Context()
    GTIRToOIR().visit(testee, ctx=ctx)

    assert len(ctx.horizontal_executions) == 1
    assert ctx.horizontal_executions[0].iter_tree().if_isinstance(oir.VariableKOffset).to_list()
Ejemplo n.º 3
0
def test_visit_ParAssignStmt():
    out_name = "out"
    in_name = "in"
    testee = gtir.ParAssignStmt(left=FieldAccessBuilder(out_name).build(),
                                right=FieldAccessBuilder(in_name).build())

    ctx = GTIRToOIR.Context()
    GTIRToOIR().visit(testee, ctx=ctx)
    result_horizontal_executions = ctx.horizontal_executions

    assert len(result_horizontal_executions) == 1
    assign = isinstance_and_return(result_horizontal_executions[0].body[0],
                                   oir.AssignStmt)

    left = isinstance_and_return(assign.left, oir.FieldAccess)
    right = isinstance_and_return(assign.right, oir.FieldAccess)
    assert left.name == out_name
    assert right.name == in_name
Ejemplo n.º 4
0
 def visit_Assign(self, node: Assign) -> gtir.ParAssignStmt:
     assert isinstance(node.target, FieldRef) or isinstance(node.target, VarRef)
     return gtir.ParAssignStmt(left=self.visit(node.target), right=self.visit(node.value))
Ejemplo n.º 5
0
 def visit_ParAssignStmt(self, node: gtir.ParAssignStmt,
                         **kwargs: Any) -> gtir.ParAssignStmt:
     right = self.visit(node.right, **kwargs)
     left = self.visit(node.left, new_dtype=right.dtype, **kwargs)
     return gtir.ParAssignStmt(left=left, right=right)