Beispiel #1
0
 def __init__(self, node_type, rhs):
     '''Initializes the UnaryExpression with the specified arguments.
     Arguments:
         node_type - Specifies the type of operation that this UnaryExpression represents
         rhs - Right-hand site of the operation. Since this is an unary operation, this is the only argument.
     '''
     Guard.against_empty(node_type, "The UnaryExpression node type is required")
     if node_type == self.CollectionLength:
         Guard.accepts(rhs, (ConstantExpression,), "The CollectionLength unary expression can only take ConstantExpressions that hold tuples or lists as parameters.")
         if not isinstance(rhs.evaluate(), (list, tuple)):
             raise ValueError("The CollectionLength unary expression can only take ConstantExpressions that hold tuples or lists as parameters.")
     self.node_type = node_type
     self.rhs = rhs
Beispiel #2
0
 def __init__(self, node_type, lhs, rhs):
     '''Initializes the BinaryExpression with the specified arguments.
     Arguments:
         node_type - Specifies the type of operation that this BinaryExpression represents
         lhs - Left-hand side of the operation (as in the first argument)
         rhs - Right-hand site of the operation (as in the second argument)
     '''
     Guard.against_empty(node_type, "The BinaryExpression node type is required")
     Guard.accepts(lhs, (Expression,), "Lhs must be an expression (an instance of a class that inherits from pynq.Expression), but was %s" % lhs.__class__.__name__)
     Guard.accepts(rhs, (Expression,), "Rhs must be an expression (an instance of a class that inherits from pynq.Expression) but was %s" % rhs.__class__.__name__)
     self.node_type = node_type
     self.lhs = lhs
     self.rhs = rhs
Beispiel #3
0
 def __init__(self, node_type, rhs):
     '''Initializes the UnaryExpression with the specified arguments.
     Arguments:
         node_type - Specifies the type of operation that this UnaryExpression represents
         rhs - Right-hand site of the operation. Since this is an unary operation, this is the only argument.
     '''
     Guard.against_empty(node_type,
                         "The UnaryExpression node type is required")
     if node_type == self.CollectionLength:
         Guard.accepts(
             rhs, (ConstantExpression, ),
             "The CollectionLength unary expression can only take ConstantExpressions that hold tuples or lists as parameters."
         )
         if not isinstance(rhs.evaluate(), (list, tuple)):
             raise ValueError(
                 "The CollectionLength unary expression can only take ConstantExpressions that hold tuples or lists as parameters."
             )
     self.node_type = node_type
     self.rhs = rhs
Beispiel #4
0
 def __init__(self, node_type, lhs, rhs):
     '''Initializes the BinaryExpression with the specified arguments.
     Arguments:
         node_type - Specifies the type of operation that this BinaryExpression represents
         lhs - Left-hand side of the operation (as in the first argument)
         rhs - Right-hand site of the operation (as in the second argument)
     '''
     Guard.against_empty(node_type,
                         "The BinaryExpression node type is required")
     Guard.accepts(
         lhs, (Expression, ),
         "Lhs must be an expression (an instance of a class that inherits from pynq.Expression), but was %s"
         % lhs.__class__.__name__)
     Guard.accepts(
         rhs, (Expression, ),
         "Rhs must be an expression (an instance of a class that inherits from pynq.Expression) but was %s"
         % rhs.__class__.__name__)
     self.node_type = node_type
     self.lhs = lhs
     self.rhs = rhs
Beispiel #5
0
 def do(self, a):
     Guard.accepts(a, (int, float))
     pass
Beispiel #6
0
 def do(self, a):
     Guard.accepts(a, (int, float), "Argument a must be an integer or a float")
     pass
Beispiel #7
0
 def do(self, a):
     Guard.accepts(a, (int, float))
     pass
Beispiel #8
0
 def do(self, a):
     Guard.accepts(a, (int, float),
                   "Argument a must be an integer or a float")
     pass